ipsec: IPSec protection for multi-point tunnel interfaces
[vpp.git] / src / vnet / l2 / l2_input_vtr.c
index 60a3963..be3e6ba 100644 (file)
@@ -57,9 +57,9 @@ format_l2_invtr_trace (u8 * s, va_list * args)
   return s;
 }
 
+#ifndef CLIB_MARCH_VARIANT
 l2_invtr_main_t l2_invtr_main;
-
-static vlib_node_registration_t l2_invtr_node;
+#endif /* CLIB_MARCH_VARIANT */
 
 #define foreach_l2_invtr_error                 \
 _(L2_INVTR,    "L2 inverter packets")          \
@@ -86,9 +86,9 @@ typedef enum
 } l2_invtr_next_t;
 
 
-static uword
-l2_invtr_node_fn (vlib_main_t * vm,
-                 vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (l2_invtr_node) (vlib_main_t * vm,
+                             vlib_node_runtime_t * node,
+                             vlib_frame_t * frame)
 {
   u32 n_left_from, *from, *to_next;
   l2_invtr_next_t next_index;
@@ -111,7 +111,6 @@ l2_invtr_node_fn (vlib_main_t * vm,
          vlib_buffer_t *b0, *b1;
          u32 next0, next1;
          u32 sw_if_index0, sw_if_index1;
-         u32 feature_bitmap0, feature_bitmap1;
 
          /* Prefetch next iteration. */
          {
@@ -160,23 +159,11 @@ l2_invtr_node_fn (vlib_main_t * vm,
          sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
          sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_RX];
 
-         /* process 2 packets */
-
-         /* Remove ourself from the feature bitmap */
-         feature_bitmap0 =
-           vnet_buffer (b0)->l2.feature_bitmap & ~L2INPUT_FEAT_VTR;
-         feature_bitmap1 =
-           vnet_buffer (b1)->l2.feature_bitmap & ~L2INPUT_FEAT_VTR;
-
-         /* save for next feature graph nodes */
-         vnet_buffer (b0)->l2.feature_bitmap = feature_bitmap0;
-         vnet_buffer (b1)->l2.feature_bitmap = feature_bitmap1;
-
          /* Determine the next node */
-         next0 = feat_bitmap_get_next_node_index (msm->feat_next_node_index,
-                                                  feature_bitmap0);
-         next1 = feat_bitmap_get_next_node_index (msm->feat_next_node_index,
-                                                  feature_bitmap1);
+         next0 = vnet_l2_feature_next (b0, msm->feat_next_node_index,
+                                       L2INPUT_FEAT_VTR);
+         next1 = vnet_l2_feature_next (b1, msm->feat_next_node_index,
+                                       L2INPUT_FEAT_VTR);
 
          l2_output_config_t *config0;
          l2_output_config_t *config1;
@@ -188,10 +175,7 @@ l2_invtr_node_fn (vlib_main_t * vm,
              if (config0->output_vtr.push_and_pop_bytes)
                {
                  /* perform the tag rewrite on two packets */
-                 if (l2_vtr_process
-                     (b0,
-                      &(vec_elt_at_index
-                        (l2output_main.configs, sw_if_index0)->input_vtr)))
+                 if (l2_vtr_process (b0, &config0->input_vtr))
                    {
                      /* Drop packet */
                      next0 = L2_INVTR_NEXT_DROP;
@@ -212,10 +196,7 @@ l2_invtr_node_fn (vlib_main_t * vm,
            {
              if (config1->output_vtr.push_and_pop_bytes)
                {
-                 if (l2_vtr_process
-                     (b1,
-                      &(vec_elt_at_index
-                        (l2output_main.configs, sw_if_index1)->input_vtr)))
+                 if (l2_vtr_process (b1, &config1->input_vtr))
                    {
                      /* Drop packet */
                      next1 = L2_INVTR_NEXT_DROP;
@@ -241,9 +222,9 @@ l2_invtr_node_fn (vlib_main_t * vm,
                    vlib_add_trace (vm, node, b0, sizeof (*t));
                  ethernet_header_t *h0 = vlib_buffer_get_current (b0);
                  t->sw_if_index = sw_if_index0;
-                 clib_memcpy (t->src, h0->src_address, 6);
-                 clib_memcpy (t->dst, h0->dst_address, 6);
-                 clib_memcpy (t->raw, &h0->type, sizeof (t->raw));
+                 clib_memcpy_fast (t->src, h0->src_address, 6);
+                 clib_memcpy_fast (t->dst, h0->dst_address, 6);
+                 clib_memcpy_fast (t->raw, &h0->type, sizeof (t->raw));
                }
              if (b1->flags & VLIB_BUFFER_IS_TRACED)
                {
@@ -251,9 +232,9 @@ l2_invtr_node_fn (vlib_main_t * vm,
                    vlib_add_trace (vm, node, b1, sizeof (*t));
                  ethernet_header_t *h1 = vlib_buffer_get_current (b1);
                  t->sw_if_index = sw_if_index0;
-                 clib_memcpy (t->src, h1->src_address, 6);
-                 clib_memcpy (t->dst, h1->dst_address, 6);
-                 clib_memcpy (t->raw, &h1->type, sizeof (t->raw));
+                 clib_memcpy_fast (t->src, h1->src_address, 6);
+                 clib_memcpy_fast (t->dst, h1->dst_address, 6);
+                 clib_memcpy_fast (t->raw, &h1->type, sizeof (t->raw));
                }
            }
 
@@ -270,7 +251,6 @@ l2_invtr_node_fn (vlib_main_t * vm,
          vlib_buffer_t *b0;
          u32 next0;
          u32 sw_if_index0;
-         u32 feature_bitmap0;
 
          /* speculatively enqueue b0 to the current next frame */
          bi0 = from[0];
@@ -284,18 +264,9 @@ l2_invtr_node_fn (vlib_main_t * vm,
 
          sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
 
-         /* process 1 packet */
-
-         /* Remove ourself from the feature bitmap */
-         feature_bitmap0 =
-           vnet_buffer (b0)->l2.feature_bitmap & ~L2INPUT_FEAT_VTR;
-
-         /* save for next feature graph nodes */
-         vnet_buffer (b0)->l2.feature_bitmap = feature_bitmap0;
-
          /* Determine the next node */
-         next0 = feat_bitmap_get_next_node_index (msm->feat_next_node_index,
-                                                  feature_bitmap0);
+         next0 = vnet_l2_feature_next (b0, msm->feat_next_node_index,
+                                       L2INPUT_FEAT_VTR);
 
          l2_output_config_t *config0;
          config0 = vec_elt_at_index (l2output_main.configs, sw_if_index0);
@@ -305,10 +276,7 @@ l2_invtr_node_fn (vlib_main_t * vm,
              if (config0->output_vtr.push_and_pop_bytes)
                {
                  /* perform the tag rewrite on one packet */
-                 if (l2_vtr_process
-                     (b0,
-                      &(vec_elt_at_index
-                        (l2output_main.configs, sw_if_index0)->input_vtr)))
+                 if (l2_vtr_process (b0, &config0->input_vtr))
                    {
                      /* Drop packet */
                      next0 = L2_INVTR_NEXT_DROP;
@@ -333,9 +301,9 @@ l2_invtr_node_fn (vlib_main_t * vm,
                vlib_add_trace (vm, node, b0, sizeof (*t));
              ethernet_header_t *h0 = vlib_buffer_get_current (b0);
              t->sw_if_index = sw_if_index0;
-             clib_memcpy (t->src, h0->src_address, 6);
-             clib_memcpy (t->dst, h0->dst_address, 6);
-             clib_memcpy (t->raw, &h0->type, sizeof (t->raw));
+             clib_memcpy_fast (t->src, h0->src_address, 6);
+             clib_memcpy_fast (t->dst, h0->dst_address, 6);
+             clib_memcpy_fast (t->raw, &h0->type, sizeof (t->raw));
            }
 
          /* verify speculative enqueue, maybe switch current next frame */
@@ -352,8 +320,7 @@ l2_invtr_node_fn (vlib_main_t * vm,
 
 
 /* *INDENT-OFF* */
-VLIB_REGISTER_NODE (l2_invtr_node,static) = {
-  .function = l2_invtr_node_fn,
+VLIB_REGISTER_NODE (l2_invtr_node) = {
   .name = "l2-input-vtr",
   .vector_size = sizeof (u32),
   .format_trace = format_l2_invtr_trace,
@@ -371,8 +338,9 @@ VLIB_REGISTER_NODE (l2_invtr_node,static) = {
 };
 /* *INDENT-ON* */
 
-VLIB_NODE_FUNCTION_MULTIARCH (l2_invtr_node, l2_invtr_node_fn)
-     clib_error_t *l2_invtr_init (vlib_main_t * vm)
+#ifndef CLIB_MARCH_VARIANT
+clib_error_t *
+l2_invtr_init (vlib_main_t * vm)
 {
   l2_invtr_main_t *mp = &l2_invtr_main;
 
@@ -390,6 +358,7 @@ VLIB_NODE_FUNCTION_MULTIARCH (l2_invtr_node, l2_invtr_node_fn)
 }
 
 VLIB_INIT_FUNCTION (l2_invtr_init);
+#endif /* CLIB_MARCH_VARIANT */
 
 
 /*