aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/gre
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2019-03-26 07:02:58 +0000
committerDamjan Marion <dmarion@me.com>2019-03-26 16:33:28 +0000
commit4c3ba81709bab8f9fcdef650e7f742fe9ddbae32 (patch)
treefb8dba665f570749b785bd5dc76dfce317367fca /src/vnet/gre
parentaf3f0783b0ef189d54bb8fdf0a112347a420e9bb (diff)
ADJ: midchain delegate to performing stacking
this can be used by e.g. tunnels so it doesn't need to be implemented for each tunnel type. Change-Id: I0790f89aa49f83421612b35108cce67693285999 Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/gre')
-rw-r--r--src/vnet/gre/gre.h18
-rw-r--r--src/vnet/gre/interface.c83
2 files changed, 7 insertions, 94 deletions
diff --git a/src/vnet/gre/gre.h b/src/vnet/gre/gre.h
index 416ab300877..a1a03dfb535 100644
--- a/src/vnet/gre/gre.h
+++ b/src/vnet/gre/gre.h
@@ -181,11 +181,6 @@ typedef struct
CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
/**
- * Linkage into the FIB object graph
- */
- fib_node_t node;
-
- /**
* The hash table's key stored in separate memory since the tunnel_t
* memory can realloc.
*/
@@ -208,19 +203,6 @@ typedef struct
gre_tunnel_type_t type;
/**
- * The FIB entry sourced by the tunnel for its destination prefix
- */
- fib_node_index_t fib_entry_index;
-
- /**
- * The tunnel is a child of the FIB entry for its desintion. This is
- * so it receives updates when the forwarding information for that entry
- * changes.
- * The tunnels sibling index on the FIB entry's dependency list.
- */
- u32 sibling_index;
-
- /**
* an L2 tunnel always rquires an L2 midchain. cache here for DP.
*/
adj_index_t l2_adj_index;
diff --git a/src/vnet/gre/interface.c b/src/vnet/gre/interface.c
index b9bfb79c172..4f5f528acf9 100644
--- a/src/vnet/gre/interface.c
+++ b/src/vnet/gre/interface.c
@@ -112,14 +112,6 @@ gre_tunnel_db_remove (gre_tunnel_t * t)
t->key = NULL;
}
-static gre_tunnel_t *
-gre_tunnel_from_fib_node (fib_node_t * node)
-{
- ASSERT (FIB_NODE_TYPE_GRE_TUNNEL == node->fn_type);
- return ((gre_tunnel_t *) (((char *) node) -
- STRUCT_OFFSET_OF (gre_tunnel_t, node)));
-}
-
/**
* gre_tunnel_stack
*
@@ -146,14 +138,11 @@ gre_tunnel_stack (adj_index_t ai)
if ((vnet_hw_interface_get_flags (vnet_get_main (), gt->hw_if_index) &
VNET_HW_INTERFACE_FLAG_LINK_UP) == 0)
{
- adj_nbr_midchain_unstack (ai);
+ adj_midchain_delegate_unstack (ai);
}
else
{
- adj_nbr_midchain_stack_on_fib_entry (ai,
- gt->fib_entry_index,
- fib_forw_chain_type_from_fib_proto
- (gt->tunnel_dst.fp_proto));
+ adj_midchain_delegate_stack (ai, gt->outer_fib_index, &gt->tunnel_dst);
}
}
@@ -182,55 +171,6 @@ gre_tunnel_restack (gre_tunnel_t * gt)
}
}
-/**
- * Function definition to backwalk a FIB node
- */
-static fib_node_back_walk_rc_t
-gre_tunnel_back_walk (fib_node_t * node, fib_node_back_walk_ctx_t * ctx)
-{
- gre_tunnel_restack (gre_tunnel_from_fib_node (node));
-
- return (FIB_NODE_BACK_WALK_CONTINUE);
-}
-
-/**
- * Function definition to get a FIB node from its index
- */
-static fib_node_t *
-gre_tunnel_fib_node_get (fib_node_index_t index)
-{
- gre_tunnel_t *gt;
- gre_main_t *gm;
-
- gm = &gre_main;
- gt = pool_elt_at_index (gm->tunnels, index);
-
- return (&gt->node);
-}
-
-/**
- * Function definition to inform the FIB node that its last lock has gone.
- */
-static void
-gre_tunnel_last_lock_gone (fib_node_t * node)
-{
- /*
- * The MPLS GRE tunnel is a root of the graph. As such
- * it never has children and thus is never locked.
- */
- ASSERT (0);
-}
-
-/*
- * Virtual function table registered by MPLS GRE tunnels
- * for participation in the FIB object graph.
- */
-const static fib_node_vft_t gre_vft = {
- .fnv_get = gre_tunnel_fib_node_get,
- .fnv_last_lock = gre_tunnel_last_lock_gone,
- .fnv_back_walk = gre_tunnel_back_walk,
-};
-
static int
vnet_gre_tunnel_add (vnet_gre_add_del_tunnel_args_t * a,
u32 outer_fib_index, u32 * sw_if_indexp)
@@ -267,7 +207,6 @@ vnet_gre_tunnel_add (vnet_gre_add_del_tunnel_args_t * a,
t->dev_instance = t_idx; /* actual */
t->user_instance = u_idx; /* name */
- fib_node_init (&t->node, FIB_NODE_TYPE_GRE_TUNNEL);
t->type = a->tunnel_type;
if (t->type == GRE_TUNNEL_TYPE_ERSPAN)
@@ -357,11 +296,6 @@ vnet_gre_tunnel_add (vnet_gre_add_del_tunnel_args_t * a,
}
}
- t->fib_entry_index = fib_table_entry_special_add
- (outer_fib_index, &t->tunnel_dst, FIB_SOURCE_RR, FIB_ENTRY_FLAG_NONE);
- t->sibling_index = fib_entry_child_add
- (t->fib_entry_index, FIB_NODE_TYPE_GRE_TUNNEL, t_idx);
-
if (t->type != GRE_TUNNEL_TYPE_L3)
{
t->l2_adj_index = adj_nbr_add_or_lock
@@ -403,10 +337,10 @@ vnet_gre_tunnel_delete (vnet_gre_add_del_tunnel_args_t * a,
ethernet_delete_interface (vnm, t->hw_if_index);
if (t->l2_adj_index != ADJ_INDEX_INVALID)
- adj_unlock (t->l2_adj_index);
-
- fib_entry_child_remove (t->fib_entry_index, t->sibling_index);
- fib_table_entry_delete_index (t->fib_entry_index, FIB_SOURCE_RR);
+ {
+ adj_midchain_delegate_unstack (t->l2_adj_index);
+ adj_unlock (t->l2_adj_index);
+ }
ASSERT ((t->type != GRE_TUNNEL_TYPE_ERSPAN) || (t->gre_sn != NULL));
if ((t->type == GRE_TUNNEL_TYPE_ERSPAN) && (t->gre_sn->ref_count-- == 1))
@@ -419,7 +353,6 @@ vnet_gre_tunnel_delete (vnet_gre_add_del_tunnel_args_t * a,
hash_unset (gm->instance_used, t->user_instance);
gre_tunnel_db_remove (t);
- fib_node_deinit (&t->node);
pool_put (gm->tunnels, t);
if (sw_if_indexp)
@@ -690,9 +623,7 @@ VLIB_CLI_COMMAND (show_gre_tunnel_command, static) = {
clib_error_t *
gre_interface_init (vlib_main_t * vm)
{
- fib_node_register_type (FIB_NODE_TYPE_GRE_TUNNEL, &gre_vft);
-
- return 0;
+ return (NULL);
}
VLIB_INIT_FUNCTION (gre_interface_init);