FD.io VPP  v21.10.1-2-g0a485f517
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 #include <vnet/l2/l2_bd.h>
30 #include <vnet/l2/l2_bvi.h>
31 #include <vnet/l2/l2_arp_term.h>
32 #include <vnet/ip/ip_types_api.h>
34 
35 #include <vnet/format_fns.h>
36 #include <vnet/l2/l2.api_enum.h>
37 #include <vnet/l2/l2.api_types.h>
38 
39 #define REPLY_MSG_ID_BASE l2input_main.msg_id_base
41 
42 static void
44  u32 rx_sw_if_index, u32 tx_sw_if_index)
45 {
47 
48  mp = vl_msg_api_alloc (sizeof (*mp));
49  clib_memset (mp, 0, sizeof (*mp));
50  mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_L2_XCONNECT_DETAILS);
51  mp->context = context;
52  mp->rx_sw_if_index = htonl (rx_sw_if_index);
53  mp->tx_sw_if_index = htonl (tx_sw_if_index);
54 
55  vl_api_send_msg (reg, (u8 *) mp);
56 }
57 
58 static void
60 {
64  l2_input_config_t *config;
65 
67  if (!reg)
68  return;
69 
70  /* *INDENT-OFF* */
72  {
73  config = vec_elt_at_index (l2im->configs, sw_if_index);
74  if (l2_input_is_xconnect (config))
76  config->output_sw_if_index);
77  }
78  /* *INDENT-ON* */
79 }
80 
81 static void
83 {
84  int rv = 0;
85  vl_api_l2_fib_clear_table_reply_t *rmp;
86 
87  /* Clear all MACs including static MACs */
89 
90  REPLY_MACRO (VL_API_L2_FIB_CLEAR_TABLE_REPLY);
91 }
92 
93 static void
96  l2fib_entry_key_t * l2fe_key,
97  l2fib_entry_result_t * l2fe_res, u32 context)
98 {
100 
101  mp = vl_msg_api_alloc (sizeof (*mp));
102  clib_memset (mp, 0, sizeof (*mp));
103  mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_L2_FIB_TABLE_DETAILS);
104 
105  mp->bd_id =
106  ntohl (l2input_main.bd_configs[l2fe_key->fields.bd_index].bd_id);
107 
108  mac_address_encode ((mac_address_t *) l2fe_key->fields.mac, mp->mac);
109  mp->sw_if_index = ntohl (l2fe_res->fields.sw_if_index);
110  mp->static_mac = (l2fib_entry_result_is_set_STATIC (l2fe_res) ? 1 : 0);
111  mp->filter_mac = (l2fib_entry_result_is_set_FILTER (l2fe_res) ? 1 : 0);
112  mp->bvi_mac = (l2fib_entry_result_is_set_BVI (l2fe_res) ? 1 : 0);
113  mp->context = context;
114 
115  vl_api_send_msg (reg, (u8 *) mp);
116 }
117 
118 static void
120 {
122  bd_main_t *bdm = &bd_main;
123  l2fib_entry_key_t *l2fe_key = NULL;
124  l2fib_entry_result_t *l2fe_res = NULL;
125  u32 ni, bd_id = ntohl (mp->bd_id);
126  u32 bd_index;
128  uword *p;
129 
131  if (!reg)
132  return;
133 
134  /* see l2fib_table_dump: ~0 means "any" */
135  if (bd_id == ~0)
136  bd_index = ~0;
137  else
138  {
139  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
140  if (p == 0)
141  return;
142 
143  bd_index = p[0];
144  }
145 
146  l2fib_table_dump (bd_index, &l2fe_key, &l2fe_res);
147 
148  vec_foreach_index (ni, l2fe_key)
149  {
150  send_l2fib_table_entry (am, reg, vec_elt_at_index (l2fe_key, ni),
151  vec_elt_at_index (l2fe_res, ni), mp->context);
152  }
153  vec_free (l2fe_key);
154  vec_free (l2fe_res);
155 }
156 
157 static void
159 {
160  bd_main_t *bdm = &bd_main;
161  l2input_main_t *l2im = &l2input_main;
162  vl_api_l2fib_add_del_reply_t *rmp;
163  int rv = 0;
164  u32 bd_id = ntohl (mp->bd_id);
165  uword *p = hash_get (bdm->bd_index_by_bd_id, bd_id);
166 
167  if (!p)
168  {
169  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
170  goto bad_sw_if_index;
171  }
172  u32 bd_index = p[0];
173 
175 
176  mac_address_decode (mp->mac, &mac);
177  if (mp->is_add)
178  {
179  if (mp->filter_mac)
180  l2fib_add_filter_entry (mac.bytes, bd_index);
181  else
182  {
184  u32 sw_if_index = ntohl (mp->sw_if_index);
186  if (vec_len (l2im->configs) <= sw_if_index)
187  {
188  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
189  goto bad_sw_if_index;
190  }
191  else
192  {
193  l2_input_config_t *config;
194  config = vec_elt_at_index (l2im->configs, sw_if_index);
195  if (!l2_input_is_bridge (config))
196  {
197  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
198  goto bad_sw_if_index;
199  }
200  }
201  if (mp->static_mac)
202  flags |= L2FIB_ENTRY_RESULT_FLAG_STATIC;
203  if (mp->bvi_mac)
204  flags |= L2FIB_ENTRY_RESULT_FLAG_BVI;
205  l2fib_add_entry (mac.bytes, bd_index, sw_if_index, flags);
206  }
207  }
208  else
209  {
210  u32 sw_if_index = ntohl (mp->sw_if_index);
211  if (l2fib_del_entry (mac.bytes, bd_index, sw_if_index))
212  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
213  }
214 
216 
217  REPLY_MACRO (VL_API_L2FIB_ADD_DEL_REPLY);
218 }
219 
220 static void
222 {
223  int rv = 0;
224  vl_api_want_l2_macs_events2_reply_t *rmp;
227  u32 pid = ntohl (mp->pid);
228 
229  if (mp->enable_disable)
230  {
231  if ((lm->client_pid == 0) || (lm->client_pid == pid))
232  {
233  if (mp->max_macs_in_event)
234  fm->max_macs_in_event = mp->max_macs_in_event * 10;
235  else
236  {
237  rv = VNET_API_ERROR_INVALID_VALUE;
238  goto exit;
239  }
240 
241  /* if scan_delay was not set before */
242  if (fm->event_scan_delay == 0.0)
243  fm->event_scan_delay = (f64) (10) * 10e-3;
244 
245  lm->client_pid = pid;
246  lm->client_index = mp->client_index;
248  }
249  else if (lm->client_pid != pid)
250  {
251  rv = VNET_API_ERROR_L2_MACS_EVENT_CLINET_PRESENT;
252  goto exit;
253  }
254  }
255  else if (lm->client_pid)
256  {
257  lm->client_pid = 0;
258  lm->client_index = 0;
259  }
260 
261 exit:
262  REPLY_MACRO (VL_API_WANT_L2_MACS_EVENTS2_REPLY);
263 }
264 
265 static void
267 {
268  int rv = 0;
269  vl_api_want_l2_macs_events_reply_t *rmp;
272  u32 pid = ntohl (mp->pid);
273  u32 learn_limit = ntohl (mp->learn_limit);
274 
275  if (mp->enable_disable)
276  {
277  if ((lm->client_pid == 0) || (lm->client_pid == pid))
278  {
279  if ((mp->max_macs_in_event == 0) || (mp->scan_delay == 0) ||
280  (learn_limit == 0) || (learn_limit > L2LEARN_DEFAULT_LIMIT))
281  {
282  rv = VNET_API_ERROR_INVALID_VALUE;
283  goto exit;
284  }
285  lm->client_pid = pid;
286  lm->client_index = mp->client_index;
287 
288  fm->max_macs_in_event = mp->max_macs_in_event * 10;
289  fm->event_scan_delay = (f64) (mp->scan_delay) * 10e-3;
290 
291  /* change learn limit and flush all learned MACs */
292  lm->global_learn_limit = learn_limit;
294  }
295  else if (lm->client_pid != pid)
296  {
297  rv = VNET_API_ERROR_L2_MACS_EVENT_CLINET_PRESENT;
298  goto exit;
299  }
300  }
301  else if (lm->client_pid)
302  {
303  lm->client_pid = 0;
304  lm->client_index = 0;
305  if (learn_limit && (learn_limit <= L2LEARN_DEFAULT_LIMIT))
306  lm->global_learn_limit = learn_limit;
307  else
309  }
310 
311 exit:
312  REPLY_MACRO (VL_API_WANT_L2_MACS_EVENTS_REPLY);
313 }
314 
315 static void
317 {
318  int rv = 0;
320  vl_api_l2fib_flush_int_reply_t *rmp;
321 
323 
324  u32 sw_if_index = ntohl (mp->sw_if_index);
326 
328  REPLY_MACRO (VL_API_L2FIB_FLUSH_INT_REPLY);
329 }
330 
331 static void
333 {
334  int rv = 0;
335  vl_api_l2fib_flush_all_reply_t *rmp;
336 
338  REPLY_MACRO (VL_API_L2FIB_FLUSH_ALL_REPLY);
339 }
340 
341 static void
343 {
344  int rv = 0;
346  bd_main_t *bdm = &bd_main;
347  vl_api_l2fib_flush_bd_reply_t *rmp;
348 
349  u32 bd_id = ntohl (mp->bd_id);
350  uword *p = hash_get (bdm->bd_index_by_bd_id, bd_id);
351  if (p == 0)
352  {
353  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
354  goto out;
355  }
356  l2fib_flush_bd_mac (vm, *p);
357 out:
358  REPLY_MACRO (VL_API_L2FIB_FLUSH_BD_REPLY);
359 }
360 
361 static void
363 {
364  int rv = 0;
366  vl_api_l2fib_set_scan_delay_reply_t *rmp;
367  u16 scan_delay = ntohs (mp->scan_delay);
368 
369  if (mp->scan_delay)
370  {
371  fm->event_scan_delay = (f64) (scan_delay) *10e-3;
373  }
374  else
375  {
376  rv = VNET_API_ERROR_INVALID_VALUE;
377  goto exit;
378  }
379 
380 exit:
381  REPLY_MACRO (VL_API_L2FIB_SET_SCAN_DELAY_REPLY);
382 }
383 
384 static void
386 {
388  int rv = 0;
389  u32 rbm = 0;
390 
392 
393  u32 sw_if_index = ntohl (mp->sw_if_index);
394  u32 flags = ntohl (mp->feature_bitmap);
395  u32 bitmap = 0;
396 
397  if (flags & L2_LEARN)
398  bitmap |= L2INPUT_FEAT_LEARN;
399 
400  if (flags & L2_FWD)
401  bitmap |= L2INPUT_FEAT_FWD;
402 
403  if (flags & L2_FLOOD)
404  bitmap |= L2INPUT_FEAT_FLOOD;
405 
406  if (flags & L2_UU_FLOOD)
407  bitmap |= L2INPUT_FEAT_UU_FLOOD;
408 
409  if (flags & L2_ARP_TERM)
410  bitmap |= L2INPUT_FEAT_ARP_TERM;
411 
412  rbm = l2input_intf_bitmap_enable (sw_if_index, bitmap, mp->is_set);
413 
415 
416  /* *INDENT-OFF* */
417  REPLY_MACRO2(VL_API_L2_FLAGS_REPLY,
418  ({
419  rmp->resulting_feature_bitmap = ntohl(rbm);
420  }));
421  /* *INDENT-ON* */
422 }
423 
424 static void
427 {
428  vl_api_bridge_domain_set_default_learn_limit_reply_t *rmp;
429  int rv = 0;
430 
432  REPLY_MACRO (VL_API_BRIDGE_DOMAIN_SET_DEFAULT_LEARN_LIMIT_REPLY);
433 }
434 
435 static void
438 {
440  bd_main_t *bdm = &bd_main;
441  vl_api_bridge_domain_set_learn_limit_reply_t *rmp;
442  int rv = 0;
443  u32 bd_id = ntohl (mp->bd_id);
444  uword *p;
445 
446  if (bd_id == 0)
447  {
448  rv = VNET_API_ERROR_BD_NOT_MODIFIABLE;
449  goto out;
450  }
451 
452  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
453  if (p == 0)
454  {
455  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
456  goto out;
457  }
458  bd_set_learn_limit (vm, *p, ntohl (mp->learn_limit));
459 out:
460  REPLY_MACRO (VL_API_BRIDGE_DOMAIN_SET_LEARN_LIMIT_REPLY);
461 }
462 
463 static void
465  * mp)
466 {
468  bd_main_t *bdm = &bd_main;
469  vl_api_bridge_domain_set_mac_age_reply_t *rmp;
470  int rv = 0;
471  u32 bd_id = ntohl (mp->bd_id);
472  uword *p;
473 
474  if (bd_id == 0)
475  {
476  rv = VNET_API_ERROR_BD_NOT_MODIFIABLE;
477  goto out;
478  }
479 
480  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
481  if (p == 0)
482  {
483  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
484  goto out;
485  }
486  bd_set_mac_age (vm, *p, mp->mac_age);
487 out:
488  REPLY_MACRO (VL_API_BRIDGE_DOMAIN_SET_MAC_AGE_REPLY);
489 }
490 
491 static void
493 {
495  .is_add = mp->is_add,
496  .flood = mp->flood,
497  .uu_flood = mp->uu_flood,
498  .forward = mp->forward,
499  .learn = mp->learn,
500  .arp_term = mp->arp_term,
501  .arp_ufwd = mp->arp_ufwd,
502  .mac_age = mp->mac_age,
503  .bd_id = ntohl (mp->bd_id),
504  .bd_tag = mp->bd_tag
505  };
506 
507  int rv = bd_add_del (&a);
508 
509  vl_api_bridge_domain_add_del_reply_t *rmp;
510  REPLY_MACRO (VL_API_BRIDGE_DOMAIN_ADD_DEL_REPLY);
511 }
512 
513 static void
515  vl_api_registration_t * reg,
516  l2_bridge_domain_t * bd_config,
517  u32 n_sw_ifs, u32 context)
518 {
521  vl_api_bridge_domain_sw_if_t *sw_ifs;
522  l2_input_config_t *input_cfg;
523 
524  mp = vl_msg_api_alloc (sizeof (*mp) +
525  (n_sw_ifs * sizeof (vl_api_bridge_domain_sw_if_t)));
526  clib_memset (mp, 0, sizeof (*mp));
527  mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_BRIDGE_DOMAIN_DETAILS);
528  mp->bd_id = ntohl (bd_config->bd_id);
529  mp->flood = bd_feature_flood (bd_config);
530  mp->uu_flood = bd_feature_uu_flood (bd_config);
531  mp->forward = bd_feature_forward (bd_config);
532  mp->learn = bd_feature_learn (bd_config);
533  mp->arp_term = bd_feature_arp_term (bd_config);
534  mp->arp_ufwd = bd_feature_arp_ufwd (bd_config);
535  mp->bvi_sw_if_index = ntohl (bd_config->bvi_sw_if_index);
536  mp->uu_fwd_sw_if_index = ntohl (bd_config->uu_fwd_sw_if_index);
537  mp->mac_age = bd_config->mac_age;
538  if (bd_config->bd_tag)
539  {
540  strncpy ((char *) mp->bd_tag, (char *) bd_config->bd_tag,
541  ARRAY_LEN (mp->bd_tag) - 1);
542  mp->bd_tag[ARRAY_LEN (mp->bd_tag) - 1] = 0;
543  }
544 
545  mp->context = context;
546 
547  sw_ifs = (vl_api_bridge_domain_sw_if_t *) mp->sw_if_details;
548  vec_foreach (m, bd_config->members)
549  {
550  sw_ifs->sw_if_index = ntohl (m->sw_if_index);
551  input_cfg = vec_elt_at_index (l2im->configs, m->sw_if_index);
552  sw_ifs->shg = input_cfg->shg;
553  sw_ifs++;
554  mp->n_sw_ifs++;
555  }
556  mp->n_sw_ifs = htonl (mp->n_sw_ifs);
557 
558  vl_api_send_msg (reg, (u8 *) mp);
559 }
560 
561 static void
563 {
564  bd_main_t *bdm = &bd_main;
565  l2input_main_t *l2im = &l2input_main;
567  u32 bd_id, bd_index, end, filter_sw_if_index;
568 
570  if (!reg)
571  return;
572 
573  filter_sw_if_index = ntohl (mp->sw_if_index);
574  if (filter_sw_if_index != ~0)
575  return; /* UNIMPLEMENTED */
576 
577  bd_id = ntohl (mp->bd_id);
578  if (bd_id == 0)
579  return;
580 
581  if (bd_id == ~0)
582  bd_index = 0, end = vec_len (l2im->bd_configs);
583  else
584  {
585  bd_index = bd_find_index (bdm, bd_id);
586  if (bd_index == ~0)
587  return;
588 
589  end = bd_index + 1;
590  }
591 
592  for (; bd_index < end; bd_index++)
593  {
594  l2_bridge_domain_t *bd_config =
595  l2input_bd_config_from_index (l2im, bd_index);
596  /* skip placeholder bd_id 0 */
597  if (bd_config && (bd_config->bd_id > 0))
598  send_bridge_domain_details (l2im, reg, bd_config,
599  vec_len (bd_config->members),
600  mp->context);
601  }
602 }
603 
604 static bd_flags_t
605 bd_flags_decode (vl_api_bd_flags_t v)
606 {
607  bd_flags_t f = L2_NONE;
608 
609  v = ntohl (v);
610 
611  if (v & BRIDGE_API_FLAG_LEARN)
612  f |= L2_LEARN;
613  if (v & BRIDGE_API_FLAG_FWD)
614  f |= L2_FWD;
615  if (v & BRIDGE_API_FLAG_FLOOD)
616  f |= L2_FLOOD;
617  if (v & BRIDGE_API_FLAG_UU_FLOOD)
618  f |= L2_UU_FLOOD;
619  if (v & BRIDGE_API_FLAG_ARP_TERM)
620  f |= L2_ARP_TERM;
621  if (v & BRIDGE_API_FLAG_ARP_UFWD)
622  f |= L2_ARP_UFWD;
623 
624  return (f);
625 }
626 
627 static void
629 {
631  bd_main_t *bdm = &bd_main;
633  u32 bitmap = 0;
634  int rv = 0;
635 
637  u32 bd_id = ntohl (mp->bd_id);
638  if (bd_id == 0)
639  {
640  rv = VNET_API_ERROR_BD_NOT_MODIFIABLE;
641  goto out;
642  }
643 
644  u32 bd_index = bd_find_index (bdm, bd_id);
645  if (bd_index == ~0)
646  {
647  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
648  goto out;
649  }
650 
651  bitmap = bd_set_flags (vm, bd_index, flags, mp->is_set);
652 
653 out:
654  /* *INDENT-OFF* */
655  REPLY_MACRO2(VL_API_BRIDGE_FLAGS_REPLY,
656  ({
657  rmp->resulting_feature_bitmap = ntohl(bitmap);
658  }));
659  /* *INDENT-ON* */
660 }
661 
662 static void
665 {
666  int rv = 0;
667  vl_api_l2_interface_vlan_tag_rewrite_reply_t *rmp;
668  vnet_main_t *vnm = vnet_get_main ();
670  u32 vtr_op;
671 
673 
674  vtr_op = ntohl (mp->vtr_op);
675 
676  /* The L2 code is unsuspicious */
677  switch (vtr_op)
678  {
679  case L2_VTR_DISABLED:
680  case L2_VTR_PUSH_1:
681  case L2_VTR_PUSH_2:
682  case L2_VTR_POP_1:
683  case L2_VTR_POP_2:
688  break;
689 
690  default:
691  rv = VNET_API_ERROR_INVALID_VALUE;
692  goto bad_sw_if_index;
693  }
694 
695  rv = l2vtr_configure (vm, vnm, ntohl (mp->sw_if_index), vtr_op,
696  ntohl (mp->push_dot1q), ntohl (mp->tag1),
697  ntohl (mp->tag2));
698 
700 
701  REPLY_MACRO (VL_API_L2_INTERFACE_VLAN_TAG_REWRITE_REPLY);
702 }
703 
704 static void
707 {
708  vl_api_l2_interface_pbb_tag_rewrite_reply_t *rmp;
709  vnet_main_t *vnm = vnet_get_main ();
711  u32 vtr_op;
712  int rv = 0;
713  mac_address_t b_dmac, b_smac;
714 
716 
717  vtr_op = ntohl (mp->vtr_op);
718 
719  switch (vtr_op)
720  {
721  case L2_VTR_DISABLED:
722  case L2_VTR_PUSH_2:
723  case L2_VTR_POP_2:
725  break;
726 
727  default:
728  rv = VNET_API_ERROR_INVALID_VALUE;
729  goto bad_sw_if_index;
730  }
731 
732  mac_address_decode (mp->b_dmac, &b_dmac);
733  mac_address_decode (mp->b_smac, &b_smac);
734 
735  rv = l2pbb_configure (vm, vnm, ntohl (mp->sw_if_index), vtr_op,
736  b_dmac.bytes, b_smac.bytes, ntohs (mp->b_vlanid),
737  ntohl (mp->i_sid), ntohs (mp->outer_tag));
738 
740 
741  REPLY_MACRO (VL_API_L2_INTERFACE_PBB_TAG_REWRITE_REPLY);
742 }
743 
744 static void
747 {
748  vl_api_sw_interface_set_l2_xconnect_reply_t *rmp;
749  int rv = 0;
750  u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index);
751  u32 tx_sw_if_index = ntohl (mp->tx_sw_if_index);
753  vnet_main_t *vnm = vnet_get_main ();
754 
756 
757  if (mp->enable)
758  {
760  rv = set_int_l2_mode (vm, vnm, MODE_L2_XC,
761  rx_sw_if_index, 0,
763  }
764  else
765  {
766  rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0,
767  L2_BD_PORT_TYPE_NORMAL, 0, 0);
768  }
769 
770  switch (rv)
771  {
772  case MODE_ERROR_ETH:
773  rv = VNET_API_ERROR_NON_ETHERNET;
774  break;
775  case MODE_ERROR_BVI_DEF:
776  rv = VNET_API_ERROR_BD_ALREADY_HAS_BVI;
777  break;
778  }
779 
782 
783  REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_XCONNECT_REPLY);
784 }
785 
786 static int
787 l2_bd_port_type_decode (vl_api_l2_port_type_t v, l2_bd_port_type_t * l)
788 {
789  v = clib_net_to_host_u32 (v);
790 
791  switch (v)
792  {
795  return 0;
797  *l = L2_BD_PORT_TYPE_BVI;
798  return 0;
801  return 0;
802  }
803 
804  return (VNET_API_ERROR_INVALID_VALUE);
805 }
806 
807 static void
810 {
811  bd_main_t *bdm = &bd_main;
812  vl_api_sw_interface_set_l2_bridge_reply_t *rmp;
813  int rv = 0;
815  vnet_main_t *vnm = vnet_get_main ();
817 
819  u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index);
820  rv = l2_bd_port_type_decode (mp->port_type, &pt);
821 
822  if (0 != rv)
823  goto out;
824  if (mp->enable)
825  {
826  VALIDATE_BD_ID (mp);
827  u32 bd_id = ntohl (mp->bd_id);
828  u32 bd_index = bd_find_or_add_bd_index (bdm, bd_id);
829 
831  rx_sw_if_index, bd_index, pt, mp->shg, 0);
832  }
833  else
834  {
835  rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, pt, 0, 0);
836  }
837 
838  switch (rv)
839  {
840  case MODE_ERROR_ETH:
841  rv = VNET_API_ERROR_NON_ETHERNET;
842  break;
843  case MODE_ERROR_BVI_DEF:
844  rv = VNET_API_ERROR_BD_ALREADY_HAS_BVI;
845  break;
846  }
847 
850 out:
851  REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_BRIDGE_REPLY);
852 }
853 
854 static void
856  vl_api_registration_t * reg,
857  u32 bd_id,
858  const ip46_address_t * ip,
859  ip46_type_t itype,
860  const mac_address_t * mac, u32 context)
861 {
863 
864  mp = vl_msg_api_alloc (sizeof (*mp));
865  clib_memset (mp, 0, sizeof (*mp));
866  mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_BD_IP_MAC_DETAILS);
867 
868  mp->context = context;
869  mp->entry.bd_id = ntohl (bd_id);
870 
871  ip_address_encode (ip, itype, &mp->entry.ip);
872  mac_address_encode (mac, mp->entry.mac);
873 
874  vl_api_send_msg (reg, (u8 *) mp);
875 }
876 
877 static void
879 {
881  bd_main_t *bdm = &bd_main;
882  l2_bridge_domain_t *bd_config;
883  u32 bd_id = ntohl (mp->bd_id);
884  u32 bd_index, start, end;
886  uword *p;
887 
889  if (!reg)
890  return;
891 
892  /* see bd_id: ~0 means "any" */
893  if (bd_id == ~0)
894  {
895  start = 1;
897  }
898  else
899  {
900  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
901  if (p == 0)
902  return;
903 
904  bd_index = p[0];
906  start = bd_index;
907  end = start + 1;
908  }
909 
910  for (bd_index = start; bd_index < end; bd_index++)
911  {
912  bd_config = vec_elt_at_index (l2input_main.bd_configs, bd_index);
913  if (bd_is_valid (bd_config))
914  {
915  ip4_address_t ip4_addr;
916  ip6_address_t *ip6_addr;
918  u64 mac64;
919  bd_id = bd_config->bd_id;
920 
921  /* *INDENT-OFF* */
922  hash_foreach (ip4_addr.as_u32, mac64, bd_config->mac_by_ip4,
923  ({
924  ip46_address_t ip = {
925  .ip4 = ip4_addr,
926  };
927  mac_address_from_u64(&mac, mac64);
928 
930  &mac, mp->context);
931  }));
932 
933  hash_foreach_mem (ip6_addr, mac64, bd_config->mac_by_ip6,
934  ({
935  ip46_address_t ip = {
936  .ip6 = *ip6_addr,
937  };
938  mac_address_from_u64(&mac, mac64);
939 
941  &mac, mp->context);
942  }));
943  /* *INDENT-ON* */
944  }
945  }
946 }
947 
948 static void
950 {
951  ip46_address_t ip_addr = ip46_address_initializer;
952  vl_api_bd_ip_mac_add_del_reply_t *rmp;
953  bd_main_t *bdm = &bd_main;
954  u32 bd_index, bd_id;
957  int rv = 0;
958  uword *p;
959 
960  bd_id = ntohl (mp->entry.bd_id);
961 
962  if (bd_id == 0)
963  {
964  rv = VNET_API_ERROR_BD_NOT_MODIFIABLE;
965  goto out;
966  }
967 
968  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
969  if (p == 0)
970  {
971  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
972  goto out;
973  }
974  bd_index = p[0];
975 
976  type = ip_address_decode (&mp->entry.ip, &ip_addr);
977  mac_address_decode (mp->entry.mac, &mac);
978 
979  if (bd_add_del_ip_mac (bd_index, type, &ip_addr, &mac, mp->is_add))
980  rv = VNET_API_ERROR_UNSPECIFIED;
981 
982 out:
983  REPLY_MACRO (VL_API_BD_IP_MAC_ADD_DEL_REPLY);
984 }
985 
986 static void
988 {
989  vl_api_bd_ip_mac_flush_reply_t *rmp;
990  bd_main_t *bdm = &bd_main;
991  u32 bd_index, bd_id;
992  int rv = 0;
993  uword *p;
994 
995  bd_id = ntohl (mp->bd_id);
996 
997  if (bd_id == 0)
998  {
999  rv = VNET_API_ERROR_BD_NOT_MODIFIABLE;
1000  goto out;
1001  }
1002 
1003  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
1004  if (p == 0)
1005  {
1006  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
1007  goto out;
1008  }
1009  bd_index = p[0];
1010 
1011  bd_flush_ip_mac (bd_index);
1012 
1013 out:
1014  REPLY_MACRO (VL_API_BD_IP_MAC_FLUSH_REPLY);
1015 }
1016 
1018  u32 sw_if_index, u8 enable);
1019 
1020 static void
1022  mp)
1023 {
1024  int rv;
1025  vl_api_l2_interface_efp_filter_reply_t *rmp;
1026  vnet_main_t *vnm = vnet_get_main ();
1027 
1028  VALIDATE_SW_IF_INDEX (mp);
1029 
1030  // enable/disable the feature
1031  l2_efp_filter_configure (vnm, ntohl (mp->sw_if_index), mp->enable_disable);
1032  rv = vnm->api_errno;
1033 
1035  REPLY_MACRO (VL_API_L2_INTERFACE_EFP_FILTER_REPLY);
1036 }
1037 
1038 static void
1040 {
1041  extern int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index,
1042  int is_add);
1043  vl_api_l2_patch_add_del_reply_t *rmp;
1044  int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index,
1045  int is_add);
1046  int rv = 0;
1047 
1050 
1051  rv = vnet_l2_patch_add_del (ntohl (mp->rx_sw_if_index),
1052  ntohl (mp->tx_sw_if_index),
1053  (int) (mp->is_add != 0));
1054 
1057 
1058  REPLY_MACRO (VL_API_L2_PATCH_ADD_DEL_REPLY);
1059 }
1060 
1061 static void
1063 {
1064  vl_api_sw_interface_set_vpath_reply_t *rmp;
1065  int rv = 0;
1066  u32 sw_if_index = ntohl (mp->sw_if_index);
1067 
1068  VALIDATE_SW_IF_INDEX (mp);
1069 
1070  l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_VPATH, mp->enable);
1071  vnet_feature_enable_disable ("ip4-unicast", "vpath-input-ip4",
1072  sw_if_index, mp->enable, 0, 0);
1073  vnet_feature_enable_disable ("ip4-multicast", "vpath-input-ip4",
1074  sw_if_index, mp->enable, 0, 0);
1075  vnet_feature_enable_disable ("ip6-unicast", "vpath-input-ip6",
1076  sw_if_index, mp->enable, 0, 0);
1077  vnet_feature_enable_disable ("ip6-multicast", "vpath-input-ip6",
1078  sw_if_index, mp->enable, 0, 0);
1079 
1081 
1082  REPLY_MACRO (VL_API_SW_INTERFACE_SET_VPATH_REPLY);
1083 }
1084 
1085 static void
1087 {
1090  u32 sw_if_index;
1091  int rv;
1092 
1093  mac_address_decode (mp->mac, &mac);
1094 
1095  rv = l2_bvi_create (ntohl (mp->user_instance), &mac, &sw_if_index);
1096 
1097  /* *INDENT-OFF* */
1098  REPLY_MACRO2(VL_API_BVI_CREATE_REPLY,
1099  ({
1100  rmp->sw_if_index = ntohl (sw_if_index);
1101  }));
1102  /* *INDENT-ON* */
1103 }
1104 
1105 static void
1107 {
1108  vl_api_bvi_delete_reply_t *rmp;
1109  int rv;
1110 
1111  rv = l2_bvi_delete (ntohl (mp->sw_if_index));
1112 
1113  REPLY_MACRO (VL_API_BVI_DELETE_REPLY);
1114 }
1115 
1116 static bool
1118  const l2_arp_term_publish_event_t * e2)
1119 {
1120  if (e1 == NULL || e2 == NULL)
1121  return false;
1122  return (ip46_address_is_equal (&e1->ip, &e2->ip) &&
1123  (e1->sw_if_index == e2->sw_if_index) &&
1124  (mac_address_equal (&e1->mac, &e2->mac)));
1125 }
1126 
1127 static uword
1129  vlib_frame_t * f)
1130 {
1131  /* These cross the longjmp boundary (vlib_process_wait_for_event)
1132  * and need to be volatile - to prevent them from being optimized into
1133  * a register - which could change during suspension */
1134  volatile f64 last = vlib_time_now (vm);
1135  volatile l2_arp_term_publish_event_t last_event = { };
1136 
1138 
1139  while (1)
1140  {
1141  uword event_type = L2_ARP_TERM_EVENT_PUBLISH;
1143  f64 now;
1144 
1146 
1147  vlib_process_get_event_data (vm, &event_type);
1148  now = vlib_time_now (vm);
1149 
1150  if (event_type == L2_ARP_TERM_EVENT_PUBLISH)
1151  {
1153 
1154  vec_foreach (event, l2am->publish_events)
1155  {
1156  /* dampen duplicate events - cast away volatile */
1158  (event, (l2_arp_term_publish_event_t *) & last_event) &&
1159  (now - last) < 10.0)
1160  {
1161  continue;
1162  }
1163  last_event = *event;
1164  last = now;
1165 
1166  pool_foreach (reg, vpe_api_main.l2_arp_term_events_registrations)
1167  {
1168  vl_api_registration_t *vl_reg;
1169  vl_reg =
1171  ALWAYS_ASSERT (vl_reg != NULL);
1172 
1173  if (vl_reg && vl_api_can_send_msg (vl_reg))
1174  {
1176  vevent = vl_msg_api_alloc (sizeof *vevent);
1177  clib_memset (vevent, 0, sizeof *vevent);
1178  vevent->_vl_msg_id =
1179  htons (REPLY_MSG_ID_BASE + VL_API_L2_ARP_TERM_EVENT);
1180  vevent->client_index = reg->client_index;
1181  vevent->pid = reg->client_pid;
1182  ip_address_encode (&event->ip, event->type, &vevent->ip);
1183  vevent->sw_if_index = htonl (event->sw_if_index);
1184  mac_address_encode (&event->mac, vevent->mac);
1185  vl_api_send_msg (vl_reg, (u8 *) vevent);
1186  }
1187  }
1188  }
1190  }
1191  }
1192 
1193  return 0;
1194 }
1195 
1196 /* *INDENT-OFF* */
1198  .function = l2_arp_term_process,
1199  .type = VLIB_NODE_TYPE_PROCESS,
1200  .name = "l2-arp-term-publisher",
1201 };
1202 /* *INDENT-ON* */
1203 
1204 static void
1206  mp)
1207 {
1208  vl_api_want_l2_arp_term_events_reply_t *rmp;
1211  int rv = 0;
1212  uword *p;
1213 
1214  p = hash_get (am->l2_arp_term_events_registration_hash, mp->client_index);
1215 
1216  if (p)
1217  {
1218  if (mp->enable)
1219  {
1220  clib_warning ("pid %d: already enabled...", mp->pid);
1221  rv = VNET_API_ERROR_INVALID_REGISTRATION;
1222  goto reply;
1223  }
1224  else
1225  {
1226  rp = pool_elt_at_index (am->l2_arp_term_events_registrations, p[0]);
1227  pool_put (am->l2_arp_term_events_registrations, rp);
1228  hash_unset (am->l2_arp_term_events_registration_hash,
1229  mp->client_index);
1230  if (pool_elts (am->l2_arp_term_events_registrations) == 0)
1232  goto reply;
1233  }
1234  }
1235  if (mp->enable == 0)
1236  {
1237  clib_warning ("pid %d: already disabled...", mp->pid);
1238  rv = VNET_API_ERROR_INVALID_REGISTRATION;
1239  goto reply;
1240  }
1241  pool_get (am->l2_arp_term_events_registrations, rp);
1242  rp->client_index = mp->client_index;
1243  rp->client_pid = mp->pid;
1244  hash_set (am->l2_arp_term_events_registration_hash, rp->client_index,
1245  rp - am->l2_arp_term_events_registrations);
1247 
1248 reply:
1249  REPLY_MACRO (VL_API_WANT_L2_ARP_TERM_EVENTS_REPLY);
1250 }
1251 
1252 static clib_error_t *
1254 {
1256  vpe_api_main_t *am;
1257  uword *p;
1258 
1259  am = &vpe_api_main;
1260 
1261  /* remove from the registration hash */
1262  p = hash_get (am->l2_arp_term_events_registration_hash, client_index);
1263 
1264  if (p)
1265  {
1266  rp = pool_elt_at_index (am->l2_arp_term_events_registrations, p[0]);
1267  pool_put (am->l2_arp_term_events_registrations, rp);
1268  hash_unset (am->l2_arp_term_events_registration_hash, client_index);
1269  if (pool_elts (am->l2_arp_term_events_registrations) == 0)
1271  }
1272  return (NULL);
1273 }
1274 
1276 
1277 #include <vnet/l2/l2.api.c>
1278 static clib_error_t *
1280 {
1282 
1283  /* Mark VL_API_BRIDGE_DOMAIN_DUMP as mp safe */
1284  am->is_mp_safe[VL_API_BRIDGE_DOMAIN_DUMP] = 1;
1285 
1286  /*
1287  * Set up the (msg_name, crc, message-id) table
1288  */
1290 
1291  return 0;
1292 }
1293 
1295 
1296 /*
1297  * fd.io coding-style-patch-verification: ON
1298  *
1299  * Local Variables:
1300  * eval: (c-set-style "gnu")
1301  * End:
1302  */
vec_reset_length
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Definition: vec_bootstrap.h:194
vl_api_l2_interface_vlan_tag_rewrite_t::push_dot1q
u32 push_dot1q
Definition: l2.api:448
l2fib_add_filter_entry
static void l2fib_add_filter_entry(const u8 *mac, u32 bd_index)
Definition: l2_fib.h:453
vl_api_sw_interface_set_l2_xconnect_t::tx_sw_if_index
vl_api_interface_index_t tx_sw_if_index
Definition: l2.api:506
l2fib_flush_int_mac
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:901
vl_api_l2fib_set_scan_delay_t_handler
static void vl_api_l2fib_set_scan_delay_t_handler(vl_api_l2fib_set_scan_delay_t *mp)
Definition: l2_api.c:362
vl_api_bd_ip_mac_details_t::context
u32 context
Definition: l2.api:589
vl_api_l2fib_add_del_t::filter_mac
bool filter_mac
Definition: l2.api:139
l2_bridge_domain_add_del_args_t
Definition: l2_bd.h:124
vl_api_want_l2_macs_events_t::client_index
u32 client_index
Definition: l2.api:155
l2_arp_term_publish_ctx_t_::mac
mac_address_t mac
Definition: l2_arp_term.h:26
vl_api_bridge_domain_add_del_t::arp_ufwd
bool arp_ufwd
Definition: l2.api:330
vl_api_bridge_domain_add_del_t_handler
static void vl_api_bridge_domain_add_del_t_handler(vl_api_bridge_domain_add_del_t *mp)
Definition: l2_api.c:492
L2_VTR_TRANSLATE_2_2
@ L2_VTR_TRANSLATE_2_2
Definition: l2_vtr.h:38
L2_FWD
@ L2_FWD
Definition: l2_bd.h:157
l2_bd_port_type_decode
static int l2_bd_port_type_decode(vl_api_l2_port_type_t v, l2_bd_port_type_t *l)
Definition: l2_api.c:787
VALIDATE_SW_IF_INDEX
#define VALIDATE_SW_IF_INDEX(mp)
Definition: api_helper_macros.h:281
vl_api_client_index_to_registration
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79
l2_bvi_create
int l2_bvi_create(u32 user_instance, const mac_address_t *mac_in, u32 *sw_if_indexp)
Definition: l2_bvi.c:136
api.h
vl_api_bridge_domain_add_del_t::is_add
bool is_add[default=true]
Definition: l2.api:333
send_l2_xconnect_details
static void send_l2_xconnect_details(vl_api_registration_t *reg, u32 context, u32 rx_sw_if_index, u32 tx_sw_if_index)
Definition: l2_api.c:43
vl_api_l2_fib_table_details_t::static_mac
bool static_mac
Definition: l2.api:59
l2_bridge_domain_t
Definition: l2_bd.h:63
mac
vl_api_mac_address_t mac
Definition: l2.api:559
hash_set
#define hash_set(h, key, value)
Definition: hash.h:255
vl_api_l2_interface_vlan_tag_rewrite_t
L2 interface vlan tag rewrite configure request.
Definition: l2.api:442
ntohs
#define ntohs(x)
Definition: af_xdp.bpf.c:29
vl_api_sw_interface_set_l2_bridge_t::shg
u8 shg
Definition: l2.api:542
vl_api_bd_ip_mac_dump_t::bd_id
u32 bd_id
Definition: l2.api:601
vl_api_bridge_domain_details_t::bvi_sw_if_index
vl_api_interface_index_t bvi_sw_if_index
Definition: l2.api:387
vl_api_l2_fib_clear_table_t
L2 fib clear table request, clear all mac entries in the l2 fib.
Definition: l2.api:79
BAD_RX_SW_IF_INDEX_LABEL
#define BAD_RX_SW_IF_INDEX_LABEL
Definition: api_helper_macros.h:303
vl_api_bridge_domain_details_t::arp_ufwd
bool arp_ufwd
Definition: l2.api:384
l2_input_config_t
Definition: l2_input.h:42
vl_api_bvi_create_t::user_instance
u32 user_instance[default=0xffffffff]
Definition: l2.api:643
vl_api_bridge_flags_t::bd_id
u32 bd_id
Definition: l2.api:416
vl_api_bridge_domain_details_t
L2 bridge domain operational state response.
Definition: l2.api:375
REPLY_MACRO2
#define REPLY_MACRO2(t, body)
Definition: api_helper_macros.h:65
vl_api_bridge_flags_reply_t
Set bridge flags response.
Definition: l2.api:426
BRIDGE_API_FLAG_UU_FLOOD
@ BRIDGE_API_FLAG_UU_FLOOD
Definition: l2.api:400
l2input_main
l2input_main_t l2input_main
Definition: l2_input_node.c:78
VALIDATE_TX_SW_IF_INDEX
#define VALIDATE_TX_SW_IF_INDEX(mp)
Definition: api_helper_macros.h:309
l2_arp_term_main_t_
Definition: l2_arp_term.h:34
l2input_main_t
Definition: l2_input.h:83
vl_api_send_msg
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:35
VLIB_API_INIT_FUNCTION
VLIB_API_INIT_FUNCTION(l2_api_hookup)
vl_api_bridge_domain_add_del_t::arp_term
bool arp_term
Definition: l2.api:329
vl_api_l2fib_flush_int_t_handler
static void vl_api_l2fib_flush_int_t_handler(vl_api_l2fib_flush_int_t *mp)
Definition: l2_api.c:316
l2_arp_term_main
l2_arp_term_main_t l2_arp_term_main
Definition: l2_arp_term.c:33
l2fib_entry_result_t_::fields
struct l2fib_entry_result_t_::@469::@471 fields
vl_api_bvi_create_reply_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: l2.api:655
vlib_process_wait_for_event
static uword * vlib_process_wait_for_event(vlib_main_t *vm)
Definition: node_funcs.h:660
vl_api_sw_interface_set_l2_xconnect_t::rx_sw_if_index
vl_api_interface_index_t rx_sw_if_index
Definition: l2.api:505
f
vlib_frame_t * f
Definition: interface_output.c:1098
vl_api_bridge_domain_details_t::sw_if_details
vl_api_bridge_domain_sw_if_t sw_if_details[n_sw_ifs]
Definition: l2.api:390
ip46_address_initializer
#define ip46_address_initializer
Definition: ip46_address.h:52
l2_flood_member_t::sw_if_index
u32 sw_if_index
Definition: l2_bd.h:55
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:549
vl_api_want_l2_macs_events2_t::enable_disable
bool enable_disable[default=true]
Definition: l2.api:176
vl_api_l2_fib_table_details_t
l2 fib table details structure
Definition: l2.api:53
vl_api_l2_arp_term_event_t
Tell client about an IP4 ARP resolution event or MAC/IP info from ARP requests in L2 BDs.
Definition: l2.api:693
bd_feature_flood
static_always_inline u8 bd_feature_flood(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:195
vl_api_bridge_domain_dump_t::sw_if_index
vl_api_interface_index_t sw_if_index[default=0xffffffff]
Definition: l2.api:347
vl_api_want_l2_macs_events2_t::pid
u32 pid
Definition: l2.api:177
vl_api_bd_ip_mac_flush_t_handler
static void vl_api_bd_ip_mac_flush_t_handler(vl_api_bd_ip_mac_flush_t *mp)
Definition: l2_api.c:987
vl_api_bridge_domain_add_del_t::mac_age
u8 mac_age
Definition: l2.api:331
vl_api_l2_interface_efp_filter_t::enable_disable
bool enable_disable[default=true]
Definition: l2.api:615
vl_api_bridge_domain_dump_t_handler
static void vl_api_bridge_domain_dump_t_handler(vl_api_bridge_domain_dump_t *mp)
Definition: l2_api.c:562
vl_api_l2_interface_efp_filter_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: l2.api:614
vl_api_l2_patch_add_del_t_handler
static void vl_api_l2_patch_add_del_t_handler(vl_api_l2_patch_add_del_t *mp)
Definition: l2_api.c:1039
bd_main_t
Definition: l2_bd.h:33
vl_api_l2_interface_pbb_tag_rewrite_t::b_vlanid
u16 b_vlanid
Definition: l2.api:474
vl_api_sw_interface_set_vpath_t_handler
static void vl_api_sw_interface_set_vpath_t_handler(vl_api_sw_interface_set_vpath_t *mp)
Definition: l2_api.c:1062
vl_api_want_l2_arp_term_events_t_handler
static void vl_api_want_l2_arp_term_events_t_handler(vl_api_want_l2_arp_term_events_t *mp)
Definition: l2_api.c:1205
vpe_api_main_t
Definition: api_helper_macros.h:414
vl_api_bd_ip_mac_flush_t
Flush bridge domain IP to MAC entries.
Definition: l2.api:574
vl_api_l2_fib_table_dump_t_handler
static void vl_api_l2_fib_table_dump_t_handler(vl_api_l2_fib_table_dump_t *mp)
Definition: l2_api.c:119
vl_api_want_l2_macs_events2_t
Register to receive L2 MAC events for learned and aged MAC.
Definition: l2.api:171
l2_input_is_xconnect
static bool l2_input_is_xconnect(const l2_input_config_t *input)
Definition: l2_input.h:242
bd_flags_decode
static bd_flags_t bd_flags_decode(vl_api_bd_flags_t v)
Definition: l2_api.c:605
IP46_TYPE_IP4
@ IP46_TYPE_IP4
Definition: ip46_address.h:26
ip4_address_t::as_u32
u32 as_u32
Definition: ip4_packet.h:57
vl_api_l2_patch_add_del_t::is_add
bool is_add[default=true]
Definition: l2.api:491
L2_FLOOD
@ L2_FLOOD
Definition: l2_bd.h:158
vl_api_bridge_domain_set_learn_limit_t_handler
static void vl_api_bridge_domain_set_learn_limit_t_handler(vl_api_bridge_domain_set_learn_limit_t *mp)
Definition: l2_api.c:436
hash_foreach
#define hash_foreach(key_var, value_var, h, body)
Definition: hash.h:441
vl_api_sw_interface_set_vpath_t::enable
bool enable[default=0xffffffff]
Definition: l2.api:629
u16
unsigned short u16
Definition: types.h:57
vl_api_l2_interface_pbb_tag_rewrite_t::b_smac
vl_api_mac_address_t b_smac
Definition: l2.api:473
am
app_main_t * am
Definition: application.c:489
vl_api_l2_arp_term_event_t::client_index
u32 client_index
Definition: l2.api:695
vl_api_sw_interface_set_vpath_t
Interface set vpath request.
Definition: l2.api:624
pool_put
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:305
vl_api_want_l2_macs_events2_t::max_macs_in_event
u8 max_macs_in_event[default=10]
Definition: l2.api:175
l2_input_config_t::output_sw_if_index
u32 output_sw_if_index
Definition: l2_input.h:56
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
bd_feature_learn
static_always_inline u8 bd_feature_learn(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:215
l2learn_main_t::client_index
u32 client_index
Definition: l2_learn.h:43
REPLY_MSG_ID_BASE
#define REPLY_MSG_ID_BASE
Definition: l2_api.c:39
vl_api_bridge_domain_add_del_t
L2 bridge domain add or delete request.
Definition: l2.api:320
fm
vnet_feature_main_t * fm
Definition: nat44_ei_hairpinning.c:592
l2vtr_configure
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
vl_api_bridge_domain_dump_t::client_index
u32 client_index
Definition: l2.api:344
MODE_ERROR_ETH
#define MODE_ERROR_ETH
Definition: l2_input.h:289
vl_api_sw_interface_set_l2_xconnect_t::enable
bool enable[default=true]
Definition: l2.api:507
vl_api_bridge_domain_details_t::uu_flood
bool uu_flood
Definition: l2.api:380
vl_api_l2fib_flush_int_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: l2.api:116
vl_api_bd_ip_mac_dump_t_handler
static void vl_api_bd_ip_mac_dump_t_handler(vl_api_bd_ip_mac_dump_t *mp)
Definition: l2_api.c:878
vl_api_sw_interface_set_l2_bridge_t_handler
static void vl_api_sw_interface_set_l2_bridge_t_handler(vl_api_sw_interface_set_l2_bridge_t *mp)
Definition: l2_api.c:809
l2_learn.h
l2input_bd_config_from_index
static_always_inline l2_bridge_domain_t * l2input_bd_config_from_index(l2input_main_t *l2im, u32 bd_index)
Definition: l2_input.h:107
vl_api_l2_flags_t_handler
static void vl_api_l2_flags_t_handler(vl_api_l2_flags_t *mp)
Definition: l2_api.c:385
L2_VTR_TRANSLATE_1_1
@ L2_VTR_TRANSLATE_1_1
Definition: l2_vtr.h:35
l2_arp_term_set_publisher_node
void l2_arp_term_set_publisher_node(bool on)
Definition: l2_arp_term.c:103
vl_api_bridge_domain_details_t::context
u32 context
Definition: l2.api:377
vlib_frame_t
Definition: node.h:372
vl_api_bridge_domain_set_learn_limit_t::bd_id
u32 bd_id
Definition: l2.api:303
l2_bridge_domain_t::mac_age
u8 mac_age
Definition: l2_bd.h:105
vl_api_bridge_domain_details_t::n_sw_ifs
u32 n_sw_ifs
Definition: l2.api:389
vl_api_bd_ip_mac_details_t
bridge domain IP to MAC entry details structure
Definition: l2.api:587
L2_BD_PORT_TYPE_UU_FWD
@ L2_BD_PORT_TYPE_UU_FWD
Definition: l2_bd.h:30
vl_api_l2_interface_pbb_tag_rewrite_t::b_dmac
vl_api_mac_address_t b_dmac
Definition: l2.api:472
vl_api_l2_fib_clear_table_t_handler
static void vl_api_l2_fib_clear_table_t_handler(vl_api_l2_fib_clear_table_t *mp)
Definition: l2_api.c:82
vl_api_bvi_delete_t
Delete BVI interface request.
Definition: l2.api:663
vl_api_bridge_domain_set_mac_age_t::mac_age
u8 mac_age
Definition: l2.api:277
bd_flush_ip_mac
void bd_flush_ip_mac(u32 bd_index)
Flush IP address to MAC address mapping tables in a BD.
Definition: l2_bd.c:1022
vl_api_bridge_domain_dump_t::bd_id
u32 bd_id[default=0xffffffff]
Definition: l2.api:346
l2fib_add_entry
void l2fib_add_entry(const u8 *mac, u32 bd_index, u32 sw_if_index, l2fib_entry_result_flags_t flags)
Add an entry to the l2fib.
Definition: l2_fib.c:441
BRIDGE_API_FLAG_FLOOD
@ BRIDGE_API_FLAG_FLOOD
Definition: l2.api:399
hash_unset
#define hash_unset(h, key)
Definition: hash.h:261
l2_fib.h
l2_arp_term_publish_ctx_t_
Definition: l2_arp_term.h:21
vl_api_l2_fib_table_dump_t::client_index
u32 client_index
Definition: l2.api:70
L2_ARP_TERM
@ L2_ARP_TERM
Definition: l2_bd.h:160
vl_api_bridge_domain_details_t::flood
bool flood
Definition: l2.api:379
vl_api_l2fib_flush_int_t
L2 FIB flush interface entries.
Definition: l2.api:112
MODE_L2_BRIDGE
#define MODE_L2_BRIDGE
Definition: l2_input.h:285
l2learn_main_t::bd_default_learn_limit
u32 bd_default_learn_limit
Definition: l2_learn.h:39
ip_address_decode
ip46_type_t ip_address_decode(const vl_api_address_t *in, ip46_address_t *out)
Decode/Encode for struct/union types.
Definition: ip_types_api.c:172
vl_api_bridge_flags_reply_t::resulting_feature_bitmap
u32 resulting_feature_bitmap
Definition: l2.api:430
bd_add_del
int bd_add_del(l2_bridge_domain_add_del_args_t *a)
Definition: l2_bd.c:1361
l2_bridge_domain_t::mac_by_ip4
uword * mac_by_ip4
Definition: l2_bd.h:101
vl_api_want_l2_macs_events_t::max_macs_in_event
u8 max_macs_in_event[default=10]
Definition: l2.api:159
vl_api_bd_ip_mac_flush_t::bd_id
u32 bd_id
Definition: l2.api:578
vl_api_l2_fib_table_details_t::bvi_mac
bool bvi_mac
Definition: l2.api:61
vl_api_l2_interface_vlan_tag_rewrite_t::vtr_op
u32 vtr_op
Definition: l2.api:447
vl_api_l2_arp_term_event_t::pid
u32 pid
Definition: l2.api:696
pool_foreach
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:534
vl_api_l2_xconnect_dump_t
Dump L2 XConnects.
Definition: l2.api:39
bd_add_del_ip_mac
u32 bd_add_del_ip_mac(u32 bd_index, ip46_type_t type, const ip46_address_t *ip, const mac_address_t *mac, u8 is_add)
Add/delete IP address to MAC address mapping.
Definition: l2_bd.c:945
vl_api_sw_interface_set_l2_bridge_t::bd_id
u32 bd_id
Definition: l2.api:540
vnet_l2_patch_add_del
int vnet_l2_patch_add_del(u32 rx_sw_if_index, u32 tx_sw_if_index, int is_add)
Definition: l2_patch.c:232
l2learn_main_t
Definition: l2_learn.h:26
pid
u32 pid
Definition: dhcp.api:164
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
vl_api_bd_ip_mac_add_del_t::entry
vl_api_bd_ip_mac_t entry
Definition: l2.api:567
ip46_address_is_equal
static u8 ip46_address_is_equal(const ip46_address_t *ip46_1, const ip46_address_t *ip46_2)
Definition: ip46_address.h:93
vl_api_l2fib_add_del_t_handler
static void vl_api_l2fib_add_del_t_handler(vl_api_l2fib_add_del_t *mp)
Definition: l2_api.c:158
vl_api_bridge_domain_set_default_learn_limit_t::learn_limit
u32 learn_limit
Definition: l2.api:289
bd_id
u32 bd_id
Definition: gbp.api:188
l2_bridge_domain_t::uu_fwd_sw_if_index
u32 uu_fwd_sw_if_index
Definition: l2_bd.h:80
vl_api_bridge_domain_add_del_t::forward
bool forward
Definition: l2.api:327
vlib_process_get_event_data
static void * vlib_process_get_event_data(vlib_main_t *vm, uword *return_event_type_opaque)
Definition: node_funcs.h:530
vl_api_l2_fib_table_details_t::mac
vl_api_mac_address_t mac
Definition: l2.api:57
vec_elt_at_index
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Definition: vec_bootstrap.h:203
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
vl_api_l2_xconnect_dump_t::client_index
u32 client_index
Definition: l2.api:41
vl_api_bridge_domain_details_t::uu_fwd_sw_if_index
vl_api_interface_index_t uu_fwd_sw_if_index
Definition: l2.api:388
vl_api_registration_
An API client registration, only in vpp/vlib.
Definition: api_common.h:47
REPLY_MACRO
#define REPLY_MACRO(t)
Definition: api_helper_macros.h:30
hash_get
#define hash_get(h, key)
Definition: hash.h:249
setup_message_id_table
static void setup_message_id_table(api_main_t *am)
Definition: sr_mpls_api.c:174
ARRAY_LEN
#define ARRAY_LEN(x)
Definition: clib.h:70
vpe_client_registration_t::client_pid
u32 client_pid
Definition: api_helper_macros.h:411
end
f64 end
end of the time range
Definition: mactime.api:44
vl_api_l2_interface_pbb_tag_rewrite_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: l2.api:469
L2_VTR_DISABLED
@ L2_VTR_DISABLED
Definition: l2_vtr.h:30
vl_api_sw_interface_set_l2_bridge_t::rx_sw_if_index
vl_api_interface_index_t rx_sw_if_index
Definition: l2.api:539
l2fib_flush_all_mac
void l2fib_flush_all_mac(vlib_main_t *vm)
Flush all non static MACs - flushes all valid BDs.
Definition: l2_fib.c:922
vl_api_bridge_domain_add_del_t::uu_flood
bool uu_flood
Definition: l2.api:326
l2_bvi.h
vl_api_bridge_domain_set_mac_age_t
L2 bridge domain set mac age.
Definition: l2.api:272
vec_foreach_index
#define vec_foreach_index(var, v)
Iterate over vector indices.
Definition: vec_bootstrap.h:220
l2fib_clear_table
void l2fib_clear_table(void)
Definition: l2_fib.c:379
MODE_L3
#define MODE_L3
Definition: l2_input.h:284
uword
u64 uword
Definition: types.h:112
last
static heap_elt_t * last(heap_header_t *h)
Definition: heap.c:53
vl_api_bridge_domain_details_t::bd_tag
string bd_tag[64]
Definition: l2.api:386
l2_vtr.h
vl_api_bridge_domain_set_default_learn_limit_t_handler
static void vl_api_bridge_domain_set_default_learn_limit_t_handler(vl_api_bridge_domain_set_default_learn_limit_t *mp)
Definition: l2_api.c:425
tx_sw_if_index
vl_api_interface_index_t tx_sw_if_index
Definition: ip.api:577
bd_feature_uu_flood
static_always_inline u8 bd_feature_uu_flood(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:202
vl_api_l2_arp_term_event_t::mac
vl_api_mac_address_t mac
Definition: l2.api:699
l2input_intf_bitmap_enable
u32 l2input_intf_bitmap_enable(u32 sw_if_index, l2input_feat_masks_t feature_bitmap, u32 enable)
Enable (or disable) the feature in the bitmap for the given interface.
Definition: l2_input.c:177
L2_VTR_POP_1
@ L2_VTR_POP_1
Definition: l2_vtr.h:33
vl_api_bvi_create_t
Create BVI interface instance request.
Definition: l2.api:638
L2_ARP_UFWD
@ L2_ARP_UFWD
Definition: l2_bd.h:161
vlibapi_get_main
static api_main_t * vlibapi_get_main(void)
Definition: api_common.h:390
L2_API_PORT_TYPE_NORMAL
@ L2_API_PORT_TYPE_NORMAL
Definition: l2.api:517
vl_api_bridge_domain_add_del_t::bd_id
u32 bd_id
Definition: l2.api:324
vl_api_l2_fib_table_details_t::bd_id
u32 bd_id
Definition: l2.api:56
MODE_ERROR_BVI_DEF
#define MODE_ERROR_BVI_DEF
Definition: l2_input.h:290
l2fib_entry_key_t::fields
struct l2fib_entry_key_t::@465::@467 fields
interface.h
f64
double f64
Definition: types.h:142
vl_api_bridge_domain_add_del_t::bd_tag
string bd_tag[64]
Definition: l2.api:332
vl_api_sw_interface_set_l2_bridge_t::enable
bool enable[default=true]
Definition: l2.api:543
l2_input_config_t::shg
u8 shg
Definition: l2_input.h:67
l2_bvi_delete
int l2_bvi_delete(u32 sw_if_index)
Definition: l2_bvi.c:210
vl_api_l2_interface_vlan_tag_rewrite_t::tag2
u32 tag2
Definition: l2.api:450
pool_get
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:255
l2fib_entry_result_t_
Definition: l2_fib.h:160
vec_validate
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
Definition: vec.h:523
mac_address_t_::bytes
u8 bytes[6]
Definition: mac_address.h:25
vl_api_l2_xconnect_dump_t_handler
static void vl_api_l2_xconnect_dump_t_handler(vl_api_l2_xconnect_dump_t *mp)
Definition: l2_api.c:59
vl_api_bd_ip_mac_add_del_t_handler
static void vl_api_bd_ip_mac_add_del_t_handler(vl_api_bd_ip_mac_add_del_t *mp)
Definition: l2_api.c:949
BAD_TX_SW_IF_INDEX_LABEL
#define BAD_TX_SW_IF_INDEX_LABEL
Definition: api_helper_macros.h:317
vl_api_l2_patch_add_del_t::tx_sw_if_index
vl_api_interface_index_t tx_sw_if_index
Definition: l2.api:490
l2_input_is_bridge
static bool l2_input_is_bridge(const l2_input_config_t *input)
Definition: l2_input.h:236
bd_find_or_add_bd_index
static u32 bd_find_or_add_bd_index(bd_main_t *bdm, u32 bd_id)
Get or create a bridge domain.
Definition: l2_bd.h:202
bd_feature_arp_ufwd
static_always_inline u8 bd_feature_arp_ufwd(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:229
vl_api_l2_interface_pbb_tag_rewrite_t::i_sid
u32 i_sid
Definition: l2.api:475
vl_api_l2_fib_table_dump_t
Dump l2 fib (aka bridge domain) table.
Definition: l2.api:68
vl_api_l2_interface_vlan_tag_rewrite_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: l2.api:446
L2_VTR_PUSH_1
@ L2_VTR_PUSH_1
Definition: l2_vtr.h:31
ip4_address_t
Definition: ip4_packet.h:50
bd_set_flags
u32 bd_set_flags(vlib_main_t *vm, u32 bd_index, bd_flags_t flags, u32 enable)
Set the learn/forward/flood flags for the bridge domain.
Definition: l2_bd.c:294
ALWAYS_ASSERT
#define ALWAYS_ASSERT(truth)
Definition: error_bootstrap.h:89
vl_api_l2fib_flush_bd_t
L2 FIB flush bridge domain entries.
Definition: l2.api:100
IP46_TYPE_IP6
@ IP46_TYPE_IP6
Definition: ip46_address.h:27
l2learn_main_t::global_learn_limit
u32 global_learn_limit
Definition: l2_learn.h:36
l2_api_hookup
static clib_error_t * l2_api_hookup(vlib_main_t *vm)
Definition: l2_api.c:1279
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
vl_api_l2_flags_t
Set interface L2 flags (such as L2_LEARN, L2_FWD, L2_FLOOD, L2_UU_FLOOD, or L2_ARP_TERM bits).
Definition: l2.api:245
vl_api_l2_interface_efp_filter_t
L2 interface ethernet flow point filtering enable/disable request.
Definition: l2.api:610
L2_ARP_TERM_EVENT_PUBLISH
@ L2_ARP_TERM_EVENT_PUBLISH
Definition: l2_arp_term.h:31
want_l2_arp_term_events_reaper
static clib_error_t * want_l2_arp_term_events_reaper(u32 client_index)
Definition: l2_api.c:1253
vl_api_bridge_domain_set_learn_limit_t::learn_limit
u32 learn_limit
Definition: l2.api:304
vl_api_l2fib_add_del_t::bd_id
u32 bd_id
Definition: l2.api:135
bd_flags_t
enum bd_flags_t_ bd_flags_t
L2_LEARN
@ L2_LEARN
Definition: l2_bd.h:156
l2pbb_configure
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
vl_api_want_l2_arp_term_events_t::enable
bool enable
Definition: l2.api:681
vl_api_bvi_delete_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: l2.api:667
l2_input.h
vl_api_l2_flags_reply_t
Set interface L2 flags response.
Definition: l2.api:259
BAD_SW_IF_INDEX_LABEL
#define BAD_SW_IF_INDEX_LABEL
Definition: api_helper_macros.h:289
vnet_main_t::api_errno
vnet_api_error_t api_errno
Definition: vnet.h:109
vl_api_l2_fib_table_dump_t::bd_id
u32 bd_id
Definition: l2.api:72
api_main_t
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:228
vl_api_bvi_create_t::mac
vl_api_mac_address_t mac
Definition: l2.api:642
l2learn_main
l2learn_main_t l2learn_main
Definition: l2_learn.c:32
set_int_l2_mode
u32 set_int_l2_mode(vlib_main_t *vm, vnet_main_t *vnet_main, u32 mode, u32 sw_if_index, u32 bd_index, l2_bd_port_type_t port_type, u32 shg, u32 xc_sw_if_index)
Set the subinterface to run in l2 or l3 mode.
Definition: l2_input.c:256
vl_api_want_l2_macs_events_t::enable_disable
bool enable_disable[default=true]
Definition: l2.api:160
vl_api_l2_fib_table_details_t::filter_mac
bool filter_mac
Definition: l2.api:60
vl_api_l2fib_add_del_t
L2 FIB add entry request.
Definition: l2.api:130
vl_api_l2_interface_vlan_tag_rewrite_t_handler
static void vl_api_l2_interface_vlan_tag_rewrite_t_handler(vl_api_l2_interface_vlan_tag_rewrite_t *mp)
Definition: l2_api.c:664
vl_api_bridge_domain_details_t::bd_id
u32 bd_id
Definition: l2.api:378
vl_api_bridge_domain_details_t::arp_term
bool arp_term
Definition: l2.api:383
vl_api_bridge_domain_add_del_t::flood
bool flood
Definition: l2.api:325
vl_api_l2_flags_t::is_set
bool is_set
Definition: l2.api:250
send_bd_ip_mac_entry
static void send_bd_ip_mac_entry(vpe_api_main_t *am, vl_api_registration_t *reg, u32 bd_id, const ip46_address_t *ip, ip46_type_t itype, const mac_address_t *mac, u32 context)
Definition: l2_api.c:855
l2fib_flush_bd_mac
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:911
vnet_main_t
Definition: vnet.h:76
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
vl_api_l2fib_add_del_t::mac
vl_api_mac_address_t mac
Definition: l2.api:134
l2fib_main_t
Definition: l2_fib.h:42
vl_api_sw_interface_set_l2_xconnect_t_handler
static void vl_api_sw_interface_set_l2_xconnect_t_handler(vl_api_sw_interface_set_l2_xconnect_t *mp)
Definition: l2_api.c:746
BRIDGE_API_FLAG_LEARN
@ BRIDGE_API_FLAG_LEARN
Definition: l2.api:397
l2_arp_term.h
vl_api_l2fib_set_scan_delay_t::scan_delay
u16 scan_delay[default=10]
Definition: l2.api:189
bd_is_valid
static u32 bd_is_valid(l2_bridge_domain_t *bd_config)
Definition: l2_bd.h:140
vl_api_l2fib_flush_bd_t_handler
static void vl_api_l2fib_flush_bd_t_handler(vl_api_l2fib_flush_bd_t *mp)
Definition: l2_api.c:342
l2_bridge_domain_t::bd_id
u32 bd_id
Definition: l2_bd.h:83
l2_bridge_domain_t::bvi_sw_if_index
u32 bvi_sw_if_index
Definition: l2_bd.h:74
BRIDGE_API_FLAG_ARP_UFWD
@ BRIDGE_API_FLAG_ARP_UFWD
Definition: l2.api:402
vl_api_bridge_domain_dump_t::context
u32 context
Definition: l2.api:345
L2_UU_FLOOD
@ L2_UU_FLOOD
Definition: l2_bd.h:159
L2LEARN_DEFAULT_LIMIT
#define L2LEARN_DEFAULT_LIMIT
Definition: l2_learn.h:53
vl_api_l2fib_flush_bd_t::bd_id
u32 bd_id
Definition: l2.api:104
bd_find_index
u32 bd_find_index(bd_main_t *bdm, u32 bd_id)
Get a bridge domain.
Definition: l2_bd.c:70
L2_BD_PORT_TYPE_NORMAL
@ L2_BD_PORT_TYPE_NORMAL
Definition: l2_bd.h:28
VL_MSG_API_REAPER_FUNCTION
VL_MSG_API_REAPER_FUNCTION(want_l2_arp_term_events_reaper)
mac_address_from_u64
static_always_inline void mac_address_from_u64(mac_address_t *mac, u64 u)
Definition: mac_address.h:122
vl_api_bridge_domain_details_t::learn
bool learn
Definition: l2.api:382
vl_api_l2fib_add_del_t::bvi_mac
bool bvi_mac
Definition: l2.api:140
vl_api_want_l2_macs_events_t_handler
static void vl_api_want_l2_macs_events_t_handler(vl_api_want_l2_macs_events_t *mp)
Definition: l2_api.c:266
vl_api_want_l2_macs_events_t::scan_delay
u8 scan_delay[default=10]
Definition: l2.api:158
mac_address_encode
void mac_address_encode(const mac_address_t *in, u8 *out)
Definition: ethernet_types_api.c:26
format_fns.h
u64
unsigned long u64
Definition: types.h:89
vl_api_can_send_msg
static int vl_api_can_send_msg(vl_api_registration_t *rp)
Definition: api.h:48
l2fib_main
l2fib_main_t l2fib_main
Definition: l2_fib.c:50
L2_API_PORT_TYPE_BVI
@ L2_API_PORT_TYPE_BVI
Definition: l2.api:519
BAD_BD_ID_LABEL
#define BAD_BD_ID_LABEL
Definition: api_helper_macros.h:331
vl_api_l2_xconnect_details_t::context
u32 context
Definition: l2.api:30
l2_arp_term_publish_event_is_equal
static bool l2_arp_term_publish_event_is_equal(const l2_arp_term_publish_event_t *e1, const l2_arp_term_publish_event_t *e2)
Definition: l2_api.c:1117
VALIDATE_RX_SW_IF_INDEX
#define VALIDATE_RX_SW_IF_INDEX(mp)
Definition: api_helper_macros.h:295
VALIDATE_BD_ID
#define VALIDATE_BD_ID(mp)
Definition: api_helper_macros.h:323
u32
unsigned int u32
Definition: types.h:88
vl_api_l2fib_add_del_t::is_add
bool is_add[default=true]
Definition: l2.api:137
send_bridge_domain_details
static void send_bridge_domain_details(l2input_main_t *l2im, vl_api_registration_t *reg, l2_bridge_domain_t *bd_config, u32 n_sw_ifs, u32 context)
Definition: l2_api.c:514
vl_api_want_l2_arp_term_events_t
Register for IP4 ARP resolution event on receiving ARP reply or MAC/IP info from ARP requests in L2 B...
Definition: l2.api:677
l2fib_del_entry
u32 l2fib_del_entry(const u8 *mac, u32 bd_index, u32 sw_if_index)
Delete an entry from the l2fib.
Definition: l2_fib.c:742
vl_api_bd_ip_mac_add_del_t::is_add
bool is_add[default=true]
Definition: l2.api:566
vl_api_sw_interface_set_l2_bridge_t
Interface bridge mode request.
Definition: l2.api:535
ethernet_types_api.h
vl_api_l2_patch_add_del_t::rx_sw_if_index
vl_api_interface_index_t rx_sw_if_index
Definition: l2.api:489
vl_api_l2_interface_pbb_tag_rewrite_t::vtr_op
u32 vtr_op
Definition: l2.api:470
vl_api_l2_xconnect_details_t::rx_sw_if_index
vl_api_interface_index_t rx_sw_if_index
Definition: l2.api:31
BRIDGE_API_FLAG_ARP_TERM
@ BRIDGE_API_FLAG_ARP_TERM
Definition: l2.api:401
vl_api_l2_interface_pbb_tag_rewrite_t
L2 interface pbb tag rewrite configure request.
Definition: l2.api:465
api_helper_macros.h
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
vl_api_l2fib_flush_all_t
L2 FIB flush all entries.
Definition: l2.api:89
L2_VTR_TRANSLATE_2_1
@ L2_VTR_TRANSLATE_2_1
Definition: l2_vtr.h:37
VLIB_NODE_TYPE_PROCESS
@ VLIB_NODE_TYPE_PROCESS
Definition: node.h:84
vl_api_l2_fib_table_details_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: l2.api:58
pool_elts
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:127
mac_address_decode
void mac_address_decode(const u8 *in, mac_address_t *out)
Conversion functions to/from (decode/encode) API types to VPP internal types.
Definition: ethernet_types_api.c:20
vl_api_bridge_flags_t::flags
vl_api_bd_flags_t flags
Definition: l2.api:418
vl_api_l2_fib_table_details_t::context
u32 context
Definition: l2.api:55
vl_api_bd_ip_mac_dump_t::context
u32 context
Definition: l2.api:600
l2_arp_term_main_t_::publish_events
l2_arp_term_publish_event_t * publish_events
Definition: l2_arp_term.h:38
vl_api_want_l2_macs_events2_t::client_index
u32 client_index
Definition: l2.api:173
vl_api_bridge_domain_details_t::forward
bool forward
Definition: l2.api:381
bd_feature_forward
static_always_inline u8 bd_feature_forward(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:209
vl_api_l2_arp_term_event_t::ip
vl_api_address_t ip
Definition: l2.api:697
vl_api_bridge_domain_details_t::mac_age
u8 mac_age
Definition: l2.api:385
l2_flood_member_t
Definition: l2_bd.h:53
vl_api_bridge_flags_t::is_set
bool is_set
Definition: l2.api:417
vl_api_l2fib_add_del_t::static_mac
bool static_mac
Definition: l2.api:138
vnet_feature_enable_disable
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
Definition: pnat_test_stubs.h:50
mac_address_t_
Definition: mac_address.h:21
vl_api_bridge_flags_t_handler
static void vl_api_bridge_flags_t_handler(vl_api_bridge_flags_t *mp)
Definition: l2_api.c:628
vl_api_want_l2_arp_term_events_t::pid
u32 pid
Definition: l2.api:682
now
f64 now
Definition: nat44_ei_out2in.c:710
vpe_client_registration_t::client_index
u32 client_index
Definition: api_helper_macros.h:410
vnet_main
vnet_main_t vnet_main
Definition: misc.c:43
bd_feature_arp_term
static_always_inline u8 bd_feature_arp_term(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:222
vl_api_l2_flags_t::feature_bitmap
u32 feature_bitmap
Definition: l2.api:251
vl_api_bd_ip_mac_details_t::entry
vl_api_bd_ip_mac_t entry
Definition: l2.api:590
l2_arp_term_publish_ctx_t_::type
ip46_type_t type
Definition: l2_arp_term.h:24
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
bd_main
bd_main_t bd_main
Definition: l2_bd.c:44
ip_address_encode
void ip_address_encode(const ip46_address_t *in, ip46_type_t type, vl_api_address_t *out)
Definition: ip_types_api.c:206
vlib_get_main
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:38
L2_API_PORT_TYPE_UU_FWD
@ L2_API_PORT_TYPE_UU_FWD
Definition: l2.api:522
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
vl_api_sw_interface_set_l2_xconnect_t
Set L2 XConnect between two interfaces request.
Definition: l2.api:501
vl_api_l2fib_add_del_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: l2.api:136
a
a
Definition: bitmap.h:525
vl_api_l2_interface_pbb_tag_rewrite_t::outer_tag
u16 outer_tag
Definition: l2.api:471
rt
vnet_interface_output_runtime_t * rt
Definition: interface_output.c:419
vl_api_bridge_domain_set_learn_limit_t
L2 bridge domain set learn limit.
Definition: l2.api:299
ip
vl_api_address_t ip
Definition: l2.api:558
l2_arp_term_process
static uword l2_arp_term_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: l2_api.c:1128
vl_api_bd_ip_mac_dump_t::client_index
u32 client_index
Definition: l2.api:599
L2_VTR_PUSH_2
@ L2_VTR_PUSH_2
Definition: l2_vtr.h:32
vl_api_want_l2_macs_events2_t_handler
static void vl_api_want_l2_macs_events2_t_handler(vl_api_want_l2_macs_events2_t *mp)
Definition: l2_api.c:221
l2_bridge_domain_t::members
l2_flood_member_t * members
Definition: l2_bd.h:86
l2_bridge_domain_t::bd_tag
u8 * bd_tag
Definition: l2_bd.h:111
vl_api_l2_flags_reply_t::resulting_feature_bitmap
u32 resulting_feature_bitmap
Definition: l2.api:263
vl_api_l2_xconnect_details_t
Reply to l2_xconnect_dump.
Definition: l2.api:28
ip46_type_t
ip46_type_t
Definition: ip46_address.h:22
l2fib_entry_result_flags_t
enum l2fib_entry_result_flags_t_ l2fib_entry_result_flags_t
vl_api_l2_patch_add_del_t
L2 interface patch add / del request.
Definition: l2.api:485
vl_api_l2_fib_table_dump_t::context
u32 context
Definition: l2.api:71
vl_api_bvi_create_t_handler
static void vl_api_bvi_create_t_handler(vl_api_bvi_create_t *mp)
Definition: l2_api.c:1086
vl_api_l2_xconnect_dump_t::context
u32 context
Definition: l2.api:42
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
L2_VTR_TRANSLATE_1_2
@ L2_VTR_TRANSLATE_1_2
Definition: l2_vtr.h:36
vl_api_want_l2_arp_term_events_t::client_index
u32 client_index
Definition: l2.api:679
l2_bd_port_type_t
enum l2_bd_port_type_t_ l2_bd_port_type_t
context
u32 context
Definition: ip.api:852
vl_api_bridge_flags_t
Set bridge flags request.
Definition: l2.api:412
rv
int __clib_unused rv
Definition: application.c:491
l2fib_entry_key_t
Definition: l2_fib.h:77
bd_set_learn_limit
void bd_set_learn_limit(vlib_main_t *vm, u32 bd_index, u32 learn_limit)
Set learn limit for the bridge domain.
Definition: l2_bd.c:367
l2_arp_term_publish_ctx_t_::sw_if_index
u32 sw_if_index
Definition: l2_arp_term.h:23
vlib_time_now
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:327
vnet.h
api_errno.h
vl_api_l2fib_flush_all_t_handler
static void vl_api_l2fib_flush_all_t_handler(vl_api_l2fib_flush_all_t *mp)
Definition: l2_api.c:332
vlib_node_runtime_t
Definition: node.h:454
vl_api_l2fib_set_scan_delay_t
set l2 table scan delay
Definition: l2.api:185
vl_api_bd_ip_mac_add_del_t
Definition: l2.api:562
l2_bridge_domain_t::mac_by_ip6
uword * mac_by_ip6
Definition: l2_bd.h:102
vl_api_bd_ip_mac_dump_t
Dump bridge domain IP to MAC entries.
Definition: l2.api:597
l2input_main_t::configs
l2_input_config_t * configs
Definition: l2_input.h:90
vl_api_bvi_delete_t_handler
static void vl_api_bvi_delete_t_handler(vl_api_bvi_delete_t *mp)
Definition: l2_api.c:1106
bd_set_mac_age
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:344
vl_api_bridge_domain_set_mac_age_t_handler
static void vl_api_bridge_domain_set_mac_age_t_handler(vl_api_bridge_domain_set_mac_age_t *mp)
Definition: l2_api.c:464
l2fib_table_dump
void l2fib_table_dump(u32 bd_index, l2fib_entry_key_t **l2fe_key, l2fib_entry_result_t **l2fe_res)
Definition: l2_fib.c:129
send_l2fib_table_entry
static void send_l2fib_table_entry(vpe_api_main_t *am, vl_api_registration_t *reg, l2fib_entry_key_t *l2fe_key, l2fib_entry_result_t *l2fe_res, u32 context)
Definition: l2_api.c:94
MODE_L2_XC
#define MODE_L2_XC
Definition: l2_input.h:286
vl_api_sw_interface_set_l2_bridge_t::port_type
vl_api_l2_port_type_t port_type
Definition: l2.api:541
L2FIB_ENTRY_RESULT_FLAG_NONE
@ L2FIB_ENTRY_RESULT_FLAG_NONE
Definition: l2_fib.h:147
L2_NONE
@ L2_NONE
Definition: l2_bd.h:155
l2_arp_term_process_node
vlib_node_registration_t l2_arp_term_process_node
(constructor) VLIB_REGISTER_NODE (l2_arp_term_process_node)
Definition: l2_api.c:1197
vl_api_l2_interface_pbb_tag_rewrite_t_handler
static void vl_api_l2_interface_pbb_tag_rewrite_t_handler(vl_api_l2_interface_pbb_tag_rewrite_t *mp)
Definition: l2_api.c:706
vl_api_l2_xconnect_details_t::tx_sw_if_index
vl_api_interface_index_t tx_sw_if_index
Definition: l2.api:32
vl_api_want_l2_macs_events_t::learn_limit
u32 learn_limit[default=1000]
Definition: l2.api:157
vpe_client_registration_t
Definition: api_helper_macros.h:408
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
l2_bd.h
ip_types_api.h
vl_api_l2_arp_term_event_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: l2.api:698
L2_VTR_POP_2
@ L2_VTR_POP_2
Definition: l2_vtr.h:34
hash_foreach_mem
#define hash_foreach_mem(key_var, value_var, h, body)
Definition: hash.h:460
vl_api_want_l2_macs_events_t
Register to receive L2 MAC events for learned and aged MAC.
Definition: l2.api:152
l2_arp_term_publish_ctx_t_::ip
ip46_address_t ip
Definition: l2_arp_term.h:25
BRIDGE_API_FLAG_FWD
@ BRIDGE_API_FLAG_FWD
Definition: l2.api:398
L2_BD_PORT_TYPE_BVI
@ L2_BD_PORT_TYPE_BVI
Definition: l2_bd.h:29
bd_main_t::bd_index_by_bd_id
uword * bd_index_by_bd_id
Definition: l2_bd.h:36
vl_api_bridge_domain_set_mac_age_t::bd_id
u32 bd_id
Definition: l2.api:276
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
mac_address_equal
static_always_inline int mac_address_equal(const mac_address_t *a, const mac_address_t *b)
Definition: mac_address.h:140
vl_api_bridge_domain_add_del_t::learn
bool learn
Definition: l2.api:328
vl_api_sw_interface_set_vpath_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: l2.api:628
vl_api_bridge_domain_set_default_learn_limit_t
L2 bridge domain set default learn limit.
Definition: l2.api:285
l2input_main_t::bd_configs
l2_bridge_domain_t * bd_configs
Definition: l2_input.h:93
vl_api_l2_flags_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: l2.api:249
l2learn_main_t::client_pid
u32 client_pid
Definition: l2_learn.h:42
vl_api_bvi_create_reply_t
Create BVI interface instance response.
Definition: l2.api:651
vpe_api_main
vpe_api_main_t vpe_api_main
Definition: interface_api.c:47
vl_api_l2_interface_efp_filter_t_handler
static void vl_api_l2_interface_efp_filter_t_handler(vl_api_l2_interface_efp_filter_t *mp)
Definition: l2_api.c:1021
vl_msg_api_alloc
void * vl_msg_api_alloc(int nbytes)
Definition: memory_shared.c:199
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
vl_api_bridge_domain_dump_t
L2 bridge domain request operational state details.
Definition: l2.api:342
vl_api_l2_interface_vlan_tag_rewrite_t::tag1
u32 tag1
Definition: l2.api:449
vl_api_want_l2_macs_events_t::pid
u32 pid
Definition: l2.api:161
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105
l2_efp_filter_configure
void l2_efp_filter_configure(vnet_main_t *vnet_main, u32 sw_if_index, u8 enable)
Enable/disable the EFP Filter check on the subinterface.
Definition: l2_efp_filter.c:507