summaryrefslogtreecommitdiff
path: root/isisd/isis_lsp.c
diff options
context:
space:
mode:
authorIsabella de Leon <ideleon@microsoft.com>2022-09-27 11:09:21 -0700
committerIsabella de Leon <ideleon@microsoft.com>2022-09-30 10:39:18 -0700
commit49b27ea24dc8f7e532058940b7f96897c1941a3c (patch)
tree9b6c9d73a28814961e9a4700113c7a3a10b21425 /isisd/isis_lsp.c
parent77a39a5db2fa1563aab73a97ccbce593b3b29b9f (diff)
isisd: Add overload timer and overload on startup functionality
Signed-off-by: Isabella de Leon <ideleon@microsoft.com>
Diffstat (limited to 'isisd/isis_lsp.c')
-rw-r--r--isisd/isis_lsp.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c
index 5387f37039..fbf559713f 100644
--- a/isisd/isis_lsp.c
+++ b/isisd/isis_lsp.c
@@ -68,6 +68,8 @@ static void lsp_l2_refresh_pseudo(struct thread *thread);
static void lsp_destroy(struct isis_lsp *lsp);
+static bool device_startup;
+
int lsp_id_cmp(uint8_t *id1, uint8_t *id2)
{
return memcmp(id1, id2, ISIS_SYS_ID_LEN + 2);
@@ -437,6 +439,18 @@ bool isis_level2_adj_up(struct isis_area *area)
return false;
}
+/*
+ * Unset the overload bit after the timer expires
+ */
+void set_overload_on_start_timer(struct thread *thread)
+{
+ struct isis_area *area = THREAD_ARG(thread);
+ assert(area);
+
+ area->t_overload_on_startup_timer = NULL;
+ isis_area_overload_bit_set(area, false);
+}
+
static void isis_reset_attach_bit(struct isis_adjacency *adj)
{
struct isis_area *area = adj->circuit->area;
@@ -1431,6 +1445,20 @@ static int lsp_regenerate(struct isis_area *area, int level)
if ((area == NULL) || (area->is_type & level) != level)
return ISIS_ERROR;
+ /*
+ * Check if the device is initializing and set overload bit on startup
+ * is configured.
+ */
+ if (device_startup) {
+ if (area->overload_on_startup_time > 0) {
+ isis_area_overload_bit_set(area, true);
+ thread_add_timer(master, set_overload_on_start_timer,
+ area, area->overload_on_startup_time,
+ &area->t_overload_on_startup_timer);
+ }
+ device_startup = false;
+ }
+
head = &area->lspdb[level - 1];
memset(lspid, 0, ISIS_SYS_ID_LEN + 2);
memcpy(lspid, area->isis->sysid, ISIS_SYS_ID_LEN);
@@ -2373,6 +2401,7 @@ int isis_lsp_iterate_is_reach(struct isis_lsp *lsp, uint16_t mtid,
void lsp_init(void)
{
+ device_startup = true;
hook_register(isis_adj_state_change_hook,
lsp_handle_adj_state_change);
}