fib: refresh adj pointer after fib_walk_sync due to possible realloc
[vpp.git] / src / vnet / ip-neighbor / ip_neighbor.c
index ceec373..6af76d2 100644 (file)
@@ -339,7 +339,7 @@ ip_neighbor_mk_incomplete (adj_index_t ai)
                          ethernet_build_rewrite (vnet_get_main (),
                                                  adj->
                                                  rewrite_header.sw_if_index,
-                                                 adj_get_link_type (ai),
+                                                 VNET_LINK_ARP,
                                                  VNET_REWRITE_FOR_SW_INTERFACE_ADDRESS_BROADCAST));
 }
 
@@ -615,6 +615,13 @@ ip_neighbor_update (vnet_main_t * vnm, adj_index_t ai)
           * wouldn't be bad either, but that's more code than i'm prepared to
           * write at this time for relatively little reward.
           */
+         /*
+          * adj_nbr_update_rewrite may actually call fib_walk_sync.
+          * fib_walk_sync may allocate a new adjacency and potentially cause
+          * a realloc for adj_pool. When that happens, adj pointer is no
+          * longer valid here.x We refresh adj pointer accordingly.
+          */
+         adj = adj_get (ai);
          ip_neighbor_probe (adj);
        }
       break;