FD.io VPP  v17.10-9-gd594711
Vector Packet Processing
l2_api.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * l2_api.c - layer 2 forwarding api
4  *
5  * Copyright (c) 2016 Cisco and/or its affiliates.
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at:
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *------------------------------------------------------------------
18  */
19 
20 #include <vnet/vnet.h>
21 #include <vlibmemory/api.h>
22 
23 #include <vnet/interface.h>
24 #include <vnet/api_errno.h>
25 #include <vnet/l2/l2_input.h>
26 #include <vnet/l2/l2_fib.h>
27 #include <vnet/l2/l2_vtr.h>
28 #include <vnet/l2/l2_learn.h>
29 
30 #include <vnet/vnet_msg_enum.h>
31 
32 #define vl_typedefs /* define message structures */
33 #include <vnet/vnet_all_api_h.h>
34 #undef vl_typedefs
35 
36 #define vl_endianfun /* define message structures */
37 #include <vnet/vnet_all_api_h.h>
38 #undef vl_endianfun
39 
40 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
41 #define vl_api_bridge_domain_details_t_print vl_noop_handler
42 
43 /* instantiate all the print functions we know about */
44 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
45 #define vl_printfun
46 #include <vnet/vnet_all_api_h.h>
47 #undef vl_printfun
48 
50 
51 #define foreach_vpe_api_msg \
52 _(L2_XCONNECT_DUMP, l2_xconnect_dump) \
53 _(L2_FIB_CLEAR_TABLE, l2_fib_clear_table) \
54 _(L2_FIB_TABLE_DUMP, l2_fib_table_dump) \
55 _(L2FIB_FLUSH_ALL, l2fib_flush_all) \
56 _(L2FIB_FLUSH_INT, l2fib_flush_int) \
57 _(L2FIB_FLUSH_BD, l2fib_flush_bd) \
58 _(L2FIB_ADD_DEL, l2fib_add_del) \
59 _(WANT_L2_MACS_EVENTS, want_l2_macs_events) \
60 _(L2_FLAGS, l2_flags) \
61 _(BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del) \
62 _(BRIDGE_DOMAIN_DUMP, bridge_domain_dump) \
63 _(BRIDGE_FLAGS, bridge_flags) \
64 _(L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite) \
65 _(L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite) \
66 _(BRIDGE_DOMAIN_SET_MAC_AGE, bridge_domain_set_mac_age)
67 
68 static void
70  u32 rx_sw_if_index, u32 tx_sw_if_index)
71 {
73 
74  mp = vl_msg_api_alloc (sizeof (*mp));
75  memset (mp, 0, sizeof (*mp));
76  mp->_vl_msg_id = ntohs (VL_API_L2_XCONNECT_DETAILS);
77  mp->context = context;
78  mp->rx_sw_if_index = htonl (rx_sw_if_index);
79  mp->tx_sw_if_index = htonl (tx_sw_if_index);
80 
81  vl_msg_api_send_shmem (q, (u8 *) & mp);
82 }
83 
84 static void
86 {
88  vnet_main_t *vnm = vnet_get_main ();
91  vnet_sw_interface_t *swif;
92  l2_input_config_t *config;
93 
95  if (q == 0)
96  return;
97 
98  /* *INDENT-OFF* */
99  pool_foreach (swif, im->sw_interfaces,
100  ({
101  config = vec_elt_at_index (l2im->configs, swif->sw_if_index);
102  if (config->xconnect)
103  send_l2_xconnect_details (q, mp->context, swif->sw_if_index,
104  config->output_sw_if_index);
105  }));
106  /* *INDENT-ON* */
107 }
108 
109 static void
111 {
112  int rv = 0;
113  vl_api_l2_fib_clear_table_reply_t *rmp;
114 
115  /* Clear all MACs including static MACs */
117 
118  REPLY_MACRO (VL_API_L2_FIB_CLEAR_TABLE_REPLY);
119 }
120 
121 static void
124  l2fib_entry_key_t * l2fe_key,
125  l2fib_entry_result_t * l2fe_res, u32 context)
126 {
128 
129  mp = vl_msg_api_alloc (sizeof (*mp));
130  memset (mp, 0, sizeof (*mp));
131  mp->_vl_msg_id = ntohs (VL_API_L2_FIB_TABLE_DETAILS);
132 
133  mp->bd_id =
134  ntohl (l2input_main.bd_configs[l2fe_key->fields.bd_index].bd_id);
135 
136  mp->mac = l2fib_make_key (l2fe_key->fields.mac, 0);
137  mp->sw_if_index = ntohl (l2fe_res->fields.sw_if_index);
138  mp->static_mac = l2fe_res->fields.static_mac;
139  mp->filter_mac = l2fe_res->fields.filter;
140  mp->bvi_mac = l2fe_res->fields.bvi;
141  mp->context = context;
142 
143  vl_msg_api_send_shmem (q, (u8 *) & mp);
144 }
145 
146 static void
148 {
150  bd_main_t *bdm = &bd_main;
151  l2fib_entry_key_t *l2fe_key = NULL;
152  l2fib_entry_result_t *l2fe_res = NULL;
153  u32 ni, bd_id = ntohl (mp->bd_id);
154  u32 bd_index;
156  uword *p;
157 
159  if (q == 0)
160  return;
161 
162  /* see l2fib_table_dump: ~0 means "any" */
163  if (bd_id == ~0)
164  bd_index = ~0;
165  else
166  {
167  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
168  if (p == 0)
169  return;
170 
171  bd_index = p[0];
172  }
173 
174  l2fib_table_dump (bd_index, &l2fe_key, &l2fe_res);
175 
176  vec_foreach_index (ni, l2fe_key)
177  {
178  send_l2fib_table_entry (am, q, vec_elt_at_index (l2fe_key, ni),
179  vec_elt_at_index (l2fe_res, ni), mp->context);
180  }
181  vec_free (l2fe_key);
182  vec_free (l2fe_res);
183 }
184 
185 static void
187 {
188  bd_main_t *bdm = &bd_main;
189  l2input_main_t *l2im = &l2input_main;
190  vl_api_l2fib_add_del_reply_t *rmp;
191  int rv = 0;
192  u32 bd_id = ntohl (mp->bd_id);
193  uword *p = hash_get (bdm->bd_index_by_bd_id, bd_id);
194 
195  if (!p)
196  {
197  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
198  goto bad_sw_if_index;
199  }
200  u32 bd_index = p[0];
201 
202  u64 mac = mp->mac;
203  if (mp->is_add)
204  {
205  if (mp->filter_mac)
206  l2fib_add_filter_entry (mac, bd_index);
207  else
208  {
209  u32 sw_if_index = ntohl (mp->sw_if_index);
211  if (vec_len (l2im->configs) <= sw_if_index)
212  {
213  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
214  goto bad_sw_if_index;
215  }
216  else
217  {
218  l2_input_config_t *config;
219  config = vec_elt_at_index (l2im->configs, sw_if_index);
220  if (config->bridge == 0)
221  {
222  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
223  goto bad_sw_if_index;
224  }
225  }
226  u8 static_mac = mp->static_mac ? 1 : 0;
227  u8 bvi_mac = mp->bvi_mac ? 1 : 0;
228  l2fib_add_fwd_entry (mac, bd_index, sw_if_index, static_mac,
229  bvi_mac);
230  }
231  }
232  else
233  {
234  l2fib_del_entry (mac, bd_index);
235  }
236 
238 
239  REPLY_MACRO (VL_API_L2FIB_ADD_DEL_REPLY);
240 }
241 
242 static void
244 {
245  int rv = 0;
246  vl_api_want_l2_macs_events_reply_t *rmp;
248  l2fib_main_t *fm = &l2fib_main;
249  u32 pid = ntohl (mp->pid);
250  u32 learn_limit = ntohl (mp->learn_limit);
251 
252  if (mp->enable_disable)
253  {
254  if (lm->client_pid == 0)
255  {
256  lm->client_pid = pid;
257  lm->client_index = mp->client_index;
258 
259  if (mp->max_macs_in_event)
260  fm->max_macs_in_event = mp->max_macs_in_event * 10;
261  else
263 
264  if (mp->scan_delay)
265  fm->event_scan_delay = (f64) (mp->scan_delay) * 10e-3;
266  else
268 
269  /* change learn limit and flush all learned MACs */
270  if (learn_limit && (learn_limit < L2LEARN_DEFAULT_LIMIT))
271  lm->global_learn_limit = learn_limit;
272  else
274 
276  }
277  else if (lm->client_pid != pid)
278  {
279  rv = VNET_API_ERROR_L2_MACS_EVENT_CLINET_PRESENT;
280  goto exit;
281  }
282  }
283  else if (lm->client_pid)
284  {
285  lm->client_pid = 0;
286  lm->client_index = 0;
287  if (learn_limit && (learn_limit < L2LEARN_DEFAULT_LIMIT))
288  lm->global_learn_limit = learn_limit;
289  else
291  }
292 
293 exit:
294  REPLY_MACRO (VL_API_WANT_L2_MACS_EVENTS_REPLY);
295 }
296 
297 static void
299 {
300  int rv = 0;
302  vl_api_l2fib_flush_int_reply_t *rmp;
303 
305 
306  u32 sw_if_index = ntohl (mp->sw_if_index);
307  l2fib_flush_int_mac (vm, sw_if_index);
308 
310  REPLY_MACRO (VL_API_L2FIB_FLUSH_INT_REPLY);
311 }
312 
313 static void
315 {
316  int rv = 0;
317  vl_api_l2fib_flush_all_reply_t *rmp;
318 
320  REPLY_MACRO (VL_API_L2FIB_FLUSH_ALL_REPLY);
321 }
322 
323 static void
325 {
326  int rv = 0;
328  bd_main_t *bdm = &bd_main;
329  vl_api_l2fib_flush_bd_reply_t *rmp;
330 
331  u32 bd_id = ntohl (mp->bd_id);
332  uword *p = hash_get (bdm->bd_index_by_bd_id, bd_id);
333  if (p == 0)
334  {
335  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
336  goto out;
337  }
338  l2fib_flush_bd_mac (vm, *p);
339 out:
340  REPLY_MACRO (VL_API_L2FIB_FLUSH_BD_REPLY);
341 }
342 
343 static void
345 {
347  int rv = 0;
348  u32 rbm = 0;
349 
351 
352  u32 sw_if_index = ntohl (mp->sw_if_index);
353  u32 flags = ntohl (mp->feature_bitmap);
354  u32 bitmap = 0;
355 
356  if (flags & L2_LEARN)
357  bitmap |= L2INPUT_FEAT_LEARN;
358 
359  if (flags & L2_FWD)
360  bitmap |= L2INPUT_FEAT_FWD;
361 
362  if (flags & L2_FLOOD)
363  bitmap |= L2INPUT_FEAT_FLOOD;
364 
365  if (flags & L2_UU_FLOOD)
366  bitmap |= L2INPUT_FEAT_UU_FLOOD;
367 
368  if (flags & L2_ARP_TERM)
369  bitmap |= L2INPUT_FEAT_ARP_TERM;
370 
371  rbm = l2input_intf_bitmap_enable (sw_if_index, bitmap, mp->is_set);
372 
374 
375  /* *INDENT-OFF* */
376  REPLY_MACRO2(VL_API_L2_FLAGS_REPLY,
377  ({
378  rmp->resulting_feature_bitmap = ntohl(rbm);
379  }));
380  /* *INDENT-ON* */
381 }
382 
383 static void
385  * mp)
386 {
388  bd_main_t *bdm = &bd_main;
389  vl_api_bridge_domain_set_mac_age_reply_t *rmp;
390  int rv = 0;
391  u32 bd_id = ntohl (mp->bd_id);
392  uword *p;
393 
394  if (bd_id == 0)
395  {
396  rv = VNET_API_ERROR_BD_NOT_MODIFIABLE;
397  goto out;
398  }
399 
400  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
401  if (p == 0)
402  {
403  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
404  goto out;
405  }
406  bd_set_mac_age (vm, *p, mp->mac_age);
407 out:
408  REPLY_MACRO (VL_API_BRIDGE_DOMAIN_SET_MAC_AGE_REPLY);
409 }
410 
411 static void
413 {
415  .is_add = mp->is_add,
416  .flood = mp->flood,
417  .uu_flood = mp->uu_flood,
418  .forward = mp->forward,
419  .learn = mp->learn,
420  .arp_term = mp->arp_term,
421  .mac_age = mp->mac_age,
422  .bd_id = ntohl (mp->bd_id),
423  .bd_tag = mp->bd_tag
424  };
425 
426  int rv = bd_add_del (&a);
427 
428  vl_api_bridge_domain_add_del_reply_t *rmp;
429  REPLY_MACRO (VL_API_BRIDGE_DOMAIN_ADD_DEL_REPLY);
430 }
431 
432 static void
435  l2_bridge_domain_t * bd_config,
436  u32 n_sw_ifs, u32 context)
437 {
441  l2_input_config_t *input_cfg;
442 
443  mp = vl_msg_api_alloc (sizeof (*mp) +
444  (n_sw_ifs * sizeof (vl_api_bridge_domain_sw_if_t)));
445  memset (mp, 0, sizeof (*mp));
446  mp->_vl_msg_id = ntohs (VL_API_BRIDGE_DOMAIN_DETAILS);
447  mp->bd_id = ntohl (bd_config->bd_id);
448  mp->flood = bd_feature_flood (bd_config);
449  mp->uu_flood = bd_feature_uu_flood (bd_config);
450  mp->forward = bd_feature_forward (bd_config);
451  mp->learn = bd_feature_learn (bd_config);
452  mp->arp_term = bd_feature_arp_term (bd_config);
453  mp->bvi_sw_if_index = ntohl (bd_config->bvi_sw_if_index);
454  mp->mac_age = bd_config->mac_age;
455  if (bd_config->bd_tag)
456  {
457  strncpy ((char *) mp->bd_tag, (char *) bd_config->bd_tag,
458  ARRAY_LEN (mp->bd_tag) - 1);
459  mp->bd_tag[ARRAY_LEN (mp->bd_tag) - 1] = 0;
460  }
461 
462  mp->context = context;
463 
465  vec_foreach (m, bd_config->members)
466  {
467  sw_ifs->sw_if_index = ntohl (m->sw_if_index);
468  input_cfg = vec_elt_at_index (l2im->configs, m->sw_if_index);
469  sw_ifs->shg = input_cfg->shg;
470  sw_ifs++;
471  mp->n_sw_ifs++;
472  }
473  mp->n_sw_ifs = htonl (mp->n_sw_ifs);
474 
475  vl_msg_api_send_shmem (q, (u8 *) & mp);
476 }
477 
478 static void
480 {
481  bd_main_t *bdm = &bd_main;
482  l2input_main_t *l2im = &l2input_main;
483 
486  if (q == 0)
487  return;
488 
489  u32 bd_id = ntohl (mp->bd_id);
490  if (bd_id == 0)
491  return;
492 
493  u32 bd_index, end;
494  if (bd_id == ~0)
495  bd_index = 0, end = vec_len (l2im->bd_configs);
496  else
497  {
498  bd_index = bd_find_index (bdm, bd_id);
499  if (bd_index == ~0)
500  return;
501 
502  end = bd_index + 1;
503  }
504 
505  for (; bd_index < end; bd_index++)
506  {
507  l2_bridge_domain_t *bd_config =
508  l2input_bd_config_from_index (l2im, bd_index);
509  /* skip dummy bd_id 0 */
510  if (bd_config && (bd_config->bd_id > 0))
511  send_bridge_domain_details (l2im, q, bd_config,
512  vec_len (bd_config->members),
513  mp->context);
514  }
515 }
516 
517 static void
519 {
521  bd_main_t *bdm = &bd_main;
523  int rv = 0;
524 
525  u32 flags = ntohl (mp->feature_bitmap);
526  u32 bd_id = ntohl (mp->bd_id);
527  if (bd_id == 0)
528  {
529  rv = VNET_API_ERROR_BD_NOT_MODIFIABLE;
530  goto out;
531  }
532 
533  u32 bd_index = bd_find_index (bdm, bd_id);
534  if (bd_index == ~0)
535  {
536  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
537  goto out;
538  }
539 
540  u32 bitmap = bd_set_flags (vm, bd_index, flags, mp->is_set);
541 
542 out:
543  /* *INDENT-OFF* */
544  REPLY_MACRO2(VL_API_BRIDGE_FLAGS_REPLY,
545  ({
546  rmp->resulting_feature_bitmap = ntohl(bitmap);
547  }));
548  /* *INDENT-ON* */
549 }
550 
551 static void
554 {
555  int rv = 0;
556  vl_api_l2_interface_vlan_tag_rewrite_reply_t *rmp;
557  vnet_main_t *vnm = vnet_get_main ();
559  u32 vtr_op;
560 
562 
563  vtr_op = ntohl (mp->vtr_op);
564 
565  /* The L2 code is unsuspicious */
566  switch (vtr_op)
567  {
568  case L2_VTR_DISABLED:
569  case L2_VTR_PUSH_1:
570  case L2_VTR_PUSH_2:
571  case L2_VTR_POP_1:
572  case L2_VTR_POP_2:
577  break;
578 
579  default:
580  rv = VNET_API_ERROR_INVALID_VALUE;
581  goto bad_sw_if_index;
582  }
583 
584  rv = l2vtr_configure (vm, vnm, ntohl (mp->sw_if_index), vtr_op,
585  ntohl (mp->push_dot1q), ntohl (mp->tag1),
586  ntohl (mp->tag2));
587 
589 
590  REPLY_MACRO (VL_API_L2_INTERFACE_VLAN_TAG_REWRITE_REPLY);
591 }
592 
593 static void
596 {
597  vl_api_l2_interface_pbb_tag_rewrite_reply_t *rmp;
598  vnet_main_t *vnm = vnet_get_main ();
600  u32 vtr_op;
601  int rv = 0;
602 
604 
605  vtr_op = ntohl (mp->vtr_op);
606 
607  switch (vtr_op)
608  {
609  case L2_VTR_DISABLED:
610  case L2_VTR_PUSH_2:
611  case L2_VTR_POP_2:
613  break;
614 
615  default:
616  rv = VNET_API_ERROR_INVALID_VALUE;
617  goto bad_sw_if_index;
618  }
619 
620  rv = l2pbb_configure (vm, vnm, ntohl (mp->sw_if_index), vtr_op,
621  mp->b_dmac, mp->b_smac, ntohs (mp->b_vlanid),
622  ntohl (mp->i_sid), ntohs (mp->outer_tag));
623 
625 
626  REPLY_MACRO (VL_API_L2_INTERFACE_PBB_TAG_REWRITE_REPLY);
627 }
628 
629 /*
630  * l2_api_hookup
631  * Add vpe's API message handlers to the table.
632  * vlib has alread mapped shared memory and
633  * added the client registration handlers.
634  * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
635  */
636 #define vl_msg_name_crc_list
637 #include <vnet/vnet_all_api_h.h>
638 #undef vl_msg_name_crc_list
639 
640 static void
642 {
643 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
644  foreach_vl_msg_name_crc_l2;
645 #undef _
646 }
647 
648 static clib_error_t *
650 {
651  api_main_t *am = &api_main;
652 
653 #define _(N,n) \
654  vl_msg_api_set_handlers(VL_API_##N, #n, \
655  vl_api_##n##_t_handler, \
656  vl_noop_handler, \
657  vl_api_##n##_t_endian, \
658  vl_api_##n##_t_print, \
659  sizeof(vl_api_##n##_t), 1);
661 #undef _
662 
663  /*
664  * Set up the (msg_name, crc, message-id) table
665  */
667 
668  return 0;
669 }
670 
672 
673 /*
674  * fd.io coding-style-patch-verification: ON
675  *
676  * Local Variables:
677  * eval: (c-set-style "gnu")
678  * End:
679  */
static_always_inline u8 bd_feature_forward(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:169
static void vl_api_l2_fib_table_dump_t_handler(vl_api_l2_fib_table_dump_t *mp)
Definition: l2_api.c:147
static void l2fib_add_fwd_entry(u64 mac, u32 bd_index, u32 sw_if_index, u8 static_mac, u8 bvi_mac)
Definition: l2_fib.h:379
u32 bd_set_flags(vlib_main_t *vm, u32 bd_index, u32 flags, u32 enable)
Set the learn/forward/flood flags for the bridge domain.
Definition: l2_bd.c:232
#define vec_foreach_index(var, v)
Iterate over vector indices.
L2 FIB add entry request.
Definition: l2.api:123
l2_input_config_t * configs
Definition: l2_input.h:66
Set bridge flags response.
Definition: l2.api:329
l2 fib table details structure
Definition: l2.api:47
a
Definition: bitmap.h:516
u32 l2vtr_configure(vlib_main_t *vlib_main, vnet_main_t *vnet_main, u32 sw_if_index, u32 vtr_op, u32 push_dot1q, u32 vtr_tag1, u32 vtr_tag2)
Configure vtag tag rewrite on the given interface.
Definition: l2_vtr.c:136
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
u32 bvi_sw_if_index
Definition: l2_bd.h:64
static void vl_api_l2_flags_t_handler(vl_api_l2_flags_t *mp)
Definition: l2_api.c:344
vnet_interface_main_t interface_main
Definition: vnet.h:56
#define REPLY_MACRO2(t, body)
#define NULL
Definition: clib.h:55
#define L2_FLOOD
Definition: l2_bd.h:131
#define L2_FWD
Definition: l2_bd.h:130
u32 l2fib_del_entry(u64 mac, u32 bd_index)
Delete an entry from the l2fib.
Definition: l2_fib.c:683
VLIB_API_INIT_FUNCTION(l2_api_hookup)
L2 bridge domain set mac age.
Definition: l2.api:221
l2_flood_member_t * members
Definition: l2_bd.h:70
Dump L2 XConnects.
Definition: l2.api:33
static void vl_api_bridge_domain_add_del_t_handler(vl_api_bridge_domain_add_del_t *mp)
Definition: l2_api.c:412
u32 max_macs_in_event
Definition: l2_fib.h:59
L2 bridge domain request operational state details.
Definition: l2.api:261
int bd_add_del(l2_bridge_domain_add_del_args_t *a)
Definition: l2_bd.c:1127
Definition: l2_fib.h:108
static_always_inline u8 bd_feature_uu_flood(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:162
static void vl_api_l2fib_add_del_t_handler(vl_api_l2fib_add_del_t *mp)
Definition: l2_api.c:186
u32 client_index
Definition: l2_learn.h:39
Reply to l2_xconnect_dump.
Definition: l2.api:22
static void send_l2_xconnect_details(unix_shared_memory_queue_t *q, u32 context, u32 rx_sw_if_index, u32 tx_sw_if_index)
Definition: l2_api.c:69
L2 bridge domain operational state response.
Definition: l2.api:291
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:437
L2 bridge domain sw interface operational state response.
Definition: l2.api:273
u32 feature_bitmap
Definition: l2.api:200
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static_always_inline u8 bd_feature_arp_term(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:182
static void vl_api_l2_fib_clear_table_t_handler(vl_api_l2_fib_clear_table_t *mp)
Definition: l2_api.c:110
#define L2_UU_FLOOD
Definition: l2_bd.h:132
L2 FIB flush bridge domain entries.
Definition: l2.api:94
unsigned long u64
Definition: types.h:89
uword * bd_index_by_bd_id
Definition: l2_bd.h:27
void * vl_msg_api_alloc(int nbytes)
Dump l2 fib (aka bridge domain) table.
Definition: l2.api:62
static_always_inline u8 bd_feature_flood(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:155
#define hash_get(h, key)
Definition: hash.h:248
f64 event_scan_delay
Definition: l2_fib.h:56
Set interface L2 flags (such as L2_LEARN, L2_FWD, L2_FLOOD, L2_UU_FLOOD, or L2_ARP_TERM bits)...
Definition: l2.api:194
L2 FIB flush all entries.
Definition: l2.api:83
L2 fib clear table request, clear all mac entries in the l2 fib.
Definition: l2.api:73
static void l2fib_add_filter_entry(u64 mac, u32 bd_index)
Definition: l2_fib.h:386
Set interface L2 flags response.
Definition: l2.api:208
void l2fib_flush_bd_mac(vlib_main_t *vm, u32 bd_index)
Flush all non static MACs in a bridge domain.
Definition: l2_fib.c:790
#define REPLY_MACRO(t)
void l2fib_flush_all_mac(vlib_main_t *vm)
Flush all non static MACs - flushes all valid BDs.
Definition: l2_fib.c:801
static clib_error_t * l2_api_hookup(vlib_main_t *vm)
Definition: l2_api.c:649
#define L2FIB_EVENT_MAX_MACS_DEFAULT
Definition: l2_fib.h:37
l2fib_main_t l2fib_main
Definition: l2_fib.c:55
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:182
u32 l2pbb_configure(vlib_main_t *vlib_main, vnet_main_t *vnet_main, u32 sw_if_index, u32 vtr_op, u8 *b_dmac, u8 *b_smac, u16 b_vlanid, u32 i_sid, u16 vlan_outer_tag)
Definition: l2_vtr.c:54
void bd_set_mac_age(vlib_main_t *vm, u32 bd_index, u8 age)
Set the mac age for the bridge domain.
Definition: l2_bd.c:276
#define BAD_SW_IF_INDEX_LABEL
api_main_t api_main
Definition: api_shared.c:35
vlib_main_t * vm
Definition: buffer.c:283
static void vl_api_l2_xconnect_dump_t_handler(vl_api_l2_xconnect_dump_t *mp)
Definition: l2_api.c:85
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:336
#define foreach_vpe_api_msg
Definition: l2_api.c:51
static_always_inline u8 bd_feature_learn(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:175
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
static void setup_message_id_table(api_main_t *am)
Definition: l2_api.c:641
void l2fib_clear_table(void)
Definition: l2_fib.c:287
struct l2fib_entry_key_t::@178::@180 fields
#define ARRAY_LEN(x)
Definition: clib.h:59
#define L2FIB_EVENT_SCAN_DELAY_DEFAULT
Definition: l2_fib.h:34
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
unsigned int u32
Definition: types.h:88
static_always_inline l2_bridge_domain_t * l2input_bd_config_from_index(l2input_main_t *l2im, u32 bd_index)
Definition: l2_input.h:81
Definition: l2_fib.h:71
Register to recive L2 MAC events for leanred and aged MAC.
Definition: l2.api:145
struct l2fib_entry_result_t::@186::@188 fields
u32 global_learn_limit
Definition: l2_learn.h:35
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
u64 uword
Definition: types.h:112
u32 l2input_intf_bitmap_enable(u32 sw_if_index, u32 feature_bitmap, u32 enable)
Enable (or disable) the feature in the bitmap for the given interface.
Definition: l2_input.c:534
u32 resulting_feature_bitmap
Definition: l2.api:212
static void vl_api_l2_interface_vlan_tag_rewrite_t_handler(vl_api_l2_interface_vlan_tag_rewrite_t *mp)
Definition: l2_api.c:553
#define L2FIB_EVENT_LEARN_LIMIT_DEFAULT
Definition: l2_fib.h:40
l2input_main_t l2input_main
Definition: l2_input.c:113
L2 FIB flush interface entries.
Definition: l2.api:106
static void vl_api_l2fib_flush_bd_t_handler(vl_api_l2fib_flush_bd_t *mp)
Definition: l2_api.c:324
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
double f64
Definition: types.h:142
unsigned char u8
Definition: types.h:56
#define L2_ARP_TERM
Definition: l2_bd.h:133
static void vl_api_want_l2_macs_events_t_handler(vl_api_want_l2_macs_events_t *mp)
Definition: l2_api.c:243
static void vl_api_bridge_flags_t_handler(vl_api_bridge_flags_t *mp)
Definition: l2_api.c:518
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:659
L2 interface vlan tag rewrite configure request.
Definition: l2.api:345
static void vl_api_l2fib_flush_all_t_handler(vl_api_l2fib_flush_all_t *mp)
Definition: l2_api.c:314
static u64 l2fib_make_key(u8 *mac_address, u16 bd_index)
Definition: l2_fib.h:152
l2_bridge_domain_t * bd_configs
Definition: l2_input.h:69
static void vl_api_bridge_domain_set_mac_age_t_handler(vl_api_bridge_domain_set_mac_age_t *mp)
Definition: l2_api.c:384
void l2fib_table_dump(u32 bd_index, l2fib_entry_key_t **l2fe_key, l2fib_entry_result_t **l2fe_res)
Definition: l2_fib.c:75
L2 interface pbb tag rewrite configure request.
Definition: l2.api:368
l2learn_main_t l2learn_main
Definition: l2_learn.h:51
u32 sw_if_index
Definition: l2.api:198
#define vec_foreach(var, vec)
Vector iterator.
Set bridge flags (such as L2_LEARN, L2_FWD, L2_FLOOD, L2_UU_FLOOD, or L2_ARP_TERM bits) request...
Definition: l2.api:315
vl_api_bridge_domain_sw_if_t sw_if_details[n_sw_ifs]
Definition: l2.api:304
u32 sw_if_index
Definition: l2_bd.h:46
u32 bd_find_index(bd_main_t *bdm, u32 bd_id)
Get a bridge domain.
Definition: l2_bd.c:67
static void 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)
Definition: l2_api.c:433
u32 flags
Definition: vhost-user.h:77
bd_main_t bd_main
Definition: l2_bd.c:44
vpe_api_main_t vpe_api_main
Definition: interface_api.c:49
#define L2_LEARN
Definition: l2_bd.h:129
u32 client_pid
Definition: l2_learn.h:38
void l2fib_flush_int_mac(vlib_main_t *vm, u32 sw_if_index)
Flush all non static MACs from an interface.
Definition: l2_fib.c:780
static void vl_api_l2fib_flush_int_t_handler(vl_api_l2fib_flush_int_t *mp)
Definition: l2_api.c:298
static void vl_api_l2_interface_pbb_tag_rewrite_t_handler(vl_api_l2_interface_pbb_tag_rewrite_t *mp)
Definition: l2_api.c:595
#define L2LEARN_DEFAULT_LIMIT
Definition: l2_learn.h:49
static void send_l2fib_table_entry(vpe_api_main_t *am, unix_shared_memory_queue_t *q, l2fib_entry_key_t *l2fe_key, l2fib_entry_result_t *l2fe_res, u32 context)
Definition: l2_api.c:122
#define VALIDATE_SW_IF_INDEX(mp)
struct _unix_shared_memory_queue unix_shared_memory_queue_t
static void vl_api_bridge_domain_dump_t_handler(vl_api_bridge_domain_dump_t *mp)
Definition: l2_api.c:479
L2 bridge domain add or delete request.
Definition: l2.api:241