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/vnet/bier/bier_api.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/vnet/bier/bier_api.c')
-rw-r--r-- | src/vnet/bier/bier_api.c | 64 |
1 files changed, 37 insertions, 27 deletions
diff --git a/src/vnet/bier/bier_api.c b/src/vnet/bier/bier_api.c index d8248b1b2bd..66f6b422810 100644 --- a/src/vnet/bier/bier_api.c +++ b/src/vnet/bier/bier_api.c @@ -169,10 +169,10 @@ vl_api_bier_route_add_del_t_handler (vl_api_bier_route_add_del_t * mp) vnm = vnet_get_main (); vnm->api_errno = 0; - bp = ntohl(mp->br_bp); + bp = ntohl(mp->br_route.br_bp); brpaths = NULL; - if (mp->br_tbl_id.bt_hdr_len_id >= BIER_HDR_LEN_2048) + if (mp->br_route.br_tbl_id.bt_hdr_len_id >= BIER_HDR_LEN_2048) { rv = VNET_API_ERROR_BIER_BSL_UNSUP; goto done; @@ -184,19 +184,19 @@ vl_api_bier_route_add_del_t_handler (vl_api_bier_route_add_del_t * mp) } bier_table_id_t bti = { - .bti_set = mp->br_tbl_id.bt_set, - .bti_sub_domain = mp->br_tbl_id.bt_sub_domain, - .bti_hdr_len = mp->br_tbl_id.bt_hdr_len_id, + .bti_set = mp->br_route.br_tbl_id.bt_set, + .bti_sub_domain = mp->br_route.br_tbl_id.bt_sub_domain, + .bti_hdr_len = mp->br_route.br_tbl_id.bt_hdr_len_id, .bti_type = BIER_TABLE_MPLS_SPF, .bti_ecmp = BIER_ECMP_TABLE_ID_MAIN, }; - vec_validate(brpaths, mp->br_n_paths - 1); + vec_validate(brpaths, mp->br_route.br_n_paths - 1); vec_foreach_index(ii, brpaths) { brpath = &brpaths[ii]; - rv = fib_path_api_parse(&mp->br_paths[ii], brpath); + rv = fib_api_path_decode(&mp->br_route.br_paths[ii], brpath); if (0 != rv) { @@ -242,9 +242,12 @@ send_bier_route_details (const bier_table_t *bt, const bier_entry_t *be, void *args) { - fib_route_path_encode_t *api_rpaths = NULL, *api_rpath; bier_route_details_walk_t *ctx = args; vl_api_bier_route_details_t *mp; + fib_path_encode_ctx_t path_ctx = { + .rpaths = NULL, + }; + fib_route_path_t *rpath; vl_api_fib_path_t *fp; u32 n_paths, m_size; @@ -258,24 +261,25 @@ send_bier_route_details (const bier_table_t *bt, mp->_vl_msg_id = ntohs(VL_API_BIER_ROUTE_DETAILS); mp->context = ctx->context; - mp->br_tbl_id.bt_set = bt->bt_id.bti_set; - mp->br_tbl_id.bt_sub_domain = bt->bt_id.bti_sub_domain; - mp->br_tbl_id.bt_hdr_len_id = bt->bt_id.bti_hdr_len; - mp->br_bp = htons(be->be_bp); - mp->br_n_paths = htonl(n_paths); + mp->br_route.br_tbl_id.bt_set = bt->bt_id.bti_set; + mp->br_route.br_tbl_id.bt_sub_domain = bt->bt_id.bti_sub_domain; + mp->br_route.br_tbl_id.bt_hdr_len_id = bt->bt_id.bti_hdr_len; + mp->br_route.br_bp = htonl(be->be_bp); + mp->br_route.br_n_paths = htonl(n_paths); fib_path_list_walk_w_ext(be->be_path_list, NULL, fib_path_encode, - &api_rpaths); + &path_ctx); - fp = mp->br_paths; - vec_foreach (api_rpath, api_rpaths) + fp = mp->br_route.br_paths; + vec_foreach (rpath, path_ctx.rpaths) { - fib_api_path_encode(api_rpath, fp); + fib_api_path_encode(rpath, fp); fp++; } + vec_free(path_ctx.rpaths); vl_api_send_msg (ctx->reg, (u8 *) mp); } @@ -506,16 +510,16 @@ vl_api_bier_disp_entry_add_del_t_handler (vl_api_bier_disp_entry_add_del_t * mp) brp->frp_rpf_id = ntohl(mp->bde_paths[ii].rpf_id); } - if (0 == mp->bde_paths[ii].afi) + if (FIB_API_PATH_NH_PROTO_IP4 == mp->bde_paths[ii].proto) { - clib_memcpy_fast (&brp->frp_addr.ip4, - mp->bde_paths[ii].next_hop, + clib_memcpy (&brp->frp_addr.ip4, + &mp->bde_paths[ii].nh.address.ip4, sizeof (brp->frp_addr.ip4)); } - else + else if (FIB_API_PATH_NH_PROTO_IP6 == mp->bde_paths[ii].proto) { - clib_memcpy_fast (&brp->frp_addr.ip6, - mp->bde_paths[ii].next_hop, + clib_memcpy (&brp->frp_addr.ip6, + &mp->bde_paths[ii].nh.address.ip6, sizeof (brp->frp_addr.ip6)); } if (ip46_address_is_zero(&brp->frp_addr)) @@ -601,7 +605,6 @@ send_bier_disp_entry_details (const bier_disp_table_t *bdt, u16 bp, void *args) { - fib_route_path_encode_t *api_rpaths = NULL, *api_rpath; bier_disp_entry_details_walk_t *ctx = args; vl_api_bier_disp_entry_details_t *mp; bier_hdr_proto_id_t pproto; @@ -611,8 +614,14 @@ send_bier_disp_entry_details (const bier_disp_table_t *bdt, FOR_EACH_BIER_HDR_PROTO(pproto) { fib_node_index_t pl = bde->bde_pl[pproto]; + if (INDEX_INVALID != pl) { + fib_path_encode_ctx_t path_ctx = { + .rpaths = NULL, + }; + fib_route_path_t *rpath; + n_paths = fib_path_list_get_n_paths(pl); m_size = sizeof(*mp) + (n_paths * sizeof(vl_api_fib_path_t)); mp = vl_msg_api_alloc(m_size); @@ -631,16 +640,17 @@ send_bier_disp_entry_details (const bier_disp_table_t *bdt, fib_path_list_walk_w_ext(pl, NULL, fib_path_encode, - &api_rpaths); + &path_ctx); fp = mp->bde_paths; - vec_foreach (api_rpath, api_rpaths) + vec_foreach (rpath, path_ctx.rpaths) { - fib_api_path_encode(api_rpath, fp); + fib_api_path_encode(rpath, fp); fp++; } vl_api_send_msg (ctx->reg, (u8 *) mp); + vec_free(path_ctx.rpaths); } } } |