summaryrefslogtreecommitdiffstats
path: root/src/vnet/bier
diff options
context:
space:
mode:
authorNeale Ranns <neale.ranns@cisco.com>2018-05-01 05:17:55 -0700
committerOle Trøan <otroan@employees.org>2019-06-18 13:31:39 +0000
commit097fa66b986f06281f603767d321ab13ab6c88c3 (patch)
treeed052819615d08ee4bd0afbc34de7e64e4598105 /src/vnet/bier
parent39baa32186fd3e4b20d9f58afbbfe7b8daebed62 (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')
-rw-r--r--src/vnet/bier/bier.api21
-rw-r--r--src/vnet/bier/bier_api.c64
-rw-r--r--src/vnet/bier/bier_entry.c2
-rw-r--r--src/vnet/bier/bier_fmask.c12
-rw-r--r--src/vnet/bier/bier_fmask.h2
-rw-r--r--src/vnet/bier/bier_table.c9
6 files changed, 63 insertions, 47 deletions
diff --git a/src/vnet/bier/bier.api b/src/vnet/bier/bier.api
index b5ac8cabd39..0cc56cab50a 100644
--- a/src/vnet/bier/bier.api
+++ b/src/vnet/bier/bier.api
@@ -1,3 +1,4 @@
+/* Hey Emacs use -*- mode: C -*- */
/*
* Copyright (c) 2016 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,7 +19,7 @@
This file defines vpp BIER control-plane API messages which are generally
called through a shared memory interface.
*/
-option version = "1.1.0";
+option version = "1.2.0";
import "vnet/fib/fib_types.api";
/** \brief BIER Table Identifier
@@ -77,16 +78,21 @@ define bier_table_details
@param br_n_paths - The number of paths
@param br_paths - The array of paths
*/
+typedef bier_route
+{
+ u32 br_bp;
+ vl_api_bier_table_id_t br_tbl_id;
+ u8 br_n_paths;
+ vl_api_fib_path_t br_paths[br_n_paths];
+};
+
autoreply define bier_route_add_del
{
u32 client_index;
u32 context;
- u32 br_bp;
u8 br_is_add;
u8 br_is_replace;
- vl_api_bier_table_id_t br_tbl_id;
- u8 br_n_paths;
- vl_api_fib_path_t br_paths[br_n_paths];
+ vl_api_bier_route_t br_route;
};
define bier_route_dump
@@ -99,10 +105,7 @@ define bier_route_dump
define bier_route_details
{
u32 context;
- u16 br_bp;
- vl_api_bier_table_id_t br_tbl_id;
- u32 br_n_paths;
- vl_api_fib_path_t br_paths[br_n_paths];
+ vl_api_bier_route_t br_route;
};
/** \brief BIER Imposition Add
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);
}
}
}
diff --git a/src/vnet/bier/bier_entry.c b/src/vnet/bier/bier_entry.c
index 77d96b80782..e8bf722d88f 100644
--- a/src/vnet/bier/bier_entry.c
+++ b/src/vnet/bier/bier_entry.c
@@ -147,7 +147,7 @@ bier_entry_delete (index_t bei)
be = bier_entry_get(bei);
/*
- * if we still ahve a path-list, unlink from it
+ * if we still have a path-list, unlink from it
*/
if (FIB_NODE_INDEX_INVALID != be->be_path_list)
{
diff --git a/src/vnet/bier/bier_fmask.c b/src/vnet/bier/bier_fmask.c
index b6169d3c4bb..a58a77ff281 100644
--- a/src/vnet/bier/bier_fmask.c
+++ b/src/vnet/bier/bier_fmask.c
@@ -404,7 +404,7 @@ bier_fmask_get_stats (index_t bfmi, u64 * packets, u64 * bytes)
void
bier_fmask_encode (index_t bfmi,
bier_table_id_t *btid,
- fib_route_path_encode_t *rpath)
+ fib_route_path_t *rpath)
{
bier_fmask_t *bfm;
@@ -413,17 +413,17 @@ bier_fmask_encode (index_t bfmi,
clib_memset(rpath, 0, sizeof(*rpath));
- rpath->rpath.frp_sw_if_index = ~0;
+ rpath->frp_sw_if_index = ~0;
switch (bfm->bfm_id->bfmi_nh_type)
{
case BIER_NH_UDP:
- rpath->rpath.frp_flags = FIB_ROUTE_PATH_UDP_ENCAP;
- rpath->rpath.frp_udp_encap_id = bfm->bfm_id->bfmi_id;
+ rpath->frp_flags = FIB_ROUTE_PATH_UDP_ENCAP;
+ rpath->frp_udp_encap_id = bfm->bfm_id->bfmi_id;
break;
case BIER_NH_IP:
- memcpy(&rpath->rpath.frp_addr, &bfm->bfm_id->bfmi_nh,
- sizeof(rpath->rpath.frp_addr));
+ memcpy(&rpath->frp_addr, &bfm->bfm_id->bfmi_nh,
+ sizeof(rpath->frp_addr));
break;
}
}
diff --git a/src/vnet/bier/bier_fmask.h b/src/vnet/bier/bier_fmask.h
index e522b0350e7..87845bb031b 100644
--- a/src/vnet/bier/bier_fmask.h
+++ b/src/vnet/bier/bier_fmask.h
@@ -166,7 +166,7 @@ extern void bier_fmask_child_remove (fib_node_index_t fib_entry_index,
extern void bier_fmask_get_stats (index_t bfmi, u64 * packets, u64 * bytes);
extern void bier_fmask_encode (index_t bfmi,
bier_table_id_t *btid,
- fib_route_path_encode_t *rpath);
+ fib_route_path_t *rpath);
/*
* provided for fast data-path access
diff --git a/src/vnet/bier/bier_table.c b/src/vnet/bier/bier_table.c
index a9f8a6d338f..0e8cc1e88b4 100644
--- a/src/vnet/bier/bier_table.c
+++ b/src/vnet/bier/bier_table.c
@@ -779,9 +779,12 @@ bier_table_ecmp_walk (index_t bti,
bt = bier_table_get(bti);
- fib_path_list_walk(bt->bt_pl,
- bier_table_ecmp_walk_path_list,
- &ewc);
+ if (FIB_NODE_INDEX_INVALID != bt->bt_pl)
+ {
+ fib_path_list_walk(bt->bt_pl,
+ bier_table_ecmp_walk_path_list,
+ &ewc);
+ }
}
void