ipsec: IPSec protection for multi-point tunnel interfaces
[vpp.git] / src / vnet / l2 / l2_input.c
index f94ef66..7b93fba 100644 (file)
@@ -49,6 +49,8 @@
  * For interfaces in Layer 3 mode, the packets will be routed.
  */
 
+#ifndef CLIB_MARCH_VARIANT
+
 /* Feature graph node names */
 static char *l2input_feat_names[] = {
 #define _(sym,name) name,
@@ -71,6 +73,7 @@ format_l2_input_features (u8 * s, va_list * args)
 #undef _
   };
   u32 feature_bitmap = va_arg (*args, u32);
+  u32 verbose = va_arg (*args, u32);
 
   if (feature_bitmap == 0)
     {
@@ -80,11 +83,20 @@ format_l2_input_features (u8 * s, va_list * args)
 
   feature_bitmap &= ~L2INPUT_FEAT_DROP;        /* Not a feature */
   int i;
-  for (i = L2INPUT_N_FEAT; i >= 0; i--)
-    if (feature_bitmap & (1 << i))
-      s = format (s, "%10s (%s)\n", display_names[i], l2input_feat_names[i]);
+  for (i = L2INPUT_N_FEAT - 1; i >= 0; i--)
+    {
+      if (feature_bitmap & (1 << i))
+       {
+         if (verbose)
+           s = format (s, "%17s (%s)\n",
+                       display_names[i], l2input_feat_names[i]);
+         else
+           s = format (s, "%s ", l2input_feat_names[i]);
+       }
+    }
   return s;
 }
+#endif /* CLIB_MARCH_VARIANT */
 
 typedef struct
 {
@@ -110,7 +122,11 @@ format_l2input_trace (u8 * s, va_list * args)
   return s;
 }
 
+extern l2input_main_t l2input_main;
+
+#ifndef CLIB_MARCH_VARIANT
 l2input_main_t l2input_main;
+#endif /* CLIB_MARCH_VARIANT */
 
 #define foreach_l2input_error                  \
 _(L2INPUT,     "L2 input packets")             \
@@ -177,13 +193,16 @@ classify_and_dispatch (l2input_main_t * msm, vlib_buffer_t * b0, u32 * next0)
 
       /* Disable bridge forwarding (flooding will execute instead if not xconnect) */
       feat_mask &= ~(L2INPUT_FEAT_FWD |
-                    L2INPUT_FEAT_UU_FLOOD | L2INPUT_FEAT_GBP_FWD);
+                    L2INPUT_FEAT_UU_FLOOD |
+                    L2INPUT_FEAT_UU_FWD | L2INPUT_FEAT_GBP_FWD);
+
+      if (ethertype != ETHERNET_TYPE_ARP)
+       feat_mask &= ~(L2INPUT_FEAT_ARP_UFWD);
 
       /* Disable ARP-term for non-ARP and non-ICMP6 packet */
       if (ethertype != ETHERNET_TYPE_ARP &&
          (ethertype != ETHERNET_TYPE_IP6 || protocol != IP_PROTOCOL_ICMP6))
        feat_mask &= ~(L2INPUT_FEAT_ARP_TERM);
-
       /*
        * For packet from BVI - set SHG of ARP request or ICMPv6 neighbor
        * solicitation packet from BVI to 0 so it can also flood to VXLAN
@@ -356,8 +375,8 @@ l2input_node_inline (vlib_main_t * vm,
                  l2input_trace_t *t =
                    vlib_add_trace (vm, node, b0, sizeof (*t));
                  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_fast (t->src, h0->src_address, 6);
+                 clib_memcpy_fast (t->dst, h0->dst_address, 6);
                }
              if (b1->flags & VLIB_BUFFER_IS_TRACED)
                {
@@ -365,8 +384,8 @@ l2input_node_inline (vlib_main_t * vm,
                  l2input_trace_t *t =
                    vlib_add_trace (vm, node, b1, sizeof (*t));
                  t->sw_if_index = sw_if_index1;
-                 clib_memcpy (t->src, h1->src_address, 6);
-                 clib_memcpy (t->dst, h1->dst_address, 6);
+                 clib_memcpy_fast (t->src, h1->src_address, 6);
+                 clib_memcpy_fast (t->dst, h1->dst_address, 6);
                }
              if (b2->flags & VLIB_BUFFER_IS_TRACED)
                {
@@ -374,8 +393,8 @@ l2input_node_inline (vlib_main_t * vm,
                  l2input_trace_t *t =
                    vlib_add_trace (vm, node, b2, sizeof (*t));
                  t->sw_if_index = sw_if_index2;
-                 clib_memcpy (t->src, h2->src_address, 6);
-                 clib_memcpy (t->dst, h2->dst_address, 6);
+                 clib_memcpy_fast (t->src, h2->src_address, 6);
+                 clib_memcpy_fast (t->dst, h2->dst_address, 6);
                }
              if (b3->flags & VLIB_BUFFER_IS_TRACED)
                {
@@ -383,8 +402,8 @@ l2input_node_inline (vlib_main_t * vm,
                  l2input_trace_t *t =
                    vlib_add_trace (vm, node, b3, sizeof (*t));
                  t->sw_if_index = sw_if_index3;
-                 clib_memcpy (t->src, h3->src_address, 6);
-                 clib_memcpy (t->dst, h3->dst_address, 6);
+                 clib_memcpy_fast (t->src, h3->src_address, 6);
+                 clib_memcpy_fast (t->dst, h3->dst_address, 6);
                }
            }
 
@@ -424,8 +443,8 @@ l2input_node_inline (vlib_main_t * vm,
              l2input_trace_t *t = vlib_add_trace (vm, node, b0, sizeof (*t));
              sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
              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_fast (t->src, h0->src_address, 6);
+             clib_memcpy_fast (t->dst, h0->dst_address, 6);
            }
 
          classify_and_dispatch (msm, b0, &next0);
@@ -445,9 +464,8 @@ l2input_node_inline (vlib_main_t * vm,
   return frame->n_vectors;
 }
 
-static uword
-l2input_node_fn (vlib_main_t * vm,
-                vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (l2input_node) (vlib_main_t * vm,
+                            vlib_node_runtime_t * node, vlib_frame_t * frame)
 {
   if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)))
     return l2input_node_inline (vm, node, frame, 1 /* do_trace */ );
