aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/l2/l2_bd.h
diff options
context:
space:
mode:
authorEyal Bari <ebari@cisco.com>2017-04-07 23:14:17 +0300
committerJohn Lo <loj@cisco.com>2017-04-24 22:33:14 +0000
commitb1352ed0ac39aaa7be7542275d1d43fa64ab28ac (patch)
tree9afdb2ad10cf52bb9a11f67acc555008103072d6 /src/vnet/l2/l2_bd.h
parent86326daeaa10c5ce4a8aa0b6d97c75a3bbb73493 (diff)
BD:unify bridge domain creation code
Change-Id: I29082e7a0c556069180a157e55b3698cf8cd38c7 Signed-off-by: Eyal Bari <ebari@cisco.com>
Diffstat (limited to 'src/vnet/l2/l2_bd.h')
-rw-r--r--src/vnet/l2/l2_bd.h37
1 files changed, 28 insertions, 9 deletions
diff --git a/src/vnet/l2/l2_bd.h b/src/vnet/l2/l2_bd.h
index 83733411..e502d497 100644
--- a/src/vnet/l2/l2_bd.h
+++ b/src/vnet/l2/l2_bd.h
@@ -128,28 +128,47 @@ u32 bd_remove_member (l2_bridge_domain_t * bd_config, u32 sw_if_index);
u32 bd_set_flags (vlib_main_t * vm, u32 bd_index, u32 flags, u32 enable);
void bd_set_mac_age (vlib_main_t * vm, u32 bd_index, u8 age);
+int bd_add_del (l2_bridge_domain_add_del_args_t * args);
/**
- * \brief Get or create a bridge domain.
+ * \brief Get a bridge domain.
+ *
+ * Get a bridge domain with the given bridge domain ID.
+ *
+ * \param bdm bd_main pointer.
+ * \param bd_id The bridge domain ID
+ * \return The bridge domain index in \c l2input_main->l2_bridge_domain_t vector.
+ */
+u32 bd_find_index (bd_main_t * bdm, u32 bd_id);
+
+/**
+ * \brief Create a bridge domain.
*
- * Get or create a bridge domain with the given bridge domain ID.
+ * Create a bridge domain with the given bridge domain ID
*
* \param bdm bd_main pointer.
- * \param bd_id The bridge domain ID or ~0 if an arbitrary unused bridge domain should be used.
* \return The bridge domain index in \c l2input_main->l2_bridge_domain_t vector.
*/
-u32 bd_find_or_add_bd_index (bd_main_t * bdm, u32 bd_id);
+u32 bd_add_bd_index (bd_main_t * bdm, u32 bd_id);
/**
- * \brief Delete a bridge domain.
+ * \brief Get or create a bridge domain.
*
- * Delete an existing bridge domain with the given bridge domain ID.
+ * Get a bridge domain with the given bridge domain ID, if one exists, otherwise
+ * create one with the given ID, or the first unused ID if the given ID is ~0..
*
* \param bdm bd_main pointer.
- * \param bd_id The bridge domain ID.
- * \return 0 on success and -1 if the bridge domain does not exist.
+ * \param bd_id The bridge domain ID
+ * \return The bridge domain index in \c l2input_main->l2_bridge_domain_t vector.
*/
-int bd_delete_bd_index (bd_main_t * bdm, u32 bd_id);
+static inline u32
+bd_find_or_add_bd_index (bd_main_t * bdm, u32 bd_id)
+{
+ u32 bd_index = bd_find_index (bdm, bd_id);
+ if (bd_index == ~0)
+ return bd_add_bd_index (bdm, bd_id);
+ return bd_index;
+}
u32 bd_add_del_ip_mac (u32 bd_index,
u8 * ip_addr, u8 * mac_addr, u8 is_ip6, u8 is_add);