summaryrefslogtreecommitdiffstats
path: root/src/vnet/mfib
diff options
context:
space:
mode:
authorNeale Ranns <neale@graphiant.com>2022-03-23 14:51:57 +0000
committerDamjan Marion <dmarion@me.com>2022-03-24 11:29:27 +0000
commit60bb4534270c4c931ac441e9ec7de9bf09e47401 (patch)
treeeaa2b4ae8554f6fd02fbee341b28358a6ab8c0b1 /src/vnet/mfib
parent03b22e62e108fc2ed7a0186e372dc752b0afa46c (diff)
fib: Fix crash when removing a covering prefix
Type: fix When a covering entry is removed from the table, the covered entries first see it 'updated' and then 'removed'. the crash occurs because the covered prefixes share (simple pointer copy) the covereds hash table of path extensions. During the cervers deletion this hash table has been removed and the update of the covered crashes when recaluationg forwarding becuase it uses the free'd hash. Fix is to refetch the shared hash table (which is NULL) when the covered is updated. Signed-off-by: Neale Ranns <neale@graphiant.com> Change-Id: Icefca9d7b21da975111d0e974d75f663fc0cc00c
Diffstat (limited to 'src/vnet/mfib')
-rw-r--r--src/vnet/mfib/mfib_entry.c2
-rw-r--r--src/vnet/mfib/mfib_entry_src.h2
-rw-r--r--src/vnet/mfib/mfib_entry_src_rr.c24
3 files changed, 18 insertions, 10 deletions
diff --git a/src/vnet/mfib/mfib_entry.c b/src/vnet/mfib/mfib_entry.c
index 20945aa6781..244dd4fb206 100644
--- a/src/vnet/mfib/mfib_entry.c
+++ b/src/vnet/mfib/mfib_entry.c
@@ -499,7 +499,7 @@ mfib_entry_alloc (u32 fib_index,
}
static inline mfib_path_ext_t *
-mfib_entry_path_ext_find (mfib_path_ext_t *exts,
+mfib_entry_path_ext_find (uword *exts,
fib_node_index_t path_index)
{
uword *p;
diff --git a/src/vnet/mfib/mfib_entry_src.h b/src/vnet/mfib/mfib_entry_src.h
index b85c010779c..ab3cb3ebda7 100644
--- a/src/vnet/mfib/mfib_entry_src.h
+++ b/src/vnet/mfib/mfib_entry_src.h
@@ -109,7 +109,7 @@ typedef struct mfib_entry_src_t_
/**
* Hash table of path extensions
*/
- mfib_path_ext_t *mfes_exts;
+ uword *mfes_exts;
/**
* Covering entry (if needed)
diff --git a/src/vnet/mfib/mfib_entry_src_rr.c b/src/vnet/mfib/mfib_entry_src_rr.c
index a6a1e0d8aa5..5f697a5fad1 100644
--- a/src/vnet/mfib/mfib_entry_src_rr.c
+++ b/src/vnet/mfib/mfib_entry_src_rr.c
@@ -20,8 +20,8 @@
#include <vnet/fib/fib_path_list.h>
static void
-mfib_entry_src_rr_deactiviate (mfib_entry_t *mfib_entry,
- mfib_entry_src_t *msrc)
+mfib_entry_src_rr_deactivate (mfib_entry_t *mfib_entry,
+ mfib_entry_src_t *msrc)
{
mfib_entry_t *cover;
@@ -42,8 +42,8 @@ mfib_entry_src_rr_deactiviate (mfib_entry_t *mfib_entry,
}
static void
-mfib_entry_src_rr_activiate (mfib_entry_t *mfib_entry,
- mfib_entry_src_t *msrc)
+mfib_entry_src_rr_activate (mfib_entry_t *mfib_entry,
+ mfib_entry_src_t *msrc)
{
mfib_entry_src_t *csrc;
mfib_entry_t *cover;
@@ -72,8 +72,8 @@ static mfib_src_res_t
mfib_entry_src_rr_cover_change (mfib_entry_t *mfib_entry,
mfib_entry_src_t *msrc)
{
- mfib_entry_src_rr_deactiviate(mfib_entry, msrc);
- mfib_entry_src_rr_activiate(mfib_entry, msrc);
+ mfib_entry_src_rr_deactivate(mfib_entry, msrc);
+ mfib_entry_src_rr_activate(mfib_entry, msrc);
return (MFIB_SRC_REEVALUATE);
}
@@ -87,6 +87,7 @@ mfib_entry_src_rr_cover_update (mfib_entry_t *mfib_entry,
* so there's no need to check for a new one. but we do need to
* copy down any new flags and input interfaces
*/
+ mfib_entry_src_t *csrc;
mfib_entry_t *cover;
cover = mfib_entry_get(msrc->mfes_cover);
@@ -95,6 +96,13 @@ mfib_entry_src_rr_cover_update (mfib_entry_t *mfib_entry,
msrc->mfes_itfs = cover->mfe_itfs;
msrc->mfes_rpf_id = cover->mfe_rpf_id;
+ /* The update to the cover could have removed the extensions.
+ * When a cover is removed from the table, the covereds see it first
+ * updated (to have no forwarding) and then changed
+ */
+ csrc = mfib_entry_get_best_src(cover);
+ msrc->mfes_exts = (csrc ? csrc->mfes_exts : NULL);
+
return (MFIB_SRC_REEVALUATE);
}
@@ -102,8 +110,8 @@ void
mfib_entry_src_rr_module_init (void)
{
mfib_entry_src_vft mvft = {
- .mev_activate = mfib_entry_src_rr_activiate,
- .mev_deactivate = mfib_entry_src_rr_deactiviate,
+ .mev_activate = mfib_entry_src_rr_activate,
+ .mev_deactivate = mfib_entry_src_rr_deactivate,
.mev_cover_change = mfib_entry_src_rr_cover_change,
.mev_cover_update = mfib_entry_src_rr_cover_update,
};