From: Daniel Walton Date: Wed, 10 May 2017 13:42:56 +0000 (-0400) Subject: zebra: do not crash if zebrad.lsp_process_q is NULL X-Git-Tag: reindent-master-before~176^2~1 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=33c32282722f62190dd644b203865a09979e7754;p=matthieu%2Ffrr.git zebra: do not crash if zebrad.lsp_process_q is NULL Signed-off-by: Daniel Walton --- diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index bb9c913e3c..65e7f9ab95 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -156,7 +156,7 @@ static int snhlfe_del_all (zebra_slsp_t *slsp); static char * snhlfe2str (zebra_snhlfe_t *snhlfe, char *buf, int size); -static void +static int mpls_processq_init (struct zebra_t *zebra); @@ -1037,6 +1037,12 @@ lsp_processq_add (zebra_lsp_t *lsp) if (CHECK_FLAG (lsp->flags, LSP_FLAG_SCHEDULED)) return 0; + if (zebrad.lsp_process_q == NULL) + { + zlog_err ("%s: work_queue does not exist!", __func__); + return -1; + } + work_queue_add (zebrad.lsp_process_q, lsp); SET_FLAG (lsp->flags, LSP_FLAG_SCHEDULED); return 0; @@ -1693,14 +1699,14 @@ snhlfe2str (zebra_snhlfe_t *snhlfe, char *buf, int size) /* * Initialize work queue for processing changed LSPs. */ -static void +static int mpls_processq_init (struct zebra_t *zebra) { zebra->lsp_process_q = work_queue_new (zebra->master, "LSP processing"); if (!zebra->lsp_process_q) { zlog_err ("%s: could not initialise work queue!", __func__); - return; + return -1; } zebra->lsp_process_q->spec.workfunc = &lsp_process; @@ -1709,6 +1715,8 @@ mpls_processq_init (struct zebra_t *zebra) zebra->lsp_process_q->spec.completion_func = &lsp_processq_complete; zebra->lsp_process_q->spec.max_retries = 0; zebra->lsp_process_q->spec.hold = 10; + + return 0; } @@ -2978,12 +2986,14 @@ zebra_mpls_init_tables (struct zebra_vrf *zvrf) void zebra_mpls_init (void) { + mpls_enabled = 0; + if (mpls_kernel_init () < 0) { zlog_warn ("Disabling MPLS support (no kernel support)"); return; } - mpls_enabled = 1; - mpls_processq_init (&zebrad); + if (! mpls_processq_init (&zebrad)) + mpls_enabled = 1; }