Skip to content

Commit

Permalink
zebra: On shutdown, free up srv6 list data
Browse files Browse the repository at this point in the history
Signed-off-by: Donald Sharp <[email protected]>
  • Loading branch information
donaldsharp committed Dec 12, 2023
1 parent 315262c commit 9393d36
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions zebra/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ void zebra_finalize(struct event *dummy)

zebra_pw_terminate();

zebra_srv6_terminate();

label_manager_terminate();

ns_terminate();
Expand Down
20 changes: 19 additions & 1 deletion zebra/zebra_srv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,10 @@ void zebra_notify_srv6_locator_delete(struct srv6_locator *locator)
}
}

struct zebra_srv6 srv6;

struct zebra_srv6 *zebra_srv6_get_default(void)
{
static struct zebra_srv6 srv6;
static bool first_execution = true;

if (first_execution) {
Expand Down Expand Up @@ -408,6 +409,23 @@ int release_daemon_srv6_locator_chunks(struct zserv *client)
return count;
}

void zebra_srv6_terminate(void)
{
struct srv6_locator *locator;

if (!srv6.locators)
return;

while (listcount(srv6.locators)) {
locator = listnode_head(srv6.locators);

listnode_delete(srv6.locators, locator);
srv6_locator_free(locator);
}

list_delete(&srv6.locators);
}

void zebra_srv6_init(void)
{
hook_register(zserv_client_close, zebra_srv6_cleanup);
Expand Down
1 change: 1 addition & 0 deletions zebra/zebra_srv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ void zebra_notify_srv6_locator_add(struct srv6_locator *locator);
void zebra_notify_srv6_locator_delete(struct srv6_locator *locator);

extern void zebra_srv6_init(void);
extern void zebra_srv6_terminate(void);
extern struct zebra_srv6 *zebra_srv6_get_default(void);
extern bool zebra_srv6_is_enable(void);

Expand Down

0 comments on commit 9393d36

Please sign in to comment.