Add GPE CLI/API for setting encap mode
[vpp.git] / src / vnet / lisp-gpe / decap.c
index 5fd449c..9c5234e 100644 (file)
@@ -62,10 +62,17 @@ static u32 next_proto_to_next_index[LISP_GPE_NEXT_PROTOS] = {
 always_inline u32
 next_protocol_to_next_index (lisp_gpe_header_t * lgh, u8 * next_header)
 {
+  lisp_gpe_main_t *lgm = vnet_lisp_gpe_get_main ();
+
   /* lisp-gpe router */
   if (PREDICT_TRUE ((lgh->flags & LISP_GPE_FLAGS_P)
-                   && lgh->next_protocol < LISP_GPE_NEXT_PROTOS))
-    return next_proto_to_next_index[lgh->next_protocol];
+                   || GPE_ENCAP_VXLAN == lgm->encap_mode))
+    {
+      if (PREDICT_FALSE (lgh->next_protocol > LISP_GPE_NEXT_PROTOS))
+       return LISP_GPE_INPUT_NEXT_DROP;
+
+      return next_proto_to_next_index[lgh->next_protocol];
+    }
   /* legacy lisp router */
   else if ((lgh->flags & LISP_GPE_FLAGS_P) == 0)
     {