aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2021-06-08 18:44:37 +0200
committerDave Wallace <dwallacelf@gmail.com>2021-06-09 15:16:10 +0000
commitd0f23a316404025f946317826b9234b8afcc93ac (patch)
tree69a8f42554cd11dd4c51b573d9ecffd8f791a6cb
parent655c37760724c26c1de15602bf8e4087854af042 (diff)
fib: make sure dpo is valid even when path pool expands
The path pool can expand during in fib_path_attached_next_hop_get_adj() when calling adj_nbr_add_or_lock(). If dpo points to a path->fp_dpo, its reference becomes stale. Use a temporary copy instead. Type: fix Change-Id: Ie966cb5f3f7b416425964dca12f1f586bfc2010c Signed-off-by: Benoît Ganne <bganne@cisco.com> (cherry picked from commit e9d7b0982d7bd189097260b6581abff472da251a)
-rw-r--r--src/vnet/fib/fib_path.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/vnet/fib/fib_path.c b/src/vnet/fib/fib_path.c
index 01140d5d0dc..04ef5450923 100644
--- a/src/vnet/fib/fib_path.c
+++ b/src/vnet/fib/fib_path.c
@@ -664,14 +664,18 @@ fib_path_attached_next_hop_get_adj (fib_path_t *path,
static void
fib_path_attached_next_hop_set (fib_path_t *path)
{
+ dpo_id_t tmp = DPO_INVALID;
+
/*
* resolve directly via the adjacency discribed by the
* interface and next-hop
*/
+ dpo_copy (&tmp, &path->fp_dpo);
path = fib_path_attached_next_hop_get_adj(path,
dpo_proto_to_link(path->fp_nh_proto),
- &path->fp_dpo);
-
+ &tmp);
+ dpo_copy(&path->fp_dpo, &tmp);
+ dpo_reset(&tmp);
ASSERT(dpo_is_adj(&path->fp_dpo));
/*
@@ -1089,16 +1093,20 @@ FIXME comment
/*
* restack the DPO to pick up the correct DPO sub-type
*/
+ dpo_id_t tmp = DPO_INVALID;
uword if_is_up;
if_is_up = vnet_sw_interface_is_up(
vnet_get_main(),
path->attached_next_hop.fp_interface);
+ dpo_copy (&tmp, &path->fp_dpo);
path = fib_path_attached_next_hop_get_adj(
path,
dpo_proto_to_link(path->fp_nh_proto),
- &path->fp_dpo);
+ &tmp);
+ dpo_copy(&path->fp_dpo, &tmp);
+ dpo_reset(&tmp);
path->fp_oper_flags &= ~FIB_PATH_OPER_FLAG_RESOLVED;
if (if_is_up && adj_is_up(path->fp_dpo.dpoi_index))
@@ -2439,11 +2447,17 @@ fib_path_contribute_forwarding (fib_node_index_t path_index,
case FIB_FORW_CHAIN_TYPE_NSH:
case FIB_FORW_CHAIN_TYPE_MCAST_IP4:
case FIB_FORW_CHAIN_TYPE_MCAST_IP6:
- path = fib_path_attached_next_hop_get_adj(
- path,
- fib_forw_chain_type_to_link_type(fct),
- dpo);
- break;
+ {
+ dpo_id_t tmp = DPO_INVALID;
+ dpo_copy (&tmp, dpo);
+ path = fib_path_attached_next_hop_get_adj(
+ path,
+ fib_forw_chain_type_to_link_type(fct),
+ &tmp);
+ dpo_copy (dpo, &tmp);
+ dpo_reset(&tmp);
+ break;
+ }
case FIB_FORW_CHAIN_TYPE_BIER:
break;
}