From: Donald Sharp Date: Thu, 30 Jun 2022 15:59:39 +0000 (-0400) Subject: zebra: move allow_delete to zrouter.allow_delete X-Git-Tag: base_8.4~282^2~1 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=88b0baa64865918fe042444b32bb684db54fdbc1;p=matthieu%2Ffrr.git zebra: move allow_delete to zrouter.allow_delete Instead of having global allow_delete move it to where it belongs in the zrouter data structure. Additionally show this data in `show zebra` Signed-off-by: Donald Sharp --- diff --git a/zebra/main.c b/zebra/main.c index e516688a19..46cf2eea7d 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -71,9 +71,6 @@ struct thread_master *master; /* Route retain mode flag. */ int retain_mode = 0; -/* Allow non-frr entities to delete frr routes */ -int allow_delete = 0; - int graceful_restart; bool v6_rr_semantics = false; @@ -336,7 +333,7 @@ int main(int argc, char **argv) // batch_mode = 1; break; case 'a': - allow_delete = 1; + zrouter.allow_delete = true; break; case 'e': { unsigned long int parsed_multipath = diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 63f15b0f20..5314ef8600 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -77,9 +77,6 @@ static struct dplane_ctx_q rib_dplane_q; DEFINE_HOOK(rib_update, (struct route_node * rn, const char *reason), (rn, reason)); -/* Should we allow non FRR processes to delete our routes */ -extern int allow_delete; - /* Each route type's string and default distance value. */ static const struct { int key; @@ -3722,8 +3719,8 @@ void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, rn, fib, zebra_route_string(fib->type)); } - if (allow_delete - || CHECK_FLAG(dest->flags, RIB_ROUTE_ANY_QUEUED)) { + if (zrouter.allow_delete || + CHECK_FLAG(dest->flags, RIB_ROUTE_ANY_QUEUED)) { UNSET_FLAG(fib->status, ROUTE_ENTRY_INSTALLED); /* Unset flags. */ for (rtnh = fib->nhe->nhg.nexthop; rtnh; @@ -3768,8 +3765,8 @@ void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, if (same) { struct nexthop *tmp_nh; - if (fromkernel && CHECK_FLAG(flags, ZEBRA_FLAG_SELFROUTE) - && !allow_delete) { + if (fromkernel && CHECK_FLAG(flags, ZEBRA_FLAG_SELFROUTE) && + !zrouter.allow_delete) { rib_install_kernel(rn, same, NULL); route_unlock_node(rn); diff --git a/zebra/zebra_router.c b/zebra/zebra_router.c index 9fccda9e08..f7ad30b41f 100644 --- a/zebra/zebra_router.c +++ b/zebra/zebra_router.c @@ -278,6 +278,8 @@ void zebra_router_init(bool asic_offload, bool notify_on_ack) { zrouter.sequence_num = 0; + zrouter.allow_delete = false; + zrouter.packets_to_process = ZEBRA_ZAPI_PACKETS_TO_PROCESS; zrouter.nhg_keep = ZEBRA_DEFAULT_NHG_KEEP_TIMER; diff --git a/zebra/zebra_router.h b/zebra/zebra_router.h index d51e7a2b7d..0e2725c977 100644 --- a/zebra/zebra_router.h +++ b/zebra/zebra_router.h @@ -229,6 +229,9 @@ struct zebra_router { #define ZEBRA_DEFAULT_NHG_KEEP_TIMER 180 uint32_t nhg_keep; + + /* Should we allow non FRR processes to delete our routes */ + bool allow_delete; }; #define GRACEFUL_RESTART_TIME 60 diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 6ae55cdba4..e6038d0bc2 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -66,8 +66,6 @@ #include "zebra/rtadv.h" #include "zebra/zebra_neigh.h" -extern int allow_delete; - /* context to manage dumps in multiple tables or vrfs */ struct route_show_ctx { bool multi; /* dump multiple tables or vrf */ @@ -2699,7 +2697,7 @@ DEFUN (allow_external_route_update, "allow-external-route-update", "Allow FRR routes to be overwritten by external processes\n") { - allow_delete = 1; + zrouter.allow_delete = true; return CMD_SUCCESS; } @@ -2710,7 +2708,7 @@ DEFUN (no_allow_external_route_update, NO_STR "Allow FRR routes to be overwritten by external processes\n") { - allow_delete = 0; + zrouter.allow_delete = false; return CMD_SUCCESS; } @@ -3911,7 +3909,7 @@ DEFPY (zebra_nexthop_group_keep, static int config_write_protocol(struct vty *vty) { - if (allow_delete) + if (zrouter.allow_delete) vty_out(vty, "allow-external-route-update\n"); if (zrouter.nhg_keep != ZEBRA_DEFAULT_NHG_KEEP_TIMER) @@ -4011,6 +4009,8 @@ DEFUN (show_zebra, ttable_add_row(table, "Kernel NHG|%s", zrouter.supports_nhgs ? "Available" : "Unavailable"); + ttable_add_row(table, "Allow Non FRR route deletion|%s", + zrouter.allow_delete ? "Yes" : "No"); ttable_add_row(table, "v4 All LinkDown Routes|%s", zrouter.all_linkdownv4 ? "On" : "Off"); ttable_add_row(table, "v4 Default LinkDown Routes|%s",