ip: use main heap for mtrie, part 2 (remove args)
[vpp.git] / src / vnet / ip / ip4_forward.c
index ea78d55..9197180 100644 (file)
@@ -640,6 +640,8 @@ void
 ip4_sw_interface_enable_disable (u32 sw_if_index, u32 is_enable)
 {
   ip4_main_t *im = &ip4_main;
+  vnet_main_t *vnm = vnet_get_main ();
+  vnet_hw_interface_t *hi = vnet_get_sup_hw_interface (vnm, sw_if_index);
 
   vec_validate_init_empty (im->ip_enabled_by_sw_if_index, sw_if_index, 0);
 
@@ -664,6 +666,11 @@ ip4_sw_interface_enable_disable (u32 sw_if_index, u32 is_enable)
   vnet_feature_enable_disable ("ip4-multicast", "ip4-not-enabled",
                               sw_if_index, !is_enable, 0, 0);
 
+  if (is_enable)
+    hi->l3_if_count++;
+  else if (hi->l3_if_count)
+    hi->l3_if_count--;
+
   {
     ip4_enable_disable_interface_callback_t *cb;
     vec_foreach (cb, im->enable_disable_interface_callbacks)
@@ -779,7 +786,10 @@ ip4_add_del_interface_address_internal (vlib_main_t * vm,
          goto done;
        }
 
-      ip_interface_address_del (lm, if_address_index, addr_fib);
+      error = ip_interface_address_del (lm, vnm, if_address_index, addr_fib,
+                                       address_length, sw_if_index);
+      if (error)
+       goto done;
     }
   else
     {
@@ -2053,7 +2063,7 @@ ip4_ttl_inc (vlib_buffer_t * b, ip4_header_t * ip)
   ttl += 1;
   ip->ttl = ttl;
 
-  ASSERT (ip->checksum == ip4_header_checksum (ip));
+  ASSERT (ip4_header_checksum_is_valid (ip));
 }
 
 /* Decrement TTL & update checksum.
@@ -2094,7 +2104,7 @@ ip4_ttl_and_checksum_check (vlib_buffer_t * b, ip4_header_t * ip, u16 * next,
     }
 
   /* Verify checksum. */
-  ASSERT ((ip->checksum == ip4_header_checksum (ip)) ||
+  ASSERT (ip4_header_checksum_is_valid (ip) ||
          (b->flags & VNET_BUFFER_F_OFFLOAD_IP_CKSUM));
 }
 
@@ -2231,8 +2241,7 @@ ip4_rewrite_inline_with_gso (vlib_main_t * vm,
          next[0] = next_index;
          if (is_midchain)
            vnet_calc_checksums_inline (vm, b[0], 1 /* is_ip4 */ ,
-                                       0 /* is_ip6 */ ,
-                                       0 /* with gso */ );
+                                       0 /* is_ip6 */ );
        }
       else
        {
@@ -2256,9 +2265,8 @@ ip4_rewrite_inline_with_gso (vlib_main_t * vm,
                                                adj1->ia_cfg_index);
          next[1] = next_index;
          if (is_midchain)
-           vnet_calc_checksums_inline (vm, b[0], 1 /* is_ip4 */ ,
-                                       0 /* is_ip6 */ ,
-                                       0 /* with gso */ );
+           vnet_calc_checksums_inline (vm, b[1], 1 /* is_ip4 */ ,
+                                       0 /* is_ip6 */ );
        }
       else
        {
@@ -2409,8 +2417,7 @@ ip4_rewrite_inline_with_gso (vlib_main_t * vm,
          if (is_midchain)
            {
              vnet_calc_checksums_inline (vm, b[0], 1 /* is_ip4 */ ,
-                                         0 /* is_ip6 */ ,
-                                         0 /* with gso */ );
+                                         0 /* is_ip6 */ );
 
              /* Guess we are only writing on ipv4 header. */
              vnet_rewrite_one_header (adj0[0], ip0, sizeof (ip4_header_t));
@@ -2517,8 +2524,7 @@ ip4_rewrite_inline_with_gso (vlib_main_t * vm,
            {
              /* this acts on the packet that is about to be encapped */
              vnet_calc_checksums_inline (vm, b[0], 1 /* is_ip4 */ ,
-                                         0 /* is_ip6 */ ,
-                                         0 /* with gso */ );
+                                         0 /* is_ip6 */ );
 
              /* Guess we are only writing on ipv4 header. */
              vnet_rewrite_one_header (adj0[0], ip0, sizeof (ip4_header_t));
@@ -3081,29 +3087,6 @@ VLIB_CLI_COMMAND (set_ip_classify_command, static) =
 };
 /* *INDENT-ON* */
 
-static clib_error_t *
-ip4_config (vlib_main_t * vm, unformat_input_t * input)
-{
-  ip4_main_t *im = &ip4_main;
-  uword heapsize = 0;
-
-  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
-    {
-      if (unformat (input, "heap-size %U", unformat_memory_size, &heapsize))
-       ;
-      else
-       return clib_error_return (0,
-                                 "invalid heap-size parameter `%U'",
-                                 format_unformat_error, input);
-    }
-
-  im->mtrie_heap_size = heapsize;
-
-  return 0;
-}
-
-VLIB_EARLY_CONFIG_FUNCTION (ip4_config, "ip");
-
 /*
  * fd.io coding-style-patch-verification: ON
  *