From 695b279ae3b564b3d850a6eb70e79dccd0c6d5d3 Mon Sep 17 00:00:00 2001 From: Mark Stapp Date: Thu, 18 Nov 2021 07:32:01 -0500 Subject: [PATCH 1/2] zebra: free LSP workqueue early, revert PR 10050 this reverts commit dd9538c5f36f9d6110, which tried to clear the LSP workqueue late during shutdown. Signed-off-by: Mark Stapp --- zebra/main.c | 3 +++ zebra/zebra_router.c | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/zebra/main.c b/zebra/main.c index 038022ceb2..275d9af5d2 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -183,6 +183,9 @@ static void sigint(void) } } + if (zrouter.lsp_process_q) + work_queue_free_and_null(&zrouter.lsp_process_q); + vrf_terminate(); ns_walk_func(zebra_ns_early_shutdown, NULL, NULL); diff --git a/zebra/zebra_router.c b/zebra/zebra_router.c index 4ce756c953..a80c573855 100644 --- a/zebra/zebra_router.c +++ b/zebra/zebra_router.c @@ -235,9 +235,6 @@ void zebra_router_terminate(void) RB_FOREACH_SAFE (zrt, zebra_router_table_head, &zrouter.tables, tmp) zebra_router_free_table(zrt); - if (zrouter.lsp_process_q) - work_queue_free_and_null(&zrouter.lsp_process_q); - work_queue_free_and_null(&zrouter.ribq); meta_queue_free(zrouter.mq); From b0d10d93e2ab72b3664fc1e4e1b3a622bb164455 Mon Sep 17 00:00:00 2001 From: Mark Stapp Date: Thu, 18 Nov 2021 07:21:34 -0500 Subject: [PATCH 2/2] zebra: during shutdown, don't process LSPs on the lsp workqueue During zebra shutdown, we clear out the LSP workqueue. The LSPs will be uninstalled and freed during the shutdown process, so just ignore any LSPs that happen to be on the workqueue. Signed-off-by: Mark Stapp --- zebra/zebra_mpls.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index 00ac98cbc0..1b4fc1b75d 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -1037,6 +1037,16 @@ static void lsp_processq_del(struct work_queue *wq, void *data) struct zebra_lsp *lsp; struct hash *lsp_table; struct zebra_nhlfe *nhlfe; + bool in_shutdown = false; + + /* If zebra is shutting down, don't delete any structs, + * just ignore this callback. The LSPs will be cleaned up + * during the shutdown processing. + */ + in_shutdown = atomic_load_explicit(&zrouter.in_shutdown, + memory_order_relaxed); + if (in_shutdown) + return; zvrf = vrf_info_lookup(VRF_DEFAULT); assert(zvrf);