vxlan: decap use vlib_buffer_enqueue_to_next 87/14487/5
authorEyal Bari <ebari@cisco.com>
Sun, 26 Aug 2018 12:20:07 +0000 (15:20 +0300)
committerJohn Lo <loj@cisco.com>
Tue, 28 Aug 2018 00:47:37 +0000 (00:47 +0000)
Change-Id: I43832cdadda820772ba9052890bba59b24e70c6c
Signed-off-by: Eyal Bari <ebari@cisco.com>
Signed-off-by: Damjan Marion <damarion@cisco.com>
src/vnet.am
src/vnet/CMakeLists.txt
src/vnet/vxlan/decap.c
src/vnet/vxlan/vxlan.h

index baddaf3..b9ff17d 100644 (file)
@@ -260,6 +260,9 @@ nobase_include_HEADERS +=                   \
   vnet/vxlan/vxlan_error.def                   \
   vnet/vxlan/vxlan.api.h
 
+libvnet_multiversioning_sources +=             \
+  vnet/vxlan/decap.c
+
 API_FILES += vnet/vxlan/vxlan.api
 
 ########################################
index 491b8b9..9f36e67 100644 (file)
@@ -264,6 +264,8 @@ list(APPEND VNET_HEADERS
   vxlan/vxlan_error.def
 )
 
+list(APPEND VNET_MULTIARCH_SOURCES vxlan/decap.c)
+
 list(APPEND VNET_API_FILES vxlan/vxlan.api)
 
 ##############################################################################
index ad23f0a..7c1b6b1 100644 (file)
 #include <vnet/pg/pg.h>
 #include <vnet/vxlan/vxlan.h>
 
+#ifndef CLIB_MARCH_VARIANT
 vlib_node_registration_t vxlan4_input_node;
 vlib_node_registration_t vxlan6_input_node;
