summaryrefslogtreecommitdiffstats
path: root/src/vnet/nhrp/nhrp.c
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2019-12-17 20:15:03 +0000
committerJohn Lo <loj@cisco.com>2019-12-19 15:17:40 +0000
commit4c16d80067b35973ebc5a86d685db52fea2fd052 (patch)
treecaf9604e08d907fda6f5c152675e6305b9f173f3 /src/vnet/nhrp/nhrp.c
parentcfffeae1e333c45e8417c9252432efbff28e371a (diff)
gre: multipoint ingress lookup fix
Type: fix Change-Id: I170edd62220a63cb19efea3032e173fb87730b1b Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/nhrp/nhrp.c')
-rw-r--r--src/vnet/nhrp/nhrp.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/vnet/nhrp/nhrp.c b/src/vnet/nhrp/nhrp.c
index a89f6cd9459..e97fbe05b9c 100644
--- a/src/vnet/nhrp/nhrp.c
+++ b/src/vnet/nhrp/nhrp.c
@@ -20,8 +20,55 @@
#include <vnet/fib/fib_table.h>
#include <vnet/adj/adj_midchain.h>
+typedef struct nhrp_key_t_
+{
+ ip46_address_t nk_peer;
+ u32 nk_sw_if_index;
+} nhrp_key_t;
+
+struct nhrp_entry_t_
+{
+ nhrp_key_t *ne_key;
+ fib_prefix_t ne_nh;
+ u32 ne_fib_index;
+};
+
static uword *nhrp_db;
static nhrp_entry_t *nhrp_pool;
+static nhrp_vft_t *nhrp_vfts;
+
+#define NHRP_NOTIFY(_ne, _fn) { \
+ nhrp_vft_t *_vft; \
+ vec_foreach(_vft, nhrp_vfts) { \
+ if (_vft->_fn) { \
+ _vft->_fn(_ne); \
+ } \
+ } \
+}
+
+u32
+nhrp_entry_get_sw_if_index (const nhrp_entry_t * ne)
+{
+ return (ne->ne_key->nk_sw_if_index);
+}
+
+u32
+nhrp_entry_get_fib_index (const nhrp_entry_t * ne)
+{
+ return (ne->ne_fib_index);
+}
+
+const ip46_address_t *
+nhrp_entry_get_peer (const nhrp_entry_t * ne)
+{
+ return (&ne->ne_key->nk_peer);
+}
+
+const fib_prefix_t *
+nhrp_entry_get_nh (const nhrp_entry_t * ne)
+{
+ return (&ne->ne_nh);
+}
void
nhrp_entry_adj_stack (const nhrp_entry_t * ne, adj_index_t ai)
@@ -113,6 +160,8 @@ nhrp_entry_add (u32 sw_if_index,
adj_nbr_walk_nh (sw_if_index,
ne->ne_nh.fp_proto,
&ne->ne_key->nk_peer, nhrp_entry_add_adj_walk, ne);
+
+ NHRP_NOTIFY (ne, nv_added);
}
else
return (VNET_API_ERROR_ENTRY_ALREADY_EXISTS);
@@ -135,6 +184,8 @@ nhrp_entry_del (u32 sw_if_index, const ip46_address_t * peer)
ne->ne_nh.fp_proto,
&ne->ne_key->nk_peer, nhrp_entry_del_adj_walk, ne);
+ NHRP_NOTIFY (ne, nv_deleted);
+
clib_mem_free (ne->ne_key);
pool_put (nhrp_pool, ne);
}
@@ -178,6 +229,26 @@ nhrp_walk (nhrp_walk_cb_t fn, void *ctx)
/* *INDENT-ON* */
}
+void
+nhrp_walk_itf (u32 sw_if_index, nhrp_walk_cb_t fn, void *ctx)
+{
+ index_t nei;
+
+ /* *INDENT-OFF* */
+ pool_foreach_index(nei, nhrp_pool,
+ ({
+ if (sw_if_index == nhrp_entry_get_sw_if_index(nhrp_entry_get(nei)))
+ fn(nei, ctx);
+ }));
+ /* *INDENT-ON* */
+}
+
+void
+nhrp_register (const nhrp_vft_t * vft)
+{
+ vec_add1 (nhrp_vfts, *vft);
+}
+
static clib_error_t *
nhrp_init (vlib_main_t * vm)
{