]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: do not crash if zebrad.lsp_process_q is NULL
authorDaniel Walton <dwalton@cumulusnetworks.com>
Wed, 10 May 2017 13:42:56 +0000 (09:42 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 10 May 2017 14:06:47 +0000 (10:06 -0400)
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
zebra/zebra_mpls.c

index bb9c913e3cf3504b3314cac32e66401df15e53cf..65e7f9ab95c8a8435f76483b318fd82eaa834d90 100644 (file)
@@ -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;
 }