u32 bd_id;
u32 bd_index;
u32 sw_if_index = ~0;
- u32 filter_mac = 0;
u32 static_mac = 0;
u32 bvi_mac = 0;
uword *p;
if (unformat (input, "filter"))
{
- filter_mac = 1;
- static_mac = 1;
-
+ l2fib_add_filter_entry (mac, bd_index);
+ return 0;
}
- else
+
+ if (!unformat_user (input, unformat_vnet_sw_interface, vnm, &sw_if_index))
{
+ error = clib_error_return (0, "unknown interface `%U'",
+ format_unformat_error, input);
+ goto done;
+ }
- if (!unformat_user
- (input, unformat_vnet_sw_interface, vnm, &sw_if_index))
- {
- error = clib_error_return (0, "unknown interface `%U'",
- format_unformat_error, input);
- goto done;
- }
- if (unformat (input, "static"))
- {
- static_mac = 1;
- }
- else if (unformat (input, "bvi"))
- {
- bvi_mac = 1;
- static_mac = 1;
- }
+ if (unformat (input, "static"))
+ {
+ static_mac = 1;
+ }
+ else if (unformat (input, "bvi"))
+ {
+ bvi_mac = 1;
+ static_mac = 1;
}
if (vec_len (l2input_main.configs) <= sw_if_index)
goto done;
}
- if (filter_mac)
- l2fib_add_filter_entry (mac, bd_index);
- else
- l2fib_add_fwd_entry (mac, bd_index, sw_if_index, static_mac, bvi_mac);
+ l2fib_add_fwd_entry (mac, bd_index, sw_if_index, static_mac, bvi_mac);
done:
return error;
u32 client = lm->client_pid;
u32 cl_idx = lm->client_index;
vl_api_l2_macs_event_t *mp = 0;
- unix_shared_memory_queue_t *q = 0;
+ vl_api_registration_t *reg = 0;
if (client)
{
mp = allocate_mac_evt_buf (client, cl_idx);
- q = vl_api_client_index_to_input_queue (lm->client_index);
+ reg = vl_api_client_index_to_registration (lm->client_index);
}
for (i = 0; i < h->nbuckets; i++)
if (PREDICT_FALSE (evt_idx >= fm->max_macs_in_event))
{
/* event message full, send it and start a new one */
- if (q && (q->cursize < q->maxsize))
+ if (reg && vl_api_can_send_msg (reg))
{
mp->n_macs = htonl (evt_idx);
- vl_msg_api_send_shmem (q, (u8 *) & mp);
+ vl_api_send_msg (reg, (u8 *) mp);
mp = allocate_mac_evt_buf (client, cl_idx);
}
else
{
- if (q)
+ if (reg)
clib_warning ("MAC event to pid %d queue stuffed!"
" %d MAC entries lost", client,
evt_idx);
/* copy mac entry to event msg */
clib_memcpy (mp->mac[evt_idx].mac_addr, key.fields.mac,
6);
- mp->mac[evt_idx].is_del = 0;
+ mp->mac[evt_idx].action = result.fields.lrn_mov ?
+ MAC_EVENT_ACTION_MOVE : MAC_EVENT_ACTION_ADD;
mp->mac[evt_idx].sw_if_index =
htonl (result.fields.sw_if_index);
- /* clear event bit and update mac entry */
+ /* clear event bits and update mac entry */
result.fields.lrn_evt = 0;
+ result.fields.lrn_mov = 0;
BVT (clib_bihash_kv) kv;
kv.key = key.raw;
kv.value = result.raw;
{
/* copy mac entry to event msg */
clib_memcpy (mp->mac[evt_idx].mac_addr, key.fields.mac, 6);
- mp->mac[evt_idx].is_del = 1;
+ mp->mac[evt_idx].action = MAC_EVENT_ACTION_DELETE;
mp->mac[evt_idx].sw_if_index =
htonl (result.fields.sw_if_index);
evt_idx++;
/* send any outstanding mac event message else free message buffer */
if (evt_idx)
{
- if (q && (q->cursize < q->maxsize))
+ if (reg && vl_api_can_send_msg (reg))
{
mp->n_macs = htonl (evt_idx);
- vl_msg_api_send_shmem (q, (u8 *) & mp);
+ vl_api_send_msg (reg, (u8 *) mp);
}
else
{
- if (q)
+ if (reg)
clib_warning ("MAC event to pid %d queue stuffed!"
" %d MAC entries lost", client, evt_idx);
vl_msg_api_free (mp);