fib: Fix some more realloc errors
Type: fix
Change-Id: I6011f5d6eae79019d3c16a260a9bedf0a76d2151
Signed-off-by: Neale Ranns <nranns@cisco.com>
diff --git a/src/vnet/fib/fib_entry.c b/src/vnet/fib/fib_entry.c
index d8c57fd..3bef28e 100644
--- a/src/vnet/fib/fib_entry.c
+++ b/src/vnet/fib/fib_entry.c
@@ -708,7 +708,7 @@
{
fib_entry = fib_entry_post_flag_update_actions(fib_entry,
old_flags);
- fib_entry_src_action_installed(fib_entry, source);
+ fib_entry = fib_entry_src_action_installed(fib_entry, source);
return (fib_entry);
}
diff --git a/src/vnet/fib/fib_entry_src.c b/src/vnet/fib/fib_entry_src.c
index d534135..ad8b23e 100644
--- a/src/vnet/fib/fib_entry_src.c
+++ b/src/vnet/fib/fib_entry_src.c
@@ -91,7 +91,7 @@
.fes_entry_flags = flags,
};
- FIB_ENTRY_SRC_VFT_INVOKE(&esrc, fesv_init, (&esrc));
+ FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, &esrc, fesv_init, (&esrc));
vec_add1(fib_entry->fe_srcs, esrc);
vec_sort_with_function(fib_entry->fe_srcs,
@@ -213,7 +213,7 @@
ASSERT(NULL != esrc);
- FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_deinit, (esrc));
+ FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_deinit, (esrc));
fib_path_ext_list_flush(&esrc->fes_path_exts);
vec_del1(fib_entry->fe_srcs, index);
@@ -776,7 +776,7 @@
orig_src->fes_src,
orig_src->fes_entry_flags);
- FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_copy,
+ FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_copy,
(orig_src, fib_entry, esrc));
fib_path_list_unlock(esrc->fes_pl);
@@ -1095,7 +1095,7 @@
ASSERT(esrc->fes_flags & FIB_ENTRY_SRC_FLAG_ACTIVE);
- FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_deactivate,
+ FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_deactivate,
(esrc, fib_entry));
esrc->fes_flags &= ~(FIB_ENTRY_SRC_FLAG_ACTIVE |
@@ -1134,7 +1134,7 @@
vec_foreach(esrc, fib_entry->fe_srcs)
{
- FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_fwd_update,
+ FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_fwd_update,
(esrc, fib_entry, source));
}
}
@@ -1223,18 +1223,20 @@
fib_entry_src_action_fwd_update(fib_entry, source);
}
-void
-fib_entry_src_action_installed (const fib_entry_t *fib_entry,
+fib_entry_t *
+fib_entry_src_action_installed (fib_entry_t *fib_entry,
fib_source_t source)
{
fib_entry_src_t *esrc;
esrc = fib_entry_src_find(fib_entry, source);
- FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_installed,
+ FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_installed,
(esrc, fib_entry));
fib_entry_src_action_fwd_update(fib_entry, source);
+
+ return (fib_entry);
}
/*
@@ -1251,7 +1253,6 @@
fib_entry_flag_t flags,
const dpo_id_t *dpo)
{
- fib_node_index_t fib_entry_index;
fib_entry_src_t *esrc;
esrc = fib_entry_src_find_or_create(fib_entry, source, flags);
@@ -1261,7 +1262,7 @@
if (flags != esrc->fes_entry_flags)
{
- FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_flags_change,
+ FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_flags_change,
(esrc, fib_entry, flags));
}
esrc->fes_entry_flags = flags;
@@ -1274,20 +1275,13 @@
return (fib_entry);
}
- /*
- * save variable so we can recover from a fib_entry realloc.
- */
- fib_entry_index = fib_entry_get_index(fib_entry);
-
- FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_add,
+ FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_add,
(esrc,
fib_entry,
flags,
fib_entry_get_dpo_proto(fib_entry),
dpo));
- fib_entry = fib_entry_get(fib_entry_index);
-
esrc->fes_flags |= FIB_ENTRY_SRC_FLAG_ADDED;
fib_path_list_lock(esrc->fes_pl);
@@ -1314,7 +1308,7 @@
fib_entry_flag_t flags,
const dpo_id_t *dpo)
{
- fib_node_index_t fib_entry_index, old_path_list_index;
+ fib_node_index_t old_path_list_index;
fib_entry_src_t *esrc;
esrc = fib_entry_src_find_or_create(fib_entry, source, flags);
@@ -1327,20 +1321,13 @@
old_path_list_index = esrc->fes_pl;
esrc->fes_entry_flags = flags;
- /*
- * save variable so we can recover from a fib_entry realloc.
- */
- fib_entry_index = fib_entry_get_index(fib_entry);
-
- FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_add,
+ FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_add,
(esrc,
fib_entry,
flags,
fib_entry_get_dpo_proto(fib_entry),
dpo));
- fib_entry = fib_entry_get(fib_entry_index);
-
esrc->fes_flags |= FIB_ENTRY_SRC_FLAG_ADDED;
fib_path_list_lock(esrc->fes_pl);
@@ -1435,14 +1422,14 @@
}
else if (esrc->fes_flags & FIB_ENTRY_SRC_FLAG_CONTRIBUTING)
{
- FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_deactivate,
+ FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_deactivate,
(esrc, fib_entry));
esrc->fes_flags &= ~FIB_ENTRY_SRC_FLAG_CONTRIBUTING;
}
old_path_list = esrc->fes_pl;
- FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_remove, (esrc));
+ FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_remove, (esrc));
fib_path_list_unlock(old_path_list);
fib_entry_unlock(fib_entry_get_index(fib_entry));
@@ -1584,15 +1571,10 @@
fib_entry_flag_t flags,
const fib_route_path_t *rpaths)
{
- fib_node_index_t old_path_list, fib_entry_index;
+ fib_node_index_t old_path_list;
fib_path_list_flags_t pl_flags;
fib_entry_src_t *esrc;
- /*
- * save variable so we can recover from a fib_entry realloc.
- */
- fib_entry_index = fib_entry_get_index(fib_entry);
-
esrc = fib_entry_src_find(fib_entry, source);
if (NULL == esrc)
{
@@ -1625,9 +1607,8 @@
pl_flags = fib_entry_src_flags_2_path_list_flags(fib_entry_get_flags_i(fib_entry));
fib_entry_flags_update(fib_entry, rpaths, &pl_flags, esrc);
- FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_path_add,
+ FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_path_add,
(esrc, fib_entry, pl_flags, rpaths));
- fib_entry = fib_entry_get(fib_entry_index);
fib_path_list_lock(esrc->fes_pl);
fib_path_list_unlock(old_path_list);
@@ -1650,17 +1631,12 @@
fib_entry_flag_t flags,
const fib_route_path_t *rpaths)
{
- fib_node_index_t old_path_list, fib_entry_index;
+ fib_node_index_t old_path_list;
fib_path_list_flags_t pl_flags;
fib_entry_src_t *esrc;
esrc = fib_entry_src_find(fib_entry, source);
- /*
- * save variable so we can recover from a fib_entry realloc.
- */
- fib_entry_index = fib_entry_get_index(fib_entry);
-
if (NULL == esrc)
{
const dpo_id_t *dpo;
@@ -1681,7 +1657,7 @@
{
if (flags != esrc->fes_entry_flags)
{
- FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_flags_change,
+ FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_flags_change,
(esrc, fib_entry, flags));
}
esrc->fes_entry_flags = flags;
@@ -1700,12 +1676,10 @@
fib_entry_flags_update(fib_entry, rpaths, &pl_flags, esrc);
- FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_path_swap,
+ FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_path_swap,
(esrc, fib_entry,
pl_flags, rpaths));
- fib_entry = fib_entry_get(fib_entry_index);
-
fib_path_list_lock(esrc->fes_pl);
fib_path_list_unlock(old_path_list);
@@ -1739,7 +1713,7 @@
pl_flags = fib_entry_src_flags_2_path_list_flags(fib_entry_get_flags_i(fib_entry));
fib_entry_flags_update(fib_entry, rpaths, &pl_flags, esrc);
- FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_path_remove,
+ FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_path_remove,
(esrc, pl_flags, rpaths));
/*
@@ -1901,7 +1875,7 @@
if (NULL != esrc)
{
- FIB_ENTRY_SRC_VFT_INVOKE(esrc, fesv_set_data,
+ FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, esrc, fesv_set_data,
(esrc, fib_entry, data));
}
}
diff --git a/src/vnet/fib/fib_entry_src.h b/src/vnet/fib/fib_entry_src.h
index 3080057..edeaaf9 100644
--- a/src/vnet/fib/fib_entry_src.h
+++ b/src/vnet/fib/fib_entry_src.h
@@ -226,14 +226,16 @@
} \
}
-#define FIB_ENTRY_SRC_VFT_INVOKE(esrc, func, args) \
+#define FIB_ENTRY_SRC_VFT_INVOKE(_fe, esrc, func, args) \
{ \
const fib_entry_src_vft_t *_vft; \
+ fib_node_index_t _fei = fib_entry_get_index(_fe); \
_vft = fib_entry_src_get_vft(esrc); \
if (_vft->func) { \
(esrc)->fes_flags &= ~FIB_ENTRY_SRC_FLAG_STALE; \
_vft->func args; \
} \
+ _fe = fib_entry_get(_fei); \
}
#define FIB_ENTRY_SRC_VFT_INVOKE_AND_RETURN(esrc, func, args) \
@@ -313,8 +315,8 @@
fib_source_t source,
const fib_route_path_t *path);
-extern void fib_entry_src_action_installed(const fib_entry_t *fib_entry,
- fib_source_t source);
+extern fib_entry_t* fib_entry_src_action_installed(fib_entry_t *fib_entry,
+ fib_source_t source);
extern void fib_entry_src_inherit (const fib_entry_t *cover,
fib_entry_t *covered);
diff --git a/src/vnet/fib/fib_entry_src_interface.c b/src/vnet/fib/fib_entry_src_interface.c
index 88154ef..e172577 100644
--- a/src/vnet/fib/fib_entry_src_interface.c
+++ b/src/vnet/fib/fib_entry_src_interface.c
@@ -56,8 +56,10 @@
fib_path_list_flags_t pl_flags,
const fib_route_path_t *paths)
{
+ fib_node_index_t fib_entry_index;
ip_adjacency_t *adj;
+ fib_entry_index = fib_entry_get_index(entry);
src->fes_pl = fib_path_list_create(pl_flags, paths);
/*
@@ -69,7 +71,8 @@
adj_index_t ai;
ai = fib_path_list_get_adj(src->fes_pl,
- fib_entry_get_default_chain_type(entry));
+ fib_entry_get_default_chain_type(
+ fib_entry_get(fib_entry_index)));
if (INDEX_INVALID != ai)
{
adj = adj_get(ai);
diff --git a/src/vnet/fib/fib_entry_src_interpose.c b/src/vnet/fib/fib_entry_src_interpose.c
index 02db391..af650a9 100644
--- a/src/vnet/fib/fib_entry_src_interpose.c
+++ b/src/vnet/fib/fib_entry_src_interpose.c
@@ -207,7 +207,7 @@
* there is another source for this entry. activate it so it
* can provide forwarding
*/
- FIB_ENTRY_SRC_VFT_INVOKE(best_src, fesv_deactivate,
+ FIB_ENTRY_SRC_VFT_INVOKE(fib_entry, best_src, fesv_deactivate,
(best_src, fib_entry));
}
}