hs-test: add nginx+quic test
[vpp.git] / src / vnet / mfib / ip6_mfib.c
index 690f4ed..ac0dd82 100644 (file)
@@ -19,6 +19,8 @@
 #include <vnet/mfib/mfib_entry.h>
 #include <vnet/fib/ip6_fib.h>
 
+ip6_mfib_table_instance_t ip6_mfib_table;
+
 /**
  * Key and mask for radix
  */
@@ -181,6 +183,7 @@ ip6_create_mfib_with_table_id (u32 table_id,
         mfib_table_entry_path_update(mfib_table->mft_index,
                                      &pfx,
                                      MFIB_SOURCE_SPECIAL,
+                                     MFIB_ENTRY_FLAG_NONE,
                                      &path_for_us);
     }));
 
@@ -244,7 +247,6 @@ ip6_mfib_interface_enable_disable (u32 sw_if_index, int is_enable)
     };
     u32 mfib_index;
 
-    vec_validate (ip6_main.mfib_index_by_sw_if_index, sw_if_index);
     mfib_index = ip6_mfib_table_get_index_for_sw_if_index(sw_if_index);
 
     if (is_enable)
@@ -254,6 +256,7 @@ ip6_mfib_interface_enable_disable (u32 sw_if_index, int is_enable)
             mfib_table_entry_path_update(mfib_index,
                                          &pfx,
                                          MFIB_SOURCE_SPECIAL,
+                                         MFIB_ENTRY_FLAG_NONE,
                                          &path);
         });
     }
