FD.io VPP  v19.08-23-g4b943d6
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/ip/ip_types_api.h>
33 
34 #include <vnet/vnet_msg_enum.h>
35 
36 #define vl_typedefs /* define message structures */
37 #include <vnet/vnet_all_api_h.h>
38 #undef vl_typedefs
39 
40 #define vl_endianfun /* define message structures */
41 #include <vnet/vnet_all_api_h.h>
42 #undef vl_endianfun
43 
44 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
45 #define vl_api_bridge_domain_details_t_print vl_noop_handler
46 
47 /* instantiate all the print functions we know about */
48 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
49 #define vl_printfun
50 #include <vnet/vnet_all_api_h.h>
51 #undef vl_printfun
52 
54 
55 #define foreach_vpe_api_msg \
56 _(L2_XCONNECT_DUMP, l2_xconnect_dump) \
57 _(L2_FIB_CLEAR_TABLE, l2_fib_clear_table) \
58 _(L2_FIB_TABLE_DUMP, l2_fib_table_dump) \
59 _(L2FIB_FLUSH_ALL, l2fib_flush_all) \
60 _(L2FIB_FLUSH_INT, l2fib_flush_int) \
61 _(L2FIB_FLUSH_BD, l2fib_flush_bd) \
62 _(L2FIB_ADD_DEL, l2fib_add_del) \
63 _(WANT_L2_MACS_EVENTS, want_l2_macs_events) \
64 _(L2_FLAGS, l2_flags) \
65 _(SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect) \
66 _(SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge) \
67 _(L2_PATCH_ADD_DEL, l2_patch_add_del) \
68 _(L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter) \
69 _(BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del) \
70 _(BD_IP_MAC_FLUSH, bd_ip_mac_flush) \
71 _(BD_IP_MAC_DUMP, bd_ip_mac_dump) \
72 _(BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del) \
73 _(BRIDGE_DOMAIN_DUMP, bridge_domain_dump) \
74 _(BRIDGE_FLAGS, bridge_flags) \
75 _(L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite) \
76 _(L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite) \
77 _(BRIDGE_DOMAIN_SET_MAC_AGE, bridge_domain_set_mac_age) \
78 _(SW_INTERFACE_SET_VPATH, sw_interface_set_vpath) \
79 _(BVI_CREATE, bvi_create) \
80 _(BVI_DELETE, bvi_delete)
81 
82 static void
84  u32 rx_sw_if_index, u32 tx_sw_if_index)
85 {
87 
88  mp = vl_msg_api_alloc (sizeof (*mp));
89  clib_memset (mp, 0, sizeof (*mp));
90  mp->_vl_msg_id = ntohs (VL_API_L2_XCONNECT_DETAILS);
91  mp->context = context;
92  mp->rx_sw_if_index = htonl (rx_sw_if_index);
93  mp->tx_sw_if_index = htonl (tx_sw_if_index);
94 
95  vl_api_send_msg (reg, (u8 *) mp);
96 }
97 
98 static void
100 {
102  vnet_main_t *vnm = vnet_get_main ();
104  l2input_main_t *l2im = &l2input_main;
105  vnet_sw_interface_t *swif;
106  l2_input_config_t *config;
107 
109  if (!reg)
110  return;
111 
112  /* *INDENT-OFF* */
113  pool_foreach (swif, im->sw_interfaces,
114  ({
115  config = vec_elt_at_index (l2im->configs, swif->sw_if_index);
116  if (config->xconnect)
117  send_l2_xconnect_details (reg, mp->context, swif->sw_if_index,
118  config->output_sw_if_index);
119  }));
120  /* *INDENT-ON* */
121 }
122 
123 static void
125 {
126  int rv = 0;
127  vl_api_l2_fib_clear_table_reply_t *rmp;
128 
129  /* Clear all MACs including static MACs */
131 
132  REPLY_MACRO (VL_API_L2_FIB_CLEAR_TABLE_REPLY);
133 }
134 
135 static void
137  vl_api_registration_t * reg,
138  l2fib_entry_key_t * l2fe_key,
139  l2fib_entry_result_t * l2fe_res, u32 context)
140 {
142 
143  mp = vl_msg_api_alloc (sizeof (*mp));
144  clib_memset (mp, 0, sizeof (*mp));
145  mp->_vl_msg_id = ntohs (VL_API_L2_FIB_TABLE_DETAILS);
146 
147  mp->bd_id =
148  ntohl (l2input_main.bd_configs[l2fe_key->fields.bd_index].bd_id);
149 
150  clib_memcpy (mp->mac, l2fe_key->fields.mac, 6);
151  mp->sw_if_index = ntohl (l2fe_res->fields.sw_if_index);
152  mp->static_mac = (l2fib_entry_result_is_set_STATIC (l2fe_res) ? 1 : 0);
153  mp->filter_mac = (l2fib_entry_result_is_set_FILTER (l2fe_res) ? 1 : 0);
154  mp->bvi_mac = (l2fib_entry_result_is_set_BVI (l2fe_res) ? 1 : 0);
155  mp->context = context;
156 
157  vl_api_send_msg (reg, (u8 *) mp);
158 }
159 
160 static void
162 {
164  bd_main_t *bdm = &bd_main;
165  l2fib_entry_key_t *l2fe_key = NULL;
166  l2fib_entry_result_t *l2fe_res = NULL;
167  u32 ni, bd_id = ntohl (mp->bd_id);
168  u32 bd_index;
170  uword *p;
171 
173  if (!reg)
174  return;
175 
176  /* see l2fib_table_dump: ~0 means "any" */
177  if (bd_id == ~0)
178  bd_index = ~0;
179  else
180  {
181  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
182  if (p == 0)
183  return;
184 
185  bd_index = p[0];
186  }
187 
188  l2fib_table_dump (bd_index, &l2fe_key, &l2fe_res);
189 
190  vec_foreach_index (ni, l2fe_key)
191  {
192  send_l2fib_table_entry (am, reg, vec_elt_at_index (l2fe_key, ni),
193  vec_elt_at_index (l2fe_res, ni), mp->context);
194  }
195  vec_free (l2fe_key);
196  vec_free (l2fe_res);
197 }
198 
199 static void
201 {
202  bd_main_t *bdm = &bd_main;
203  l2input_main_t *l2im = &l2input_main;
204  vl_api_l2fib_add_del_reply_t *rmp;
205  int rv = 0;
206  u32 bd_id = ntohl (mp->bd_id);
207  uword *p = hash_get (bdm->bd_index_by_bd_id, bd_id);
208 
209  if (!p)
210  {
211  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
212  goto bad_sw_if_index;
213  }
214  u32 bd_index = p[0];
215 
216  u8 mac[6];
217 
218  clib_memcpy (mac, mp->mac, 6);
219  if (mp->is_add)
220  {
221  if (mp->filter_mac)
222  l2fib_add_filter_entry (mac, bd_index);
223  else
224  {
226  u32 sw_if_index = ntohl (mp->sw_if_index);
228  if (vec_len (l2im->configs) <= sw_if_index)
229  {
230  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
231  goto bad_sw_if_index;
232  }
233  else
234  {
235  l2_input_config_t *config;
236  config = vec_elt_at_index (l2im->configs, sw_if_index);
237  if (config->bridge == 0)
238  {
239  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
240  goto bad_sw_if_index;
241  }
242  }
243  if (mp->static_mac)
244  flags |= L2FIB_ENTRY_RESULT_FLAG_STATIC;
245  if (mp->bvi_mac)
246  flags |= L2FIB_ENTRY_RESULT_FLAG_BVI;
247  l2fib_add_entry (mac, bd_index, sw_if_index, flags);
248  }
249  }
250  else
251  {
252  u32 sw_if_index = ntohl (mp->sw_if_index);
253  if (l2fib_del_entry (mac, bd_index, sw_if_index))
254  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
255  }
256 
258 
259  REPLY_MACRO (VL_API_L2FIB_ADD_DEL_REPLY);
260 }
261 
262 static void
264 {
265  int rv = 0;
266  vl_api_want_l2_macs_events_reply_t *rmp;
269  u32 pid = ntohl (mp->pid);
270  u32 learn_limit = ntohl (mp->learn_limit);
271 
272  if (mp->enable_disable)
273  {
274  if (lm->client_pid == 0)
275  {
276  lm->client_pid = pid;
277  lm->client_index = mp->client_index;
278 
279  if (mp->max_macs_in_event)
280  fm->max_macs_in_event = mp->max_macs_in_event * 10;
281  else
283 
284  if (mp->scan_delay)
285  fm->event_scan_delay = (f64) (mp->scan_delay) * 10e-3;
286  else
288 
289  /* change learn limit and flush all learned MACs */
290  if (learn_limit && (learn_limit < L2LEARN_DEFAULT_LIMIT))
291  lm->global_learn_limit = learn_limit;
292  else
294 
296  }
297  else if (lm->client_pid != pid)
298  {
299  rv = VNET_API_ERROR_L2_MACS_EVENT_CLINET_PRESENT;
300  goto exit;
301  }
302  }
303  else if (lm->client_pid)
304  {
305  lm->client_pid = 0;
306  lm->client_index = 0;
307  if (learn_limit && (learn_limit < L2LEARN_DEFAULT_LIMIT))
308  lm->global_learn_limit = learn_limit;
309  else
311  }
312 
313 exit:
314  REPLY_MACRO (VL_API_WANT_L2_MACS_EVENTS_REPLY);
315 }
316 
317 static void
319 {
320  int rv = 0;
322  vl_api_l2fib_flush_int_reply_t *rmp;
323 
325 
326  u32 sw_if_index = ntohl (mp->sw_if_index);
327  l2fib_flush_int_mac (vm, sw_if_index);
328 
330  REPLY_MACRO (VL_API_L2FIB_FLUSH_INT_REPLY);
331 }
332 
333 static void
335 {
336  int rv = 0;
337  vl_api_l2fib_flush_all_reply_t *rmp;
338 
340  REPLY_MACRO (VL_API_L2FIB_FLUSH_ALL_REPLY);
341 }
342 
343 static void
345 {
346  int rv = 0;
348  bd_main_t *bdm = &bd_main;
349  vl_api_l2fib_flush_bd_reply_t *rmp;
350 
351  u32 bd_id = ntohl (mp->bd_id);
352  uword *p = hash_get (bdm->bd_index_by_bd_id, bd_id);
353  if (p == 0)
354  {
355  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
356  goto out;
357  }
358  l2fib_flush_bd_mac (vm, *p);
359 out:
360  REPLY_MACRO (VL_API_L2FIB_FLUSH_BD_REPLY);
361 }
362 
363 static void
365 {
367  int rv = 0;
368  u32 rbm = 0;
369 
371 
372  u32 sw_if_index = ntohl (mp->sw_if_index);
373  u32 flags = ntohl (mp->feature_bitmap);
374  u32 bitmap = 0;
375 
376  if (flags & L2_LEARN)
377  bitmap |= L2INPUT_FEAT_LEARN;
378 
379  if (flags & L2_FWD)
380  bitmap |= L2INPUT_FEAT_FWD;
381 
382  if (flags & L2_FLOOD)
383  bitmap |= L2INPUT_FEAT_FLOOD;
384 
385  if (flags & L2_UU_FLOOD)
386  bitmap |= L2INPUT_FEAT_UU_FLOOD;
387 
388  if (flags & L2_ARP_TERM)
389  bitmap |= L2INPUT_FEAT_ARP_TERM;
390 
391  rbm = l2input_intf_bitmap_enable (sw_if_index, bitmap, mp->is_set);
392 
394 
395  /* *INDENT-OFF* */
396  REPLY_MACRO2(VL_API_L2_FLAGS_REPLY,
397  ({
398  rmp->resulting_feature_bitmap = ntohl(rbm);
399  }));
400  /* *INDENT-ON* */
401 }
402 
403 static void
405  * mp)
406 {
408  bd_main_t *bdm = &bd_main;
409  vl_api_bridge_domain_set_mac_age_reply_t *rmp;
410  int rv = 0;
411  u32 bd_id = ntohl (mp->bd_id);
412  uword *p;
413 
414  if (bd_id == 0)
415  {
416  rv = VNET_API_ERROR_BD_NOT_MODIFIABLE;
417  goto out;
418  }
419 
420  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
421  if (p == 0)
422  {
423  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
424  goto out;
425  }
426  bd_set_mac_age (vm, *p, mp->mac_age);
427 out:
428  REPLY_MACRO (VL_API_BRIDGE_DOMAIN_SET_MAC_AGE_REPLY);
429 }
430 
431 static void
433 {
435  .is_add = mp->is_add,
436  .flood = mp->flood,
437  .uu_flood = mp->uu_flood,
438  .forward = mp->forward,
439  .learn = mp->learn,
440  .arp_term = mp->arp_term,
441  .arp_ufwd = mp->arp_ufwd,
442  .mac_age = mp->mac_age,
443  .bd_id = ntohl (mp->bd_id),
444  .bd_tag = mp->bd_tag
445  };
446 
447  int rv = bd_add_del (&a);
448 
449  vl_api_bridge_domain_add_del_reply_t *rmp;
450  REPLY_MACRO (VL_API_BRIDGE_DOMAIN_ADD_DEL_REPLY);
451 }
452 
453 static void
455  vl_api_registration_t * reg,
456  l2_bridge_domain_t * bd_config,
457  u32 n_sw_ifs, u32 context)
458 {
462  l2_input_config_t *input_cfg;
463 
464  mp = vl_msg_api_alloc (sizeof (*mp) +
465  (n_sw_ifs * sizeof (vl_api_bridge_domain_sw_if_t)));
466  clib_memset (mp, 0, sizeof (*mp));
467  mp->_vl_msg_id = ntohs (VL_API_BRIDGE_DOMAIN_DETAILS);
468  mp->bd_id = ntohl (bd_config->bd_id);
469  mp->flood = bd_feature_flood (bd_config);
470  mp->uu_flood = bd_feature_uu_flood (bd_config);
471  mp->forward = bd_feature_forward (bd_config);
472  mp->learn = bd_feature_learn (bd_config);
473  mp->arp_term = bd_feature_arp_term (bd_config);
474  mp->arp_ufwd = bd_feature_arp_ufwd (bd_config);
475  mp->bvi_sw_if_index = ntohl (bd_config->bvi_sw_if_index);
476  mp->uu_fwd_sw_if_index = ntohl (bd_config->uu_fwd_sw_if_index);
477  mp->mac_age = bd_config->mac_age;
478  if (bd_config->bd_tag)
479  {
480  strncpy ((char *) mp->bd_tag, (char *) bd_config->bd_tag,
481  ARRAY_LEN (mp->bd_tag) - 1);
482  mp->bd_tag[ARRAY_LEN (mp->bd_tag) - 1] = 0;
483  }
484 
485  mp->context = context;
486 
488  vec_foreach (m, bd_config->members)
489  {
490  sw_ifs->sw_if_index = ntohl (m->sw_if_index);
491  input_cfg = vec_elt_at_index (l2im->configs, m->sw_if_index);
492  sw_ifs->shg = input_cfg->shg;
493  sw_ifs++;
494  mp->n_sw_ifs++;
495  }
496  mp->n_sw_ifs = htonl (mp->n_sw_ifs);
497 
498  vl_api_send_msg (reg, (u8 *) mp);
499 }
500 
501 static void
503 {
504  bd_main_t *bdm = &bd_main;
505  l2input_main_t *l2im = &l2input_main;
507  u32 bd_id, bd_index, end;
508 
510  if (!reg)
511  return;
512 
513  bd_id = ntohl (mp->bd_id);
514  if (bd_id == 0)
515  return;
516 
517  if (bd_id == ~0)
518  bd_index = 0, end = vec_len (l2im->bd_configs);
519  else
520  {
521  bd_index = bd_find_index (bdm, bd_id);
522  if (bd_index == ~0)
523  return;
524 
525  end = bd_index + 1;
526  }
527 
528  for (; bd_index < end; bd_index++)
529  {
530  l2_bridge_domain_t *bd_config =
531  l2input_bd_config_from_index (l2im, bd_index);
532  /* skip dummy bd_id 0 */
533  if (bd_config && (bd_config->bd_id > 0))
534  send_bridge_domain_details (l2im, reg, bd_config,
535  vec_len (bd_config->members),
536  mp->context);
537  }
538 }
539 
540 static bd_flags_t
541 bd_flags_decode (vl_api_bd_flags_t v)
542 {
543  bd_flags_t f = L2_NONE;
544 
545  v = ntohl (v);
546 
547  if (v & BRIDGE_API_FLAG_LEARN)
548  f |= L2_LEARN;
549  if (v & BRIDGE_API_FLAG_FWD)
550  f |= L2_FWD;
551  if (v & BRIDGE_API_FLAG_FLOOD)
552  f |= L2_FLOOD;
553  if (v & BRIDGE_API_FLAG_UU_FLOOD)
554  f |= L2_UU_FLOOD;
555  if (v & BRIDGE_API_FLAG_ARP_TERM)
556  f |= L2_ARP_TERM;
557  if (v & BRIDGE_API_FLAG_ARP_UFWD)
558  f |= L2_ARP_UFWD;
559 
560  return (f);
561 }
562 
563 static void
565 {
567  bd_main_t *bdm = &bd_main;
569  u32 bitmap = 0;
570  int rv = 0;
571 
573  u32 bd_id = ntohl (mp->bd_id);
574  if (bd_id == 0)
575  {
576  rv = VNET_API_ERROR_BD_NOT_MODIFIABLE;
577  goto out;
578  }
579 
580  u32 bd_index = bd_find_index (bdm, bd_id);
581  if (bd_index == ~0)
582  {
583  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
584  goto out;
585  }
586 
587  bitmap = bd_set_flags (vm, bd_index, flags, mp->is_set);
588 
589 out:
590  /* *INDENT-OFF* */
591  REPLY_MACRO2(VL_API_BRIDGE_FLAGS_REPLY,
592  ({
593  rmp->resulting_feature_bitmap = ntohl(bitmap);
594  }));
595  /* *INDENT-ON* */
596 }
597 
598 static void
601 {
602  int rv = 0;
603  vl_api_l2_interface_vlan_tag_rewrite_reply_t *rmp;
604  vnet_main_t *vnm = vnet_get_main ();
606  u32 vtr_op;
607 
609 
610  vtr_op = ntohl (mp->vtr_op);
611 
612  /* The L2 code is unsuspicious */
613  switch (vtr_op)
614  {
615  case L2_VTR_DISABLED:
616  case L2_VTR_PUSH_1:
617  case L2_VTR_PUSH_2:
618  case L2_VTR_POP_1:
619  case L2_VTR_POP_2:
624  break;
625 
626  default:
627  rv = VNET_API_ERROR_INVALID_VALUE;
628  goto bad_sw_if_index;
629  }
630 
631  rv = l2vtr_configure (vm, vnm, ntohl (mp->sw_if_index), vtr_op,
632  ntohl (mp->push_dot1q), ntohl (mp->tag1),
633  ntohl (mp->tag2));
634 
636 
637  REPLY_MACRO (VL_API_L2_INTERFACE_VLAN_TAG_REWRITE_REPLY);
638 }
639 
640 static void
643 {
644  vl_api_l2_interface_pbb_tag_rewrite_reply_t *rmp;
645  vnet_main_t *vnm = vnet_get_main ();
647  u32 vtr_op;
648  int rv = 0;
649 
651 
652  vtr_op = ntohl (mp->vtr_op);
653 
654  switch (vtr_op)
655  {
656  case L2_VTR_DISABLED:
657  case L2_VTR_PUSH_2:
658  case L2_VTR_POP_2:
660  break;
661 
662  default:
663  rv = VNET_API_ERROR_INVALID_VALUE;
664  goto bad_sw_if_index;
665  }
666 
667  rv = l2pbb_configure (vm, vnm, ntohl (mp->sw_if_index), vtr_op,
668  mp->b_dmac, mp->b_smac, ntohs (mp->b_vlanid),
669  ntohl (mp->i_sid), ntohs (mp->outer_tag));
670 
672 
673  REPLY_MACRO (VL_API_L2_INTERFACE_PBB_TAG_REWRITE_REPLY);
674 }
675 
676 static void
679 {
680  vl_api_sw_interface_set_l2_xconnect_reply_t *rmp;
681  int rv = 0;
682  u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index);
683  u32 tx_sw_if_index = ntohl (mp->tx_sw_if_index);
685  vnet_main_t *vnm = vnet_get_main ();
686 
688 
689  if (mp->enable)
690  {
692  rv = set_int_l2_mode (vm, vnm, MODE_L2_XC,
693  rx_sw_if_index, 0,
694  L2_BD_PORT_TYPE_NORMAL, 0, tx_sw_if_index);
695  }
696  else
697  {
698  rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0,
699  L2_BD_PORT_TYPE_NORMAL, 0, 0);
700  }
701 
702  switch (rv)
703  {
704  case MODE_ERROR_ETH:
705  rv = VNET_API_ERROR_NON_ETHERNET;
706  break;
707  case MODE_ERROR_BVI_DEF:
708  rv = VNET_API_ERROR_BD_ALREADY_HAS_BVI;
709  break;
710  }
711 
714 
715  REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_XCONNECT_REPLY);
716 }
717 
718 static int
719 l2_bd_port_type_decode (vl_api_l2_port_type_t v, l2_bd_port_type_t * l)
720 {
721  v = clib_net_to_host_u32 (v);
722 
723  switch (v)
724  {
727  return 0;
729  *l = L2_BD_PORT_TYPE_BVI;
730  return 0;
733  return 0;
734  }
735 
736  return (VNET_API_ERROR_INVALID_VALUE);
737 }
738 
739 static void
742 {
743  bd_main_t *bdm = &bd_main;
744  vl_api_sw_interface_set_l2_bridge_reply_t *rmp;
745  int rv = 0;
747  vnet_main_t *vnm = vnet_get_main ();
749 
751  u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index);
752  rv = l2_bd_port_type_decode (mp->port_type, &pt);
753 
754  if (0 != rv)
755  goto out;
756  if (mp->enable)
757  {
758  VALIDATE_BD_ID (mp);
759  u32 bd_id = ntohl (mp->bd_id);
760  u32 bd_index = bd_find_or_add_bd_index (bdm, bd_id);
761 
762  rv = set_int_l2_mode (vm, vnm, MODE_L2_BRIDGE,
763  rx_sw_if_index, bd_index, pt, mp->shg, 0);
764  }
765  else
766  {
767  rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, pt, 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 out:
783  REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_BRIDGE_REPLY);
784 }
785 
786 static void
788  vl_api_registration_t * reg,
789  u32 bd_id,
790  const ip46_address_t * ip,
791  ip46_type_t itype,
792  const mac_address_t * mac, u32 context)
793 {
795 
796  mp = vl_msg_api_alloc (sizeof (*mp));
797  clib_memset (mp, 0, sizeof (*mp));
798  mp->_vl_msg_id = ntohs (VL_API_BD_IP_MAC_DETAILS);
799 
800  mp->context = context;
801  mp->entry.bd_id = ntohl (bd_id);
802 
803  ip_address_encode (ip, itype, &mp->entry.ip);
804  mac_address_encode (mac, mp->entry.mac);
805 
806  vl_api_send_msg (reg, (u8 *) mp);
807 }
808 
809 static void
811 {
813  bd_main_t *bdm = &bd_main;
814  l2_bridge_domain_t *bd_config;
815  u32 bd_id = ntohl (mp->bd_id);
816  u32 bd_index, start, end;
818  uword *p;
819 
821  if (!reg)
822  return;
823 
824  /* see bd_id: ~0 means "any" */
825  if (bd_id == ~0)
826  {
827  start = 1;
829  }
830  else
831  {
832  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
833  if (p == 0)
834  return;
835 
836  bd_index = p[0];
838  start = bd_index;
839  end = start + 1;
840  }
841 
842  for (bd_index = start; bd_index < end; bd_index++)
843  {
844  bd_config = vec_elt_at_index (l2input_main.bd_configs, bd_index);
845  if (bd_is_valid (bd_config))
846  {
847  ip4_address_t ip4_addr;
848  ip6_address_t *ip6_addr;
850  u64 mac64;
851  bd_id = bd_config->bd_id;
852 
853  /* *INDENT-OFF* */
854  hash_foreach (ip4_addr.as_u32, mac64, bd_config->mac_by_ip4,
855  ({
856  ip46_address_t ip = {
857  .ip4 = ip4_addr,
858  };
859  mac_address_from_u64(&mac, mac64);
860 
861  send_bd_ip_mac_entry (am, reg, bd_id, &ip, IP46_TYPE_IP4,
862  &mac, mp->context);
863  }));
864 
865  hash_foreach_mem (ip6_addr, mac64, bd_config->mac_by_ip6,
866  ({
867  ip46_address_t ip = {
868  .ip6 = *ip6_addr,
869  };
870  mac_address_from_u64(&mac, mac64);
871 
872  send_bd_ip_mac_entry (am, reg, bd_id, &ip, IP46_TYPE_IP6,
873  &mac, mp->context);
874  }));
875  /* *INDENT-ON* */
876  }
877  }
878 }
879 
880 static void
882 {
883  ip46_address_t ip_addr = ip46_address_initializer;
884  vl_api_bd_ip_mac_add_del_reply_t *rmp;
885  bd_main_t *bdm = &bd_main;
886  u32 bd_index, bd_id;
889  int rv = 0;
890  uword *p;
891 
892  bd_id = ntohl (mp->entry.bd_id);
893 
894  if (bd_id == 0)
895  {
896  rv = VNET_API_ERROR_BD_NOT_MODIFIABLE;
897  goto out;
898  }
899 
900  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
901  if (p == 0)
902  {
903  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
904  goto out;
905  }
906  bd_index = p[0];
907 
908  type = ip_address_decode (&mp->entry.ip, &ip_addr);
909  mac_address_decode (mp->entry.mac, &mac);
910 
911  if (bd_add_del_ip_mac (bd_index, type, &ip_addr, &mac, mp->is_add))
912  rv = VNET_API_ERROR_UNSPECIFIED;
913 
914 out:
915  REPLY_MACRO (VL_API_BD_IP_MAC_ADD_DEL_REPLY);
916 }
917 
918 static void
920 {
921  vl_api_bd_ip_mac_flush_reply_t *rmp;
922  bd_main_t *bdm = &bd_main;
923  u32 bd_index, bd_id;
924  int rv = 0;
925  uword *p;
926 
927  bd_id = ntohl (mp->bd_id);
928 
929  if (bd_id == 0)
930  {
931  rv = VNET_API_ERROR_BD_NOT_MODIFIABLE;
932  goto out;
933  }
934 
935  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
936  if (p == 0)
937  {
938  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
939  goto out;
940  }
941  bd_index = p[0];
942 
943  bd_flush_ip_mac (bd_index);
944 
945 out:
946  REPLY_MACRO (VL_API_BD_IP_MAC_FLUSH_REPLY);
947 }
948 
949 extern void l2_efp_filter_configure (vnet_main_t * vnet_main,
950  u32 sw_if_index, u8 enable);
951 
952 static void
954  mp)
955 {
956  int rv;
957  vl_api_l2_interface_efp_filter_reply_t *rmp;
958  vnet_main_t *vnm = vnet_get_main ();
959 
961 
962  // enable/disable the feature
963  l2_efp_filter_configure (vnm, ntohl (mp->sw_if_index), mp->enable_disable);
964  rv = vnm->api_errno;
965 
967  REPLY_MACRO (VL_API_L2_INTERFACE_EFP_FILTER_REPLY);
968 }
969 
970 static void
972 {
973  extern int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index,
974  int is_add);
975  vl_api_l2_patch_add_del_reply_t *rmp;
976  int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index,
977  int is_add);
978  int rv = 0;
979 
982 
983  rv = vnet_l2_patch_add_del (ntohl (mp->rx_sw_if_index),
984  ntohl (mp->tx_sw_if_index),
985  (int) (mp->is_add != 0));
986 
989 
990  REPLY_MACRO (VL_API_L2_PATCH_ADD_DEL_REPLY);
991 }
992 
993 static void
995 {
996  vl_api_sw_interface_set_vpath_reply_t *rmp;
997  int rv = 0;
998  u32 sw_if_index = ntohl (mp->sw_if_index);
999 
1000  VALIDATE_SW_IF_INDEX (mp);
1001 
1002  l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_VPATH, mp->enable);
1003  vnet_feature_enable_disable ("ip4-unicast", "vpath-input-ip4",
1004  sw_if_index, mp->enable, 0, 0);
1005  vnet_feature_enable_disable ("ip4-multicast", "vpath-input-ip4",
1006  sw_if_index, mp->enable, 0, 0);
1007  vnet_feature_enable_disable ("ip6-unicast", "vpath-input-ip6",
1008  sw_if_index, mp->enable, 0, 0);
1009  vnet_feature_enable_disable ("ip6-multicast", "vpath-input-ip6",
1010  sw_if_index, mp->enable, 0, 0);
1011 
1013 
1014  REPLY_MACRO (VL_API_SW_INTERFACE_SET_VPATH_REPLY);
1015 }
1016 
1017 static void
1019 {
1022  u32 sw_if_index;
1023  int rv;
1024 
1025  mac_address_decode (mp->mac, &mac);
1026 
1027  rv = l2_bvi_create (ntohl (mp->user_instance), &mac, &sw_if_index);
1028 
1029  /* *INDENT-OFF* */
1030  REPLY_MACRO2(VL_API_BVI_CREATE_REPLY,
1031  ({
1032  rmp->sw_if_index = ntohl (sw_if_index);
1033  }));
1034  /* *INDENT-ON* */
1035 }
1036 
1037 static void
1039 {
1040  vl_api_bvi_delete_reply_t *rmp;
1041  int rv;
1042 
1043  rv = l2_bvi_delete (ntohl (mp->sw_if_index));
1044 
1045  REPLY_MACRO (VL_API_BVI_DELETE_REPLY);
1046 }
1047 
1048 /*
1049  * l2_api_hookup
1050  * Add vpe's API message handlers to the table.
1051  * vlib has already mapped shared memory and
1052  * added the client registration handlers.
1053  * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
1054  */
1055 #define vl_msg_name_crc_list
1056 #include <vnet/vnet_all_api_h.h>
1057 #undef vl_msg_name_crc_list
1058 
1059 static void
1061 {
1062 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
1063  foreach_vl_msg_name_crc_l2;
1064 #undef _
1065 }
1066 
1067 static clib_error_t *
1069 {
1070  api_main_t *am = &api_main;
1071 
1072 #define _(N,n) \
1073  vl_msg_api_set_handlers(VL_API_##N, #n, \
1074  vl_api_##n##_t_handler, \
1075  vl_noop_handler, \
1076  vl_api_##n##_t_endian, \
1077  vl_api_##n##_t_print, \
1078  sizeof(vl_api_##n##_t), 1);
1080 #undef _
1081 
1082  /* Mark VL_API_BRIDGE_DOMAIN_DUMP as mp safe */
1083  am->is_mp_safe[VL_API_BRIDGE_DOMAIN_DUMP] = 1;
1084 
1085  /*
1086  * Set up the (msg_name, crc, message-id) table
1087  */
1089 
1090  return 0;
1091 }
1092 
1094 
1095 /*
1096  * fd.io coding-style-patch-verification: ON
1097  *
1098  * Local Variables:
1099  * eval: (c-set-style "gnu")
1100  * End:
1101  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:439
static_always_inline u8 bd_feature_forward(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:176
static void vl_api_l2_fib_table_dump_t_handler(vl_api_l2_fib_table_dump_t *mp)
Definition: l2_api.c:161
#define BAD_RX_SW_IF_INDEX_LABEL
static bd_flags_t bd_flags_decode(vl_api_bd_flags_t v)
Definition: l2_api.c:541
#define vec_foreach_index(var, v)
Iterate over vector indices.
L2 FIB add entry request.
Definition: l2.api:128
l2_input_config_t * configs
Definition: l2_input.h:61
Set bridge flags response.
Definition: l2.api:357
#define VALIDATE_TX_SW_IF_INDEX(mp)
u32 flags
Definition: vhost_user.h:141
u32 uu_fwd_sw_if_index
Definition: l2_bd.h:80
l2 fib table details structure
Definition: l2.api:52
static void vl_api_bvi_delete_t_handler(vl_api_bvi_delete_t *mp)
Definition: l2_api.c:1038
vl_api_bd_ip_mac_t entry
Definition: l2.api:521
vl_api_mac_address_t mac
Definition: l2.api:490
a
Definition: bitmap.h:538
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_l2_port_type_t port_type
Definition: l2.api:472
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:812
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
static void vl_api_sw_interface_set_l2_bridge_t_handler(vl_api_sw_interface_set_l2_bridge_t *mp)
Definition: l2_api.c:741
Create BVI interface instance request.
Definition: l2.api:569
u32 bvi_sw_if_index
Definition: l2_bd.h:74
void mac_address_encode(const mac_address_t *in, u8 *out)
static void vl_api_l2_patch_add_del_t_handler(vl_api_l2_patch_add_del_t *mp)
Definition: l2_api.c:971
static void vl_api_l2_flags_t_handler(vl_api_l2_flags_t *mp)
Definition: l2_api.c:364
vnet_interface_main_t interface_main
Definition: vnet.h:56
unsigned long u64
Definition: types.h:89
#define REPLY_MACRO2(t, body)
#define NULL
Definition: clib.h:58
struct l2fib_entry_key_t::@278::@280 fields
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:34
Definition: l2_bd.h:152
VLIB_API_INIT_FUNCTION(l2_api_hookup)
L2 bridge domain set mac age.
Definition: l2.api:233
l2_flood_member_t * members
Definition: l2_bd.h:86
Dump L2 XConnects.
Definition: l2.api:38
static void vl_api_bridge_domain_add_del_t_handler(vl_api_bridge_domain_add_del_t *mp)
Definition: l2_api.c:432
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
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:83
static void vl_api_bd_ip_mac_dump_t_handler(vl_api_bd_ip_mac_dump_t *mp)
Definition: l2_api.c:810
u32 max_macs_in_event
Definition: l2_fib.h:59
enum l2fib_entry_result_flags_t_ l2fib_entry_result_flags_t
L2 bridge domain request operational state details.
Definition: l2.api:275
int bd_add_del(l2_bridge_domain_add_del_args_t *a)
Definition: l2_bd.c:1261
bridge domain IP to MAC entry details structure
Definition: l2.api:518
static_always_inline u8 bd_feature_uu_flood(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:169
static void vl_api_l2fib_add_del_t_handler(vl_api_l2fib_add_del_t *mp)
Definition: l2_api.c:200
void * vl_msg_api_alloc(int nbytes)
unsigned char u8
Definition: types.h:56
u32 client_index
Definition: l2_learn.h:39
double f64
Definition: types.h:142
#define fm
#define clib_memcpy(d, s, n)
Definition: string.h:180
Definition: l2_fib.h:137
Reply to l2_xconnect_dump.
Definition: l2.api:27
static_always_inline u8 bd_feature_arp_ufwd(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:196
L2 bridge domain operational state response.
Definition: l2.api:306
l2learn_main_t l2learn_main
Definition: l2_learn.c:33
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:493
static void vl_api_bd_ip_mac_flush_t_handler(vl_api_bd_ip_mac_flush_t *mp)
Definition: l2_api.c:919
vl_api_interface_index_t sw_if_index
Definition: gre.api:50
#define MODE_L2_BRIDGE
Definition: l2_input.h:220
L2 bridge domain sw interface operational state response.
Definition: l2.api:287
#define hash_foreach(key_var, value_var, h, body)
Definition: hash.h:442
u32 feature_bitmap
Definition: l2.api:212
#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:189
static void vl_api_l2_fib_clear_table_t_handler(vl_api_l2_fib_clear_table_t *mp)
Definition: l2_api.c:124
L2 FIB flush bridge domain entries.
Definition: l2.api:99
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:401
unsigned int u32
Definition: types.h:88
uword * bd_index_by_bd_id
Definition: l2_bd.h:36
ip46_type_t ip_address_decode(const vl_api_address_t *in, ip46_address_t *out)
Definition: ip_types_api.c:161
Dump l2 fib (aka bridge domain) table.
Definition: l2.api:67
vl_api_fib_path_type_t type
Definition: fib_types.api:123
static_always_inline u8 bd_feature_flood(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:162
vnet_api_error_t api_errno
Definition: vnet.h:78
#define hash_get(h, key)
Definition: hash.h:249
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:206
L2 FIB flush all entries.
Definition: l2.api:88
L2 fib clear table request, clear all mac entries in the l2 fib.
Definition: l2.api:78
u32 bd_id
Definition: gbp.api:274
Set interface L2 flags response.
Definition: l2.api:220
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:815
enum l2_bd_port_type_t_ l2_bd_port_type_t
static void vl_api_bd_ip_mac_add_del_t_handler(vl_api_bd_ip_mac_add_del_t *mp)
Definition: l2_api.c:881
#define REPLY_MACRO(t)
#define BAD_TX_SW_IF_INDEX_LABEL
void l2fib_flush_all_mac(vlib_main_t *vm)
Flush all non static MACs - flushes all valid BDs.
Definition: l2_fib.c:826
static_always_inline void mac_address_from_u64(mac_address_t *mac, u64 u)
Definition: mac_address.h:122
struct l2fib_entry_result_t_::@286::@288 fields
Create BVI interface instance response.
Definition: l2.api:582
#define hash_foreach_mem(key_var, value_var, h, body)
Definition: hash.h:461
static clib_error_t * l2_api_hookup(vlib_main_t *vm)
Definition: l2_api.c:1068
#define L2FIB_EVENT_MAX_MACS_DEFAULT
Definition: l2_fib.h:37
l2fib_main_t l2fib_main
Definition: l2_fib.c:55
static u32 bd_is_valid(l2_bridge_domain_t *bd_config)
Definition: l2_bd.h:134
Definition: l2_bd.h:150
#define ip46_address_initializer
Definition: ip6_packet.h:96
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:203
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:300
An API client registration, only in vpp/vlib.
Definition: api_common.h:46
#define BAD_SW_IF_INDEX_LABEL
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:454
u32 l2fib_del_entry(const u8 *mac, u32 bd_index, u32 sw_if_index)
Delete an entry from the l2fib.
Definition: l2_fib.c:685
int l2_bvi_delete(u32 sw_if_index)
Definition: l2_bvi.c:210
vlib_main_t * vm
Definition: buffer.c:312
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:787
static void vl_api_l2_xconnect_dump_t_handler(vl_api_l2_xconnect_dump_t *mp)
Definition: l2_api.c:99
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:341
#define foreach_vpe_api_msg
Definition: l2_api.c:55
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:252
#define MODE_ERROR_ETH
Definition: l2_input.h:224
static_always_inline u8 bd_feature_learn(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:182
static void setup_message_id_table(api_main_t *am)
Definition: l2_api.c:1060
void l2fib_clear_table(void)
Definition: l2_fib.c:343
#define ARRAY_LEN(x)
Definition: clib.h:62
uword * mac_by_ip6
Definition: l2_bd.h:102
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:56
#define VALIDATE_RX_SW_IF_INDEX(mp)
Dump bridge domain IP to MAC entries.
Definition: l2.api:528
void bd_flush_ip_mac(u32 bd_index)
Flush IP address to MAC address mapping tables in a BD.
Definition: l2_bd.c:889
#define L2FIB_EVENT_SCAN_DELAY_DEFAULT
Definition: l2_fib.h:34
Set L2 XConnect between two interfaces request.
Definition: l2.api:432
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:196
static_always_inline l2_bridge_domain_t * l2input_bd_config_from_index(l2input_main_t *l2im, u32 bd_index)
Definition: l2_input.h:76
ip46_type_t
Definition: ip6_packet.h:70
Definition: l2_fib.h:71
Register to receive L2 MAC events for learned and aged MAC.
Definition: l2.api:150
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:591
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:538
#define BAD_BD_ID_LABEL
u32 global_learn_limit
Definition: l2_learn.h:35
#define VALIDATE_BD_ID(mp)
#define MODE_L2_XC
Definition: l2_input.h:221
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
u32 resulting_feature_bitmap
Definition: l2.api:224
static void vl_api_l2_interface_vlan_tag_rewrite_t_handler(vl_api_l2_interface_vlan_tag_rewrite_t *mp)
Definition: l2_api.c:600
Interface bridge mode request.
Definition: l2.api:466
#define L2FIB_EVENT_LEARN_LIMIT_DEFAULT
Definition: l2_fib.h:40
static void vl_api_sw_interface_set_l2_xconnect_t_handler(vl_api_sw_interface_set_l2_xconnect_t *mp)
Definition: l2_api.c:678
l2input_main_t l2input_main
Definition: l2_input.c:128
static void vl_api_bvi_create_t_handler(vl_api_bvi_create_t *mp)
Definition: l2_api.c:1018
L2 FIB flush interface entries.
Definition: l2.api:111
static void vl_api_l2fib_flush_bd_t_handler(vl_api_l2fib_flush_bd_t *mp)
Definition: l2_api.c:344
vl_api_address_t ip
Definition: l2.api:489
vl_api_bd_flags_t flags
Definition: l2.api:349
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static void vl_api_want_l2_macs_events_t_handler(vl_api_want_l2_macs_events_t *mp)
Definition: l2_api.c:263
u64 uword
Definition: types.h:112
L2 interface ethernet flow point filtering enable/disable request.
Definition: l2.api:541
static void vl_api_bridge_flags_t_handler(vl_api_bridge_flags_t *mp)
Definition: l2_api.c:564
int vnet_l2_patch_add_del(u32 rx_sw_if_index, u32 tx_sw_if_index, int is_add)
Definition: l2_patch.c:229
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:833
static void vl_api_l2_interface_efp_filter_t_handler(vl_api_l2_interface_efp_filter_t *mp)
Definition: l2_api.c:953
L2 interface vlan tag rewrite configure request.
Definition: l2.api:373
static void vl_api_l2fib_flush_all_t_handler(vl_api_l2fib_flush_all_t *mp)
Definition: l2_api.c:334
l2_bridge_domain_t * bd_configs
Definition: l2_input.h:64
static void l2fib_add_filter_entry(const u8 *mac, u32 bd_index)
Definition: l2_fib.h:433
static void vl_api_bridge_domain_set_mac_age_t_handler(vl_api_bridge_domain_set_mac_age_t *mp)
Definition: l2_api.c:404
void ip_address_encode(const ip46_address_t *in, ip46_type_t type, vl_api_address_t *out)
Definition: ip_types_api.c:178
L2 interface patch add / del request.
Definition: l2.api:416
void l2fib_table_dump(u32 bd_index, l2fib_entry_key_t **l2fe_key, l2fib_entry_result_t **l2fe_res)
Definition: l2_fib.c:132
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:136
Interface set vpath request.
Definition: l2.api:555
#define MODE_ERROR_BVI_DEF
Definition: l2_input.h:225
static int l2_bd_port_type_decode(vl_api_l2_port_type_t v, l2_bd_port_type_t *l)
Definition: l2_api.c:719
u8 * is_mp_safe
Message is mp safe vector.
Definition: api_common.h:226
L2 interface pbb tag rewrite configure request.
Definition: l2.api:396
u32 sw_if_index
Definition: l2.api:210
#define vec_foreach(var, vec)
Vector iterator.
uword * mac_by_ip4
Definition: l2_bd.h:101
Set bridge flags request.
Definition: l2.api:343
Delete BVI interface request.
Definition: l2.api:594
vl_api_bridge_domain_sw_if_t sw_if_details[n_sw_ifs]
Definition: l2.api:321
u32 sw_if_index
Definition: l2_bd.h:55
u32 bd_find_index(bd_main_t *bdm, u32 bd_id)
Get a bridge domain.
Definition: l2_bd.c:70
vl_api_bd_ip_mac_t entry
Definition: l2.api:498
bd_main_t bd_main
Definition: l2_bd.c:44
vpe_api_main_t vpe_api_main
Definition: interface_api.c:49
u32 context
Definition: gre.api:45
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.
api_main_t api_main
Definition: api_shared.c:35
u32 client_pid
Definition: l2_learn.h:38
void mac_address_decode(const u8 *in, mac_address_t *out)
Conversion functions to/from (decode/encode) API types to VPP internal types.
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:805
static void vl_api_l2fib_flush_int_t_handler(vl_api_l2fib_flush_int_t *mp)
Definition: l2_api.c:318
Flush bridge domain IP to MAC entries.
Definition: l2.api:505
static void vl_api_l2_interface_pbb_tag_rewrite_t_handler(vl_api_l2_interface_pbb_tag_rewrite_t *mp)
Definition: l2_api.c:642
vl_api_mac_address_t mac
Definition: l2.api:573
#define L2LEARN_DEFAULT_LIMIT
Definition: l2_learn.h:49
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: feature.c:274
int l2_bvi_create(u32 user_instance, const mac_address_t *mac_in, u32 *sw_if_indexp)
Definition: l2_bvi.c:136
#define VALIDATE_SW_IF_INDEX(mp)
#define MODE_L3
Definition: l2_input.h:219
enum bd_flags_t_ bd_flags_t
static void vl_api_bridge_domain_dump_t_handler(vl_api_bridge_domain_dump_t *mp)
Definition: l2_api.c:502
L2 bridge domain add or delete request.
Definition: l2.api:254
static void vl_api_sw_interface_set_vpath_t_handler(vl_api_sw_interface_set_vpath_t *mp)
Definition: l2_api.c:994