@@ -456,7 +474,6 @@ l2input_node_fn (vlib_main_t * vm,
 
 /* *INDENT-OFF* */
 VLIB_REGISTER_NODE (l2input_node) = {
-  .function = l2input_node_fn,
   .name = "l2-input",
   .vector_size = sizeof (u32),
   .format_trace = format_l2input_trace,
@@ -477,8 +494,9 @@ VLIB_REGISTER_NODE (l2input_node) = {
 };
 /* *INDENT-ON* */
 
-VLIB_NODE_FUNCTION_MULTIARCH (l2input_node, l2input_node_fn)
-     clib_error_t *l2input_init (vlib_main_t * vm)
+#ifndef CLIB_MARCH_VARIANT
+clib_error_t *
+l2input_init (vlib_main_t * vm)
 {
   l2input_main_t *mp = &l2input_main;
 
@@ -517,7 +535,8 @@ l2input_intf_config (u32 sw_if_index)
 
 /** Enable (or disable) the feature in the bitmap for the given interface. */
 u32
-l2input_intf_bitmap_enable (u32 sw_if_index, u32 feature_bitmap, u32 enable)
+l2input_intf_bitmap_enable (u32 sw_if_index,
+                           l2input_feat_masks_t feature_bitmap, u32 enable)
 {
   l2_input_config_t *config = l2input_intf_config (sw_if_index);
 
@@ -648,7 +667,7 @@ set_int_l2_mode (vlib_main_t * vm, vnet_main_t * vnet_main, /*           */
 
       /* Clear L2 output config */
       out_config = l2output_intf_config (sw_if_index);
-      memset (out_config, 0, sizeof (l2_output_config_t));
+      clib_memset (out_config, 0, sizeof (l2_output_config_t));
 
       /* Make sure any L2-output packet to this interface now in L3 mode is
        * dropped. This may happen if L2 FIB MAC entry is stale */
@@ -688,6 +707,7 @@ set_int_l2_mode (vlib_main_t * vm, vnet_main_t * vnet_main, /*           */
                                     L2INPUT_FEAT_UU_FWD |
                                     L2INPUT_FEAT_FLOOD |
                                     L2INPUT_FEAT_LEARN |
+                                    L2INPUT_FEAT_ARP_UFWD |
                                     L2INPUT_FEAT_ARP_TERM);
 
          /* Make sure last-chance drop is configured */
@@ -840,6 +860,7 @@ set_int_l2_mode (vlib_main_t * vm, vnet_main_t * vnet_main, /*           */
 
   return 0;
 }
+#endif /* CLIB_MARCH_VARIANT */
 
 /**
  * Set subinterface in bridging mode with a bridge-domain ID.
@@ -1202,6 +1223,7 @@ _(l2output_init)                          \
 _(l2_patch_init)                               \
 _(l2_xcrw_init)
 
+#ifndef CLIB_MARCH_VARIANT
 clib_error_t *
 l2_init (vlib_main_t * vm)
 {
@@ -1216,6 +1238,7 @@ while (0);
 }
 
 VLIB_INIT_FUNCTION (l2_init);
+#endif /* CLIB_MARCH_VARIANT */
 
 /*
  * fd.io coding-style-patch-verification: ON