From 6ba8db2186790da961c6d65d2bca66a8e9495090 Mon Sep 17 00:00:00 2001 From: Rafael Zalamena Date: Fri, 17 Apr 2020 12:14:37 -0300 Subject: [PATCH] zebra: notify data plane providers about shutdown Call the `dp_fini` callback twice: once at the beginning of the shutdown and then again right before `exit()`ing zebra. Signed-off-by: Rafael Zalamena --- zebra/zebra_dplane.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c index 76447c260b..143354b166 100644 --- a/zebra/zebra_dplane.c +++ b/zebra/zebra_dplane.c @@ -3557,12 +3557,20 @@ bool dplane_is_in_shutdown(void) */ void zebra_dplane_pre_finish(void) { + struct zebra_dplane_provider *dp; + if (IS_ZEBRA_DEBUG_DPLANE) zlog_debug("Zebra dataplane pre-fini called"); zdplane_info.dg_is_shutdown = true; - /* TODO -- Notify provider(s) of pending shutdown */ + /* Notify provider(s) of pending shutdown. */ + TAILQ_FOREACH(dp, &zdplane_info.dg_providers_q, dp_prov_link) { + if (dp->dp_fini == NULL) + continue; + + dp->dp_fini(dp, true); + } } /* @@ -3863,6 +3871,8 @@ done: */ void zebra_dplane_shutdown(void) { + struct zebra_dplane_provider *dp; + if (IS_ZEBRA_DEBUG_DPLANE) zlog_debug("Zebra dataplane shutdown called"); @@ -3881,7 +3891,13 @@ void zebra_dplane_shutdown(void) zdplane_info.dg_pthread = NULL; zdplane_info.dg_master = NULL; - /* TODO -- Notify provider(s) of final shutdown */ + /* Notify provider(s) of final shutdown. */ + TAILQ_FOREACH(dp, &zdplane_info.dg_providers_q, dp_prov_link) { + if (dp->dp_fini == NULL) + continue; + + dp->dp_fini(dp, false); + } /* TODO -- Clean-up provider objects */ -- 2.39.5