From 4c3f39353d0307a35180e597c0b0454439e848e9 Mon Sep 17 00:00:00 2001 From: Pierre Pfister Date: Wed, 27 Jul 2016 17:46:11 +0100 Subject: Add IP adjacency registration function Given that it is possible and easy to add dynamic IP adjacencies, it might be helpful to have an explicit call to do so. This way, additional information such as how to display the adjacency can be provided at the same time. Change-Id: I5c735ae45ed763560352f637e3462f2931dc97d9 Signed-off-by: Pierre Pfister --- plugins/ila-plugin/ila/ila.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'plugins/ila-plugin/ila/ila.c') diff --git a/plugins/ila-plugin/ila/ila.c b/plugins/ila-plugin/ila/ila.c index 69fbb82a..c0e6da11 100644 --- a/plugins/ila-plugin/ila/ila.c +++ b/plugins/ila-plugin/ila/ila.c @@ -15,6 +15,7 @@ #include #include +#include static ila_main_t ila_main; @@ -794,6 +795,16 @@ vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h, return error; } +u8 *ila_format_adjacency(u8 * s, + struct ip_lookup_main_t * lm, + ip_adjacency_t *adj) +{ + ila_main_t *ilm = &ila_main; + ila_adj_data_t * ad = (ila_adj_data_t *) & adj->opaque; + ila_entry_t *ie = pool_elt_at_index (ilm->entries, ad->entry_index); + return format(s, "idx:%d sir:%U", ad->entry_index, format_ip6_address, &ie->sir_address); +} + clib_error_t * ila_init (vlib_main_t * vm) { @@ -810,14 +821,15 @@ ila_init (vlib_main_t * vm) "ila id to entry index table", ilm->lookup_table_nbuckets, ilm->lookup_table_size); - vlib_node_t *ip6_lookup_node = - vlib_get_node_by_name (vm, (u8 *) "ip6-lookup"); - - ilm->ip6_lookup_next_index = - vlib_node_add_next (vm, ip6_lookup_node->index, ila_ila2sir_node.index); return NULL; } +VNET_IP6_REGISTER_ADJACENCY(ila2sir) = { + .node_name = "ila-to-sir", + .fn = ila_format_adjacency, + .next_index = &ila_main.ip6_lookup_next_index +}; + VLIB_INIT_FUNCTION (ila_init); static clib_error_t * -- cgit 1.2.3-korg