From 15732f5d05f46498457b98ae3e187870210e69c4 Mon Sep 17 00:00:00 2001 From: Vladislav Grishenko Date: Wed, 27 Oct 2021 00:07:01 +0500 Subject: fib: refetech the adj after the walk in case the pool realloc'd Follow e3aeb38fa82b77ae84643f5140d9674056b6b5ca Type: fix Signed-off-by: Vladislav Grishenko Change-Id: I743911cacc026af5da392d26eaf47ab83ea1de99 --- src/vnet/adj/adj_nbr.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/vnet/adj/adj_nbr.c b/src/vnet/adj/adj_nbr.c index d289bb6a2a8..b3a027b7af4 100644 --- a/src/vnet/adj/adj_nbr.c +++ b/src/vnet/adj/adj_nbr.c @@ -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); -- cgit 1.2.3-korg