Skip to content

Commit

Permalink
zebra: On shutdown, ensure ctx's in rib_dplane_q are freed
Browse files Browse the repository at this point in the history
a) Rename rib_init to zebra_rib_init() to better follow how
things are named

b) on shutdown cycle through the rib_dplane_q and free
up any contexts sitting in it.

Signed-off-by: Donald Sharp <[email protected]>
  • Loading branch information
donaldsharp committed Nov 16, 2023
1 parent 9c29812 commit b0e588d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
3 changes: 2 additions & 1 deletion zebra/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ void zebra_finalize(struct event *dummy)
/* Final shutdown of ns resources */
ns_walk_func(zebra_ns_final_shutdown, NULL, NULL);

zebra_rib_terminate();
zebra_router_terminate();

ns_terminate();
Expand Down Expand Up @@ -410,7 +411,7 @@ int main(int argc, char **argv)
/* Zebra related initialize. */
zebra_router_init(asic_offload, notify_on_ack, v6_with_v4_nexthop);
zserv_init();
rib_init();
zebra_rib_init();
zebra_if_init();
zebra_debug_init();

Expand Down
3 changes: 2 additions & 1 deletion zebra/rib.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,8 @@ extern void rib_update_table(struct route_table *table,
extern void rib_sweep_route(struct event *t);
extern void rib_sweep_table(struct route_table *table);
extern void rib_close_table(struct route_table *table);
extern void rib_init(void);
extern void zebra_rib_init(void);
extern void zebra_rib_terminate(void);
extern unsigned long rib_score_proto(uint8_t proto, unsigned short instance);
extern unsigned long rib_score_proto_table(uint8_t proto,
unsigned short instance,
Expand Down
16 changes: 15 additions & 1 deletion zebra/zebra_rib.c
Original file line number Diff line number Diff line change
Expand Up @@ -4984,7 +4984,7 @@ static void check_route_info(void)
}

/* Routing information base initialize. */
void rib_init(void)
void zebra_rib_init(void)
{
check_route_info();

Expand All @@ -4996,6 +4996,20 @@ void rib_init(void)
zebra_dplane_init(rib_dplane_results);
}

void zebra_rib_terminate(void)
{
struct zebra_dplane_ctx *ctx;

EVENT_OFF(t_dplane);

ctx = dplane_ctx_dequeue(&rib_dplane_q);
while (ctx) {
dplane_ctx_fini(&ctx);

ctx = dplane_ctx_dequeue(&rib_dplane_q);
}
}

/*
* vrf_id_get_next
*
Expand Down

0 comments on commit b0e588d

Please sign in to comment.