diff options
author | Neale Ranns <neale.ranns@cisco.com> | 2018-05-01 05:17:55 -0700 |
---|---|---|
committer | Ole Trøan <otroan@employees.org> | 2019-06-18 13:31:39 +0000 |
commit | 097fa66b986f06281f603767d321ab13ab6c88c3 (patch) | |
tree | ed052819615d08ee4bd0afbc34de7e64e4598105 /src/plugins/unittest/mfib_test.c | |
parent | 39baa32186fd3e4b20d9f58afbbfe7b8daebed62 (diff) |
fib: fib api updates
Enhance the route add/del APIs to take a set of paths rather than just one.
Most unicast routing protocols calcualte all the available paths in one
run of the algorithm so updating all the paths at once is beneficial for the client.
two knobs control the behaviour:
is_multipath - if set the the set of paths passed will be added to those
that already exist, otherwise the set will replace them.
is_add - add or remove the set
is_add=0, is_multipath=1 and an empty set, results in deleting the route.
It is also considerably faster to add multiple paths at once, than one at a time:
vat# ip_add_del_route 1.1.1.1/32 count 100000 multipath via 10.10.10.11
100000 routes in .572240 secs, 174751.80 routes/sec
vat# ip_add_del_route 1.1.1.1/32 count 100000 multipath via 10.10.10.12
100000 routes in .528383 secs, 189256.54 routes/sec
vat# ip_add_del_route 1.1.1.1/32 count 100000 multipath via 10.10.10.13
100000 routes in .757131 secs, 132077.52 routes/sec
vat# ip_add_del_route 1.1.1.1/32 count 100000 multipath via 10.10.10.14
100000 routes in .878317 secs, 113854.12 routes/sec
vat# ip_route_add_del 1.1.1.1/32 count 100000 multipath via 10.10.10.11 via 10.10.10.12 via 10.10.10.13 via 10.10.10.14
100000 routes in .900212 secs, 111084.93 routes/sec
Change-Id: I416b93f7684745099c1adb0b33edac58c9339c1a
Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
Signed-off-by: Ole Troan <ot@cisco.com>
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Diffstat (limited to 'src/plugins/unittest/mfib_test.c')
-rw-r--r-- | src/plugins/unittest/mfib_test.c | 227 |
1 files changed, 114 insertions, 113 deletions
diff --git a/src/plugins/unittest/mfib_test.c b/src/plugins/unittest/mfib_test.c index 0707a6f57c8..2497a299c50 100644 --- a/src/plugins/unittest/mfib_test.c +++ b/src/plugins/unittest/mfib_test.c @@ -233,7 +233,7 @@ mfib_test_entry (fib_node_index_t fei, MFIB_TEST_REP((eflags == mfe->mfe_flags), "%U has %U expect %U", - format_mfib_prefix, &pfx, + format_mfib_prefix, pfx, format_mfib_entry_flags, mfe->mfe_flags, format_mfib_entry_flags, eflags); @@ -241,7 +241,7 @@ mfib_test_entry (fib_node_index_t fei, { MFIB_TEST_REP((DPO_DROP == mfe->mfe_rep.dpoi_type), "%U links to %U", - format_mfib_prefix, &pfx, + format_mfib_prefix, pfx, format_dpo_id, &mfe->mfe_rep, 0); } else @@ -257,7 +257,7 @@ mfib_test_entry (fib_node_index_t fei, MFIB_TEST_REP((DPO_REPLICATE == tmp.dpoi_type), "%U links to %U", - format_mfib_prefix, &pfx, + format_mfib_prefix, pfx, format_dpo_type, tmp.dpoi_type); va_start(ap, n_buckets); @@ -288,11 +288,11 @@ mfib_test_entry_itf (fib_node_index_t fei, MFIB_TEST_REP((NULL != mfi), "%U has interface %d", - format_mfib_prefix, &pfx, sw_if_index); + format_mfib_prefix, pfx, sw_if_index); MFIB_TEST_REP((flags == mfi->mfi_flags), "%U interface %d has flags %U expect %U", - format_mfib_prefix, &pfx, sw_if_index, + format_mfib_prefix, pfx, sw_if_index, format_mfib_itf_flags, flags, format_mfib_itf_flags, mfi->mfi_flags); @@ -408,15 +408,15 @@ mfib_test_i (fib_protocol_t PROTO, .frp_addr = zero_addr, .frp_sw_if_index = tm->hw[0]->sw_if_index, .frp_fib_index = ~0, - .frp_weight = 0, + .frp_weight = 1, .frp_flags = 0, + .frp_mitf_flags = MFIB_ITF_FLAG_ACCEPT, }; mfib_table_entry_path_update(fib_index, pfx_no_forward, MFIB_SOURCE_API, - &path_via_if0, - MFIB_ITF_FLAG_ACCEPT); + &path_via_if0); mfei_no_f = mfib_table_lookup_exact_match(fib_index, pfx_no_forward); MFIB_TEST(!mfib_test_entry(mfei_no_f, @@ -424,41 +424,42 @@ mfib_test_i (fib_protocol_t PROTO, 0), "%U no replcaitions", format_mfib_prefix, pfx_no_forward); - MFIB_TEST_NS(!mfib_test_entry_itf(mfei_no_f, tm->hw[0]->sw_if_index, - MFIB_ITF_FLAG_ACCEPT)); + MFIB_TEST(!mfib_test_entry_itf(mfei_no_f, tm->hw[0]->sw_if_index, + MFIB_ITF_FLAG_ACCEPT), + "%U interface not accepting", + format_mfib_prefix, pfx_no_forward); fib_route_path_t path_via_if1 = { .frp_proto = fib_proto_to_dpo(PROTO), .frp_addr = zero_addr, .frp_sw_if_index = tm->hw[1]->sw_if_index, .frp_fib_index = ~0, - .frp_weight = 0, + .frp_weight = 1, .frp_flags = 0, + .frp_mitf_flags = MFIB_ITF_FLAG_FORWARD, }; fib_route_path_t path_via_if2 = { .frp_proto = fib_proto_to_dpo(PROTO), .frp_addr = zero_addr, .frp_sw_if_index = tm->hw[2]->sw_if_index, .frp_fib_index = ~0, - .frp_weight = 0, + .frp_weight = 1, .frp_flags = 0, + .frp_mitf_flags = MFIB_ITF_FLAG_FORWARD, }; fib_route_path_t path_via_if3 = { .frp_proto = fib_proto_to_dpo(PROTO), .frp_addr = zero_addr, .frp_sw_if_index = tm->hw[3]->sw_if_index, .frp_fib_index = ~0, - .frp_weight = 0, + .frp_weight = 1, .frp_flags = 0, + .frp_mitf_flags = (MFIB_ITF_FLAG_FORWARD | + MFIB_ITF_FLAG_NEGATE_SIGNAL), }; - fib_route_path_t path_for_us = { - .frp_proto = fib_proto_to_dpo(PROTO), - .frp_addr = zero_addr, - .frp_sw_if_index = 0xffffffff, - .frp_fib_index = ~0, - .frp_weight = 0, - .frp_flags = FIB_ROUTE_PATH_LOCAL, - }; + fib_route_path_t *two_paths = NULL; + vec_add1(two_paths, path_via_if2); + vec_add1(two_paths, path_via_if3); /* * An (S,G) with 1 accepting and 3 forwarding paths @@ -466,24 +467,15 @@ mfib_test_i (fib_protocol_t PROTO, mfib_table_entry_path_update(fib_index, pfx_s_g, MFIB_SOURCE_API, - &path_via_if0, - MFIB_ITF_FLAG_ACCEPT); - mfib_table_entry_path_update(fib_index, - pfx_s_g, - MFIB_SOURCE_API, - &path_via_if1, - MFIB_ITF_FLAG_FORWARD); - mfib_table_entry_path_update(fib_index, - pfx_s_g, - MFIB_SOURCE_API, - &path_via_if2, - MFIB_ITF_FLAG_FORWARD); + &path_via_if0); mfib_table_entry_path_update(fib_index, pfx_s_g, MFIB_SOURCE_API, - &path_via_if3, - (MFIB_ITF_FLAG_FORWARD | - MFIB_ITF_FLAG_NEGATE_SIGNAL)); + &path_via_if1); + mfib_table_entry_paths_update(fib_index, + pfx_s_g, + MFIB_SOURCE_API, + two_paths); mfei_s_g = mfib_table_lookup_exact_match(fib_index, pfx_s_g); @@ -515,13 +507,11 @@ mfib_test_i (fib_protocol_t PROTO, mfei_g_1 = mfib_table_entry_path_update(fib_index, pfx_star_g_1, MFIB_SOURCE_API, - &path_via_if0, - MFIB_ITF_FLAG_ACCEPT); + &path_via_if0); mfib_table_entry_path_update(fib_index, pfx_star_g_1, MFIB_SOURCE_API, - &path_via_if1, - MFIB_ITF_FLAG_FORWARD); + &path_via_if1); /* * test we find the *,G and S,G via LPM and exact matches @@ -583,16 +573,15 @@ mfib_test_i (fib_protocol_t PROTO, * A (*,G/m), which the same root G as the (*,G). * different paths. test our LPM. */ + path_via_if2.frp_mitf_flags = MFIB_ITF_FLAG_ACCEPT; mfei_g_m = mfib_table_entry_path_update(fib_index, pfx_star_g_slash_m, MFIB_SOURCE_API, - &path_via_if2, - MFIB_ITF_FLAG_ACCEPT); + &path_via_if2); mfib_table_entry_path_update(fib_index, pfx_star_g_slash_m, MFIB_SOURCE_API, - &path_via_if3, - MFIB_ITF_FLAG_FORWARD); + &path_via_if3); /* * test we find the (*,G/m), (*,G) and (S,G) via LPM and exact matches @@ -656,11 +645,20 @@ mfib_test_i (fib_protocol_t PROTO, /* * Add a for-us path */ + fib_route_path_t path_for_us = { + .frp_proto = fib_proto_to_dpo(PROTO), + .frp_addr = zero_addr, + .frp_sw_if_index = 0xffffffff, + .frp_fib_index = ~0, + .frp_weight = 1, + .frp_flags = FIB_ROUTE_PATH_LOCAL, + .frp_mitf_flags = MFIB_ITF_FLAG_FORWARD, + }; + mfei = mfib_table_entry_path_update(fib_index, pfx_s_g, MFIB_SOURCE_API, - &path_for_us, - MFIB_ITF_FLAG_FORWARD); + &path_for_us); MFIB_TEST(!mfib_test_entry(mfei, MFIB_ENTRY_FLAG_NONE, @@ -693,11 +691,11 @@ mfib_test_i (fib_protocol_t PROTO, * update an existing forwarding path to be only accepting * - expect it to be removed from the replication set. */ + path_via_if3.frp_mitf_flags = MFIB_ITF_FLAG_ACCEPT; mfib_table_entry_path_update(fib_index, pfx_s_g, MFIB_SOURCE_API, - &path_via_if3, - MFIB_ITF_FLAG_ACCEPT); + &path_via_if3); MFIB_TEST(!mfib_test_entry(mfei, MFIB_ENTRY_FLAG_NONE, @@ -718,13 +716,13 @@ mfib_test_i (fib_protocol_t PROTO, * Make the path forwarding again * - expect it to be added back to the replication set */ + path_via_if3.frp_mitf_flags = (MFIB_ITF_FLAG_FORWARD | + MFIB_ITF_FLAG_ACCEPT | + MFIB_ITF_FLAG_NEGATE_SIGNAL); mfib_table_entry_path_update(fib_index, pfx_s_g, MFIB_SOURCE_API, - &path_via_if3, - (MFIB_ITF_FLAG_FORWARD | - MFIB_ITF_FLAG_ACCEPT | - MFIB_ITF_FLAG_NEGATE_SIGNAL)); + &path_via_if3); mfei = mfib_table_lookup_exact_match(fib_index, pfx_s_g); @@ -806,32 +804,37 @@ mfib_test_i (fib_protocol_t PROTO, MFIB_TEST_NS(!mfib_test_entry_no_itf(mfei, tm->hw[3]->sw_if_index)); /* - * remove the accpeting only interface + * remove */ - mfib_table_entry_path_remove(fib_index, - pfx_s_g, - MFIB_SOURCE_API, - &path_via_if0); - - MFIB_TEST(!mfib_test_entry(mfei, - MFIB_ENTRY_FLAG_SIGNAL, - 1, - DPO_ADJACENCY_MCAST, ai_2), - "%U replicate OK", - format_mfib_prefix, pfx_s_g); - MFIB_TEST_NS(!mfib_test_entry_itf(mfei, tm->hw[2]->sw_if_index, - MFIB_ITF_FLAG_FORWARD)); - MFIB_TEST_NS(!mfib_test_entry_no_itf(mfei, tm->hw[0]->sw_if_index)); - MFIB_TEST_NS(!mfib_test_entry_no_itf(mfei, tm->hw[1]->sw_if_index)); - MFIB_TEST_NS(!mfib_test_entry_no_itf(mfei, tm->hw[3]->sw_if_index)); + /* mfib_table_entry_path_remove(fib_index, */ + /* pfx_s_g, */ + /* MFIB_SOURCE_API, */ + /* &path_via_if0); */ + + /* MFIB_TEST(!mfib_test_entry(mfei, */ + /* MFIB_ENTRY_FLAG_SIGNAL, */ + /* 1, */ + /* DPO_ADJACENCY_MCAST, ai_2), */ + /* "%U replicate OK", */ + /* format_mfib_prefix, pfx_s_g); */ + /* MFIB_TEST_NS(!mfib_test_entry_itf(mfei, tm->hw[2]->sw_if_index, */ + /* MFIB_ITF_FLAG_FORWARD)); */ + /* MFIB_TEST_NS(!mfib_test_entry_no_itf(mfei, tm->hw[0]->sw_if_index)); */ + /* MFIB_TEST_NS(!mfib_test_entry_no_itf(mfei, tm->hw[1]->sw_if_index)); */ + /* MFIB_TEST_NS(!mfib_test_entry_no_itf(mfei, tm->hw[3]->sw_if_index)); */ /* - * remove the last path, the entry still has flags so it remains + * remove the last path and the accpeting only interface, + * the entry still has flags so it remains */ - mfib_table_entry_path_remove(fib_index, - pfx_s_g, - MFIB_SOURCE_API, - &path_via_if2); + vec_reset_length(two_paths); + vec_add1(two_paths, path_via_if0); + vec_add1(two_paths, path_via_if2); + + mfib_table_entry_paths_remove(fib_index, + pfx_s_g, + MFIB_SOURCE_API, + two_paths); MFIB_TEST(!mfib_test_entry(mfei, MFIB_ENTRY_FLAG_SIGNAL, @@ -858,12 +861,12 @@ mfib_test_i (fib_protocol_t PROTO, /* * An entry with a NS interface */ + path_via_if0.frp_mitf_flags = (MFIB_ITF_FLAG_ACCEPT | + MFIB_ITF_FLAG_NEGATE_SIGNAL); mfei_g_2 = mfib_table_entry_path_update(fib_index, pfx_star_g_2, MFIB_SOURCE_API, - &path_via_if0, - (MFIB_ITF_FLAG_ACCEPT | - MFIB_ITF_FLAG_NEGATE_SIGNAL)); + &path_via_if0); MFIB_TEST(!mfib_test_entry(mfei_g_2, MFIB_ENTRY_FLAG_NONE, 0), @@ -886,12 +889,12 @@ mfib_test_i (fib_protocol_t PROTO, /* * An entry with a NS interface */ + path_via_if0.frp_mitf_flags = (MFIB_ITF_FLAG_ACCEPT | + MFIB_ITF_FLAG_NEGATE_SIGNAL); mfei_g_3 = mfib_table_entry_path_update(fib_index, pfx_star_g_3, MFIB_SOURCE_API, - &path_via_if0, - (MFIB_ITF_FLAG_ACCEPT | - MFIB_ITF_NEGATE_SIGNAL)); + &path_via_if0); MFIB_TEST(!mfib_test_entry(mfei_g_3, MFIB_ENTRY_FLAG_NONE, 0), @@ -1056,28 +1059,28 @@ mfib_test_i (fib_protocol_t PROTO, .frp_addr = *addr_nbr1, .frp_sw_if_index = tm->hw[0]->sw_if_index, .frp_fib_index = ~0, - .frp_weight = 0, + .frp_weight = 1, .frp_flags = 0, + .frp_mitf_flags = MFIB_ITF_FLAG_FORWARD, }; fib_route_path_t path_via_nbr2 = { .frp_proto = fib_proto_to_dpo(PROTO), .frp_addr = *addr_nbr2, .frp_sw_if_index = tm->hw[0]->sw_if_index, .frp_fib_index = ~0, - .frp_weight = 0, + .frp_weight = 1, .frp_flags = 0, + .frp_mitf_flags = MFIB_ITF_FLAG_FORWARD, }; mfei_g_1 = mfib_table_entry_path_update(fib_index, pfx_star_g_1, MFIB_SOURCE_API, - &path_via_nbr1, - (MFIB_ITF_FLAG_FORWARD)); + &path_via_nbr1); mfei_g_1 = mfib_table_entry_path_update(fib_index, pfx_star_g_1, MFIB_SOURCE_API, - &path_via_nbr2, - (MFIB_ITF_FLAG_FORWARD)); + &path_via_nbr2); MFIB_TEST(!mfib_test_entry(mfei_g_1, MFIB_ENTRY_FLAG_NONE, 2, @@ -1230,6 +1233,7 @@ mfib_test_i (fib_protocol_t PROTO, .frp_fib_index = 0, .frp_weight = 1, .frp_flags = FIB_ROUTE_PATH_FLAG_NONE, + .frp_mitf_flags = MFIB_ITF_FLAG_FORWARD, }; dpo_id_t mldp_dpo = DPO_INVALID; @@ -1240,8 +1244,7 @@ mfib_test_i (fib_protocol_t PROTO, mfei = mfib_table_entry_path_update(fib_index, pfx_s_g, MFIB_SOURCE_API, - &path_via_mldp, - MFIB_ITF_FLAG_FORWARD); + &path_via_mldp); MFIB_TEST(!mfib_test_entry(mfei, MFIB_ENTRY_FLAG_NONE, @@ -1256,8 +1259,7 @@ mfib_test_i (fib_protocol_t PROTO, mfei = mfib_table_entry_path_update(fib_index, pfx_s_g, MFIB_SOURCE_API, - &path_for_us, - MFIB_ITF_FLAG_FORWARD); + &path_for_us); MFIB_TEST(!mfib_test_entry(mfei, MFIB_ENTRY_FLAG_NONE, 2, @@ -1321,6 +1323,7 @@ mfib_test_i (fib_protocol_t PROTO, MFIB_TEST(n_itfs == pool_elts(mfib_itf_pool), " No more Interfaces %d!=%d", n_itfs, pool_elts(mfib_itf_pool)); + vec_free(two_paths); return (res); } @@ -1531,32 +1534,36 @@ mfib_test_rr_i (fib_protocol_t FPROTO, .frp_addr = zero_addr, .frp_sw_if_index = tm->hw[0]->sw_if_index, .frp_fib_index = ~0, - .frp_weight = 0, + .frp_weight = 1, .frp_flags = 0, + .frp_mitf_flags = MFIB_ITF_FLAG_ACCEPT, }; fib_route_path_t path_via_if1 = { .frp_proto = DPROTO, .frp_addr = zero_addr, .frp_sw_if_index = tm->hw[1]->sw_if_index, .frp_fib_index = ~0, - .frp_weight = 0, + .frp_weight = 1, .frp_flags = 0, + .frp_mitf_flags = MFIB_ITF_FLAG_FORWARD, }; fib_route_path_t path_via_if2 = { .frp_proto = DPROTO, .frp_addr = zero_addr, .frp_sw_if_index = tm->hw[2]->sw_if_index, .frp_fib_index = ~0, - .frp_weight = 0, + .frp_weight = 1, .frp_flags = 0, + .frp_mitf_flags = MFIB_ITF_FLAG_FORWARD, }; fib_route_path_t path_for_us = { .frp_proto = DPROTO, .frp_addr = zero_addr, .frp_sw_if_index = 0xffffffff, .frp_fib_index = ~0, - .frp_weight = 0, + .frp_weight = 1, .frp_flags = FIB_ROUTE_PATH_LOCAL, + .frp_mitf_flags = MFIB_ITF_FLAG_FORWARD, }; /* @@ -1581,8 +1588,7 @@ mfib_test_rr_i (fib_protocol_t FPROTO, mfib_table_entry_path_update(fib_index, pfx_cover, MFIB_SOURCE_API, - &path_via_if1, - MFIB_ITF_FLAG_FORWARD); + &path_via_if1); mfei_cover = mfib_table_lookup_exact_match(fib_index, pfx_cover); @@ -1609,8 +1615,7 @@ mfib_test_rr_i (fib_protocol_t FPROTO, mfib_table_entry_path_update(fib_index, pfx_cover, MFIB_SOURCE_API, - &path_via_if2, - MFIB_ITF_FLAG_FORWARD); + &path_via_if2); /* * expect the /32 and /28 to be via both boths @@ -1667,8 +1672,7 @@ mfib_test_rr_i (fib_protocol_t FPROTO, mfib_table_entry_path_update(fib_index, pfx_cover, MFIB_SOURCE_API, - &path_via_if0, - MFIB_ITF_FLAG_ACCEPT); + &path_via_if0); /* * expect the /32 and /28 to be via both boths @@ -1706,8 +1710,7 @@ mfib_test_rr_i (fib_protocol_t FPROTO, mfib_table_entry_path_update(fib_index, pfx_cover, MFIB_SOURCE_API, - &path_for_us, - MFIB_ITF_FLAG_FORWARD); + &path_for_us); /* * expect the /32 and /28 to be via all three paths @@ -1775,11 +1778,10 @@ mfib_test_rr_i (fib_protocol_t FPROTO, /* * source the /32 with its own path */ - mfib_table_entry_path_update(fib_index, - pfx_host1, - MFIB_SOURCE_API, - &path_via_if2, - MFIB_ITF_FLAG_FORWARD); + mfei_host1 = mfib_table_entry_path_update(fib_index, + pfx_host1, + MFIB_SOURCE_API, + &path_via_if2); MFIB_TEST(!mfib_test_entry(mfei_host1, MFIB_ENTRY_FLAG_NONE, 1, @@ -1809,17 +1811,16 @@ mfib_test_rr_i (fib_protocol_t FPROTO, /* * add the RR back then remove the path and RR */ - mfib_table_entry_path_update(fib_index, - pfx_host1, - MFIB_SOURCE_API, - &path_via_if2, - MFIB_ITF_FLAG_FORWARD); + mfei_host1 = mfib_table_entry_path_update(fib_index, + pfx_host1, + MFIB_SOURCE_API, + &path_via_if2); MFIB_TEST(!mfib_test_entry(mfei_host1, MFIB_ENTRY_FLAG_NONE, 1, DPO_ADJACENCY_MCAST, ai_2), "%U replicate OK", - format_mfib_prefix, pfx_cover); + format_mfib_prefix, pfx_host1); mfib_table_entry_delete(fib_index, pfx_host1, MFIB_SOURCE_API); |