aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/bier
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/bier')
-rw-r--r--src/vnet/bier/bier_api.c59
-rw-r--r--src/vnet/bier/bier_fmask.c4
-rw-r--r--src/vnet/bier/bier_test.c125
3 files changed, 73 insertions, 115 deletions
diff --git a/src/vnet/bier/bier_api.c b/src/vnet/bier/bier_api.c
index 8f168c46e29..7263ec65720 100644
--- a/src/vnet/bier/bier_api.c
+++ b/src/vnet/bier/bier_api.c
@@ -49,6 +49,7 @@
#undef vl_printfun
#include <vlibapi/api_helper_macros.h>
+#include <vnet/fib/fib_api.h>
#define foreach_bier_api_msg \
_(BIER_TABLE_ADD_DEL, bier_table_add_del) \
@@ -164,7 +165,7 @@ vl_api_bier_route_add_del_t_handler (vl_api_bier_route_add_del_t * mp)
vnet_main_t *vnm;
bier_bp_t bp;
int rv = 0;
- u8 ii, jj;
+ u8 ii;
vnm = vnet_get_main ();
vnm->api_errno = 0;
@@ -195,61 +196,11 @@ vl_api_bier_route_add_del_t_handler (vl_api_bier_route_add_del_t * mp)
vec_foreach_index(ii, brpaths)
{
brpath = &brpaths[ii];
- memset(brpath, 0, sizeof(*brpath));
- brpath->frp_sw_if_index = ~0;
-
- vec_validate(brpath->frp_label_stack,
- mp->br_paths[ii].n_labels - 1);
- for (jj = 0; jj < mp->br_paths[ii].n_labels; jj++)
- {
- brpath->frp_label_stack[jj].fml_value =
- ntohl(mp->br_paths[ii].label_stack[jj].label);
- brpath->frp_label_stack[jj].fml_ttl =
- mp->br_paths[ii].label_stack[jj].ttl;
- brpath->frp_label_stack[jj].fml_exp =
- mp->br_paths[ii].label_stack[jj].exp;
- brpath->frp_label_stack[jj].fml_mode =
- (mp->br_paths[ii].label_stack[jj].is_uniform ?
- FIB_MPLS_LSP_MODE_UNIFORM :
- FIB_MPLS_LSP_MODE_PIPE);
- }
+ rv = fib_path_api_parse(&mp->br_paths[ii], brpath);
- if (mp->br_paths[ii].is_udp_encap)
+ if (0 != rv)
{
- brpath->frp_flags |= FIB_ROUTE_PATH_UDP_ENCAP;
- brpath->frp_udp_encap_id = ntohl(mp->br_paths[ii].next_hop_id);
- }
- else
- {
- if (0 == mp->br_paths[ii].afi)
- {
- clib_memcpy (&brpath->frp_addr.ip4,
- mp->br_paths[ii].next_hop,
- sizeof (brpath->frp_addr.ip4));
- }
- else
- {
- clib_memcpy (&brpath->frp_addr.ip6,
- mp->br_paths[ii].next_hop,
- sizeof (brpath->frp_addr.ip6));
- }
- if (ip46_address_is_zero(&brpath->frp_addr))
- {
- index_t bdti;
-
- bdti = bier_disp_table_find(ntohl(mp->br_paths[ii].table_id));
-
- if (INDEX_INVALID != bdti)
- {
- brpath->frp_fib_index = bdti;
- brpath->frp_proto = DPO_PROTO_BIER;
- }
- else
- {
- rv = VNET_API_ERROR_NO_SUCH_FIB;
- goto done;
- }
- }
+ goto done;
}
}
diff --git a/src/vnet/bier/bier_fmask.c b/src/vnet/bier/bier_fmask.c
index 31d884af060..3d7cc838ab0 100644
--- a/src/vnet/bier/bier_fmask.c
+++ b/src/vnet/bier/bier_fmask.c
@@ -356,13 +356,13 @@ format_bier_fmask (u8 *s, va_list *ap)
{
s = format(s, " output-label:%U",
format_mpls_unicast_label,
- vnet_mpls_uc_get_label(bfm->bfm_label));
+ vnet_mpls_uc_get_label(clib_net_to_host_u32(bfm->bfm_label)));
}
else
{
s = format(s, " output-bfit:[%U]",
format_bier_bift_id,
- vnet_mpls_uc_get_label(bfm->bfm_label));
+ vnet_mpls_uc_get_label(clib_net_to_host_u32(bfm->bfm_label)));
}
s = format(s, "\n %U%U",
format_white_space, indent,
diff --git a/src/vnet/bier/bier_test.c b/src/vnet/bier/bier_test.c
index 6c7af829811..204dafc3f0b 100644
--- a/src/vnet/bier/bier_test.c
+++ b/src/vnet/bier/bier_test.c
@@ -43,16 +43,17 @@ static int bier_test_do_debug;
if (!(_evald)) { \
fformat(stderr, "FAIL:%d: " _comment "\n", \
__LINE__, ##_args); \
+ res = 1; \
} else { \
if (bier_test_do_debug) \
fformat(stderr, "PASS:%d: " _comment "\n", \
__LINE__, ##_args); \
} \
- _evald; \
+ res; \
})
#define BIER_TEST(_cond, _comment, _args...) \
{ \
- if (!BIER_TEST_I(_cond, _comment, ##_args)) { \
+ if (BIER_TEST_I(_cond, _comment, ##_args)) { \
return 1; \
ASSERT(!("FAIL: " _comment)); \
} \
@@ -103,8 +104,10 @@ bier_test_mk_intf (u32 ninterfaces)
clib_error_t * error = NULL;
test_main_t *tm = &test_main;
u8 byte;
+ int res;
u32 i;
+ res = 0;
ASSERT(ninterfaces <= ARRAY_LEN(tm->hw_if_indicies));
for (i=0; i<6; i++)
@@ -146,13 +149,13 @@ bier_test_mk_intf (u32 ninterfaces)
tm->hw_if_indicies[i]);
}
- return (0);
+ return (res);
}
#define BIER_TEST_LB(_cond, _comment, _args...) \
{ \
- if (!BIER_TEST_I(_cond, _comment, ##_args)) { \
- return (0); \
+ if (BIER_TEST_I(_cond, _comment, ##_args)) { \
+ return (1); \
} \
}
@@ -168,13 +171,14 @@ bier_test_validate_entry (index_t bei,
va_start(ap, n_buckets);
+ res = 0;
bier_entry_contribute_forwarding(bei, &dpo);
- res = BIER_TEST_I((DPO_LOAD_BALANCE == dpo.dpoi_type),
- "Entry links to %U",
- format_dpo_type, dpo.dpoi_type);
+ BIER_TEST_I((DPO_LOAD_BALANCE == dpo.dpoi_type),
+ "Entry links to %U",
+ format_dpo_type, dpo.dpoi_type);
- if (res)
+ if (!res)
{
lb = load_balance_get(dpo.dpoi_index);
res = fib_test_validate_lb_v(lb, n_buckets, &ap);
@@ -193,7 +197,9 @@ bier_test_mpls_spf (void)
u32 mpls_fib_index;
test_main_t *tm;
int lb_count;
+ int res;
+ res = 0;
lb_count = pool_elts(load_balance_pool);
tm = &test_main;
#define N_BIER_ECMP_TABLES 16
@@ -245,24 +251,24 @@ bier_test_mpls_spf (void)
BIER_TEST(FIB_NODE_INDEX_INVALID == lfei, "1600/0 is not present");
lfei = fib_table_lookup(mpls_fib_index, &pfx_1600_eos);
- BIER_TEST(fib_test_validate_entry(lfei, FIB_FORW_CHAIN_TYPE_MPLS_EOS,
- 16,
- &l_o_bt[0],
- &l_o_bt[1],
- &l_o_bt[2],
- &l_o_bt[3],
- &l_o_bt[4],
- &l_o_bt[5],
- &l_o_bt[6],
- &l_o_bt[7],
- &l_o_bt[8],
- &l_o_bt[9],
- &l_o_bt[10],
- &l_o_bt[11],
- &l_o_bt[12],
- &l_o_bt[13],
- &l_o_bt[14],
- &l_o_bt[15]),
+ BIER_TEST(!fib_test_validate_entry(lfei, FIB_FORW_CHAIN_TYPE_MPLS_EOS,
+ 16,
+ &l_o_bt[0],
+ &l_o_bt[1],
+ &l_o_bt[2],
+ &l_o_bt[3],
+ &l_o_bt[4],
+ &l_o_bt[5],
+ &l_o_bt[6],
+ &l_o_bt[7],
+ &l_o_bt[8],
+ &l_o_bt[9],
+ &l_o_bt[10],
+ &l_o_bt[11],
+ &l_o_bt[12],
+ &l_o_bt[13],
+ &l_o_bt[14],
+ &l_o_bt[15]),
"1600/1 LB stacks on BIER table %d", bti);
/*
@@ -282,24 +288,24 @@ bier_test_mpls_spf (void)
BIER_TEST(FIB_NODE_INDEX_INVALID == lfei, "1600/1 is deleted");
lfei = fib_table_lookup(mpls_fib_index, &pfx_1601_eos);
- BIER_TEST(fib_test_validate_entry(lfei, FIB_FORW_CHAIN_TYPE_MPLS_EOS,
- 16,
- &l_o_bt[0],
- &l_o_bt[1],
- &l_o_bt[2],
- &l_o_bt[3],
- &l_o_bt[4],
- &l_o_bt[5],
- &l_o_bt[6],
- &l_o_bt[7],
- &l_o_bt[8],
- &l_o_bt[9],
- &l_o_bt[10],
- &l_o_bt[11],
- &l_o_bt[12],
- &l_o_bt[13],
- &l_o_bt[14],
- &l_o_bt[15]),
+ BIER_TEST(!fib_test_validate_entry(lfei, FIB_FORW_CHAIN_TYPE_MPLS_EOS,
+ 16,
+ &l_o_bt[0],
+ &l_o_bt[1],
+ &l_o_bt[2],
+ &l_o_bt[3],
+ &l_o_bt[4],
+ &l_o_bt[5],
+ &l_o_bt[6],
+ &l_o_bt[7],
+ &l_o_bt[8],
+ &l_o_bt[9],
+ &l_o_bt[10],
+ &l_o_bt[11],
+ &l_o_bt[12],
+ &l_o_bt[13],
+ &l_o_bt[14],
+ &l_o_bt[15]),
"1601/1 LB stacks on BIER table %d", bti);
/*
@@ -411,8 +417,8 @@ bier_test_mpls_spf (void)
fib_entry_contribute_forwarding(fei,
FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS,
&neos_dpo_1_1_1_1);
- BIER_TEST(fib_test_validate_lb(&neos_dpo_1_1_1_1, 1,
- &bucket_neos_99_via_10_10_10_1),
+ BIER_TEST(!fib_test_validate_lb(&neos_dpo_1_1_1_1, 1,
+ &bucket_neos_99_via_10_10_10_1),
"1.1.1.1/32 n-eos LB 1 buckets via: 99 + 10.10.10.1");
BIER_TEST(!dpo_cmp(&neos_dpo_1_1_1_1,
&bfm_1_1_1_1->bfm_dpo),
@@ -468,9 +474,9 @@ bier_test_mpls_spf (void)
fib_entry_contribute_forwarding(fei,
FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS,
&neos_dpo_1_1_1_1);
- BIER_TEST(fib_test_validate_lb(&neos_dpo_1_1_1_1, 2,
- &bucket_neos_99_via_10_10_10_1,
- &bucket_neos_100_via_10_10_10_2),
+ BIER_TEST(!fib_test_validate_lb(&neos_dpo_1_1_1_1, 2,
+ &bucket_neos_99_via_10_10_10_1,
+ &bucket_neos_100_via_10_10_10_2),
"1.1.1.1/32 n-eos LB 2 buckets "
"via: 99 + 10.10.10.1, "
"via: 100 + 10.10.10.2");
@@ -580,9 +586,9 @@ bier_test_mpls_spf (void)
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,
- &dpo_o_bfm_1_1_1_2),
+ BIER_TEST(!bier_test_validate_entry(bei_3, 2,
+ &dpo_o_bfm_1_1_1_1,
+ &dpo_o_bfm_1_1_1_2),
"BP:3 stacks on fmask 1.1.1.2 & 1.1.1.1");
/*
@@ -632,9 +638,9 @@ bier_test_mpls_spf (void)
/* suspend so the update walk kicks int */
vlib_process_suspend(vlib_get_main(), 1e-5);
- BIER_TEST(bier_test_validate_entry(bei_3, 2,
- &dpo_o_bfm_1_1_1_1,
- &dpo_o_bfm_1_1_1_2),
+ BIER_TEST(!bier_test_validate_entry(bei_3, 2,
+ &dpo_o_bfm_1_1_1_1,
+ &dpo_o_bfm_1_1_1_2),
"BP:3 stacks on fmask 1.1.1.2 & 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),
@@ -716,9 +722,7 @@ static int
bier_test_mpls_imp (void)
{
fib_node_index_t bii;
- /* test_main_t *tm; */
-
- /* tm = &test_main; */
+ int res;
/*
* Add the BIER Main table
@@ -740,6 +744,7 @@ bier_test_mpls_imp (void)
u8 buckets[BIER_HDR_BUCKETS_256];
memset(buckets, 0x5, BIER_HDR_BUCKETS_256);
+ res = 0;
bier_bit_string_init(&bbs_256, BIER_HDR_LEN_256, buckets);
bii = bier_imp_add_or_lock(&bt_0_0_0_256, 1, &bbs_256);
@@ -797,7 +802,9 @@ bier_test_mpls_disp (void)
.bti_ecmp = BIER_ECMP_TABLE_ID_MAIN,
};
index_t bti;
+ int res;
+ res = 0;
bti = bier_table_add_or_lock(&bt_0_0_0_256, 1600);
/*