fib: recursive calculation leads to delegate pool realloc 23/22723/3
authorNeale Ranns <nranns@cisco.com>
Mon, 14 Oct 2019 15:52:43 +0000 (08:52 -0700)
committerDamjan Marion <dmarion@me.com>
Mon, 14 Oct 2019 22:43:13 +0000 (22:43 +0000)
Type: fix

Change-Id: Ib7ac53d1b59b641ccd3b1d733107d7f1ba174314
Signed-off-by: Neale Ranns <nranns@cisco.com>
src/vnet/fib/fib_entry.c

index 9169dcc..833fcb3 100644 (file)
@@ -470,9 +470,12 @@ fib_entry_contribute_forwarding (fib_node_index_t fib_entry_index,
 
         if (NULL == fed)
         {
-            fed = fib_entry_delegate_find_or_add(
-                      fib_entry,
-                      fib_entry_chain_type_to_delegate_type(fct));
+            /*
+             * use a temporary DPO lest the delegate realloc in the recursive
+             * calculation.
+             */
+            dpo_id_t tmp = DPO_INVALID;
+
             /*
              * on-demand create eos/non-eos.
              * There is no on-demand delete because:
@@ -483,7 +486,14 @@ fib_entry_contribute_forwarding (fib_node_index_t fib_entry_index,
             fib_entry_src_mk_lb(fib_entry,
                                 fib_entry_get_best_src_i(fib_entry),
                                 fct,
-                                &fed->fd_dpo);
+                                &tmp);
+
+            fed = fib_entry_delegate_find_or_add(
+                fib_entry,
+                fib_entry_chain_type_to_delegate_type(fct));
+
+            dpo_copy(&fed->fd_dpo, &tmp);
+            dpo_reset(&tmp);
         }
 
         dpo_copy(dpo, &fed->fd_dpo);