summaryrefslogtreecommitdiffstats
path: root/src/vnet/lisp-gpe/decap.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2017-02-22 23:38:08 -0800
committerFlorin Coras <fcoras@cisco.com>2017-02-25 18:36:51 -0800
commit263440e789d29e6e6b0038fcfd4e28e1c7160e83 (patch)
treeddcb71bf853b74881e33b4633063efc31c5ddd00 /src/vnet/lisp-gpe/decap.c
parent5a72c1c151f843a962cc1247213c063233e8b119 (diff)
Add NSH to GPE decap path
Change-Id: I97681322fa9ca81736100b4d32eab84868886c7b Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/lisp-gpe/decap.c')
-rw-r--r--src/vnet/lisp-gpe/decap.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/vnet/lisp-gpe/decap.c b/src/vnet/lisp-gpe/decap.c
index 637d4a740c8..5fd449cee9b 100644
--- a/src/vnet/lisp-gpe/decap.c
+++ b/src/vnet/lisp-gpe/decap.c
@@ -89,6 +89,8 @@ next_index_to_iface (lisp_gpe_main_t * lgm, u32 next_index)
return &lgm->l3_ifaces;
else if (LISP_GPE_INPUT_NEXT_L2_INPUT == next_index)
return &lgm->l2_ifaces;
+ else if (LISP_GPE_INPUT_NEXT_NSH_INPUT == next_index)
+ return &lgm->nsh_ifaces;
clib_warning ("next_index not associated to an interface!");
return 0;
}
@@ -492,6 +494,52 @@ VLIB_REGISTER_NODE (lisp_gpe_ip6_input_node) = {
};
/* *INDENT-ON* */
+/**
+ * Adds arc from lisp-gpe-input to nsh-input if nsh-input is available
+ */
+static void
+gpe_add_arc_from_input_to_nsh ()
+{
+ lisp_gpe_main_t *lgm = vnet_lisp_gpe_get_main ();
+ vlib_main_t *vm = lgm->vlib_main;
+ vlib_node_t *nsh_input;
+
+ /* Arc already exists */
+ if (next_proto_to_next_index[LISP_GPE_NEXT_PROTO_NSH]
+ != LISP_GPE_INPUT_NEXT_DROP)
+ return;
+
+ /* Check if nsh-input is available */
+ if ((nsh_input = vlib_get_node_by_name (vm, (u8 *) "nsh-input")))
+ {
+ u32 slot4, slot6;
+ slot4 = vlib_node_add_next_with_slot (vm, lisp_gpe_ip4_input_node.index,
+ nsh_input->index,
+ LISP_GPE_NEXT_PROTO_NSH);
+ slot6 = vlib_node_add_next_with_slot (vm, lisp_gpe_ip6_input_node.index,
+ nsh_input->index,
+ LISP_GPE_NEXT_PROTO_NSH);
+ ASSERT (slot4 == slot6 && slot4 == LISP_GPE_INPUT_NEXT_NSH_INPUT);
+
+ next_proto_to_next_index[LISP_GPE_NEXT_PROTO_NSH] = slot4;
+ }
+}
+
+/** GPE decap init function. */
+clib_error_t *
+gpe_decap_init (vlib_main_t * vm)
+{
+ clib_error_t *error = 0;
+
+ if ((error = vlib_call_init_function (vm, lisp_gpe_init)))
+ return error;
+
+ gpe_add_arc_from_input_to_nsh ();
+ return 0;
+}
+
+VLIB_INIT_FUNCTION (gpe_decap_init);
+
/*
* fd.io coding-style-patch-verification: ON
*