#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
*/
.frp_addr = zero_addr,
.frp_sw_if_index = 0xffffffff,
.frp_fib_index = ~0,
- .frp_weight = 0,
+ .frp_weight = 1,
.frp_flags = FIB_ROUTE_PATH_LOCAL,
+ .frp_mitf_flags = MFIB_ITF_FLAG_FORWARD,
};
pool_get_aligned(ip6_main.mfibs, mfib_table, CLIB_CACHE_LINE_BYTES);
mfib_table_entry_path_update(mfib_table->mft_index,
&pfx,
MFIB_SOURCE_SPECIAL,
- &path_for_us,
- MFIB_ITF_FLAG_FORWARD);
+ &path_for_us);
}));
return (mfib_table->mft_index);
.frp_addr = zero_addr,
.frp_sw_if_index = 0xffffffff,
.frp_fib_index = ~0,
- .frp_weight = 0,
+ .frp_weight = 1,
.frp_flags = FIB_ROUTE_PATH_LOCAL,
};
.frp_addr = zero_addr,
.frp_sw_if_index = sw_if_index,
.frp_fib_index = ~0,
- .frp_weight = 0,
+ .frp_weight = 1,
+ .frp_mitf_flags = MFIB_ITF_FLAG_ACCEPT,
};
mfib_prefix_t pfx = {
.fp_proto = FIB_PROTOCOL_IP6,
mfib_table_entry_path_update(mfib_index,
&pfx,
MFIB_SOURCE_SPECIAL,
- &path,
- MFIB_ITF_FLAG_ACCEPT);
+ &path);
});
}
else
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;
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++)
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);
/*
{
len = table->prefix_lengths_in_search_order[i];
- ASSERT(len >= 0 && len <= 256);
+ ASSERT(len <= 256);
IP6_MFIB_MK_KEY(mfib, grp, src, len, key);
rv = clib_bihash_search_inline_2_40_8(&table->ip6_mhash, &key, &value);
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
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;
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);
u8 *
format_ip6_mfib_table_memory (u8 * s, va_list * args)
{
- s = format(s, "%=30s %=6d %=8s\n",
+ u64 bytes_inuse;
+
+ bytes_inuse = alloc_arena_next(&(ip6_mfib_table.ip6_mhash));
+
+ s = format(s, "%=30s %=6d %=12ld\n",
"IPv6 multicast",
- pool_elts(ip6_main.mfibs), "???");
+ pool_elts(ip6_main.mfibs),
+ bytes_inuse);
return (s);
}
} ip6_mfib_show_ctx_t;
-static int
+static walk_rc_t
ip6_mfib_table_collect_entries (fib_node_index_t mfei, void *arg)
{
ip6_mfib_show_ctx_t *ctx = arg;
vec_add1(ctx->entries, mfei);
- return (0);
+ return (WALK_CONTINUE);
}
static void
if ((kvp->key[4] >> 32) == ctx->i6w_mfib_index)
{
- return (ctx->i6w_fn(kvp->value, ctx->i6w_ctx));
+ ctx->i6w_fn(kvp->value, ctx->i6w_ctx);
}
- return (FIB_TABLE_WALK_CONTINUE);
+ return (BIHASH_WALK_CONTINUE);
}
void
};
clib_bihash_foreach_key_value_pair_40_8(
- &ip6_main.ip6_mtable.ip6_mhash,
+ &ip6_mfib_table.ip6_mhash,
ip6_mfib_walk_cb,
&ctx);
}
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)
{
ip6_mfib_table_show_one(mfib, vm, &src, &grp, mask, cover);
}
- }));
+ }
return 0;
}
.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"),
+};