X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fbier%2Fbier_test.c;h=08a8c55954ddfba50351121aebfa7643a3600bcc;hb=bb17f3c2fc0c8163bdb08ad1e66ff4ac5898508f;hp=f0e7b0cab2f6ca72b874dc95c03f92abf5479a6e;hpb=93149bb4cd0a137b2a6da4b0d9f8cb2032e44734;p=vpp.git diff --git a/src/vnet/bier/bier_test.c b/src/vnet/bier/bier_test.c index f0e7b0cab2f..08a8c55954d 100644 --- a/src/vnet/bier/bier_test.c +++ b/src/vnet/bier/bier_test.c @@ -158,7 +158,7 @@ bier_test_mk_intf (u32 ninterfaces) static int bier_test_validate_entry (index_t bei, - u16 n_buckets, + int n_buckets, ...) { dpo_id_t dpo = DPO_INVALID; @@ -170,15 +170,17 @@ bier_test_validate_entry (index_t bei, bier_entry_contribute_forwarding(bei, &dpo); - BIER_TEST_LB((DPO_LOAD_BALANCE == dpo.dpoi_type), - "Entry links to %U", - format_dpo_type, dpo.dpoi_type); + res = BIER_TEST_I((DPO_LOAD_BALANCE == dpo.dpoi_type), + "Entry links to %U", + format_dpo_type, dpo.dpoi_type); - lb = load_balance_get(dpo.dpoi_index); - res = fib_test_validate_lb_v(lb, n_buckets, &ap); + if (res) + { + lb = load_balance_get(dpo.dpoi_index); + res = fib_test_validate_lb_v(lb, n_buckets, &ap); + } dpo_reset(&dpo); - va_end(ap); return (res); @@ -308,11 +310,11 @@ bier_test_mpls_spf (void) .as_u32 = clib_host_to_net_u32(0x01010101), }, }; - fib_route_path_t *paths_1_1_1_1 = NULL; + fib_route_path_t *paths_1_1_1_1 = NULL, *input_paths_1_1_1_1; fib_route_path_t path_1_1_1_1 = { .frp_addr = nh_1_1_1_1, .frp_bier_fib_index = bti, - .frp_flags = FIB_ROUTE_PATH_BIER_FMASK, + .frp_sw_if_index = ~0, }; vec_add1(path_1_1_1_1.frp_label_stack, 500); vec_add1(paths_1_1_1_1, path_1_1_1_1); @@ -321,13 +323,10 @@ bier_test_mpls_spf (void) .fp_len = 32, .fp_proto = FIB_PROTOCOL_IP4, }; - const bier_fmask_id_t bfm_id_1_1_1_1 = { - .bfmi_hdr_type = BIER_HDR_O_MPLS, - .bfmi_nh = nh_1_1_1_1, - }; index_t bei_1; - bier_table_route_add(&bt_0_0_0_256, 1, paths_1_1_1_1); + input_paths_1_1_1_1 = vec_dup(paths_1_1_1_1); + bier_table_route_add(&bt_0_0_0_256, 1, input_paths_1_1_1_1); bei_1 = bier_table_lookup(bier_table_get(bti), 1); BIER_TEST((INDEX_INVALID != bei_1), "BP:1 present"); @@ -345,20 +344,12 @@ bier_test_mpls_spf (void) FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS, &neos_dpo_1_1_1_1); - bfmi_1_1_1_1 = bier_fmask_db_find(bti, &bfm_id_1_1_1_1); + bfmi_1_1_1_1 = bier_fmask_db_find(bti, &path_1_1_1_1); bfm_1_1_1_1 = bier_fmask_get(bfmi_1_1_1_1); - BIER_TEST(!dpo_cmp(&neos_dpo_1_1_1_1, &bfm_1_1_1_1->bfm_dpo), - "Fmask via 1.1.1.1 stacks on neos from 1.1.1.1/32"); - - /* - * and that n-eos LB at this stage is a drop.. - */ - const fib_test_lb_bucket_t bucket_drop = { - .type = FT_LB_DROP, - }; - BIER_TEST(fib_test_validate_lb(&neos_dpo_1_1_1_1, 1, &bucket_drop), - "1.1.1.1/32 n-eos LB 1 buckets via: DROP"); + BIER_TEST(!dpo_cmp(drop_dpo_get(DPO_PROTO_MPLS), + &bfm_1_1_1_1->bfm_dpo), + "Fmask via 1.1.1.1 stacks on MPLS drop"); /* * The BIER entry should stack on the forwarding chain of the fmask @@ -369,8 +360,11 @@ bier_test_mpls_spf (void) .fmask = bfmi_1_1_1_1, }, }; - BIER_TEST(bier_test_validate_entry(bei_1, 1, &bucket_drop), - "BP:1 stacks on bier drop"); + dpo_id_t dpo_bei = DPO_INVALID; + bier_entry_contribute_forwarding(bei_1, &dpo_bei); + + BIER_TEST(!dpo_cmp(&dpo_bei, drop_dpo_get(DPO_PROTO_BIER)), + "BP:1 stacks on bier drop"); /* * give 1.1.1.1/32 a path and hence a interesting n-eos chain @@ -418,7 +412,8 @@ bier_test_mpls_spf (void) BIER_TEST(!dpo_cmp(&neos_dpo_1_1_1_1, &bfm_1_1_1_1->bfm_dpo), "Fmask via 1.1.1.1 stacks on updated non-eos of 1.1.1.1/32"); - BIER_TEST(bier_test_validate_entry(bei_1, 1, &dpo_o_bfm_1_1_1_1), + bier_entry_contribute_forwarding(bei_1, &dpo_bei); + BIER_TEST((dpo_bei.dpoi_index == bfmi_1_1_1_1), "BP:1 stacks on fmask 1.1.1.1"); /* @@ -483,11 +478,13 @@ bier_test_mpls_spf (void) */ index_t bei_2; - bier_table_route_add(&bt_0_0_0_256, 2, paths_1_1_1_1); + input_paths_1_1_1_1 = vec_dup(paths_1_1_1_1); + bier_table_route_add(&bt_0_0_0_256, 2, input_paths_1_1_1_1); bei_2 = bier_table_lookup(bier_table_get(bti), 2); - BIER_TEST(bier_test_validate_entry(bei_2, 1, &dpo_o_bfm_1_1_1_1), - "BP:2 stacks on fmask 1.1.1.1"); + bier_entry_contribute_forwarding(bei_2, &dpo_bei); + BIER_TEST((dpo_bei.dpoi_index == bfmi_1_1_1_1), + "BP:2 stacks on fmask 1.1.1.1"); /* * now add a bit-position via a different next hop and expect to @@ -503,17 +500,14 @@ bier_test_mpls_spf (void) .fp_len = 32, .fp_proto = FIB_PROTOCOL_IP4, }; - fib_route_path_t *paths_1_1_1_2 = NULL, path_1_1_1_2 = { + fib_route_path_t *paths_1_1_1_2 = NULL, *input_paths_1_1_1_2, path_1_1_1_2 = { .frp_addr = nh_1_1_1_2, .frp_bier_fib_index = bti, - .frp_flags = FIB_ROUTE_PATH_BIER_FMASK, + .frp_sw_if_index = ~0, }; vec_add1(path_1_1_1_2.frp_label_stack, 501); vec_add1(paths_1_1_1_2, path_1_1_1_2); - const bier_fmask_id_t bfm_id_1_1_1_2 = { - .bfmi_hdr_type = BIER_HDR_O_MPLS, - .bfmi_nh = nh_1_1_1_2, - }; + input_paths_1_1_1_2 = vec_dup(paths_1_1_1_2); index_t bei_3; mpls_label_t *out_lbl_101 = NULL; @@ -529,7 +523,7 @@ bier_test_mpls_spf (void) 1, out_lbl_101, FIB_ROUTE_PATH_FLAG_NONE); - bier_table_route_add(&bt_0_0_0_256, 3, paths_1_1_1_2); + bier_table_route_add(&bt_0_0_0_256, 3, input_paths_1_1_1_2); bei_3 = bier_table_lookup(bier_table_get(bti), 3); BIER_TEST((INDEX_INVALID != bei_3), "BP:3 present"); @@ -547,7 +541,7 @@ bier_test_mpls_spf (void) FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS, &neos_dpo_1_1_1_2); - bfmi_1_1_1_2 = bier_fmask_db_find(bti, &bfm_id_1_1_1_2); + bfmi_1_1_1_2 = bier_fmask_db_find(bti, &path_1_1_1_2); bfm_1_1_1_2 = bier_fmask_get(bfmi_1_1_1_2); BIER_TEST(!dpo_cmp(&neos_dpo_1_1_1_2, @@ -563,13 +557,16 @@ bier_test_mpls_spf (void) .fmask = bfmi_1_1_1_2, }, }; - BIER_TEST(bier_test_validate_entry(bei_3, 1, &dpo_o_bfm_1_1_1_2), - "BP:3 stacks on fmask 1.1.1.2"); + bier_entry_contribute_forwarding(bei_3, &dpo_bei); + BIER_TEST((dpo_bei.dpoi_index == bfmi_1_1_1_2), + "BP:2 stacks on fmask 1.1.1.2"); /* * Load-balance BP:3 over both next-hops */ - bier_table_route_add(&bt_0_0_0_256, 3, paths_1_1_1_1); + paths_1_1_1_1[0] = path_1_1_1_1; + input_paths_1_1_1_1 = vec_dup(paths_1_1_1_1); + bier_table_route_add(&bt_0_0_0_256, 3, input_paths_1_1_1_1); BIER_TEST(bier_test_validate_entry(bei_3, 2, &dpo_o_bfm_1_1_1_1, @@ -589,13 +586,13 @@ bier_test_mpls_spf (void) /* * Withdraw one of the via FIB and thus bring down the fmask - * expect the bier0entry forwarding to remove this from the set + * expect the bier-entry forwarding to remove this from the set */ fib_table_entry_delete(0, &pfx_1_1_1_2_s_32, FIB_SOURCE_API); - BIER_TEST(bier_test_validate_entry(bei_3, 1, - &dpo_o_bfm_1_1_1_1), - "BP:3 post 1.1.1.2 removal stacks on fmask 1.1.1.1"); + bier_entry_contribute_forwarding(bei_3, &dpo_bei); + BIER_TEST((dpo_bei.dpoi_index == bfmi_1_1_1_1), + "BP:3 stacks on fmask 1.1.1.1"); BIER_TEST((bier_table_fwd_lookup(bier_table_get(l_o_bt[0].bier.table), 3) == bfmi_1_1_1_1), @@ -637,10 +634,12 @@ bier_test_mpls_spf (void) /* * remove the original 1.1.1.2 fmask from BP:3 */ - bier_table_route_remove(&bt_0_0_0_256, 3, paths_1_1_1_2); - BIER_TEST(bier_test_validate_entry(bei_3, 1, - &dpo_o_bfm_1_1_1_1), + input_paths_1_1_1_2 = vec_dup(paths_1_1_1_2); + bier_table_route_remove(&bt_0_0_0_256, 3, input_paths_1_1_1_2); + bier_entry_contribute_forwarding(bei_3, &dpo_bei); + BIER_TEST((dpo_bei.dpoi_index == bfmi_1_1_1_1), "BP:3 stacks on fmask 1.1.1.1"); + /* * test that the ECMP choices for BP:3 have been updated */ @@ -654,11 +653,14 @@ bier_test_mpls_spf (void) /* * remove the routes added */ - bier_table_route_remove(&bt_0_0_0_256, 2, paths_1_1_1_1); - bier_table_route_remove(&bt_0_0_0_256, 3, paths_1_1_1_2); - bier_table_route_remove(&bt_0_0_0_256, 3, paths_1_1_1_1); - bier_table_route_remove(&bt_0_0_0_256, 1, paths_1_1_1_1); - + input_paths_1_1_1_1 = vec_dup(paths_1_1_1_1); + bier_table_route_remove(&bt_0_0_0_256, 2, input_paths_1_1_1_1); + input_paths_1_1_1_2 = vec_dup(paths_1_1_1_2); + bier_table_route_remove(&bt_0_0_0_256, 3, input_paths_1_1_1_2); + input_paths_1_1_1_1 = vec_dup(paths_1_1_1_1); + bier_table_route_remove(&bt_0_0_0_256, 3, input_paths_1_1_1_1); + input_paths_1_1_1_1 = vec_dup(paths_1_1_1_1); + bier_table_route_remove(&bt_0_0_0_256, 1, input_paths_1_1_1_1); /* * delete the table @@ -668,6 +670,7 @@ bier_test_mpls_spf (void) /* * test resources are freed */ + dpo_reset(&dpo_bei); for (ii = 0; ii < N_BIER_ECMP_TABLES; ii++) { bier_table_ecmp_unlock(l_o_bt[ii].bier.table); @@ -691,6 +694,8 @@ bier_test_mpls_spf (void) vec_free(paths_1_1_1_1); vec_free(paths_1_1_1_2); + vec_free(input_paths_1_1_1_1); + vec_free(input_paths_1_1_1_2); return (0); } @@ -769,10 +774,6 @@ bier_test_mpls_imp (void) static int bier_test_mpls_disp (void) { - /* test_main_t *tm; */ - - /* tm = &test_main; */ - /* * Add the BIER Main table */ @@ -801,8 +802,9 @@ bier_test_mpls_disp (void) */ fib_route_path_t *paths_via_disp = NULL, path_via_disp = { // .frp_addr = all-zeros + .frp_proto = DPO_PROTO_BIER, .frp_bier_fib_index = bdti1, - .frp_flags = FIB_ROUTE_PATH_BIER_FMASK, + .frp_sw_if_index = ~0, }; vec_add1(paths_via_disp, path_via_disp); @@ -811,16 +813,13 @@ bier_test_mpls_disp (void) /* * the fmask should stack on the BIER disp table */ - const bier_fmask_id_t bfm_id_0_0_0_0 = { - .bfmi_hdr_type = BIER_HDR_O_MPLS, - }; bier_fmask_t *bfm_0_0_0_0; index_t bfmi_0_0_0_0; dpo_id_t dpo_disp_tbl_1 = DPO_INVALID; bier_disp_table_contribute_forwarding(bdti1, &dpo_disp_tbl_1); - bfmi_0_0_0_0 = bier_fmask_db_find(bti, &bfm_id_0_0_0_0); + bfmi_0_0_0_0 = bier_fmask_db_find(bti, &path_via_disp); bfm_0_0_0_0 = bier_fmask_get(bfmi_0_0_0_0); BIER_TEST(!dpo_cmp(&dpo_disp_tbl_1, &bfm_0_0_0_0->bfm_dpo), @@ -842,21 +841,13 @@ bier_test_mpls_disp (void) BIER_HDR_PROTO_IPV4, rpaths); /* which should stack on a lookup in the mfib table */ - const dpo_id_t *dpo_disp_entry_lb; const dpo_id_t *dpo_disp_entry_v4; bier_disp_entry_t *bde_99; index_t bdei; bdei = bier_disp_table_lookup(bdti1, clib_host_to_net_u16(src)); bde_99 = bier_disp_entry_get(bdei); - dpo_disp_entry_lb = &bde_99->bde_fwd[BIER_HDR_PROTO_IPV4].bde_dpo; - - BIER_TEST(dpo_disp_entry_lb->dpoi_type == DPO_LOAD_BALANCE, - "BIER Disp entry stacks on LB"); - - load_balance_t *lb; - lb = load_balance_get(dpo_disp_entry_lb->dpoi_index); - dpo_disp_entry_v4 = load_balance_get_bucket_i(lb, 0); + dpo_disp_entry_v4 = &bde_99->bde_fwd[BIER_HDR_PROTO_IPV4].bde_dpo; lookup_dpo_t *lkd = lookup_dpo_get(dpo_disp_entry_v4->dpoi_index);