X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Ffib%2Ffib_test.c;h=03c9ee75f48c160977e554bcfe512b61c8d79c51;hb=6f6311560380d0e992f710558e213df1b098ef94;hp=540289ce9891f176a40635b22f492154bf7c2fd0;hpb=2297af016d4c1ecdd0c695dc736e8f5a988e89bd;p=vpp.git diff --git a/src/vnet/fib/fib_test.c b/src/vnet/fib/fib_test.c index 540289ce989..03c9ee75f48 100644 --- a/src/vnet/fib/fib_test.c +++ b/src/vnet/fib/fib_test.c @@ -27,9 +27,11 @@ #include #include #include +#include #include +#include #include #include #include @@ -266,83 +268,6 @@ fib_test_build_rewrite (u8 *eth_addr) return (rewrite); } -typedef enum fib_test_lb_bucket_type_t_ { - FT_LB_LABEL_O_ADJ, - FT_LB_LABEL_STACK_O_ADJ, - FT_LB_LABEL_O_LB, - FT_LB_O_LB, - FT_LB_SPECIAL, - FT_LB_ADJ, - FT_LB_INTF, -} fib_test_lb_bucket_type_t; - -typedef struct fib_test_lb_bucket_t_ { - fib_test_lb_bucket_type_t type; - - union - { - struct - { - mpls_eos_bit_t eos; - mpls_label_t label; - u8 ttl; - adj_index_t adj; - } label_o_adj; - struct - { - mpls_eos_bit_t eos; - mpls_label_t label_stack[8]; - u8 label_stack_size; - u8 ttl; - adj_index_t adj; - } label_stack_o_adj; - struct - { - mpls_eos_bit_t eos; - mpls_label_t label; - u8 ttl; - index_t lb; - } label_o_lb; - struct - { - index_t adj; - } adj; - struct - { - index_t lb; - } lb; - struct - { - index_t adj; - } special; - }; -} fib_test_lb_bucket_t; - -typedef enum fib_test_rep_bucket_type_t_ { - FT_REP_LABEL_O_ADJ, - FT_REP_DISP_MFIB_LOOKUP, - FT_REP_INTF, -} fib_test_rep_bucket_type_t; - -typedef struct fib_test_rep_bucket_t_ { - fib_test_rep_bucket_type_t type; - - union - { - struct - { - mpls_eos_bit_t eos; - mpls_label_t label; - u8 ttl; - adj_index_t adj; - } label_o_adj; - struct - { - adj_index_t adj; - } adj; - }; -} fib_test_rep_bucket_t; - #define FIB_TEST_LB(_cond, _comment, _args...) \ { \ if (!FIB_TEST_I(_cond, _comment, ##_args)) { \ @@ -353,7 +278,7 @@ typedef struct fib_test_rep_bucket_t_ { int fib_test_validate_rep_v (const replicate_t *rep, u16 n_buckets, - va_list ap) + va_list *ap) { const fib_test_rep_bucket_t *exp; const dpo_id_t *dpo; @@ -364,7 +289,7 @@ fib_test_validate_rep_v (const replicate_t *rep, for (bucket = 0; bucket < n_buckets; bucket++) { - exp = va_arg(ap, fib_test_rep_bucket_t*); + exp = va_arg(*ap, fib_test_rep_bucket_t*); dpo = replicate_get_bucket_i(rep, bucket); @@ -429,7 +354,7 @@ fib_test_validate_rep_v (const replicate_t *rep, int fib_test_validate_lb_v (const load_balance_t *lb, u16 n_buckets, - va_list ap) + va_list *ap) { const dpo_id_t *dpo; int bucket; @@ -440,7 +365,7 @@ fib_test_validate_lb_v (const load_balance_t *lb, { const fib_test_lb_bucket_t *exp; - exp = va_arg(ap, fib_test_lb_bucket_t*); + exp = va_arg(*ap, fib_test_lb_bucket_t*); dpo = load_balance_get_bucket_i(lb, bucket); switch (exp->type) @@ -598,6 +523,16 @@ fib_test_validate_lb_v (const load_balance_t *lb, bucket, exp->adj.adj); break; + case FT_LB_L2: + FIB_TEST_I((DPO_L2_BRIDGE == dpo->dpoi_type), + "bucket %d stacks on %U", + bucket, + format_dpo_type, dpo->dpoi_type); + FIB_TEST_LB((exp->adj.adj == dpo->dpoi_index), + "bucket %d stacks on adj %d", + bucket, + exp->adj.adj); + break; case FT_LB_O_LB: FIB_TEST_I((DPO_LOAD_BALANCE == dpo->dpoi_type), "bucket %d stacks on %U", @@ -648,7 +583,7 @@ fib_test_validate_entry (fib_node_index_t fei, const replicate_t *rep; rep = replicate_get(dpo.dpoi_index); - res = fib_test_validate_rep_v(rep, n_buckets, ap); + res = fib_test_validate_rep_v(rep, n_buckets, &ap); } else { @@ -659,7 +594,7 @@ fib_test_validate_entry (fib_node_index_t fei, format_dpo_type, dpo.dpoi_type); lb = load_balance_get(dpo.dpoi_index); - res = fib_test_validate_lb_v(lb, n_buckets, ap); + res = fib_test_validate_lb_v(lb, n_buckets, &ap); /* * ensure that the LB contributed by the entry is the @@ -4066,6 +4001,45 @@ fib_test_v4 (void) "Table and LB newhash config match: %U", format_ip_flow_hash_config, lb->lb_hash_config); + /* + * A route via an L2 Bridge + */ + fei = fib_table_entry_path_add(fib_index, + &pfx_10_10_10_3_s_32, + FIB_SOURCE_API, + FIB_ENTRY_FLAG_NONE, + DPO_PROTO_ETHERNET, + &zero_addr, + tm->hw[0]->sw_if_index, + ~0, + 1, + NULL, + FIB_ROUTE_PATH_FLAG_NONE); + dpo_id_t l2_dpo = DPO_INVALID; + l2_bridge_dpo_add_or_lock(tm->hw[0]->sw_if_index, &l2_dpo); + fib_test_lb_bucket_t ip_o_l2 = { + .type = FT_LB_L2, + .adj = { + .adj = l2_dpo.dpoi_index, + }, + }; + + FIB_TEST(fib_test_validate_entry(fei, + FIB_FORW_CHAIN_TYPE_UNICAST_IP4, + 1, + &ip_o_l2), + "10.10.10.3 via L2 on Eth0"); + fib_table_entry_path_remove(fib_index, + &pfx_10_10_10_3_s_32, + FIB_SOURCE_API, + DPO_PROTO_ETHERNET, + &zero_addr, + tm->hw[0]->sw_if_index, + fib_index, + 1, + FIB_ROUTE_PATH_FLAG_NONE); + dpo_reset(&l2_dpo); + /* * CLEANUP * remove adj-fibs: @@ -4165,6 +4139,8 @@ fib_test_v4 (void) pool_elts(load_balance_map_pool)); FIB_TEST((lb_count == pool_elts(load_balance_pool)), "LB pool size is %d", pool_elts(load_balance_pool)); + FIB_TEST((0 == pool_elts(l2_bridge_dpo_pool)), "L2 DPO pool size is %d", + pool_elts(l2_bridge_dpo_pool)); return 0; }