fib: refetech the adj after the walk in case the pool realloc'd 25/35725/2
authorVladislav Grishenko <themiron@yandex-team.ru>
Tue, 26 Oct 2021 19:07:01 +0000 (00:07 +0500)
committerNeale Ranns <neale@graphiant.com>
Tue, 22 Mar 2022 09:02:30 +0000 (09:02 +0000)
Follow e3aeb38fa82b77ae84643f5140d9674056b6b5ca

Type: fix
Signed-off-by: Vladislav Grishenko <themiron@yandex-team.ru>
Change-Id: I743911cacc026af5da392d26eaf47ab83ea1de99

src/vnet/adj/adj_nbr.c

index d289bb6..b3a027b 100644 (file)
@@ -532,7 +532,7 @@ adj_nbr_update_rewrite_internal (ip_adjacency_t *adj,
 
        fib_walk_sync(FIB_NODE_TYPE_ADJ, walk_ai, &bw_ctx);
        /*
-        * fib_walk_sync may allocate a new adjacency and potentially cuase a
+        * 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. We refresh the adj pointer accordingly.
         */
@@ -793,9 +793,15 @@ adj_nbr_interface_state_change_one (adj_index_t ai,
     adj_lock (ai);
 
     adj = adj_get(ai);
-
     adj->ia_flags |= ADJ_FLAG_SYNC_WALK_ACTIVE;
     fib_walk_sync(FIB_NODE_TYPE_ADJ, ai, &bw_ctx);
+
+    /*
+     * 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. We refresh the adj pointer accordingly.
+     */
+    adj = adj_get(ai);
     adj->ia_flags &= ~ADJ_FLAG_SYNC_WALK_ACTIVE;
 
     adj_unlock (ai);
@@ -903,9 +909,15 @@ adj_nbr_interface_delete_one (adj_index_t ai,
     adj_lock(ai);
 
     adj = adj_get(ai);
-
     adj->ia_flags |= ADJ_FLAG_SYNC_WALK_ACTIVE;
     fib_walk_sync(FIB_NODE_TYPE_ADJ, ai, &bw_ctx);
+
+    /*
+     * 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. We refresh the adj pointer accordingly.
+     */
+    adj = adj_get(ai);
     adj->ia_flags &= ~ADJ_FLAG_SYNC_WALK_ACTIVE;
 
     adj_unlock(ai);