Remove c-11 memcpy checks from perf-critical code
[vpp.git] / src / plugins / map / map.c
index 6d9730f..49796e4 100644 (file)
@@ -55,7 +55,7 @@ map_main_t map_main;
 /*
  * This code supports MAP-T:
  *
- * With DMR prefix length equal to 96.
+ * With a DMR prefix length of 64 or 96 (RFC6052).
  *
  */
 
@@ -81,15 +81,9 @@ map_create_domain (ip4_address_t * ip4_prefix,
   /* Sanity check on the src prefix length */
   if (flags & MAP_DOMAIN_TRANSLATION)
     {
-      if (ip6_src_len != 96)
+      if (ip6_src_len != 96 && ip6_src_len != 64)
        {
-         clib_warning ("MAP-T only supports ip6_src_len = 96 for now.");
-         return -1;
-       }
-      if ((flags & MAP_DOMAIN_RFC6052) && ip6_prefix_len != 96)
-       {
-         clib_warning ("RFC6052 translation only supports ip6_prefix_len = "
-                       "96 for now");
+         clib_warning ("MAP-T only supports prefix lengths of 64 and 96.");
          return -1;
        }
     }
@@ -136,7 +130,7 @@ map_create_domain (ip4_address_t * ip4_prefix,
 
   /* Get domain index */
   pool_get_aligned (mm->domains, d, CLIB_CACHE_LINE_BYTES);
-  memset (d, 0, sizeof (*d));
+  clib_memset (d, 0, sizeof (*d));
   *map_domain_index = d - mm->domains;
 
   /* Init domain struct */
@@ -322,7 +316,7 @@ map_add_del_psid (u32 map_domain_index, u16 psid, ip6_address_t * tep,
       d->rules = clib_mem_alloc_aligned (l, CLIB_CACHE_LINE_BYTES);
       if (!d->rules)
        return -1;
-      memset (d->rules, 0, l);
+      clib_memset (d->rules, 0, l);
     }
 
   if (psid >= (0x1 << d->psid_length))
@@ -338,7 +332,7 @@ map_add_del_psid (u32 map_domain_index, u16 psid, ip6_address_t * tep,
     }
   else
     {
-      memset (&d->rules[psid], 0, sizeof (ip6_address_t));
+      clib_memset (&d->rules[psid], 0, sizeof (ip6_address_t));
     }
   return 0;
 }
@@ -363,12 +357,12 @@ format_map_pre_resolve (u8 * s, va_list * ap)
 
   if (FIB_NODE_INDEX_INVALID != pr->fei)
     {
-      fib_prefix_t pfx;
+      const fib_prefix_t *pfx;
 
-      fib_entry_get_prefix (pr->fei, &pfx);
+      pfx = fib_entry_get_prefix (pr->fei);
 
       return (format (s, "%U (%u)",
-                     format_ip46_address, &pfx.fp_addr, IP46_TYPE_ANY,
+                     format_ip46_address, &pfx->fp_addr, IP46_TYPE_ANY,
                      pr->dpo.dpoi_index));
     }
   else
@@ -751,8 +745,8 @@ map_pre_resolve_command_fn (vlib_main_t * vm,
   clib_error_t *error = NULL;
   int is_del = 0;
 
-  memset (&ip4nh, 0, sizeof (ip4nh));
-  memset (&ip6nh, 0, sizeof (ip6nh));
+  clib_memset (&ip4nh, 0, sizeof (ip4nh));
+  clib_memset (&ip6nh, 0, sizeof (ip6nh));
 
   /* Get a line of input. */
   if (!unformat_user (input, unformat_line_input, line_input))
@@ -980,12 +974,12 @@ format_map_domain (u8 * s, va_list * args)
   ip6_address_t ip6_prefix;
 
   if (d->rules)
-    memset (&ip6_prefix, 0, sizeof (ip6_prefix));
+    clib_memset (&ip6_prefix, 0, sizeof (ip6_prefix));
   else
     ip6_prefix = d->ip6_prefix;
 
   s = format (s,
-             "[%d] ip4-pfx %U/%d ip6-pfx %U/%d ip6-src %U/%d ea_bits_len %d "
+             "[%d] ip4-pfx %U/%d ip6-pfx %U/%d ip6-src %U/%d ea-bits-len %d "
              "psid-offset %d psid-len %d mtu %d %s",
              d - mm->domains,
              format_ip4_address, &d->ip4_prefix, d->ip4_prefix_len,
@@ -1216,8 +1210,8 @@ show_map_stats_command_fn (vlib_main_t * vm, unformat_input_t * input,
   int which, i;
   vlib_counter_t v;
 
-  memset (total_pkts, 0, sizeof (total_pkts));
-  memset (total_bytes, 0, sizeof (total_bytes));
+  clib_memset (total_pkts, 0, sizeof (total_pkts));
+  clib_memset (total_bytes, 0, sizeof (total_bytes));
 
   map_domain_counter_lock (mm);
   vec_foreach (cm, mm->domain_counters)
@@ -1813,7 +1807,7 @@ map_ip6_reass_add_fragment (map_ip6_reass_t * r, u32 pi,
       if (!prev_f)
        return -1;
 
-      clib_memcpy (prev_f->next_data, data_start, copied_len);
+      clib_memcpy_fast (prev_f->next_data, data_start, copied_len);
       prev_f->next_data_len = copied_len;
       prev_f->next_data_offset = data_offset;
     }
@@ -1823,7 +1817,7 @@ map_ip6_reass_add_fragment (map_ip6_reass_t * r, u32 pi,
        return -1;
 
       if (r->ip4_header.ip_version_and_header_length == 0)
-       clib_memcpy (&r->ip4_header, data_start, sizeof (ip4_header_t));
+       clib_memcpy_fast (&r->ip4_header, data_start, sizeof (ip4_header_t));
     }
 
   if (data_len > 20)
@@ -2314,8 +2308,8 @@ map_init (vlib_main_t * vm)
   mm->frag_ignore_df = false;
 
   vec_validate (mm->domain_counters, MAP_N_DOMAIN_COUNTER - 1);
-  mm->domain_counters[MAP_DOMAIN_COUNTER_RX].name = "rx";
-  mm->domain_counters[MAP_DOMAIN_COUNTER_TX].name = "tx";
+  mm->domain_counters[MAP_DOMAIN_COUNTER_RX].name = "/map/rx";
+  mm->domain_counters[MAP_DOMAIN_COUNTER_TX].name = "/map/tx";
 
   vlib_validate_simple_counter (&mm->icmp_relayed, 0);
   vlib_zero_simple_counter (&mm->icmp_relayed, 0);