#include <vnet/vnet_all_api_h.h>
#undef vl_endianfun
+#define vl_api_bridge_domain_details_t_endian vl_noop_handler
+#define vl_api_bridge_domain_details_t_print vl_noop_handler
+
/* instantiate all the print functions we know about */
#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
#define vl_printfun
_(L2_XCONNECT_DUMP, l2_xconnect_dump) \
_(L2_FIB_CLEAR_TABLE, l2_fib_clear_table) \
_(L2_FIB_TABLE_DUMP, l2_fib_table_dump) \
+_(L2FIB_FLUSH_ALL, l2fib_flush_all) \
_(L2FIB_FLUSH_INT, l2fib_flush_int) \
_(L2FIB_FLUSH_BD, l2fib_flush_bd) \
_(L2FIB_ADD_DEL, l2fib_add_del) \
int rv = 0;
vl_api_l2_fib_clear_table_reply_t *rmp;
- /* DAW-FIXME: This API should only clear non-static l2fib entries, but
- * that is not currently implemented. When that TODO is fixed
- * this call should be changed to pass 1 instead of 0.
- */
- l2fib_clear_table (0);
+ /* Clear all MACs including static MACs */
+ l2fib_clear_table ();
REPLY_MACRO (VL_API_L2_FIB_CLEAR_TABLE_REPLY);
}
l2fib_entry_key_t * l2fe_key,
l2fib_entry_result_t * l2fe_res, u32 context)
{
- vl_api_l2_fib_table_entry_t *mp;
+ vl_api_l2_fib_table_details_t *mp;
mp = vl_msg_api_alloc (sizeof (*mp));
memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_L2_FIB_TABLE_ENTRY);
+ mp->_vl_msg_id = ntohs (VL_API_L2_FIB_TABLE_DETAILS);
mp->bd_id =
ntohl (l2input_main.bd_configs[l2fe_key->fields.bd_index].bd_id);
REPLY_MACRO (VL_API_L2FIB_FLUSH_INT_REPLY);
}
+static void
+vl_api_l2fib_flush_all_t_handler (vl_api_l2fib_flush_all_t * mp)
+{
+ int rv = 0;
+ vl_api_l2fib_flush_all_reply_t *rmp;
+
+ l2fib_flush_all_mac (vlib_get_main ());
+ REPLY_MACRO (VL_API_L2FIB_FLUSH_ALL_REPLY);
+}
+
static void
vl_api_l2fib_flush_bd_t_handler (vl_api_l2fib_flush_bd_t * mp)
{
}
static void
-send_bridge_domain_details (unix_shared_memory_queue_t * q,
+send_bridge_domain_details (l2input_main_t * l2im,
+ unix_shared_memory_queue_t * q,
l2_bridge_domain_t * bd_config,
u32 n_sw_ifs, u32 context)
{
vl_api_bridge_domain_details_t *mp;
+ l2_flood_member_t *m;
+ vl_api_bridge_domain_sw_if_t *sw_ifs;
+ l2_input_config_t *input_cfg;
- mp = vl_msg_api_alloc (sizeof (*mp));
+ mp = vl_msg_api_alloc (sizeof (*mp) +
+ (n_sw_ifs * sizeof (vl_api_bridge_domain_sw_if_t)));
memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = ntohs (VL_API_BRIDGE_DOMAIN_DETAILS);
mp->bd_id = ntohl (bd_config->bd_id);
mp->arp_term = bd_feature_arp_term (bd_config);
mp->bvi_sw_if_index = ntohl (bd_config->bvi_sw_if_index);
mp->mac_age = bd_config->mac_age;
- mp->n_sw_ifs = ntohl (n_sw_ifs);
mp->context = context;
- vl_msg_api_send_shmem (q, (u8 *) & mp);
-}
-
-static void
-send_bd_sw_if_details (l2input_main_t * l2im,
- unix_shared_memory_queue_t * q,
- l2_flood_member_t * member, u32 bd_id, u32 context)
-{
- vl_api_bridge_domain_sw_if_details_t *mp;
- l2_input_config_t *input_cfg;
-
- mp = vl_msg_api_alloc (sizeof (*mp));
- memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_BRIDGE_DOMAIN_SW_IF_DETAILS);
- mp->bd_id = ntohl (bd_id);
- mp->sw_if_index = ntohl (member->sw_if_index);
- input_cfg = vec_elt_at_index (l2im->configs, member->sw_if_index);
- mp->shg = input_cfg->shg;
- mp->context = context;
+ sw_ifs = (vl_api_bridge_domain_sw_if_t *) mp->sw_if_details;
+ vec_foreach (m, bd_config->members)
+ {
+ sw_ifs->sw_if_index = ntohl (m->sw_if_index);
+ input_cfg = vec_elt_at_index (l2im->configs, m->sw_if_index);
+ sw_ifs->shg = input_cfg->shg;
+ sw_ifs++;
+ mp->n_sw_ifs++;
+ }
+ mp->n_sw_ifs = htonl (mp->n_sw_ifs);
vl_msg_api_send_shmem (q, (u8 *) & mp);
}
{
bd_main_t *bdm = &bd_main;
l2input_main_t *l2im = &l2input_main;
- unix_shared_memory_queue_t *q;
- l2_bridge_domain_t *bd_config;
- u32 bd_id, bd_index;
- u32 end;
-
- q = vl_api_client_index_to_input_queue (mp->client_index);
+ unix_shared_memory_queue_t *q =
+ vl_api_client_index_to_input_queue (mp->client_index);
if (q == 0)
return;
- bd_id = ntohl (mp->bd_id);
+ u32 bd_id = ntohl (mp->bd_id);
if (bd_id == 0)
return;
- bd_index = (bd_id == ~0) ? 0 : bd_find_index (bdm, bd_id);
- ASSERT (bd_index != ~0);
- end = (bd_id == ~0) ? vec_len (l2im->bd_configs) : bd_index + 1;
+ u32 bd_index, end;
+ if (bd_id == ~0)
+ bd_index = 0, end = vec_len (l2im->bd_configs);
+ else
+ {
+ bd_index = bd_find_index (bdm, bd_id);
+ if (bd_index == ~0)
+ return;
+
+ end = bd_index + 1;
+ }
for (; bd_index < end; bd_index++)
{
- bd_config = l2input_bd_config_from_index (l2im, bd_index);
+ l2_bridge_domain_t *bd_config =
+ l2input_bd_config_from_index (l2im, bd_index);
/* skip dummy bd_id 0 */
if (bd_config && (bd_config->bd_id > 0))
- {
- u32 n_sw_ifs;
- l2_flood_member_t *m;
-
- n_sw_ifs = vec_len (bd_config->members);
- send_bridge_domain_details (q, bd_config, n_sw_ifs, mp->context);
-
- vec_foreach (m, bd_config->members)
- {
- send_bd_sw_if_details (l2im, q, m, bd_config->bd_id, mp->context);
- }
- }
+ send_bridge_domain_details (l2im, q, bd_config,
+ vec_len (bd_config->members),
+ mp->context);
}
}
bd_main_t *bdm = &bd_main;
vl_api_bridge_flags_reply_t *rmp;
int rv = 0;
- u32 bd_id = ntohl (mp->bd_id);
- u32 bd_index;
- u32 flags = ntohl (mp->feature_bitmap);
- uword *p;
+ u32 flags = ntohl (mp->feature_bitmap);
+ u32 bd_id = ntohl (mp->bd_id);
if (bd_id == 0)
{
rv = VNET_API_ERROR_BD_NOT_MODIFIABLE;
goto out;
}
- p = hash_get (bdm->bd_index_by_bd_id, bd_id);
- if (p == 0)
+ u32 bd_index = bd_find_index (bdm, bd_id);
+ if (bd_index == ~0)
{
rv = VNET_API_ERROR_NO_SUCH_ENTRY;
goto out;
}
- bd_index = p[0];
-
bd_set_flags (vm, bd_index, flags, mp->is_set);
out: