]> git.proxmox.com Git - mirror_frr.git/commitdiff
zebra: Add a configurable knob `zebra nexthop-group keep (1-3600)`
authorDonald Sharp <sharpd@nvidia.com>
Wed, 15 Jun 2022 23:54:29 +0000 (19:54 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Thu, 16 Jun 2022 18:47:19 +0000 (14:47 -0400)
Allow end operator to set how long a nexthop-group is kept around
in the system after it is no-longer being used.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
doc/user/zebra.rst
zebra/zebra_nhg.c
zebra/zebra_router.c
zebra/zebra_router.h
zebra/zebra_vty.c

index 29f305520a95db5ff28f7ae341b6414324188cb7..eca67c06095f18018fdc47ec6f7e31e4a06066b3 100644 (file)
@@ -273,6 +273,12 @@ Nexthop tracking doesn't resolve nexthops via the default route by default.
 Allowing this might be useful when e.g. you want to allow BGP to peer across
 the default route.
 
+.. clicmd:: zebra nexthop-group keep (1-3600)
+
+   Set the time that zebra will keep a created and installed nexthop group
+   before removing it from the system if the nexthop group is no longer
+   being used.  The default time is 180 seconds.
+
 .. clicmd:: ip nht resolve-via-default
 
    Allow IPv4 nexthop tracking to resolve via the default route. This parameter
index 542972d175066945d27d63100ac87f49eb9c7035..f025507f7d1edefa9380582c1b3ebd23879f5525 100644 (file)
@@ -1649,8 +1649,8 @@ void zebra_nhg_decrement_ref(struct nhg_hash_entry *nhe)
            !CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_KEEP_AROUND)) {
                nhe->refcnt = 1;
                SET_FLAG(nhe->flags, NEXTHOP_GROUP_KEEP_AROUND);
-               thread_add_timer(zrouter.master, zebra_nhg_timer, nhe, 180,
-                                &nhe->timer);
+               thread_add_timer(zrouter.master, zebra_nhg_timer, nhe,
+                                zrouter.nhg_keep, &nhe->timer);
        }
 
        if (!zebra_nhg_depends_is_empty(nhe))
index 6b4a7543cd17c2ba48dbdb62b38baf707cb92199..92d519bad1c354f3f6777373da50a7759c4c3a43 100644 (file)
@@ -278,6 +278,8 @@ void zebra_router_init(bool asic_offload, bool notify_on_ack)
 
        zrouter.packets_to_process = ZEBRA_ZAPI_PACKETS_TO_PROCESS;
 
+       zrouter.nhg_keep = ZEBRA_DEFAULT_NHG_KEEP_TIMER;
+
        zebra_vxlan_init();
        zebra_mlag_init();
 
index 7aca91959c6f0295d9f1d1e8c1a313cf6aefa858..c96c8e5f46c203e3d99b35cc701830cc7f6e22e3 100644 (file)
@@ -219,6 +219,9 @@ struct zebra_router {
        bool notify_on_ack;
 
        bool supports_nhgs;
+
+#define ZEBRA_DEFAULT_NHG_KEEP_TIMER 180
+       uint32_t nhg_keep;
 };
 
 #define GRACEFUL_RESTART_TIME 60
index 88752edb9fb48566b50a5ec3a2231d7ae205ce37..9149da8b0d2e23b6f5c037fb589c6374f5c19671 100644 (file)
@@ -3850,11 +3850,31 @@ DEFUN (no_ip_zebra_import_table,
        return (zebra_import_table(AFI_IP, VRF_DEFAULT, table_id, 0, NULL, 0));
 }
 
+DEFPY (zebra_nexthop_group_keep,
+       zebra_nexthop_group_keep_cmd,
+       "[no] zebra nexthop-group keep (1-3600)",
+       NO_STR
+       ZEBRA_STR
+       "Nexthop-Group\n"
+       "How long to keep\n"
+       "Time in seconds from 1-3600\n")
+{
+       if (no)
+               zrouter.nhg_keep = ZEBRA_DEFAULT_NHG_KEEP_TIMER;
+       else
+               zrouter.nhg_keep = keep;
+
+       return CMD_SUCCESS;
+}
+
 static int config_write_protocol(struct vty *vty)
 {
        if (allow_delete)
                vty_out(vty, "allow-external-route-update\n");
 
+       if (zrouter.nhg_keep != ZEBRA_DEFAULT_NHG_KEEP_TIMER)
+               vty_out(vty, "zebra nexthop-group keep %u\n", zrouter.nhg_keep);
+
        if (zrouter.ribq->spec.hold != ZEBRA_RIB_PROCESS_HOLD_TIME)
                vty_out(vty, "zebra work-queue %u\n", zrouter.ribq->spec.hold);
 
@@ -4433,6 +4453,7 @@ void zebra_vty_init(void)
        install_element(CONFIG_NODE, &ip_multicast_mode_cmd);
        install_element(CONFIG_NODE, &no_ip_multicast_mode_cmd);
 
+       install_element(CONFIG_NODE, &zebra_nexthop_group_keep_cmd);
        install_element(CONFIG_NODE, &ip_zebra_import_table_distance_cmd);
        install_element(CONFIG_NODE, &no_ip_zebra_import_table_cmd);
        install_element(CONFIG_NODE, &zebra_workqueue_timer_cmd);