isisd: Add overload timer and overload on startup functionality

Signed-off-by: Isabella de Leon <ideleon@microsoft.com>
This commit is contained in:
Isabella de Leon 2022-09-27 11:09:21 -07:00
parent 77a39a5db2
commit 49b27ea24d
4 changed files with 31 additions and 2 deletions

View File

@ -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);
}

View File

@ -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) \

View File

@ -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)

View File

@ -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: