vppinfra: Improve code portability
[vpp.git] / src / plugins / map / map.c
index a8288a5..3cffadd 100644 (file)
@@ -97,9 +97,6 @@ map_free_extras (u32 map_domain_index)
     return;
 
   de = vec_elt_at_index (mm->domain_extras, map_domain_index);
-  if (!de)
-    return;
-
   vec_free (de->tag);
 }
 
@@ -179,6 +176,10 @@ map_create_domain (ip4_address_t * ip4_prefix,
   mm->ip6_src_prefix_tbl->add (mm->ip6_src_prefix_tbl, &d->ip6_src,
                               d->ip6_src_len, *map_domain_index);
 
+  /* Let's build a table with the MAP rule ip6 prefixes as well [dgeist] */
+  mm->ip6_prefix_tbl->add (mm->ip6_prefix_tbl, &d->ip6_prefix,
+                          d->ip6_prefix_len, *map_domain_index);
+
   /* Validate packet/byte counters */
   map_domain_counter_lock (mm);
   int i;
@@ -221,6 +222,9 @@ map_delete_domain (u32 map_domain_index)
                              d->ip4_prefix_len);
   mm->ip6_src_prefix_tbl->delete (mm->ip6_src_prefix_tbl, &d->ip6_src,
                                  d->ip6_src_len);
+  /* Addition to remove the new table [dgeist] */
+  mm->ip6_prefix_tbl->delete (mm->ip6_prefix_tbl, &d->ip6_prefix,
+                             d->ip6_prefix_len);
 
   /* Release user-assigned MAP domain name. */
   map_free_extras (map_domain_index);
@@ -554,7 +558,7 @@ map_add_domain_command_fn (vlib_main_t * vm,
        num_m_args++;
       else if (unformat (line_input, "mtu %d", &mtu))
        num_m_args++;
-      else if (unformat (line_input, "tag %v", &tag))
+      else if (unformat (line_input, "tag %s", &tag))
        ;
       else
        {
@@ -576,6 +580,7 @@ map_add_domain_command_fn (vlib_main_t * vm,
                     mtu, flags, tag);
 
 done:
+  vec_free (tag);
   unformat_free (line_input);
 
   return error;
@@ -981,10 +986,8 @@ show_map_domain_command_fn (vlib_main_t * vm, unformat_input_t * input,
   /* Get a line of input. */
   if (!unformat_user (input, unformat_line_input, line_input))
     {
-      /* *INDENT-OFF* */
-      pool_foreach(d, mm->domains,
-       ({vlib_cli_output(vm, "%U", format_map_domain, d, counters);}));
-      /* *INDENT-ON* */
+      pool_foreach (d, mm->domains)
+        {vlib_cli_output(vm, "%U", format_map_domain, d, counters);}
       return 0;
     }
 
@@ -1010,10 +1013,8 @@ show_map_domain_command_fn (vlib_main_t * vm, unformat_input_t * input,
 
   if (map_domain_index == ~0)
     {
-      /* *INDENT-OFF* */
-      pool_foreach(d, mm->domains,
-       ({vlib_cli_output(vm, "%U", format_map_domain, d, counters);}));
-      /* *INDENT-ON* */
+      pool_foreach (d, mm->domains)
+        {vlib_cli_output(vm, "%U", format_map_domain, d, counters);}
     }
   else
     {
@@ -1064,16 +1065,14 @@ show_map_stats_command_fn (vlib_main_t * vm, unformat_input_t * input,
       return 0;
     }
 
-  /* *INDENT-OFF* */
-  pool_foreach(d, mm->domains, ({
+  pool_foreach (d, mm->domains)  {
     if (d->rules) {
       rulecount+= 0x1 << d->psid_length;
       rules += sizeof(ip6_address_t) * 0x1 << d->psid_length;
     }
     domains += sizeof(*d);
     domaincount++;
-  }));
-  /* *INDENT-ON* */
+  }
 
   vlib_cli_output (vm, "MAP domains structure: %d\n", sizeof (map_domain_t));
   vlib_cli_output (vm, "MAP domains: %d (%d bytes)\n", domaincount, domains);
@@ -1257,7 +1256,6 @@ done:
 }
 
 
-/* *INDENT-OFF* */
 
 /*?
  * Set or copy the IP TOS/Traffic Class field
@@ -1314,7 +1312,7 @@ VLIB_CLI_COMMAND(map_pre_resolve_command, static) = {
 
 /*?
  * Enable or disable the MAP-E inbound security check
- * Specifiy if the inbound security check should be done on fragments
+ * Specify if the inbound security check should be done on fragments
  *
  * @cliexpar
  * @cliexstart{map params security-check}
@@ -1335,9 +1333,8 @@ VLIB_CLI_COMMAND(map_security_check_command, static) = {
   .function = map_security_check_command_fn,
 };
 
-
 /*?
- * Specifiy the IPv4 source address used for relayed ICMP error messages
+ * Specify the IPv4 source address used for relayed ICMP error messages
  *
  * @cliexpar
  * @cliexstart{map params icmp source-address}
@@ -1472,7 +1469,6 @@ VLIB_PLUGIN_REGISTER() = {
   .description = "Mapping of Address and Port (MAP)",
 };
 
-/* *INDENT-ON* */
 
 /*
  * map_init