fib feature: Code mechanics to decouple dependency of feature on adj
Type: refactor
Signed-off-by: Neale Ranns <nranns@cisco.com>
Change-Id: I1d8b88fe1eefc850865297b4f025b97e6373a6bd
diff --git a/src/vnet/adj/adj.c b/src/vnet/adj/adj.c
index 0966d97..a603925 100644
--- a/src/vnet/adj/adj.c
+++ b/src/vnet/adj/adj.c
@@ -405,10 +405,11 @@
return (ADJ_WALK_RC_CONTINUE);
}
-void
+static void
adj_feature_update (u32 sw_if_index,
u8 arc_index,
- u8 is_enable)
+ u8 is_enable,
+ void *data)
{
/*
* Walk all the adjacencies on the interface to update the cached
@@ -590,6 +591,8 @@
adj_midchain_module_init();
adj_mcast_module_init();
+ vnet_feature_register(adj_feature_update, NULL);
+
return (NULL);
}
diff --git a/src/vnet/adj/adj.h b/src/vnet/adj/adj.h
index 9d1577f..58e5ebf 100644
--- a/src/vnet/adj/adj.h
+++ b/src/vnet/adj/adj.h
@@ -390,12 +390,6 @@
extern const u8* adj_get_rewrite (adj_index_t ai);
/**
- * @brief Notify the adjacency subsystem that the features settings for
- * an interface have changed
- */
-extern void adj_feature_update (u32 sw_if_index, u8 arc_index, u8 is_enable);
-
-/**
* @brief descend the FIB graph looking for loops
*
* @param ai
diff --git a/src/vnet/feature/feature.c b/src/vnet/feature/feature.c
index 6bef262..24960d9 100644
--- a/src/vnet/feature/feature.c
+++ b/src/vnet/feature/feature.c
@@ -14,10 +14,39 @@
*/
#include <vnet/feature/feature.h>
-#include <vnet/adj/adj.h>
+
vnet_feature_main_t feature_main;
+typedef struct vnet_feature_upd_registration_t_
+{
+ vnet_feature_update_cb_t cb;
+ void *data;
+} vnet_feature_upd_registration_t;
+
+static vnet_feature_upd_registration_t *regs;
+
+void
+vnet_feature_register (vnet_feature_update_cb_t cb, void *data)
+{
+ vnet_feature_upd_registration_t *reg;
+
+ vec_add2 (regs, reg, 1);
+
+ reg->cb = cb;
+ reg->data = data;
+}
+
+static void
+vent_feature_reg_invoke (u32 sw_if_index, u8 arc_index, u8 is_enable)
+{
+ vnet_feature_upd_registration_t *reg;
+
+ vec_foreach (reg, regs)
+ reg->cb (sw_if_index, arc_index, is_enable, reg->data);
+}
+
+
static clib_error_t *
vnet_feature_init (vlib_main_t * vm)
{
@@ -265,7 +294,7 @@
fm->sw_if_index_has_features[arc_index] =
clib_bitmap_set (fm->sw_if_index_has_features[arc_index], sw_if_index,
(feature_count > 0));
- adj_feature_update (sw_if_index, arc_index, (feature_count > 0));
+ vent_feature_reg_invoke (sw_if_index, arc_index, (feature_count > 0));
fm->feature_count_by_sw_if_index[arc_index][sw_if_index] = feature_count;
return 0;
diff --git a/src/vnet/feature/feature.h b/src/vnet/feature/feature.h
index ef5f4c6..cbea659 100644
--- a/src/vnet/feature/feature.h
+++ b/src/vnet/feature/feature.h
@@ -454,6 +454,12 @@
void vnet_interface_features_show (vlib_main_t * vm, u32 sw_if_index,
int verbose);
+typedef void (*vnet_feature_update_cb_t) (u32 sw_if_index,
+ u8 arc_index,
+ u8 is_enable, void *cb);
+
+extern void vnet_feature_register (vnet_feature_update_cb_t cb, void *data);
+
#endif /* included_feature_h */
/*