diff options
author | Donald Sharp <sharpd@nvidia.com> | 2022-05-12 15:39:27 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@nvidia.com> | 2022-05-12 16:20:28 +0200 |
commit | 56b91d107ffc090c621bac4f2ff93712c49f0d7b (patch) | |
tree | b7601bde78ea1ae6a2db1c46c9f9a821babd2fcd /bgpd | |
parent | Merge pull request #11176 from anlancs/fix/bgpd-remove-for-type2-prefix (diff) | |
download | frr-56b91d107ffc090c621bac4f2ff93712c49f0d7b.tar.xz frr-56b91d107ffc090c621bac4f2ff93712c49f0d7b.zip |
bgpd: Prevent crash when issuing various forms of `bgp no-rib`
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>
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/bgpd.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 33ed7d1d9..1d5670907 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -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)"); |