summaryrefslogtreecommitdiffstats
path: root/vnet/vnet/fib/fib_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'vnet/vnet/fib/fib_test.c')
-rw-r--r--vnet/vnet/fib/fib_test.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/vnet/vnet/fib/fib_test.c b/vnet/vnet/fib/fib_test.c
index 3dc9c1d7267..c9a937ba559 100644
--- a/vnet/vnet/fib/fib_test.c
+++ b/vnet/vnet/fib/fib_test.c
@@ -4802,11 +4802,16 @@ fib_test_validate_entry (fib_node_index_t fei,
{
const load_balance_t *lb;
dpo_id_t dpo = DPO_NULL;
+ fib_prefix_t pfx;
+ index_t fw_lbi;
+ u32 fib_index;
va_list ap;
int res;
va_start(ap, n_buckets);
+ fib_entry_get_prefix(fei, &pfx);
+ fib_index = fib_entry_get_fib_index(fei);
fib_entry_contribute_forwarding(fei, fct, &dpo);
FIB_TEST_LB((DPO_LOAD_BALANCE == dpo.dpoi_type),
@@ -4816,6 +4821,37 @@ fib_test_validate_entry (fib_node_index_t fei,
res = fib_test_validate_lb_v(lb, n_buckets, ap);
+ /*
+ * ensure that the LB contributed by the entry is the
+ * same as the LB in the forwarding tables
+ */
+ switch (pfx.fp_proto)
+ {
+ case FIB_PROTOCOL_IP4:
+ fw_lbi = ip4_fib_forwarding_lookup(fib_index, &pfx.fp_addr.ip4);
+ break;
+ case FIB_PROTOCOL_IP6:
+ fw_lbi = ip6_fib_table_fwding_lookup(&ip6_main, fib_index, &pfx.fp_addr.ip6);
+ break;
+ case FIB_PROTOCOL_MPLS:
+ {
+ mpls_unicast_header_t hdr;
+
+ vnet_mpls_uc_set_label(&hdr.label_exp_s_ttl, pfx.fp_label);
+ vnet_mpls_uc_set_s(&hdr.label_exp_s_ttl, pfx.fp_eos);
+ hdr.label_exp_s_ttl = clib_host_to_net_u32(hdr.label_exp_s_ttl);
+
+ fw_lbi = mpls_fib_table_forwarding_lookup(fib_index, &hdr);
+ break;
+ }
+ default:
+ fw_lbi = 0;
+ }
+ FIB_TEST_LB((fw_lbi == dpo.dpoi_index),
+ "Contributed LB = FW LB: %U\n %U",
+ format_load_balance, fw_lbi, 0,
+ format_load_balance, dpo.dpoi_index, 0);
+
dpo_reset(&dpo);
va_end(ap);