fib: Fix some more realloc errors
[vpp.git] / src / vnet / fib / fib_entry_src_interface.c
index 4ce4f14..e172577 100644 (file)
@@ -56,27 +56,35 @@ fib_entry_src_interface_path_swap (fib_entry_src_t *src,
                                   fib_path_list_flags_t pl_flags,
                                   const fib_route_path_t *paths)
 {
+    fib_node_index_t fib_entry_index;
     ip_adjacency_t *adj;
 
+    fib_entry_index = fib_entry_get_index(entry);
     src->fes_pl = fib_path_list_create(pl_flags, paths);
 
     /*
-     * this is a hack to get the entry's prefix into the glean adjacnecy
-     * so that it is available for fast retreival in the switch path.
+     * this is a hack to get the entry's prefix into the glean adjacency
+     * so that it is available for fast retrieval in the switch path.
      */
     if (!(FIB_ENTRY_FLAG_LOCAL & src->fes_entry_flags))
     {
-        adj = adj_get(fib_path_list_get_adj(
-                         src->fes_pl,
-                         fib_entry_get_default_chain_type(entry)));
+        adj_index_t ai;
 
-       if (IP_LOOKUP_NEXT_GLEAN == adj->lookup_next_index)
+        ai = fib_path_list_get_adj(src->fes_pl,
+                                   fib_entry_get_default_chain_type(
+                                       fib_entry_get(fib_entry_index)));
+        if (INDEX_INVALID != ai)
         {
-            /*
-             * the connected prefix will link to a glean on a non-p2p
-             * u.interface.
-             */
-            adj->sub_type.glean.receive_addr = entry->fe_prefix.fp_addr;
+            adj = adj_get(ai);
+
+            if (IP_LOOKUP_NEXT_GLEAN == adj->lookup_next_index)
+            {
+                /*
+                 * the connected prefix will link to a glean on a non-p2p
+                 * u.interface.
+                 */
+                adj->sub_type.glean.receive_addr = entry->fe_prefix.fp_addr;
+            }
         }
     }
 }
@@ -125,7 +133,7 @@ fib_entry_src_interface_deactivate (fib_entry_src_t *src,
     fib_entry_t *cover;
 
     /*
-     * remove the depednecy on the covering entry
+     * remove the dependency on the covering entry
      */
     if (FIB_NODE_INDEX_INVALID != src->u.interface.fesi_cover)
     {
@@ -213,5 +221,6 @@ const static fib_entry_src_vft_t interface_src_vft = {
 void
 fib_entry_src_interface_register (void)
 {
-    fib_entry_src_register(FIB_SOURCE_INTERFACE, &interface_src_vft);    
+    fib_entry_src_behaviour_register(FIB_SOURCE_BH_INTERFACE,
+                                     &interface_src_vft);
 }