aboutsummaryrefslogtreecommitdiffstats
path: root/vnet/vnet/ip/ip4_forward.c
diff options
context:
space:
mode:
authorPierre Pfister <ppfister@cisco.com>2016-05-10 17:11:22 +0100
committerDave Barach <openvpp@barachs.net>2016-05-16 12:07:04 +0000
commit530bd8e1e68973c0b0f67e60c5520d32bb2628ad (patch)
treee71bf1b2cdc4c3e84db100b9fde086a5f57e4337 /vnet/vnet/ip/ip4_forward.c
parentaa761e128158e788f4046e24039e9ae0ee425dbb (diff)
VPP-69: Create fib or bridge domain with arbitrary ID
It appeared to me that it might be usefull to allow users to create fibs or bridge domains without a complete knowledge of the current used IDs. These changes define fib and bridge domain constructors when the provided ID is ~0. In such a case, an unused ID is used to create a new fib or bridge domain. Change-Id: Iaba69a023296e6d17bdde45980f9db84832a3995 Signed-off-by: Pierre Pfister <ppfister@cisco.com>
Diffstat (limited to 'vnet/vnet/ip/ip4_forward.c')
-rw-r--r--vnet/vnet/ip/ip4_forward.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/vnet/vnet/ip/ip4_forward.c b/vnet/vnet/ip/ip4_forward.c
index a50664cc662..a84b83bc225 100644
--- a/vnet/vnet/ip/ip4_forward.c
+++ b/vnet/vnet/ip/ip4_forward.c
@@ -103,6 +103,14 @@ find_ip4_fib_by_table_index_or_id (ip4_main_t * im,
fib_index = table_index_or_id;
if (! (flags & IP4_ROUTE_FLAG_FIB_INDEX))
{
+ if (table_index_or_id == ~0) {
+ table_index_or_id = 0;
+ while ((p = hash_get (im->fib_index_by_table_id, table_index_or_id))) {
+ table_index_or_id++;
+ }
+ return create_fib_with_table_id (im, table_index_or_id);
+ }
+
p = hash_get (im->fib_index_by_table_id, table_index_or_id);
if (! p)
return create_fib_with_table_id (im, table_index_or_id);