diff options
author | Isabella de Leon <ideleon@microsoft.com> | 2022-09-27 20:09:21 +0200 |
---|---|---|
committer | Isabella de Leon <ideleon@microsoft.com> | 2022-09-30 19:39:18 +0200 |
commit | 49b27ea24dc8f7e532058940b7f96897c1941a3c (patch) | |
tree | 9b6c9d73a28814961e9a4700113c7a3a10b21425 /isisd | |
parent | doc: Add CLI documentation for new overload on startup command (diff) | |
download | frr-49b27ea24dc8f7e532058940b7f96897c1941a3c.tar.xz frr-49b27ea24dc8f7e532058940b7f96897c1941a3c.zip |
isisd: Add overload timer and overload on startup functionality
Signed-off-by: Isabella de Leon <ideleon@microsoft.com>
Diffstat (limited to 'isisd')
-rw-r--r-- | isisd/isis_lsp.c | 29 | ||||
-rw-r--r-- | isisd/isis_lsp.h | 1 | ||||
-rw-r--r-- | isisd/isisd.c | 2 | ||||
-rw-r--r-- | isisd/isisd.h | 1 |
4 files changed, 31 insertions, 2 deletions
diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c index 5387f3703..fbf559713 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); } diff --git a/isisd/isis_lsp.h b/isisd/isis_lsp.h index b13b2a35e..d7762324d 100644 --- a/isisd/isis_lsp.h +++ b/isisd/isis_lsp.h @@ -66,6 +66,7 @@ DECLARE_RBTREE_UNIQ(lspdb, struct isis_lsp, dbe, lspdb_compare); void lsp_db_init(struct lspdb_head *head); void lsp_db_fini(struct lspdb_head *head); void lsp_tick(struct thread *thread); +void set_overload_on_start_timer(struct thread *thread); int lsp_generate(struct isis_area *area, int level); #define lsp_regenerate_schedule(area, level, all_pseudo) \ diff --git a/isisd/isisd.c b/isisd/isisd.c index 7a631128a..3ba00e6bf 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -3210,8 +3210,6 @@ void isis_area_overload_on_startup_set(struct isis_area *area, { if (area->overload_on_startup_time != startup_time) area->overload_on_startup_time = startup_time; - - // TODO: Implement overload on startup functionality } void isis_area_attached_bit_send_set(struct isis_area *area, bool attached_bit) diff --git a/isisd/isisd.h b/isisd/isisd.h index 316f979e1..f1f92b365 100644 --- a/isisd/isisd.h +++ b/isisd/isisd.h @@ -142,6 +142,7 @@ struct isis_area { struct flags flags; struct thread *t_tick; /* LSP walker */ struct thread *t_lsp_refresh[ISIS_LEVELS]; + struct thread *t_overload_on_startup_timer; struct timeval last_lsp_refresh_event[ISIS_LEVELS]; struct thread *t_rlfa_rib_update; /* t_lsp_refresh is used in two ways: |