From b0e588de88df0e8f462689c09c8bb852dc62edf9 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 16 Nov 2023 12:55:34 -0500 Subject: [PATCH] zebra: On shutdown, ensure ctx's in rib_dplane_q are freed 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 --- zebra/main.c | 3 ++- zebra/rib.h | 3 ++- zebra/zebra_rib.c | 16 +++++++++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/zebra/main.c b/zebra/main.c index aea30daa3b00..304f4797fcf4 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -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(); @@ -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(); diff --git a/zebra/rib.h b/zebra/rib.h index 665f286f67a7..2f9b0ccb7e0d 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -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, diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 05ac3f3d8e61..16a58fc63132 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -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(); @@ -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 *