diff options
author | Pierre Pfister <ppfister@cisco.com> | 2016-05-10 17:11:22 +0100 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2016-05-16 12:07:04 +0000 |
commit | 530bd8e1e68973c0b0f67e60c5520d32bb2628ad (patch) | |
tree | e71bf1b2cdc4c3e84db100b9fde086a5f57e4337 /vnet/vnet/l2/l2_bd.c | |
parent | aa761e128158e788f4046e24039e9ae0ee425dbb (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/l2/l2_bd.c')
-rw-r--r-- | vnet/vnet/l2/l2_bd.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/vnet/vnet/l2/l2_bd.c b/vnet/vnet/l2/l2_bd.c index 31f02c63eff..0676a2869a2 100644 --- a/vnet/vnet/l2/l2_bd.c +++ b/vnet/vnet/l2/l2_bd.c @@ -54,9 +54,15 @@ u32 bd_find_or_add_bd_index (bd_main_t * bdm, u32 bd_id) uword * p; u32 rv; - p = hash_get (bdm->bd_index_by_bd_id, bd_id); - if (p) - return (p[0]); + if (bd_id == ~0) { + bd_id = 0; + while (hash_get (bdm->bd_index_by_bd_id, bd_id)) + bd_id++; + } else { + p = hash_get (bdm->bd_index_by_bd_id, bd_id); + if (p) + return (p[0]); + } rv = clib_bitmap_first_clear (bdm->bd_index_bitmap); |