X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fmfib%2Fip6_mfib.c;h=1c1f5db71f790c7f161bb1968cd4ace23cea1446;hb=004869d0d4947a6e56b2d1bd481bbb6916d7a2e0;hp=0c2e4c7b7965b11844e2be11a8846d78740a1e00;hpb=32e1c010b0c34fd0984f7fc45fae648a182025c5;p=vpp.git diff --git a/src/vnet/mfib/ip6_mfib.c b/src/vnet/mfib/ip6_mfib.c index 0c2e4c7b796..1c1f5db71f7 100644 --- a/src/vnet/mfib/ip6_mfib.c +++ b/src/vnet/mfib/ip6_mfib.c @@ -151,14 +151,15 @@ static const ip6_mfib_special_t ip6_mfib_specials[] = static u32 -ip6_create_mfib_with_table_id (u32 table_id) +ip6_create_mfib_with_table_id (u32 table_id, + mfib_source_t src) { mfib_table_t *mfib_table; mfib_prefix_t pfx = { .fp_proto = FIB_PROTOCOL_IP6, }; const fib_route_path_t path_for_us = { - .frp_proto = FIB_PROTOCOL_IP6, + .frp_proto = DPO_PROTO_IP6, .frp_addr = zero_addr, .frp_sw_if_index = 0xffffffff, .frp_fib_index = ~0, @@ -182,7 +183,7 @@ ip6_create_mfib_with_table_id (u32 table_id) mfib_table->v6.table_id = table_id; - mfib_table_lock(mfib_table->mft_index, FIB_PROTOCOL_IP6); + mfib_table_lock(mfib_table->mft_index, FIB_PROTOCOL_IP6, src); mfib_table->v6.rhead = clib_mem_alloc_aligned (sizeof(*mfib_table->v6.rhead), @@ -195,6 +196,7 @@ ip6_create_mfib_with_table_id (u32 table_id) mfib_table_entry_update(mfib_table->mft_index, &all_zeros, MFIB_SOURCE_DEFAULT_ROUTE, + MFIB_RPF_ID_NONE, MFIB_ENTRY_FLAG_DROP); /* @@ -221,7 +223,7 @@ ip6_mfib_table_destroy (ip6_mfib_t *mfib) .fp_proto = FIB_PROTOCOL_IP6, }; const fib_route_path_t path_for_us = { - .frp_proto = FIB_PROTOCOL_IP6, + .frp_proto = DPO_PROTO_IP6, .frp_addr = zero_addr, .frp_sw_if_index = 0xffffffff, .frp_fib_index = ~0, @@ -258,7 +260,7 @@ void ip6_mfib_interface_enable_disable (u32 sw_if_index, int is_enable) { const fib_route_path_t path = { - .frp_proto = FIB_PROTOCOL_IP6, + .frp_proto = DPO_PROTO_IP6, .frp_addr = zero_addr, .frp_sw_if_index = sw_if_index, .frp_fib_index = ~0, @@ -296,14 +298,15 @@ ip6_mfib_interface_enable_disable (u32 sw_if_index, int is_enable) } u32 -ip6_mfib_table_find_or_create_and_lock (u32 table_id) +ip6_mfib_table_find_or_create_and_lock (u32 table_id, + mfib_source_t src) { u32 index; index = ip6_mfib_index_from_table_id(table_id); if (~0 == index) - return ip6_create_mfib_with_table_id(table_id); - mfib_table_lock(index, FIB_PROTOCOL_IP6); + return ip6_create_mfib_with_table_id(table_id, src); + mfib_table_lock(index, FIB_PROTOCOL_IP6, src); return (index); } @@ -431,7 +434,7 @@ ip6_mfib_table_entry_insert (ip6_mfib_t *mfib, { ip6_mfib_node_t *i6mn = clib_mem_alloc(sizeof(*i6mn)); - memset(i6mn, 0, sizeof(*i6mn)); + memset(i6mn->i6mn_nodes, 0, sizeof(i6mn->i6mn_nodes)); IP6_MFIB_MK_KEY_MASK(grp, src, len, &i6mn->i6mn_key); i6mn->i6mn_entry = mfib_entry_index; @@ -469,6 +472,16 @@ ip6_mfib_module_init (vlib_main_t * vm) VLIB_INIT_FUNCTION(ip6_mfib_module_init); +u8 * +format_ip6_mfib_table_memory (u8 * s, va_list * args) +{ + s = format(s, "%=30s %=6d %=8s\n", + "IPv6 multicast", + pool_elts(ip6_main.mfibs), "???"); + + return (s); +} + static void ip6_mfib_table_show_one (ip6_mfib_t *mfib, vlib_main_t * vm, @@ -483,20 +496,16 @@ ip6_mfib_table_show_one (ip6_mfib_t *mfib, } typedef struct ip6_mfib_show_ctx_t_ { - u32 fib_index; fib_node_index_t *entries; } ip6_mfib_show_ctx_t; static int -ip6_mfib_table_collect_entries (struct radix_node *rn, void *arg) +ip6_mfib_table_collect_entries (fib_node_index_t mfei, void *arg) { ip6_mfib_show_ctx_t *ctx = arg; - ip6_mfib_node_t *i6mn; - - i6mn = (ip6_mfib_node_t*) rn; - vec_add1(ctx->entries, i6mn->i6mn_entry); + vec_add1(ctx->entries, mfei); return (0); } @@ -507,13 +516,12 @@ ip6_mfib_table_show_all (ip6_mfib_t *mfib, { fib_node_index_t *mfib_entry_index; ip6_mfib_show_ctx_t ctx = { - .fib_index = mfib->index, .entries = NULL, }; - rn_walktree(mfib->rhead, - ip6_mfib_table_collect_entries, - &ctx); + ip6_mfib_table_walk(mfib, + ip6_mfib_table_collect_entries, + &ctx); vec_sort_with_function(ctx.entries, mfib_entry_cmp_for_sort); @@ -528,12 +536,47 @@ ip6_mfib_table_show_all (ip6_mfib_t *mfib, vec_free(ctx.entries); } +typedef struct ip6_mfib_radix_walk_ctx_t_ +{ + mfib_table_walk_fn_t user_fn; + void *user_ctx; +} ip6_mfib_radix_walk_ctx_t; + +static int +ip6_mfib_table_radix_walk (struct radix_node *rn, + void *arg) +{ + ip6_mfib_radix_walk_ctx_t *ctx = arg; + ip6_mfib_node_t *i6mn; + + i6mn = (ip6_mfib_node_t*) rn; + + ctx->user_fn(i6mn->i6mn_entry, ctx->user_ctx); + + return (0); +} + +void +ip6_mfib_table_walk (ip6_mfib_t *mfib, + mfib_table_walk_fn_t fn, + void *ctx) +{ + ip6_mfib_radix_walk_ctx_t rn_ctx = { + .user_fn = fn, + .user_ctx = ctx, + }; + + rn_walktree(mfib->rhead, + ip6_mfib_table_radix_walk, + &rn_ctx); +} + static clib_error_t * ip6_show_mfib (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { - ip6_main_t * im4 = &ip6_main; + ip6_main_t * im6 = &ip6_main; mfib_table_t *mfib_table; int verbose, matching; ip6_address_t grp, src = {{0}}; @@ -554,16 +597,19 @@ ip6_show_mfib (vlib_main_t * vm, unformat_ip6_address, &grp)) { matching = 1; - mask = 64; + mask = 256; } - else if (unformat (input, "%U", unformat_ip6_address, &grp)) + else if (unformat (input, "%U/%d", unformat_ip6_address, &grp, &mask)) { + memset(&src, 0, sizeof(src)); matching = 1; - mask = 32; } - else if (unformat (input, "%U/%d", - unformat_ip6_address, &grp, &mask)) + else if (unformat (input, "%U", unformat_ip6_address, &grp)) + { + memset(&src, 0, sizeof(src)); matching = 1; + mask = 128; + } else if (unformat (input, "table %d", &table_id)) ; else if (unformat (input, "index %d", &fib_index)) @@ -572,7 +618,7 @@ ip6_show_mfib (vlib_main_t * vm, break; } - pool_foreach (mfib_table, im4->mfibs, + pool_foreach (mfib_table, im6->mfibs, ({ ip6_mfib_t *mfib = &mfib_table->v6; @@ -613,7 +659,7 @@ ip6_show_mfib (vlib_main_t * vm, } /* - * This command displays the IPv4 MulticasrFIB Tables (VRF Tables) and + * 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 @@ -621,9 +667,9 @@ ip6_show_mfib (vlib_main_t * vm, * a single table or summary mode. * * @cliexpar - * Example of how to display all the IPv4 Multicast FIB tables: + * Example of how to display all the IPv6 Multicast FIB tables: * @cliexstart{show ip fib} - * ipv4-VRF:0, fib_index 0 + * ipv6-VRF:0, fib_index 0 * (*, 0.0.0.0/0): flags:D, * Interfaces: * multicast-ip6-chain @@ -635,18 +681,18 @@ ip6_show_mfib (vlib_main_t * vm, * test-eth0: Accept, * multicast-ip6-chain * [@2]: dpo-replicate: [index:1 buckets:2 to:[0:0]] - * [0] [@1]: ipv4-mcast: test-eth1: IP6: d0:d1:d2:d3:d4:01 -> 01:00:05:00:00:00 - * [1] [@1]: ipv4-mcast: test-eth2: IP6: d0:d1:d2:d3:d4:02 -> 01:00:05:00:00:00 + * [0] [@1]: ipv6-mcast: test-eth1: IP6: d0:d1:d2:d3:d4:01 -> 01:00:05:00:00:00 + * [1] [@1]: ipv6-mcast: test-eth2: IP6: d0:d1:d2:d3:d4:02 -> 01:00:05:00:00:00 * * @cliexend - * Example of how to display a summary of all IPv4 FIB tables: + * Example of how to display a summary of all IPv6 FIB tables: * @cliexstart{show ip fib summary} - * ipv4-VRF:0, fib_index 0, flow hash: src dst sport dport proto + * ipv6-VRF:0, fib_index 0, flow hash: src dst sport dport proto * Prefix length Count * 0 1 * 8 2 * 32 4 - * ipv4-VRF:7, fib_index 1, flow hash: src dst sport dport proto + * ipv6-VRF:7, fib_index 1, flow hash: src dst sport dport proto * Prefix length Count * 0 1 * 8 2