@@ -333,7 +336,7 @@ ip6_mfib_table_lookup_exact_match (const ip6_mfib_t *mfib,
 
     IP6_MFIB_MK_KEY(mfib, grp, src, len, key);
 
-    rv = clib_bihash_search_inline_2_40_8(&ip6_main.ip6_mtable.ip6_mhash,
+    rv = clib_bihash_search_inline_2_40_8(&ip6_mfib_table.ip6_mhash,
                                           &key, &value);
     if (rv == 0)
        return value.value;
@@ -356,7 +359,7 @@ ip6_mfib_table_fwd_lookup (const ip6_mfib_t *mfib,
     int i, n, len;
     int rv;
 
-    table = &ip6_main.ip6_mtable;
+    table = &ip6_mfib_table;
     n = vec_len (table->prefix_lengths_in_search_order);
 
     for (i = 0; i < n; i++)
@@ -421,7 +424,7 @@ ip6_mfib_table_lookup (const ip6_mfib_t *mfib,
     ip6_mfib_key_t key, value;
     int i, n, rv;
 
-    table = &ip6_main.ip6_mtable;
+    table = &ip6_mfib_table;
     n = vec_len (table->prefix_lengths_in_search_order);
 
     /*
@@ -455,10 +458,10 @@ compute_prefix_lengths_in_search_order (ip6_mfib_table_instance_t *table)
     int i;
     vec_reset_length (table->prefix_lengths_in_search_order);
     /* Note: bitmap reversed so this is in fact a longest prefix match */
-    clib_bitmap_foreach (i, table->non_empty_dst_address_length_bitmap,
-    ({
+    clib_bitmap_foreach (i, table->non_empty_dst_address_length_bitmap)
+     {
        vec_add1(table->prefix_lengths_in_search_order, (256 - i));
-    }));
+    }
 }
 
 void
@@ -471,7 +474,7 @@ ip6_mfib_table_entry_insert (ip6_mfib_t *mfib,
     ip6_mfib_table_instance_t *table;
     ip6_mfib_key_t key;
 
-    table = &ip6_main.ip6_mtable;
+    table = &ip6_mfib_table;
     IP6_MFIB_MK_KEY(mfib, grp, src, len, key);
     key.value = mfib_entry_index;
 
@@ -497,7 +500,7 @@ ip6_mfib_table_entry_remove (ip6_mfib_t *mfib,
 
     IP6_MFIB_MK_KEY(mfib, grp, src, len, key);
 
-    table = &ip6_main.ip6_mtable;
+    table = &ip6_mfib_table;
     clib_bihash_add_del_40_8(&table->ip6_mhash, &key, 0);
 
     ASSERT (table->dst_address_length_refcounts[len] > 0);
@@ -523,7 +526,7 @@ format_ip6_mfib_table_memory (u8 * s, va_list * args)
 {
     u64 bytes_inuse;
 
-    bytes_inuse = alloc_arena_next(&(ip6_main.ip6_mtable.ip6_mhash));
+    bytes_inuse = alloc_arena_next(&(ip6_mfib_table.ip6_mhash));
 
     s = format(s, "%=30s %=6d %=12ld\n",
                "IPv6 multicast",
@@ -609,7 +612,7 @@ typedef struct ip6_mfib_walk_ctx_t_
     void *i6w_ctx;
 } ip6_mfib_walk_ctx_t;
 
-static void
+static int
 ip6_mfib_walk_cb (clib_bihash_kv_40_8_t * kvp,
                  void *arg)
 {
@@ -619,6 +622,7 @@ ip6_mfib_walk_cb (clib_bihash_kv_40_8_t * kvp,
     {
         ctx->i6w_fn(kvp->value, ctx->i6w_ctx);
     }
+    return (BIHASH_WALK_CONTINUE);
 }
 
 void
@@ -633,7 +637,7 @@ ip6_mfib_table_walk (ip6_mfib_t *mfib,
     };
 
     clib_bihash_foreach_key_value_pair_40_8(
-        &ip6_main.ip6_mtable.ip6_mhash,
+        &ip6_mfib_table.ip6_mhash,
         ip6_mfib_walk_cb,
         &ctx);
 }
@@ -688,8 +692,8 @@ ip6_show_mfib (vlib_main_t * vm,
             break;
     }
 
-    pool_foreach (mfib_table, im6->mfibs,
-    ({
+    pool_foreach (mfib_table, im6->mfibs)
+     {
         ip6_mfib_t *mfib = &mfib_table->v6;
 
         if (table_id >= 0 && table_id != (int)mfib->table_id)
@@ -723,17 +727,18 @@ ip6_show_mfib (vlib_main_t * vm,
         {
             ip6_mfib_table_show_one(mfib, vm, &src, &grp, mask, cover);
         }
-    }));
+    }
 
     return 0;
 }
 
-/*
+/* clang-format off */
+/*?
  * This command displays the IPv6 MulticasrFIB Tables (VRF Tables) and
  * the route entries for each table.
  *
  * @note This command will run for a long time when the FIB tables are
- * comprised of millions of entries. For those senarios, consider displaying
+ * comprised of millions of entries. For those scenarios, consider displaying
  * a single table or summary mode.
  *
  * @cliexpar
@@ -769,11 +774,26 @@ ip6_show_mfib (vlib_main_t * vm,
  *                   24               2
  *                   32               4
  * @cliexend
- */
-/* *INDENT-OFF* */
?*/
+/* clang-format on */
 VLIB_CLI_COMMAND (ip6_show_fib_command, static) = {
     .path = "show ip6 mfib",
     .short_help = "show ip mfib [summary] [table <table-id>] [index <fib-id>] [<grp-addr>[/<mask>]] [<grp-addr>] [<src-addr> <grp-addr>]",
     .function = ip6_show_mfib,
 };
-/* *INDENT-ON* */
+
+static clib_error_t *
+ip6_mfib_init (vlib_main_t * vm)
+{
+    clib_bihash_init_40_8 (&ip6_mfib_table.ip6_mhash,
+                           "ip6 mFIB table",
+                           IP6_MFIB_DEFAULT_HASH_NUM_BUCKETS,
+                           IP6_MFIB_DEFAULT_HASH_MEMORY_SIZE);
+
+    return (NULL);
+}
+
+VLIB_INIT_FUNCTION (ip6_mfib_init) =
+{
+  .runs_before = VLIB_INITS("ip6_lookup_init"),
+};