fib: Adjacency creation notifications for dlegates
Type: feature
Signed-off-by: Neale Ranns <nranns@cisco.com>
Change-Id: I3feddfe44dee528b9ca05aa0150e9423306ae49d
diff --git a/src/vnet/adj/adj_delegate.c b/src/vnet/adj/adj_delegate.c
index 17d6f0d..68232c5 100644
--- a/src/vnet/adj/adj_delegate.c
+++ b/src/vnet/adj/adj_delegate.c
@@ -140,6 +140,20 @@
vec_reset_length(adj->ia_delegates);
}
+void
+adj_delegate_adj_created (ip_adjacency_t *adj)
+{
+ adj_delegate_vft_t *vft;
+
+ vec_foreach(vft, ad_vfts)
+ {
+ if (vft->adv_adj_created)
+ {
+ vft->adv_adj_created(adj_get_index(adj));
+ }
+ }
+}
+
u8*
adj_delegate_format (u8* s, ip_adjacency_t *adj)
{
diff --git a/src/vnet/adj/adj_delegate.h b/src/vnet/adj/adj_delegate.h
index f6da245..096c182 100644
--- a/src/vnet/adj/adj_delegate.h
+++ b/src/vnet/adj/adj_delegate.h
@@ -78,11 +78,17 @@
typedef u8 * (*adj_delegate_format_t)(const adj_delegate_t *aed, u8 *s);
/**
+ * Notification that an adjacency has been created
+ */
+typedef u8 * (*adj_delegate_adj_created_t)(adj_index_t ai);
+
+/**
* An ADJ delegate virtual function table
*/
typedef struct adj_delegate_vft_t_ {
adj_delegate_format_t adv_format;
adj_delegate_adj_deleted_t adv_adj_deleted;
+ adj_delegate_adj_created_t adv_adj_created;
} adj_delegate_vft_t;
/**
diff --git a/src/vnet/adj/adj_glean.c b/src/vnet/adj/adj_glean.c
index 9236911..a8a422d 100644
--- a/src/vnet/adj/adj_glean.c
+++ b/src/vnet/adj/adj_glean.c
@@ -91,6 +91,8 @@
adj_lock(adj_get_index(adj));
}
+ adj_delegate_adj_created(adj);
+
return (adj_get_index(adj));
}
diff --git a/src/vnet/adj/adj_internal.h b/src/vnet/adj/adj_internal.h
index efaa11d..2053c69 100644
--- a/src/vnet/adj/adj_internal.h
+++ b/src/vnet/adj/adj_internal.h
@@ -136,6 +136,7 @@
* Adj delegates
*/
extern void adj_delegate_adj_deleted(ip_adjacency_t *adj);
+extern void adj_delegate_adj_created(ip_adjacency_t *adj);
extern u8* adj_delegate_format(u8* s, ip_adjacency_t *adj);
#endif
diff --git a/src/vnet/adj/adj_mcast.c b/src/vnet/adj/adj_mcast.c
index c94d28e..4d7172c 100644
--- a/src/vnet/adj/adj_mcast.c
+++ b/src/vnet/adj/adj_mcast.c
@@ -88,6 +88,8 @@
adj_lock(adj_get_index(adj));
}
+ adj_delegate_adj_created(adj);
+
return (adj_get_index(adj));
}
diff --git a/src/vnet/adj/adj_nbr.c b/src/vnet/adj/adj_nbr.c
index 7f053c8..2e0888b 100644
--- a/src/vnet/adj/adj_nbr.c
+++ b/src/vnet/adj/adj_nbr.c
@@ -221,12 +221,12 @@
u32 sw_if_index)
{
adj_index_t adj_index;
- ip_adjacency_t *adj;
adj_index = adj_nbr_find(nh_proto, link_type, nh_addr, sw_if_index);
if (ADJ_INDEX_INVALID == adj_index)
{
+ ip_adjacency_t *adj;
vnet_main_t *vnm;
vnm = vnet_get_main();
@@ -256,6 +256,7 @@
adj_lock(adj_index);
}
+ adj_delegate_adj_created(adj_get(adj_index));
return (adj_index);
}
@@ -284,6 +285,8 @@
ADJ_NBR_REWRITE_FLAG_COMPLETE,
rewrite);
+ adj_delegate_adj_created(adj_get(adj_index));
+
return (adj_index);
}