return CMD_SUCCESS;
}
+DEFPY (bgp_norib,
+ bgp_norib_cmd,
+ "bgp no-rib",
+ BGP_STR
+ "Disable BGP route installation to RIB (Zebra)\n")
+{
+ if (bgp_option_check(BGP_OPT_NO_FIB)) {
+ vty_out(vty,
+ "%% No-RIB option is already set, nothing to do here.\n");
+ return CMD_SUCCESS;
+ }
+
+ bgp_option_norib_set_runtime();
+
+ return CMD_SUCCESS;
+}
+
+DEFPY (no_bgp_norib,
+ no_bgp_norib_cmd,
+ "no bgp no-rib",
+ NO_STR
+ BGP_STR
+ "Disable BGP route installation to RIB (Zebra)\n")
+{
+ if (!bgp_option_check(BGP_OPT_NO_FIB)) {
+ vty_out(vty,
+ "%% No-RIB option is not set, nothing to do here.\n");
+ return CMD_SUCCESS;
+ }
+
+ bgp_option_norib_unset_runtime();
+
+ return CMD_SUCCESS;
+}
+
DEFUN (bgp_confederation_identifier,
bgp_confederation_identifier_cmd,
"bgp confederation identifier (1-4294967295)",
if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN))
vty_out(vty, "bgp graceful-shutdown\n");
+ /* No-RIB (Zebra) option flag configuration */
+ if (bgp_option_check(BGP_OPT_NO_FIB))
+ vty_out(vty, "bgp no-rib\n");
+
/* BGP configuration. */
for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) {
install_element(BGP_NODE, &bgp_cluster_id_cmd);
install_element(BGP_NODE, &no_bgp_cluster_id_cmd);
+ /* "bgp no-rib" commands. */
+ install_element(CONFIG_NODE, &bgp_norib_cmd);
+ install_element(CONFIG_NODE, &no_bgp_norib_cmd);
+
/* "bgp confederation" commands. */
install_element(BGP_NODE, &bgp_confederation_identifier_cmd);
install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd);
pi, bgp, afi, safi);
}
+/* Announce routes of any bgp subtype of a table to zebra */
+void bgp_zebra_announce_table_all_subtypes(struct bgp *bgp, afi_t afi,
+ safi_t safi)
+{
+ struct bgp_dest *dest;
+ struct bgp_table *table;
+ struct bgp_path_info *pi;
+
+ if (!bgp_install_info_to_zebra(bgp))
+ return;
+
+ table = bgp->rib[afi][safi];
+ if (!table)
+ return;
+
+ for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest))
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
+ if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED) &&
+ pi->type == ZEBRA_ROUTE_BGP)
+ bgp_zebra_announce(dest,
+ bgp_dest_get_prefix(dest),
+ pi, bgp, afi, safi);
+}
+
void bgp_zebra_withdraw(const struct prefix *p, struct bgp_path_info *info,
struct bgp *bgp, safi_t safi)
{
zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api);
}
+/* Withdraw all entries in a BGP instances RIB table from Zebra */
+void bgp_zebra_withdraw_table_all_subtypes(struct bgp *bgp, afi_t afi, safi_t safi)
+{
+ struct bgp_dest *dest;
+ struct bgp_table *table;
+ struct bgp_path_info *pi;
+
+ if (!bgp_install_info_to_zebra(bgp))
+ return;
+
+ table = bgp->rib[afi][safi];
+ if (!table)
+ return;
+
+ for (dest = bgp_table_top(table); dest; dest = bgp_route_next(dest)) {
+ for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next) {
+ if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)
+ && (pi->type == ZEBRA_ROUTE_BGP))
+ bgp_zebra_withdraw(bgp_dest_get_prefix(dest),
+ pi, bgp, safi);
+ }
+ }
+}
+
struct bgp_redist *bgp_redist_lookup(struct bgp *bgp, afi_t afi, uint8_t type,
unsigned short instance)
{
struct bgp_path_info *path, struct bgp *bgp,
safi_t safi);
+/* Announce routes of any bgp subtype of a table to zebra */
+extern void bgp_zebra_announce_table_all_subtypes(struct bgp *bgp, afi_t afi,
+ safi_t safi);
+
+/* Withdraw all entries of any subtype in a BGP instances RIB table from Zebra */
+extern void bgp_zebra_withdraw_table_all_subtypes(struct bgp *bgp, afi_t afi,
+ safi_t safi);
+
extern void bgp_zebra_initiate_radv(struct bgp *bgp, struct peer *peer);
extern void bgp_zebra_terminate_radv(struct bgp *bgp, struct peer *peer);
return CHECK_FLAG(bm->options, flag);
}
+/* set the bgp no-rib option during runtime and remove installed routes */
+void bgp_option_norib_set_runtime(void)
+{
+ struct bgp *bgp;
+ struct listnode *node;
+ afi_t afi;
+ safi_t safi;
+
+ if (bgp_option_check(BGP_OPT_NO_FIB))
+ return;
+
+ bgp_option_set(BGP_OPT_NO_FIB);
+
+ zlog_info("Disabled BGP route installation to RIB (Zebra)");
+
+ for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) {
+ FOREACH_AFI_SAFI(afi, safi)
+ bgp_zebra_withdraw_table_all_subtypes(bgp, afi, safi);
+ }
+
+ zlog_info("All routes have been withdrawn from RIB (Zebra)");
+}
+
+/* unset the bgp no-rib option during runtime and announce routes to Zebra */
+void bgp_option_norib_unset_runtime(void)
+{
+ struct bgp *bgp;
+ struct listnode *node;
+ afi_t afi;
+ safi_t safi;
+
+ if (!bgp_option_check(BGP_OPT_NO_FIB))
+ return;
+
+ bgp_option_unset(BGP_OPT_NO_FIB);
+
+ zlog_info("Enabled BGP route installation to RIB (Zebra)");
+
+ for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) {
+ FOREACH_AFI_SAFI(afi, safi)
+ bgp_zebra_announce_table_all_subtypes(bgp, afi, safi);
+ }
+
+ zlog_info("All routes have been installed in RIB (Zebra)");
+}
+
/* Internal function to set BGP structure configureation flag. */
static void bgp_config_set(struct bgp *bgp, int config)
{
extern int bgp_option_unset(int);
extern int bgp_option_check(int);
+/* set the bgp no-rib option during runtime and remove installed routes */
+extern void bgp_option_norib_set_runtime(void);
+
+/* unset the bgp no-rib option during runtime and reset all peers */
+extern void bgp_option_norib_unset_runtime(void);
+
extern int bgp_get(struct bgp **, as_t *, const char *, enum bgp_instance_type);
extern void bgp_instance_up(struct bgp *);
extern void bgp_instance_down(struct bgp *);