LISP EID virtualization support
[vpp.git] / vnet / vnet / lisp-gpe / decap.c
index 807d4da..4684c29 100644 (file)
@@ -58,8 +58,12 @@ next_proto_to_next_index[LISP_GPE_NEXT_PROTOS] = {
 static u32
 next_protocol_to_next_index (lisp_gpe_header_t * lgh, u8 * next_header)
 {
+  /* 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];
   /* legay lisp router */
-  if (PREDICT_FALSE((lgh->flags & LISP_GPE_FLAGS_P) == 0))
+  else if ((lgh->flags & LISP_GPE_FLAGS_P) == 0)
     {
       ip4_header_t * iph = (ip4_header_t *) next_header;
       if ((iph->ip_version_and_header_length & 0xF0) == 0x40)
@@ -69,10 +73,6 @@ next_protocol_to_next_index (lisp_gpe_header_t * lgh, u8 * next_header)
       else
         return LISP_GPE_INPUT_NEXT_DROP;
     }
-  /* lisp-gpe router */
-  else if ((lgh->flags & LISP_GPE_FLAGS_P)
-      && lgh->next_protocol < LISP_GPE_NEXT_PROTOS)
-    return next_proto_to_next_index[lgh->next_protocol];
   else
     return LISP_GPE_INPUT_NEXT_DROP;
 }
@@ -82,12 +82,9 @@ lisp_gpe_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
                        vlib_frame_t * from_frame, u8 is_v4)
 {
   u32 n_left_from, next_index, * from, * to_next;
-  lisp_gpe_tunnel_key_t last_key;
   u32 pkts_decapsulated = 0;
   lisp_gpe_main_t * lgm = &lisp_gpe_main;
 
-  memset (&last_key, 0xff, sizeof (last_key));
-
   from = vlib_frame_vector_args (from_frame);
   n_left_from = from_frame->n_vectors;
 
@@ -183,8 +180,10 @@ lisp_gpe_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
 
           /* map iid/vni to lisp-gpe sw_if_index which is used by ipx_input to
            * decide the rx vrf and the input features to be applied */
-          si0 = hash_get(lgm->tunnel_term_sw_if_index_by_vni, lh0->iid);
-          si1 = hash_get(lgm->tunnel_term_sw_if_index_by_vni, lh1->iid);
+          si0 = hash_get(lgm->tunnel_term_sw_if_index_by_vni,
+                         clib_net_to_host_u32 (lh0->iid));
+          si1 = hash_get(lgm->tunnel_term_sw_if_index_by_vni,
+                         clib_net_to_host_u32 (lh1->iid));
 
           if (si0)
             {
@@ -202,7 +201,7 @@ lisp_gpe_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
             {
               vnet_buffer(b1)->sw_if_index[VLIB_RX] = si1[0];
               pkts_decapsulated++;
-              error0 = 0;
+              error1 = 0;
             }
           else
             {
@@ -256,7 +255,10 @@ lisp_gpe_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
 
           b0 = vlib_get_buffer (vm, bi0);
 
-          /* udp leaves current_data pointing at the lisp header */
+          /* udp leaves current_data pointing at the lisp header
+           * TODO: there's no difference in processing between v4 and v6
+           * encapsulated packets so the code should be simplified if ip header
+           * info is not going to be used for dp smrs/dpsec */
           if (is_v4)
             {
               vlib_buffer_advance (
@@ -297,7 +299,8 @@ lisp_gpe_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
 
           /* map iid/vni to lisp-gpe sw_if_index which is used by ipx_input to
            * decide the rx vrf and the input features to be applied */
-          si0 = hash_get(lgm->tunnel_term_sw_if_index_by_vni, lh0->iid);
+          si0 = hash_get(lgm->tunnel_term_sw_if_index_by_vni,
+                         clib_net_to_host_u32 (lh0->iid));
 
           if (si0)
             {