]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Prevent crash when issuing various forms of `bgp no-rib`
authorDonald Sharp <sharpd@nvidia.com>
Thu, 12 May 2022 13:39:27 +0000 (09:39 -0400)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Fri, 13 May 2022 06:06:45 +0000 (09:06 +0300)
The `bgp no-rib` command cycles through all the bgp rib tables
and removes them from zebra.  Modify the code so that FRR notices
that it is attempting to cycle through the safi's that are two level
tables.  In addition these safi's cannot just blindly remove the routes
from the rib as that there are none explicitly.

This code just prevents the crash in bgpd.  It does not properly cycle
through and remove the zebra changes made that are explicit to these afi's.
This should be handled as appropriate by the developers on these safi's when
it becomes important to them.

Fixes: #11178
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
bgpd/bgpd.c
doc/user/bgp.rst

index 21c88e4db978fa65e2e506c2d605d646d9f61f79..61033794a99279578440e1c8fc7e89b108d5f6b8 100644 (file)
@@ -232,8 +232,17 @@ void bgp_option_norib_set_runtime(void)
        zlog_info("Disabled BGP route installation to RIB (Zebra)");
 
        for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) {
-               FOREACH_AFI_SAFI(afi, safi)
+               FOREACH_AFI_SAFI (afi, safi) {
+                       /*
+                        * Stop a crash, more work is needed
+                        * here to properly add/remove these types of
+                        * routes from zebra.
+                        */
+                       if (!bgp_fibupd_safi(safi))
+                               continue;
+
                        bgp_zebra_withdraw_table_all_subtypes(bgp, afi, safi);
+               }
        }
 
        zlog_info("All routes have been withdrawn from RIB (Zebra)");
@@ -255,8 +264,17 @@ void bgp_option_norib_unset_runtime(void)
        zlog_info("Enabled BGP route installation to RIB (Zebra)");
 
        for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) {
-               FOREACH_AFI_SAFI(afi, safi)
+               FOREACH_AFI_SAFI (afi, safi) {
+                       /*
+                        * Stop a crash, more work is needed
+                        * here to properly add/remove these types
+                        * of routes from zebra
+                        */
+                       if (!bgp_fibupd_safi(safi))
+                               continue;
+
                        bgp_zebra_announce_table_all_subtypes(bgp, afi, safi);
+               }
        }
 
        zlog_info("All routes have been installed in RIB (Zebra)");
index 7d7335a23f0a2f267a4b1c314aec929f4b9d5584..476c06aed487517f0a56a956cbcff227498e90bb 100644 (file)
@@ -3917,7 +3917,8 @@ the daemons RIB from Zebra and unsetting it will announce all routes in the
 daemons RIB to Zebra. If the option is passed as a command line argument when
 starting the daemon and the configuration gets saved, the option will persist
 unless removed from the configuration with the negating command prior to the
-configuration write operation.
+configuration write operation.  At this point in time non SAFI_UNICAST BGP
+data is not properly withdrawn from zebra when this command is issued.
 
 .. clicmd:: bgp send-extra-data zebra