aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/fib/fib_table.c
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/fib/fib_table.c
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/fib/fib_table.c')
-rw-r--r--src/vnet/fib/fib_table.c51
1 files changed, 31 insertions, 20 deletions
diff --git a/src/vnet/fib/fib_table.c b/src/vnet/fib/fib_table.c
index 56c8f030fda..3778fa9a944 100644
--- a/src/vnet/fib/fib_table.c
+++ b/src/vnet/fib/fib_table.c
@@ -481,7 +481,7 @@ fib_table_entry_special_remove (u32 fib_index,
*/
static void
fib_table_route_path_fixup (const fib_prefix_t *prefix,
- fib_entry_flag_t eflags,
+ fib_entry_flag_t *eflags,
fib_route_path_t *path)
{
/*
@@ -496,7 +496,8 @@ fib_table_route_path_fixup (const fib_prefix_t *prefix,
/* Prefix recurses via itse;f */
path->frp_flags |= FIB_ROUTE_PATH_DROP;
}
- if (fib_prefix_is_host(prefix) &&
+ if (!(path->frp_flags & FIB_ROUTE_PATH_LOCAL) &&
+ fib_prefix_is_host(prefix) &&
ip46_address_is_zero(&path->frp_addr) &&
path->frp_sw_if_index != ~0 &&
path->frp_proto != DPO_PROTO_ETHERNET)
@@ -504,18 +505,27 @@ fib_table_route_path_fixup (const fib_prefix_t *prefix,
path->frp_addr = prefix->fp_addr;
path->frp_flags |= FIB_ROUTE_PATH_ATTACHED;
}
- if (eflags & FIB_ENTRY_FLAG_DROP)
+ if (*eflags & FIB_ENTRY_FLAG_DROP)
{
path->frp_flags |= FIB_ROUTE_PATH_DROP;
}
- if (eflags & FIB_ENTRY_FLAG_LOCAL)
+ if (*eflags & FIB_ENTRY_FLAG_LOCAL)
{
path->frp_flags |= FIB_ROUTE_PATH_LOCAL;
}
- if (eflags & FIB_ENTRY_FLAG_EXCLUSIVE)
+ if (*eflags & FIB_ENTRY_FLAG_EXCLUSIVE)
{
path->frp_flags |= FIB_ROUTE_PATH_EXCLUSIVE;
}
+ if (path->frp_flags & FIB_ROUTE_PATH_LOCAL)
+ {
+ *eflags |= FIB_ENTRY_FLAG_LOCAL;
+
+ if (path->frp_sw_if_index != ~0)
+ {
+ *eflags |= FIB_ENTRY_FLAG_CONNECTED;
+ }
+ }
}
fib_node_index_t
@@ -538,6 +548,7 @@ fib_table_entry_path_add (u32 fib_index,
.frp_fib_index = next_hop_fib_index,
.frp_weight = next_hop_weight,
.frp_flags = path_flags,
+ .frp_rpf_id = INDEX_INVALID,
.frp_label_stack = next_hop_labels,
};
fib_node_index_t fib_entry_index;
@@ -557,7 +568,7 @@ fib_table_entry_path_add2 (u32 fib_index,
const fib_prefix_t *prefix,
fib_source_t source,
fib_entry_flag_t flags,
- fib_route_path_t *rpath)
+ fib_route_path_t *rpaths)
{
fib_node_index_t fib_entry_index;
fib_table_t *fib_table;
@@ -566,16 +577,16 @@ fib_table_entry_path_add2 (u32 fib_index,
fib_table = fib_table_get(fib_index, prefix->fp_proto);
fib_entry_index = fib_table_lookup_exact_match_i(fib_table, prefix);
- for (ii = 0; ii < vec_len(rpath); ii++)
+ for (ii = 0; ii < vec_len(rpaths); ii++)
{
- fib_table_route_path_fixup(prefix, flags, &rpath[ii]);
+ fib_table_route_path_fixup(prefix, &flags, &rpaths[ii]);
}
if (FIB_NODE_INDEX_INVALID == fib_entry_index)
{
fib_entry_index = fib_entry_create(fib_index, prefix,
source, flags,
- rpath);
+ rpaths);
fib_table_entry_insert(fib_table, prefix, fib_entry_index);
fib_table->ft_src_route_counts[source]++;
@@ -585,7 +596,7 @@ fib_table_entry_path_add2 (u32 fib_index,
int was_sourced;
was_sourced = fib_entry_is_sourced(fib_entry_index, source);
- fib_entry_path_add(fib_entry_index, source, flags, rpath);;
+ fib_entry_path_add(fib_entry_index, source, flags, rpaths);;
if (was_sourced != fib_entry_is_sourced(fib_entry_index, source))
{
@@ -600,7 +611,7 @@ void
fib_table_entry_path_remove2 (u32 fib_index,
const fib_prefix_t *prefix,
fib_source_t source,
- fib_route_path_t *rpath)
+ fib_route_path_t *rpaths)
{
/*
* 1 is it present
@@ -609,8 +620,8 @@ fib_table_entry_path_remove2 (u32 fib_index,
* no => cover walk
*/
fib_node_index_t fib_entry_index;
+ fib_route_path_t *rpath;
fib_table_t *fib_table;
- u32 ii;
fib_table = fib_table_get(fib_index, prefix->fp_proto);
fib_entry_index = fib_table_lookup_exact_match_i(fib_table, prefix);
@@ -640,16 +651,16 @@ fib_table_entry_path_remove2 (u32 fib_index,
*/
fib_entry_lock(fib_entry_index);
- for (ii = 0; ii < vec_len(rpath); ii++)
+ vec_foreach(rpath, rpaths)
{
- fib_table_route_path_fixup(
- prefix,
- fib_entry_get_flags_for_source(fib_entry_index,
- source),
- &rpath[ii]);
+ fib_entry_flag_t eflags;
+
+ eflags = fib_entry_get_flags_for_source(fib_entry_index,
+ source);
+ fib_table_route_path_fixup(prefix, &eflags, rpath);
}
- src_flag = fib_entry_path_remove(fib_entry_index, source, rpath);
+ src_flag = fib_entry_path_remove(fib_entry_index, source, rpaths);
if (!(FIB_ENTRY_SRC_FLAG_ADDED & src_flag))
{
@@ -735,7 +746,7 @@ fib_table_entry_update (u32 fib_index,
for (ii = 0; ii < vec_len(paths); ii++)
{
- fib_table_route_path_fixup(prefix, flags, &paths[ii]);
+ fib_table_route_path_fixup(prefix, &flags, &paths[ii]);
}
/*
* sort the paths provided by the control plane. this means