]> git.proxmox.com Git - mirror_frr.git/commitdiff
zebra: move allow_delete to zrouter.allow_delete
authorDonald Sharp <sharpd@nvidia.com>
Thu, 30 Jun 2022 15:59:39 +0000 (11:59 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Fri, 1 Jul 2022 11:59:53 +0000 (07:59 -0400)
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 <sharpd@nvidia.com>
zebra/main.c
zebra/zebra_rib.c
zebra/zebra_router.c
zebra/zebra_router.h
zebra/zebra_vty.c

index e516688a1955a54f766f090f4c9f193bd45d079c..46cf2eea7dea60871397daa1b3d49e7c4be806a1 100644 (file)
@@ -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 =
index 63f15b0f20f4c0793bdbe2d12517ced5b0fe0b99..5314ef8600afb20b4b4bd2c99888de97db4d7721 100644 (file)
@@ -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);
 
index 9fccda9e0896aec31f125486a1d46e4287799849..f7ad30b41fb337b76694c277a5a08135816e42af 100644 (file)
@@ -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;
index d51e7a2b7d5fc2bb9d6f4ff6036ef84ab678e443..0e2725c977412ce8eb1b39a949fc613b30acf7a7 100644 (file)
@@ -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
index 6ae55cdba42b0fdec27c22ec1aaf9f8dbc1aa72c..e6038d0bc277a39d4d82b164ff3e7406ae36bc8e 100644 (file)
@@ -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",