aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/fib/fib_path.c
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2021-06-08 18:44:37 +0200
committerBenoît Ganne <bganne@cisco.com>2021-06-08 18:53:01 +0200
commite9d7b0982d7bd189097260b6581abff472da251a (patch)
tree3234ce4d5a9972bf4ac5e8f20598e89eba2fabce /src/vnet/fib/fib_path.c
parent9f10edbb46dc1937ed99469a581723cb1ac1ff45 (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>
Diffstat (limited to 'src/vnet/fib/fib_path.c')
-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 c5800454729..209cf403c6e 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))
@@ -2441,11 +2449,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;
}