+#endif
 
 typedef struct
 {
@@ -76,7 +78,10 @@ vxlan4_find_tunnel (vxlan_main_t * vxm, last_tunnel_cache4 * cache,
       int rv =
        clib_bihash_search_inline_16_8 (&vxm->vxlan4_tunnel_by_key, &key4);
       if (PREDICT_FALSE (rv != 0))
-       return 0;
+       {
+         *stats_t0 = 0;
+         return 0;
+       }
 
       *cache = key4;
     }
@@ -89,14 +94,20 @@ vxlan4_find_tunnel (vxlan_main_t * vxm, last_tunnel_cache4 * cache,
     {
       /* try multicast */
       if (PREDICT_TRUE (!ip4_address_is_multicast (&ip4_0->dst_address)))
-       return 0;
+       {
+         *stats_t0 = 0;
+         return 0;
+       }
 
       key4.key[0] = ip4_0->dst_address.as_u32;
       /* Make sure mcast VXLAN tunnel exist by packet DIP and VNI */
       int rv =
        clib_bihash_search_inline_16_8 (&vxm->vxlan4_tunnel_by_key, &key4);
       if (PREDICT_FALSE (rv != 0))
-       return 0;
+       {
+         *stats_t0 = 0;
+         return 0;
+       }
 
       *stats_t0 = pool_elt_at_index (vxm->tunnels, key4.value);
     }
@@ -126,7 +137,10 @@ vxlan6_find_tunnel (vxlan_main_t * vxm, last_tunnel_cache6 * cache,
       int rv =
        clib_bihash_search_inline_24_8 (&vxm->vxlan6_tunnel_by_key, &key6);
       if (PREDICT_FALSE (rv != 0))
-       return 0;
+       {
+         *stats_t0 = 0;
+         return 0;
+       }
 
       *cache = key6;
     }
@@ -139,7 +153,10 @@ vxlan6_find_tunnel (vxlan_main_t * vxm, last_tunnel_cache6 * cache,
     {
       /* try multicast */
       if (PREDICT_TRUE (!ip6_address_is_multicast (&ip6_0->dst_address)))
-       return 0;
+       {
+         *stats_t0 = 0;
+         return 0;
+       }
 
       /* Make sure mcast VXLAN tunnel exist by packet DIP and VNI */
       key6.key[0] = ip6_0->dst_address.as_u64[0];
@@ -147,7 +164,10 @@ vxlan6_find_tunnel (vxlan_main_t * vxm, last_tunnel_cache6 * cache,
       int rv =
        clib_bihash_search_inline_24_8 (&vxm->vxlan6_tunnel_by_key, &key6);
       if (PREDICT_FALSE (rv != 0))
-       return 0;
+       {
+         *stats_t0 = 0;
+         return 0;
+       }
 
       *stats_t0 = pool_elt_at_index (vxm->tunnels, key6.value);
     }
@@ -169,7 +189,7 @@ vxlan_input (vlib_main_t * vm,
     im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_DROP;
   last_tunnel_cache4 last4;
   last_tunnel_cache6 last6;
-  u32 pkts_decapsulated = 0;
+  u32 pkts_dropped = 0;
   u32 thread_index = vlib_get_thread_index ();
 
   if (is_ip4)
@@ -177,285 +197,240 @@ vxlan_input (vlib_main_t * vm,
   else
     memset (&last6, 0xff, sizeof last6);
 
-  u32 next_index = node->cached_next_index;
-
   u32 *from = vlib_frame_vector_args (from_frame);
   u32 n_left_from = from_frame->n_vectors;
 
-  while (n_left_from > 0)
-    {
-      u32 *to_next, n_left_to_next;
-      vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
+  vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b = bufs;
+  vlib_get_buffers (vm, from, bufs, n_left_from);
 
-      while (n_left_from >= 4 && n_left_to_next >= 2)
+  u16 nexts[VLIB_FRAME_SIZE], *next = nexts;
+  while (n_left_from >= 4)
+    {
+      /* Prefetch next iteration. */
+      vlib_prefetch_buffer_header (b[2], LOAD);
+      vlib_prefetch_buffer_header (b[3], LOAD);
+
+      /* udp leaves current_data pointing at the vxlan header */
+      void *cur0 = vlib_buffer_get_current (b[0]);
+      void *cur1 = vlib_buffer_get_current (b[1]);
+      vxlan_header_t *vxlan0 = cur0;
+      vxlan_header_t *vxlan1 = cur1;
+
+      u8 error0 = vxlan0->flags != VXLAN_FLAGS_I ? VXLAN_ERROR_BAD_FLAGS : 0;
+      u8 error1 = vxlan1->flags != VXLAN_FLAGS_I ? VXLAN_ERROR_BAD_FLAGS : 0;
+
+      ip4_header_t *ip4_0, *ip4_1;
+      ip6_header_t *ip6_0, *ip6_1;
+      if (is_ip4)
        {
-         /* Prefetch next iteration. */
-         {
-           vlib_buffer_t *p2, *p3;
-
-           p2 = vlib_get_buffer (vm, from[2]);
-           p3 = vlib_get_buffer (vm, from[3]);
-
-           vlib_prefetch_buffer_header (p2, LOAD);
-           vlib_prefetch_buffer_header (p3, LOAD);
-
-           CLIB_PREFETCH (p2->data, 2 * CLIB_CACHE_LINE_BYTES, LOAD);
-           CLIB_PREFETCH (p3->data, 2 * CLIB_CACHE_LINE_BYTES, LOAD);
-         }
-
-         u32 bi0 = to_next[0] = from[0];
-         u32 bi1 = to_next[1] = from[1];
-         from += 2;
-         to_next += 2;
-         n_left_to_next -= 2;
-         n_left_from -= 2;
-
-         vlib_buffer_t *b0, *b1;
-         b0 = vlib_get_buffer (vm, bi0);
-         b1 = vlib_get_buffer (vm, bi1);
+         ip4_0 = cur0 - sizeof (udp_header_t) - sizeof (ip4_header_t);
+         ip4_1 = cur1 - sizeof (udp_header_t) - sizeof (ip4_header_t);
+       }
+      else
+       {
+         ip6_0 = cur0 - sizeof (udp_header_t) - sizeof (ip6_header_t);
+         ip6_1 = cur1 - sizeof (udp_header_t) - sizeof (ip6_header_t);
+       }
 
-         /* udp leaves current_data pointing at the vxlan header */
-         void *cur0 = vlib_buffer_get_current (b0);
-         void *cur1 = vlib_buffer_get_current (b1);
-         vxlan_header_t *vxlan0 = cur0;
-         vxlan_header_t *vxlan1 = cur1;
+      /* pop vxlan */
+      vlib_buffer_advance (b[0], sizeof *vxlan0);
+      vlib_buffer_advance (b[1], sizeof *vxlan1);
 
-         ip4_header_t *ip4_0, *ip4_1;
-         ip6_header_t *ip6_0, *ip6_1;
-         if (is_ip4)
-           {
-             ip4_0 = cur0 - sizeof (udp_header_t) - sizeof (ip4_header_t);
-             ip4_1 = cur1 - sizeof (udp_header_t) - sizeof (ip4_header_t);
-           }
-         else
-           {
-             ip6_0 = cur0 - sizeof (udp_header_t) - sizeof (ip6_header_t);
-             ip6_1 = cur1 - sizeof (udp_header_t) - sizeof (ip6_header_t);
-           }
+      u32 fi0 = buf_fib_index (b[0], is_ip4);
+      u32 fi1 = buf_fib_index (b[1], is_ip4);
 
-         /* pop vxlan */
-         vlib_buffer_advance (b0, sizeof *vxlan0);
-         vlib_buffer_advance (b1, sizeof *vxlan1);
+      vxlan_tunnel_t *t0, *stats_t0;
+      vxlan_tunnel_t *t1, *stats_t1;
+      if (is_ip4)
+       {
+         t0 =
+           vxlan4_find_tunnel (vxm, &last4, fi0, ip4_0, vxlan0, &stats_t0);
+         t1 =
+           vxlan4_find_tunnel (vxm, &last4, fi1, ip4_1, vxlan1, &stats_t1);
+       }
+      else
+       {
+         t0 =
+           vxlan6_find_tunnel (vxm, &last6, fi0, ip6_0, vxlan0, &stats_t0);
+         t1 =
+           vxlan6_find_tunnel (vxm, &last6, fi1, ip6_1, vxlan1, &stats_t1);
+       }
 
-         u32 fi0 = buf_fib_index (b0, is_ip4);
-         u32 fi1 = buf_fib_index (b1, is_ip4);
+      error0 = t0 == 0 ? VXLAN_ERROR_NO_SUCH_TUNNEL : error0;
+      error1 = t1 == 0 ? VXLAN_ERROR_NO_SUCH_TUNNEL : error1;
 
-         vxlan_tunnel_t *t0, *stats_t0;
-         vxlan_tunnel_t *t1, *stats_t1;
-         if (is_ip4)
-           {
-             t0 =
-               vxlan4_find_tunnel (vxm, &last4, fi0, ip4_0, vxlan0,
-                                   &stats_t0);
-             t1 =
-               vxlan4_find_tunnel (vxm, &last4, fi1, ip4_1, vxlan1,
-                                   &stats_t1);
-           }
-         else
-           {
-             t0 =
-               vxlan6_find_tunnel (vxm, &last6, fi0, ip6_0, vxlan0,
-                                   &stats_t0);
-             t1 =
-               vxlan6_find_tunnel (vxm, &last6, fi1, ip6_1, vxlan1,
-                                   &stats_t1);
-           }
+      /* Prefetch next iteration. */
+      CLIB_PREFETCH (b[2]->data, CLIB_CACHE_LINE_BYTES, LOAD);
+      CLIB_PREFETCH (b[3]->data, CLIB_CACHE_LINE_BYTES, LOAD);
 
-         u32 len0 = vlib_buffer_length_in_chain (vm, b0);
-         u32 len1 = vlib_buffer_length_in_chain (vm, b1);
+      u32 len0 = vlib_buffer_length_in_chain (vm, b[0]);
+      u32 len1 = vlib_buffer_length_in_chain (vm, b[1]);
 
-         u32 next0, next1;
-         u8 error0 = 0, error1 = 0;
-         /* Validate VXLAN tunnel encap-fib index agaist packet */
-         if (PREDICT_FALSE (t0 == 0 || vxlan0->flags != VXLAN_FLAGS_I))
-           {
-             next0 = VXLAN_INPUT_NEXT_DROP;
+      /* Validate VXLAN tunnel encap-fib index agaist packet */
+      if (PREDICT_FALSE (error0 != 0))
+       {
+         next[0] = VXLAN_INPUT_NEXT_DROP;
 
-             if (t0 != 0 && vxlan0->flags != VXLAN_FLAGS_I)
-               {
-                 error0 = VXLAN_ERROR_BAD_FLAGS;
-                 vlib_increment_combined_counter
-                   (drop_counter, thread_index, stats_t0->sw_if_index, 1,
-                    len0);
-               }
-             else
-               error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
-             b0->error = node->errors[error0];
-           }
-         else
+         if (error0 == VXLAN_ERROR_BAD_FLAGS)
            {
-             next0 = t0->decap_next_index;
-
-             /* Required to make the l2 tag push / pop code work on l2 subifs */
-             if (PREDICT_TRUE (next0 == VXLAN_INPUT_NEXT_L2_INPUT))
-               vnet_update_l2_len (b0);
-
-             /* Set packet input sw_if_index to unicast VXLAN tunnel for learning */
-             vnet_buffer (b0)->sw_if_index[VLIB_RX] = t0->sw_if_index;
              vlib_increment_combined_counter
-               (rx_counter, thread_index, stats_t0->sw_if_index, 1, len0);
-             pkts_decapsulated++;
+               (drop_counter, thread_index, stats_t0->sw_if_index, 1, len0);
            }
+         b[0]->error = node->errors[error0];
+         pkts_dropped++;
+       }
+      else
+       {
+         next[0] = t0->decap_next_index;
 
-         /* Validate VXLAN tunnel encap-fib index agaist packet */
-         if (PREDICT_FALSE (t1 == 0 || vxlan1->flags != VXLAN_FLAGS_I))
-           {
-             next1 = VXLAN_INPUT_NEXT_DROP;
-
-             if (t1 != 0 && vxlan1->flags != VXLAN_FLAGS_I)
-               {
-                 error1 = VXLAN_ERROR_BAD_FLAGS;
-                 vlib_increment_combined_counter
-                   (drop_counter, thread_index, stats_t1->sw_if_index, 1,
-                    len1);
-               }
-             else
-               error1 = VXLAN_ERROR_NO_SUCH_TUNNEL;
-             b1->error = node->errors[error1];
-           }
-         else
-           {
-             next1 = t1->decap_next_index;
-
-             /* Required to make the l2 tag push / pop code work on l2 subifs */
-             if (PREDICT_TRUE (next1 == VXLAN_INPUT_NEXT_L2_INPUT))
-               vnet_update_l2_len (b1);
+         /* Required to make the l2 tag push / pop code work on l2 subifs */
+         if (PREDICT_TRUE (next[0] == VXLAN_INPUT_NEXT_L2_INPUT))
+           vnet_update_l2_len (b[0]);
 
-             /* Set packet input sw_if_index to unicast VXLAN tunnel for learning */
-             vnet_buffer (b1)->sw_if_index[VLIB_RX] = t1->sw_if_index;
-             pkts_decapsulated++;
+         /* Set packet input sw_if_index to unicast VXLAN tunnel for learning */
+         vnet_buffer (b[0])->sw_if_index[VLIB_RX] = t0->sw_if_index;
+         vlib_increment_combined_counter
+           (rx_counter, thread_index, stats_t0->sw_if_index, 1, len0);
+       }
 
-             vlib_increment_combined_counter
-               (rx_counter, thread_index, stats_t1->sw_if_index, 1, len1);
-           }
+      /* Validate VXLAN tunnel encap-fib index agaist packet */
+      if (PREDICT_FALSE (error1 != 0))
+       {
+         next[1] = VXLAN_INPUT_NEXT_DROP;
 
-         if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
-           {
-             vxlan_rx_trace_t *tr =
-               vlib_add_trace (vm, node, b0, sizeof (*tr));
-             tr->next_index = next0;
-             tr->error = error0;
-             tr->tunnel_index = t0 == 0 ? ~0 : t0 - vxm->tunnels;
-             tr->vni = vnet_get_vni (vxlan0);
-           }
-         if (PREDICT_FALSE (b1->flags & VLIB_BUFFER_IS_TRACED))
+         if (error1 == VXLAN_ERROR_BAD_FLAGS)
            {
-             vxlan_rx_trace_t *tr =
-               vlib_add_trace (vm, node, b1, sizeof (*tr));
-             tr->next_index = next1;
-             tr->error = error1;
-             tr->tunnel_index = t1 == 0 ? ~0 : t1 - vxm->tunnels;
-             tr->vni = vnet_get_vni (vxlan1);
+             vlib_increment_combined_counter
+               (drop_counter, thread_index, stats_t1->sw_if_index, 1, len1);
            }
-
-         vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
-                                          to_next, n_left_to_next,
-                                          bi0, bi1, next0, next1);
+         b[1]->error = node->errors[error1];
+         pkts_dropped++;
        }
-
-      while (n_left_from > 0 && n_left_to_next > 0)
+      else
        {
-         u32 bi0 = to_next[0] = from[0];
-         from += 1;
-         to_next += 1;
-         n_left_from -= 1;
-         n_left_to_next -= 1;
+         next[1] = t1->decap_next_index;
 
-         vlib_buffer_t *b0 = vlib_get_buffer (vm, bi0);
-
-         /* udp leaves current_data pointing at the vxlan header */
-         void *cur0 = vlib_buffer_get_current (b0);
-         vxlan_header_t *vxlan0 = cur0;
-         ip4_header_t *ip4_0;
-         ip6_header_t *ip6_0;
-         if (is_ip4)
-           ip4_0 = cur0 - sizeof (udp_header_t) - sizeof (ip4_header_t);
-         else
-           ip6_0 = cur0 - sizeof (udp_header_t) - sizeof (ip6_header_t);
+         /* Required to make the l2 tag push / pop code work on l2 subifs */
+         if (PREDICT_TRUE (next[1] == VXLAN_INPUT_NEXT_L2_INPUT))
+           vnet_update_l2_len (b[1]);
 
-         /* pop (ip, udp, vxlan) */
-         vlib_buffer_advance (b0, sizeof (*vxlan0));
+         /* Set packet input sw_if_index to unicast VXLAN tunnel for learning */
+         vnet_buffer (b[1])->sw_if_index[VLIB_RX] = t1->sw_if_index;
 
-         u32 fi0 = buf_fib_index (b0, is_ip4);
+         vlib_increment_combined_counter
+           (rx_counter, thread_index, stats_t1->sw_if_index, 1, len1);
+       }
 
-         vxlan_tunnel_t *t0, *stats_t0;
-         if (is_ip4)
-           t0 =
-             vxlan4_find_tunnel (vxm, &last4, fi0, ip4_0, vxlan0, &stats_t0);
-         else
-           t0 =
-             vxlan6_find_tunnel (vxm, &last6, fi0, ip6_0, vxlan0, &stats_t0);
+      if (PREDICT_FALSE (b[0]->flags & VLIB_BUFFER_IS_TRACED))
+       {
+         vxlan_rx_trace_t *tr =
+           vlib_add_trace (vm, node, b[0], sizeof (*tr));
+         tr->next_index = next[0];
+         tr->error = error0;
+         tr->tunnel_index = t0 == 0 ? ~0 : t0 - vxm->tunnels;
+         tr->vni = vnet_get_vni (vxlan0);
+       }
+      if (PREDICT_FALSE (b[1]->flags & VLIB_BUFFER_IS_TRACED))
+       {
+         vxlan_rx_trace_t *tr =
+           vlib_add_trace (vm, node, b[1], sizeof (*tr));
+         tr->next_index = next[1];
+         tr->error = error1;
+         tr->tunnel_index = t1 == 0 ? ~0 : t1 - vxm->tunnels;
+         tr->vni = vnet_get_vni (vxlan1);
+       }
+      b += 2;
+      next += 2;
+      n_left_from -= 2;
+    }
 
-         uword len0 = vlib_buffer_length_in_chain (vm, b0);
+  while (n_left_from > 0)
+    {
+      /* udp leaves current_data pointing at the vxlan header */
+      void *cur0 = vlib_buffer_get_current (b[0]);
+      vxlan_header_t *vxlan0 = cur0;
+      u8 error0 = vxlan0->flags != VXLAN_FLAGS_I ? VXLAN_ERROR_BAD_FLAGS : 0;
+      ip4_header_t *ip4_0;
+      ip6_header_t *ip6_0;
+      if (is_ip4)
+       ip4_0 = cur0 - sizeof (udp_header_t) - sizeof (ip4_header_t);
+      else
+       ip6_0 = cur0 - sizeof (udp_header_t) - sizeof (ip6_header_t);
+
+      /* pop (ip, udp, vxlan) */
+      vlib_buffer_advance (b[0], sizeof (*vxlan0));
+
+      u32 fi0 = buf_fib_index (b[0], is_ip4);
+
+      vxlan_tunnel_t *t0, *stats_t0;
+      if (is_ip4)
+       t0 = vxlan4_find_tunnel (vxm, &last4, fi0, ip4_0, vxlan0, &stats_t0);
+      else
+       t0 = vxlan6_find_tunnel (vxm, &last6, fi0, ip6_0, vxlan0, &stats_t0);
+
+      error0 = t0 == 0 ? VXLAN_ERROR_NO_SUCH_TUNNEL : error0;
+      uword len0 = vlib_buffer_length_in_chain (vm, b[0]);
+
+      /* Validate VXLAN tunnel encap-fib index agaist packet */
+      if (PREDICT_FALSE (error0 != 0))
+       {
+         next[0] = VXLAN_INPUT_NEXT_DROP;
 
-         u32 next0;
-         u8 error0 = 0;
-         /* Validate VXLAN tunnel encap-fib index agaist packet */
-         if (PREDICT_FALSE (t0 == 0 || vxlan0->flags != VXLAN_FLAGS_I))
+         if (error0 == VXLAN_ERROR_BAD_FLAGS)
            {
-             next0 = VXLAN_INPUT_NEXT_DROP;
-
-             if (t0 != 0 && vxlan0->flags != VXLAN_FLAGS_I)
-               {
-                 error0 = VXLAN_ERROR_BAD_FLAGS;
-                 vlib_increment_combined_counter
-                   (drop_counter, thread_index, stats_t0->sw_if_index, 1,
-                    len0);
-               }
-             else
-               error0 = VXLAN_ERROR_NO_SUCH_TUNNEL;
-             b0->error = node->errors[error0];
+             vlib_increment_combined_counter
+               (drop_counter, thread_index, stats_t0->sw_if_index, 1, len0);
            }
-         else
-           {
-             next0 = t0->decap_next_index;
-
-             /* Required to make the l2 tag push / pop code work on l2 subifs */
-             if (PREDICT_TRUE (next0 == VXLAN_INPUT_NEXT_L2_INPUT))
-               vnet_update_l2_len (b0);
+         b[0]->error = node->errors[error0];
+         pkts_dropped++;
+       }
+      else
+       {
+         next[0] = t0->decap_next_index;
 
-             /* Set packet input sw_if_index to unicast VXLAN tunnel for learning */
-             vnet_buffer (b0)->sw_if_index[VLIB_RX] = t0->sw_if_index;
-             pkts_decapsulated++;
+         /* Required to make the l2 tag push / pop code work on l2 subifs */
+         if (PREDICT_TRUE (next[0] == VXLAN_INPUT_NEXT_L2_INPUT))
+           vnet_update_l2_len (b[0]);
 
-             vlib_increment_combined_counter
-               (rx_counter, thread_index, stats_t0->sw_if_index, 1, len0);
-           }
+         /* Set packet input sw_if_index to unicast VXLAN tunnel for learning */
+         vnet_buffer (b[0])->sw_if_index[VLIB_RX] = t0->sw_if_index;
 
-         if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
-           {
-             vxlan_rx_trace_t *tr
-               = vlib_add_trace (vm, node, b0, sizeof (*tr));
-             tr->next_index = next0;
-             tr->error = error0;
-             tr->tunnel_index = t0 == 0 ? ~0 : t0 - vxm->tunnels;
-             tr->vni = vnet_get_vni (vxlan0);
-           }
-         vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
-                                          to_next, n_left_to_next,
-                                          bi0, next0);
+         vlib_increment_combined_counter
+           (rx_counter, thread_index, stats_t0->sw_if_index, 1, len0);
        }
 
-      vlib_put_next_frame (vm, node, next_index, n_left_to_next);
+      if (PREDICT_FALSE (b[0]->flags & VLIB_BUFFER_IS_TRACED))
+       {
+         vxlan_rx_trace_t *tr
+           = vlib_add_trace (vm, node, b[0], sizeof (*tr));
+         tr->next_index = next[0];
+         tr->error = error0;
+         tr->tunnel_index = t0 == 0 ? ~0 : t0 - vxm->tunnels;
+         tr->vni = vnet_get_vni (vxlan0);
+       }
+      b += 1;
+      next += 1;
+      n_left_from -= 1;
     }
+  vlib_buffer_enqueue_to_next (vm, node, from, nexts, from_frame->n_vectors);
   /* Do we still need this now that tunnel tx stats is kept? */
   u32 node_idx = is_ip4 ? vxlan4_input_node.index : vxlan6_input_node.index;
   vlib_node_increment_counter (vm, node_idx, VXLAN_ERROR_DECAPSULATED,
-                              pkts_decapsulated);
+                              from_frame->n_vectors - pkts_dropped);
 
   return from_frame->n_vectors;
 }
 
-static uword
-vxlan4_input (vlib_main_t * vm,
-             vlib_node_runtime_t * node, vlib_frame_t * from_frame)
+VLIB_NODE_FN (vxlan4_input_node) (vlib_main_t * vm,
+                                 vlib_node_runtime_t * node,
+                                 vlib_frame_t * from_frame)
 {
   return vxlan_input (vm, node, from_frame, /* is_ip4 */ 1);
 }
 
-static uword
-vxlan6_input (vlib_main_t * vm,
-             vlib_node_runtime_t * node, vlib_frame_t * from_frame)
+VLIB_NODE_FN (vxlan6_input_node) (vlib_main_t * vm,
+                                 vlib_node_runtime_t * node,
+                                 vlib_frame_t * from_frame)
 {
   return vxlan_input (vm, node, from_frame, /* is_ip4 */ 0);
 }
@@ -464,13 +439,11 @@ static char *vxlan_error_strings[] = {
 #define vxlan_error(n,s) s,
 #include <vnet/vxlan/vxlan_error.def>
 #undef vxlan_error
-#undef _
 };
 
 /* *INDENT-OFF* */
 VLIB_REGISTER_NODE (vxlan4_input_node) =
 {
-  .function = vxlan4_input,
   .name = "vxlan4-input",
   .vector_size = sizeof (u32),
   .n_errors = VXLAN_N_ERROR,
@@ -483,11 +456,9 @@ VLIB_REGISTER_NODE (vxlan4_input_node) =
 #undef _
   },
 };
-VLIB_NODE_FUNCTION_MULTIARCH (vxlan4_input_node, vxlan4_input)
 
 VLIB_REGISTER_NODE (vxlan6_input_node) =
 {
-  .function = vxlan6_input,
   .name = "vxlan6-input",
   .vector_size = sizeof (u32),
   .n_errors = VXLAN_N_ERROR,
@@ -500,7 +471,6 @@ VLIB_REGISTER_NODE (vxlan6_input_node) =
   },
   .format_trace = format_vxlan_rx_trace,
 };
-VLIB_NODE_FUNCTION_MULTIARCH (vxlan6_input_node, vxlan6_input)
 /* *INDENT-ON* */
 
 typedef enum
@@ -906,9 +876,9 @@ ip_vxlan_bypass_inline (vlib_main_t * vm,
   return frame->n_vectors;
 }
 
-static uword
-ip4_vxlan_bypass (vlib_main_t * vm,
-                 vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (ip4_vxlan_bypass_node) (vlib_main_t * vm,
+                                     vlib_node_runtime_t * node,
+                                     vlib_frame_t * frame)
 {
   return ip_vxlan_bypass_inline (vm, node, frame, /* is_ip4 */ 1);
 }
@@ -916,7 +886,6 @@ ip4_vxlan_bypass (vlib_main_t * vm,
 /* *INDENT-OFF* */
 VLIB_REGISTER_NODE (ip4_vxlan_bypass_node) =
 {
-  .function = ip4_vxlan_bypass,
   .name = "ip4-vxlan-bypass",
   .vector_size = sizeof (u32),
   .n_next_nodes = IP_VXLAN_BYPASS_N_NEXT,
@@ -928,11 +897,10 @@ VLIB_REGISTER_NODE (ip4_vxlan_bypass_node) =
   .format_trace = format_ip4_forward_next_trace,
 };
 
-VLIB_NODE_FUNCTION_MULTIARCH (ip4_vxlan_bypass_node, ip4_vxlan_bypass)
 /* *INDENT-ON* */
 
 /* Dummy init function to get us linked in. */
-clib_error_t *
+static clib_error_t *
 ip4_vxlan_bypass_init (vlib_main_t * vm)
 {
   return 0;
@@ -940,9 +908,9 @@ ip4_vxlan_bypass_init (vlib_main_t * vm)
 
 VLIB_INIT_FUNCTION (ip4_vxlan_bypass_init);
 
-static uword
-ip6_vxlan_bypass (vlib_main_t * vm,
-                 vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (ip6_vxlan_bypass_node) (vlib_main_t * vm,
+                                     vlib_node_runtime_t * node,
+                                     vlib_frame_t * frame)
 {
   return ip_vxlan_bypass_inline (vm, node, frame, /* is_ip4 */ 0);
 }
@@ -950,7 +918,6 @@ ip6_vxlan_bypass (vlib_main_t * vm,
 /* *INDENT-OFF* */
 VLIB_REGISTER_NODE (ip6_vxlan_bypass_node) =
 {
-  .function = ip6_vxlan_bypass,
   .name = "ip6-vxlan-bypass",
   .vector_size = sizeof (u32),
   .n_next_nodes = IP_VXLAN_BYPASS_N_NEXT,
@@ -962,11 +929,10 @@ VLIB_REGISTER_NODE (ip6_vxlan_bypass_node) =
   .format_trace = format_ip6_forward_next_trace,
 };
 
-VLIB_NODE_FUNCTION_MULTIARCH (ip6_vxlan_bypass_node, ip6_vxlan_bypass)
 /* *INDENT-ON* */
 
 /* Dummy init function to get us linked in. */
-clib_error_t *
+static clib_error_t *
 ip6_vxlan_bypass_init (vlib_main_t * vm)
 {
   return 0;
index ce410d7..2c309bb 100644 (file)
@@ -78,7 +78,7 @@ typedef struct
   u32 mcast_sw_if_index;
 
   /* decap next index */
-  u32 decap_next_index;
+  u16 decap_next_index;
 
   /* The FIB index for src/dst addresses */
   u32 encap_fib_index;