FD.io VPP  v21.06-3-gbb25fbf28
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/vnet_msg_enum.h>
36 
37 #define vl_typedefs /* define message structures */
38 #include <vnet/vnet_all_api_h.h>
39 #undef vl_typedefs
40 
41 #define vl_endianfun /* define message structures */
42 #include <vnet/vnet_all_api_h.h>
43 #undef vl_endianfun
44 
45 /* instantiate all the print functions we know about */
46 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
47 #define vl_printfun
48 #include <vnet/vnet_all_api_h.h>
49 #undef vl_printfun
50 
52 
53 #define foreach_vpe_api_msg \
54  _ (L2_XCONNECT_DUMP, l2_xconnect_dump) \
55  _ (L2_FIB_CLEAR_TABLE, l2_fib_clear_table) \
56  _ (L2_FIB_TABLE_DUMP, l2_fib_table_dump) \
57  _ (L2FIB_FLUSH_ALL, l2fib_flush_all) \
58  _ (L2FIB_FLUSH_INT, l2fib_flush_int) \
59  _ (L2FIB_FLUSH_BD, l2fib_flush_bd) \
60  _ (L2FIB_ADD_DEL, l2fib_add_del) \
61  _ (L2FIB_SET_SCAN_DELAY, l2fib_set_scan_delay) \
62  _ (WANT_L2_MACS_EVENTS, want_l2_macs_events) \
63  _ (WANT_L2_MACS_EVENTS2, want_l2_macs_events2) \
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  _ (WANT_L2_ARP_TERM_EVENTS, want_l2_arp_term_events) \
82  _ (BRIDGE_DOMAIN_SET_LEARN_LIMIT, bridge_domain_set_learn_limit) \
83  _ (BRIDGE_DOMAIN_SET_DEFAULT_LEARN_LIMIT, \
84  bridge_domain_set_default_learn_limit)
85 
86 static void
88  u32 rx_sw_if_index, u32 tx_sw_if_index)
89 {
91 
92  mp = vl_msg_api_alloc (sizeof (*mp));
93  clib_memset (mp, 0, sizeof (*mp));
94  mp->_vl_msg_id = ntohs (VL_API_L2_XCONNECT_DETAILS);
95  mp->context = context;
96  mp->rx_sw_if_index = htonl (rx_sw_if_index);
97  mp->tx_sw_if_index = htonl (tx_sw_if_index);
98 
99  vl_api_send_msg (reg, (u8 *) mp);
100 }
101 
102 static void
104 {
106  l2input_main_t *l2im = &l2input_main;
108  l2_input_config_t *config;
109 
111  if (!reg)
112  return;
113 
114  /* *INDENT-OFF* */
116  {
117  config = vec_elt_at_index (l2im->configs, sw_if_index);
118  if (l2_input_is_xconnect (config))
120  config->output_sw_if_index);
121  }
122  /* *INDENT-ON* */
123 }
124 
125 static void
127 {
128  int rv = 0;
129  vl_api_l2_fib_clear_table_reply_t *rmp;
130 
131  /* Clear all MACs including static MACs */
133 
134  REPLY_MACRO (VL_API_L2_FIB_CLEAR_TABLE_REPLY);
135 }
136 
137 static void
139  vl_api_registration_t * reg,
140  l2fib_entry_key_t * l2fe_key,
141  l2fib_entry_result_t * l2fe_res, u32 context)
142 {
144 
145  mp = vl_msg_api_alloc (sizeof (*mp));
146  clib_memset (mp, 0, sizeof (*mp));
147  mp->_vl_msg_id = ntohs (VL_API_L2_FIB_TABLE_DETAILS);
148 
149  mp->bd_id =
150  ntohl (l2input_main.bd_configs[l2fe_key->fields.bd_index].bd_id);
151 
152  mac_address_encode ((mac_address_t *) l2fe_key->fields.mac, mp->mac);
153  mp->sw_if_index = ntohl (l2fe_res->fields.sw_if_index);
154  mp->static_mac = (l2fib_entry_result_is_set_STATIC (l2fe_res) ? 1 : 0);
155  mp->filter_mac = (l2fib_entry_result_is_set_FILTER (l2fe_res) ? 1 : 0);
156  mp->bvi_mac = (l2fib_entry_result_is_set_BVI (l2fe_res) ? 1 : 0);
157  mp->context = context;
158 
159  vl_api_send_msg (reg, (u8 *) mp);
160 }
161 
162 static void
164 {
166  bd_main_t *bdm = &bd_main;
167  l2fib_entry_key_t *l2fe_key = NULL;
168  l2fib_entry_result_t *l2fe_res = NULL;
169  u32 ni, bd_id = ntohl (mp->bd_id);
170  u32 bd_index;
172  uword *p;
173 
175  if (!reg)
176  return;
177 
178  /* see l2fib_table_dump: ~0 means "any" */
179  if (bd_id == ~0)
180  bd_index = ~0;
181  else
182  {
183  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
184  if (p == 0)
185  return;
186 
187  bd_index = p[0];
188  }
189 
190  l2fib_table_dump (bd_index, &l2fe_key, &l2fe_res);
191 
192  vec_foreach_index (ni, l2fe_key)
193  {
194  send_l2fib_table_entry (am, reg, vec_elt_at_index (l2fe_key, ni),
195  vec_elt_at_index (l2fe_res, ni), mp->context);
196  }
197  vec_free (l2fe_key);
198  vec_free (l2fe_res);
199 }
200 
201 static void
203 {
204  bd_main_t *bdm = &bd_main;
205  l2input_main_t *l2im = &l2input_main;
206  vl_api_l2fib_add_del_reply_t *rmp;
207  int rv = 0;
208  u32 bd_id = ntohl (mp->bd_id);
209  uword *p = hash_get (bdm->bd_index_by_bd_id, bd_id);
210 
211  if (!p)
212  {
213  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
214  goto bad_sw_if_index;
215  }
216  u32 bd_index = p[0];
217 
219 
220  mac_address_decode (mp->mac, &mac);
221  if (mp->is_add)
222  {
223  if (mp->filter_mac)
224  l2fib_add_filter_entry (mac.bytes, bd_index);
225  else
226  {
228  u32 sw_if_index = ntohl (mp->sw_if_index);
230  if (vec_len (l2im->configs) <= sw_if_index)
231  {
232  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
233  goto bad_sw_if_index;
234  }
235  else
236  {
237  l2_input_config_t *config;
238  config = vec_elt_at_index (l2im->configs, sw_if_index);
239  if (!l2_input_is_bridge (config))
240  {
241  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
242  goto bad_sw_if_index;
243  }
244  }
245  if (mp->static_mac)
246  flags |= L2FIB_ENTRY_RESULT_FLAG_STATIC;
247  if (mp->bvi_mac)
248  flags |= L2FIB_ENTRY_RESULT_FLAG_BVI;
249  l2fib_add_entry (mac.bytes, bd_index, sw_if_index, flags);
250  }
251  }
252  else
253  {
254  u32 sw_if_index = ntohl (mp->sw_if_index);
255  if (l2fib_del_entry (mac.bytes, bd_index, sw_if_index))
256  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
257  }
258 
260 
261  REPLY_MACRO (VL_API_L2FIB_ADD_DEL_REPLY);
262 }
263 
264 static void
266 {
267  int rv = 0;
268  vl_api_want_l2_macs_events2_reply_t *rmp;
271  u32 pid = ntohl (mp->pid);
272 
273  if (mp->enable_disable)
274  {
275  if ((lm->client_pid == 0) || (lm->client_pid == pid))
276  {
277  if (mp->max_macs_in_event)
278  fm->max_macs_in_event = mp->max_macs_in_event * 10;
279  else
280  {
281  rv = VNET_API_ERROR_INVALID_VALUE;
282  goto exit;
283  }
284 
285  /* if scan_delay was not set before */
286  if (fm->event_scan_delay == 0.0)
287  fm->event_scan_delay = (f64) (10) * 10e-3;
288 
289  lm->client_pid = pid;
290  lm->client_index = mp->client_index;
292  }
293  else if (lm->client_pid != pid)
294  {
295  rv = VNET_API_ERROR_L2_MACS_EVENT_CLINET_PRESENT;
296  goto exit;
297  }
298  }
299  else if (lm->client_pid)
300  {
301  lm->client_pid = 0;
302  lm->client_index = 0;
303  }
304 
305 exit:
306  REPLY_MACRO (VL_API_WANT_L2_MACS_EVENTS2_REPLY);
307 }
308 
309 static void
311 {
312  int rv = 0;
313  vl_api_want_l2_macs_events_reply_t *rmp;
316  u32 pid = ntohl (mp->pid);
317  u32 learn_limit = ntohl (mp->learn_limit);
318 
319  if (mp->enable_disable)
320  {
321  if ((lm->client_pid == 0) || (lm->client_pid == pid))
322  {
323  if ((mp->max_macs_in_event == 0) || (mp->scan_delay == 0) ||
324  (learn_limit == 0) || (learn_limit > L2LEARN_DEFAULT_LIMIT))
325  {
326  rv = VNET_API_ERROR_INVALID_VALUE;
327  goto exit;
328  }
329  lm->client_pid = pid;
330  lm->client_index = mp->client_index;
331 
332  fm->max_macs_in_event = mp->max_macs_in_event * 10;
333  fm->event_scan_delay = (f64) (mp->scan_delay) * 10e-3;
334 
335  /* change learn limit and flush all learned MACs */
336  lm->global_learn_limit = learn_limit;
338  }
339  else if (lm->client_pid != pid)
340  {
341  rv = VNET_API_ERROR_L2_MACS_EVENT_CLINET_PRESENT;
342  goto exit;
343  }
344  }
345  else if (lm->client_pid)
346  {
347  lm->client_pid = 0;
348  lm->client_index = 0;
349  if (learn_limit && (learn_limit <= L2LEARN_DEFAULT_LIMIT))
350  lm->global_learn_limit = learn_limit;
351  else
353  }
354 
355 exit:
356  REPLY_MACRO (VL_API_WANT_L2_MACS_EVENTS_REPLY);
357 }
358 
359 static void
361 {
362  int rv = 0;
364  vl_api_l2fib_flush_int_reply_t *rmp;
365 
367 
368  u32 sw_if_index = ntohl (mp->sw_if_index);
370 
372  REPLY_MACRO (VL_API_L2FIB_FLUSH_INT_REPLY);
373 }
374 
375 static void
377 {
378  int rv = 0;
379  vl_api_l2fib_flush_all_reply_t *rmp;
380 
382  REPLY_MACRO (VL_API_L2FIB_FLUSH_ALL_REPLY);
383 }
384 
385 static void
387 {
388  int rv = 0;
390  bd_main_t *bdm = &bd_main;
391  vl_api_l2fib_flush_bd_reply_t *rmp;
392 
393  u32 bd_id = ntohl (mp->bd_id);
394  uword *p = hash_get (bdm->bd_index_by_bd_id, bd_id);
395  if (p == 0)
396  {
397  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
398  goto out;
399  }
400  l2fib_flush_bd_mac (vm, *p);
401 out:
402  REPLY_MACRO (VL_API_L2FIB_FLUSH_BD_REPLY);
403 }
404 
405 static void
407 {
408  int rv = 0;
410  vl_api_l2fib_set_scan_delay_reply_t *rmp;
411  u16 scan_delay = ntohs (mp->scan_delay);
412 
413  if (mp->scan_delay)
414  {
415  fm->event_scan_delay = (f64) (scan_delay) *10e-3;
417  }
418  else
419  {
420  rv = VNET_API_ERROR_INVALID_VALUE;
421  goto exit;
422  }
423 
424 exit:
425  REPLY_MACRO (VL_API_L2FIB_SET_SCAN_DELAY_REPLY);
426 }
427 
428 static void
430 {
432  int rv = 0;
433  u32 rbm = 0;
434 
436 
437  u32 sw_if_index = ntohl (mp->sw_if_index);
438  u32 flags = ntohl (mp->feature_bitmap);
439  u32 bitmap = 0;
440 
441  if (flags & L2_LEARN)
442  bitmap |= L2INPUT_FEAT_LEARN;
443 
444  if (flags & L2_FWD)
445  bitmap |= L2INPUT_FEAT_FWD;
446 
447  if (flags & L2_FLOOD)
448  bitmap |= L2INPUT_FEAT_FLOOD;
449 
450  if (flags & L2_UU_FLOOD)
451  bitmap |= L2INPUT_FEAT_UU_FLOOD;
452 
453  if (flags & L2_ARP_TERM)
454  bitmap |= L2INPUT_FEAT_ARP_TERM;
455 
456  rbm = l2input_intf_bitmap_enable (sw_if_index, bitmap, mp->is_set);
457 
459 
460  /* *INDENT-OFF* */
461  REPLY_MACRO2(VL_API_L2_FLAGS_REPLY,
462  ({
463  rmp->resulting_feature_bitmap = ntohl(rbm);
464  }));
465  /* *INDENT-ON* */
466 }
467 
468 static void
471 {
472  vl_api_bridge_domain_set_default_learn_limit_reply_t *rmp;
473  int rv = 0;
474 
476  REPLY_MACRO (VL_API_BRIDGE_DOMAIN_SET_DEFAULT_LEARN_LIMIT_REPLY);
477 }
478 
479 static void
482 {
484  bd_main_t *bdm = &bd_main;
485  vl_api_bridge_domain_set_learn_limit_reply_t *rmp;
486  int rv = 0;
487  u32 bd_id = ntohl (mp->bd_id);
488  uword *p;
489 
490  if (bd_id == 0)
491  {
492  rv = VNET_API_ERROR_BD_NOT_MODIFIABLE;
493  goto out;
494  }
495 
496  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
497  if (p == 0)
498  {
499  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
500  goto out;
501  }
502  bd_set_learn_limit (vm, *p, ntohl (mp->learn_limit));
503 out:
504  REPLY_MACRO (VL_API_BRIDGE_DOMAIN_SET_LEARN_LIMIT_REPLY);
505 }
506 
507 static void
509  * mp)
510 {
512  bd_main_t *bdm = &bd_main;
513  vl_api_bridge_domain_set_mac_age_reply_t *rmp;
514  int rv = 0;
515  u32 bd_id = ntohl (mp->bd_id);
516  uword *p;
517 
518  if (bd_id == 0)
519  {
520  rv = VNET_API_ERROR_BD_NOT_MODIFIABLE;
521  goto out;
522  }
523 
524  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
525  if (p == 0)
526  {
527  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
528  goto out;
529  }
530  bd_set_mac_age (vm, *p, mp->mac_age);
531 out:
532  REPLY_MACRO (VL_API_BRIDGE_DOMAIN_SET_MAC_AGE_REPLY);
533 }
534 
535 static void
537 {
539  .is_add = mp->is_add,
540  .flood = mp->flood,
541  .uu_flood = mp->uu_flood,
542  .forward = mp->forward,
543  .learn = mp->learn,
544  .arp_term = mp->arp_term,
545  .arp_ufwd = mp->arp_ufwd,
546  .mac_age = mp->mac_age,
547  .bd_id = ntohl (mp->bd_id),
548  .bd_tag = mp->bd_tag
549  };
550 
551  int rv = bd_add_del (&a);
552 
553  vl_api_bridge_domain_add_del_reply_t *rmp;
554  REPLY_MACRO (VL_API_BRIDGE_DOMAIN_ADD_DEL_REPLY);
555 }
556 
557 static void
559  vl_api_registration_t * reg,
560  l2_bridge_domain_t * bd_config,
561  u32 n_sw_ifs, u32 context)
562 {
565  vl_api_bridge_domain_sw_if_t *sw_ifs;
566  l2_input_config_t *input_cfg;
567 
568  mp = vl_msg_api_alloc (sizeof (*mp) +
569  (n_sw_ifs * sizeof (vl_api_bridge_domain_sw_if_t)));
570  clib_memset (mp, 0, sizeof (*mp));
571  mp->_vl_msg_id = ntohs (VL_API_BRIDGE_DOMAIN_DETAILS);
572  mp->bd_id = ntohl (bd_config->bd_id);
573  mp->flood = bd_feature_flood (bd_config);
574  mp->uu_flood = bd_feature_uu_flood (bd_config);
575  mp->forward = bd_feature_forward (bd_config);
576  mp->learn = bd_feature_learn (bd_config);
577  mp->arp_term = bd_feature_arp_term (bd_config);
578  mp->arp_ufwd = bd_feature_arp_ufwd (bd_config);
579  mp->bvi_sw_if_index = ntohl (bd_config->bvi_sw_if_index);
580  mp->uu_fwd_sw_if_index = ntohl (bd_config->uu_fwd_sw_if_index);
581  mp->mac_age = bd_config->mac_age;
582  if (bd_config->bd_tag)
583  {
584  strncpy ((char *) mp->bd_tag, (char *) bd_config->bd_tag,
585  ARRAY_LEN (mp->bd_tag) - 1);
586  mp->bd_tag[ARRAY_LEN (mp->bd_tag) - 1] = 0;
587  }
588 
589  mp->context = context;
590 
591  sw_ifs = (vl_api_bridge_domain_sw_if_t *) mp->sw_if_details;
592  vec_foreach (m, bd_config->members)
593  {
594  sw_ifs->sw_if_index = ntohl (m->sw_if_index);
595  input_cfg = vec_elt_at_index (l2im->configs, m->sw_if_index);
596  sw_ifs->shg = input_cfg->shg;
597  sw_ifs++;
598  mp->n_sw_ifs++;
599  }
600  mp->n_sw_ifs = htonl (mp->n_sw_ifs);
601 
602  vl_api_send_msg (reg, (u8 *) mp);
603 }
604 
605 static void
607 {
608  bd_main_t *bdm = &bd_main;
609  l2input_main_t *l2im = &l2input_main;
611  u32 bd_id, bd_index, end, filter_sw_if_index;
612 
614  if (!reg)
615  return;
616 
617  filter_sw_if_index = ntohl (mp->sw_if_index);
618  if (filter_sw_if_index != ~0)
619  return; /* UNIMPLEMENTED */
620 
621  bd_id = ntohl (mp->bd_id);
622  if (bd_id == 0)
623  return;
624 
625  if (bd_id == ~0)
626  bd_index = 0, end = vec_len (l2im->bd_configs);
627  else
628  {
629  bd_index = bd_find_index (bdm, bd_id);
630  if (bd_index == ~0)
631  return;
632 
633  end = bd_index + 1;
634  }
635 
636  for (; bd_index < end; bd_index++)
637  {
638  l2_bridge_domain_t *bd_config =
639  l2input_bd_config_from_index (l2im, bd_index);
640  /* skip placeholder bd_id 0 */
641  if (bd_config && (bd_config->bd_id > 0))
642  send_bridge_domain_details (l2im, reg, bd_config,
643  vec_len (bd_config->members),
644  mp->context);
645  }
646 }
647 
648 static bd_flags_t
649 bd_flags_decode (vl_api_bd_flags_t v)
650 {
651  bd_flags_t f = L2_NONE;
652 
653  v = ntohl (v);
654 
655  if (v & BRIDGE_API_FLAG_LEARN)
656  f |= L2_LEARN;
657  if (v & BRIDGE_API_FLAG_FWD)
658  f |= L2_FWD;
659  if (v & BRIDGE_API_FLAG_FLOOD)
660  f |= L2_FLOOD;
661  if (v & BRIDGE_API_FLAG_UU_FLOOD)
662  f |= L2_UU_FLOOD;
663  if (v & BRIDGE_API_FLAG_ARP_TERM)
664  f |= L2_ARP_TERM;
665  if (v & BRIDGE_API_FLAG_ARP_UFWD)
666  f |= L2_ARP_UFWD;
667 
668  return (f);
669 }
670 
671 static void
673 {
675  bd_main_t *bdm = &bd_main;
677  u32 bitmap = 0;
678  int rv = 0;
679 
681  u32 bd_id = ntohl (mp->bd_id);
682  if (bd_id == 0)
683  {
684  rv = VNET_API_ERROR_BD_NOT_MODIFIABLE;
685  goto out;
686  }
687 
688  u32 bd_index = bd_find_index (bdm, bd_id);
689  if (bd_index == ~0)
690  {
691  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
692  goto out;
693  }
694 
695  bitmap = bd_set_flags (vm, bd_index, flags, mp->is_set);
696 
697 out:
698  /* *INDENT-OFF* */
699  REPLY_MACRO2(VL_API_BRIDGE_FLAGS_REPLY,
700  ({
701  rmp->resulting_feature_bitmap = ntohl(bitmap);
702  }));
703  /* *INDENT-ON* */
704 }
705 
706 static void
709 {
710  int rv = 0;
711  vl_api_l2_interface_vlan_tag_rewrite_reply_t *rmp;
712  vnet_main_t *vnm = vnet_get_main ();
714  u32 vtr_op;
715 
717 
718  vtr_op = ntohl (mp->vtr_op);
719 
720  /* The L2 code is unsuspicious */
721  switch (vtr_op)
722  {
723  case L2_VTR_DISABLED:
724  case L2_VTR_PUSH_1:
725  case L2_VTR_PUSH_2:
726  case L2_VTR_POP_1:
727  case L2_VTR_POP_2:
732  break;
733 
734  default:
735  rv = VNET_API_ERROR_INVALID_VALUE;
736  goto bad_sw_if_index;
737  }
738 
739  rv = l2vtr_configure (vm, vnm, ntohl (mp->sw_if_index), vtr_op,
740  ntohl (mp->push_dot1q), ntohl (mp->tag1),
741  ntohl (mp->tag2));
742 
744 
745  REPLY_MACRO (VL_API_L2_INTERFACE_VLAN_TAG_REWRITE_REPLY);
746 }
747 
748 static void
751 {
752  vl_api_l2_interface_pbb_tag_rewrite_reply_t *rmp;
753  vnet_main_t *vnm = vnet_get_main ();
755  u32 vtr_op;
756  int rv = 0;
757  mac_address_t b_dmac, b_smac;
758 
760 
761  vtr_op = ntohl (mp->vtr_op);
762 
763  switch (vtr_op)
764  {
765  case L2_VTR_DISABLED:
766  case L2_VTR_PUSH_2:
767  case L2_VTR_POP_2:
769  break;
770 
771  default:
772  rv = VNET_API_ERROR_INVALID_VALUE;
773  goto bad_sw_if_index;
774  }
775 
776  mac_address_decode (mp->b_dmac, &b_dmac);
777  mac_address_decode (mp->b_smac, &b_smac);
778 
779  rv = l2pbb_configure (vm, vnm, ntohl (mp->sw_if_index), vtr_op,
780  b_dmac.bytes, b_smac.bytes, ntohs (mp->b_vlanid),
781  ntohl (mp->i_sid), ntohs (mp->outer_tag));
782 
784 
785  REPLY_MACRO (VL_API_L2_INTERFACE_PBB_TAG_REWRITE_REPLY);
786 }
787 
788 static void
791 {
792  vl_api_sw_interface_set_l2_xconnect_reply_t *rmp;
793  int rv = 0;
794  u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index);
795  u32 tx_sw_if_index = ntohl (mp->tx_sw_if_index);
797  vnet_main_t *vnm = vnet_get_main ();
798 
800 
801  if (mp->enable)
802  {
804  rv = set_int_l2_mode (vm, vnm, MODE_L2_XC,
805  rx_sw_if_index, 0,
807  }
808  else
809  {
810  rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0,
811  L2_BD_PORT_TYPE_NORMAL, 0, 0);
812  }
813 
814  switch (rv)
815  {
816  case MODE_ERROR_ETH:
817  rv = VNET_API_ERROR_NON_ETHERNET;
818  break;
819  case MODE_ERROR_BVI_DEF:
820  rv = VNET_API_ERROR_BD_ALREADY_HAS_BVI;
821  break;
822  }
823 
826 
827  REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_XCONNECT_REPLY);
828 }
829 
830 static int
831 l2_bd_port_type_decode (vl_api_l2_port_type_t v, l2_bd_port_type_t * l)
832 {
833  v = clib_net_to_host_u32 (v);
834 
835  switch (v)
836  {
839  return 0;
841  *l = L2_BD_PORT_TYPE_BVI;
842  return 0;
845  return 0;
846  }
847 
848  return (VNET_API_ERROR_INVALID_VALUE);
849 }
850 
851 static void
854 {
855  bd_main_t *bdm = &bd_main;
856  vl_api_sw_interface_set_l2_bridge_reply_t *rmp;
857  int rv = 0;
859  vnet_main_t *vnm = vnet_get_main ();
861 
863  u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index);
864  rv = l2_bd_port_type_decode (mp->port_type, &pt);
865 
866  if (0 != rv)
867  goto out;
868  if (mp->enable)
869  {
870  VALIDATE_BD_ID (mp);
871  u32 bd_id = ntohl (mp->bd_id);
872  u32 bd_index = bd_find_or_add_bd_index (bdm, bd_id);
873 
875  rx_sw_if_index, bd_index, pt, mp->shg, 0);
876  }
877  else
878  {
879  rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, pt, 0, 0);
880  }
881 
882  switch (rv)
883  {
884  case MODE_ERROR_ETH:
885  rv = VNET_API_ERROR_NON_ETHERNET;
886  break;
887  case MODE_ERROR_BVI_DEF:
888  rv = VNET_API_ERROR_BD_ALREADY_HAS_BVI;
889  break;
890  }
891 
894 out:
895  REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_BRIDGE_REPLY);
896 }
897 
898 static void
900  vl_api_registration_t * reg,
901  u32 bd_id,
902  const ip46_address_t * ip,
903  ip46_type_t itype,
904  const mac_address_t * mac, u32 context)
905 {
907 
908  mp = vl_msg_api_alloc (sizeof (*mp));
909  clib_memset (mp, 0, sizeof (*mp));
910  mp->_vl_msg_id = ntohs (VL_API_BD_IP_MAC_DETAILS);
911 
912  mp->context = context;
913  mp->entry.bd_id = ntohl (bd_id);
914 
915  ip_address_encode (ip, itype, &mp->entry.ip);
916  mac_address_encode (mac, mp->entry.mac);
917 
918  vl_api_send_msg (reg, (u8 *) mp);
919 }
920 
921 static void
923 {
925  bd_main_t *bdm = &bd_main;
926  l2_bridge_domain_t *bd_config;
927  u32 bd_id = ntohl (mp->bd_id);
928  u32 bd_index, start, end;
930  uword *p;
931 
933  if (!reg)
934  return;
935 
936  /* see bd_id: ~0 means "any" */
937  if (bd_id == ~0)
938  {
939  start = 1;
941  }
942  else
943  {
944  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
945  if (p == 0)
946  return;
947 
948  bd_index = p[0];
950  start = bd_index;
951  end = start + 1;
952  }
953 
954  for (bd_index = start; bd_index < end; bd_index++)
955  {
956  bd_config = vec_elt_at_index (l2input_main.bd_configs, bd_index);
957  if (bd_is_valid (bd_config))
958  {
959  ip4_address_t ip4_addr;
960  ip6_address_t *ip6_addr;
962  u64 mac64;
963  bd_id = bd_config->bd_id;
964 
965  /* *INDENT-OFF* */
966  hash_foreach (ip4_addr.as_u32, mac64, bd_config->mac_by_ip4,
967  ({
968  ip46_address_t ip = {
969  .ip4 = ip4_addr,
970  };
971  mac_address_from_u64(&mac, mac64);
972 
974  &mac, mp->context);
975  }));
976 
977  hash_foreach_mem (ip6_addr, mac64, bd_config->mac_by_ip6,
978  ({
979  ip46_address_t ip = {
980  .ip6 = *ip6_addr,
981  };
982  mac_address_from_u64(&mac, mac64);
983 
985  &mac, mp->context);
986  }));
987  /* *INDENT-ON* */
988  }
989  }
990 }
991 
992 static void
994 {
995  ip46_address_t ip_addr = ip46_address_initializer;
996  vl_api_bd_ip_mac_add_del_reply_t *rmp;
997  bd_main_t *bdm = &bd_main;
998  u32 bd_index, bd_id;
1000  ip46_type_t type;
1001  int rv = 0;
1002  uword *p;
1003 
1004  bd_id = ntohl (mp->entry.bd_id);
1005 
1006  if (bd_id == 0)
1007  {
1008  rv = VNET_API_ERROR_BD_NOT_MODIFIABLE;
1009  goto out;
1010  }
1011 
1012  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
1013  if (p == 0)
1014  {
1015  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
1016  goto out;
1017  }
1018  bd_index = p[0];
1019 
1020  type = ip_address_decode (&mp->entry.ip, &ip_addr);
1021  mac_address_decode (mp->entry.mac, &mac);
1022 
1023  if (bd_add_del_ip_mac (bd_index, type, &ip_addr, &mac, mp->is_add))
1024  rv = VNET_API_ERROR_UNSPECIFIED;
1025 
1026 out:
1027  REPLY_MACRO (VL_API_BD_IP_MAC_ADD_DEL_REPLY);
1028 }
1029 
1030 static void
1032 {
1033  vl_api_bd_ip_mac_flush_reply_t *rmp;
1034  bd_main_t *bdm = &bd_main;
1035  u32 bd_index, bd_id;
1036  int rv = 0;
1037  uword *p;
1038 
1039  bd_id = ntohl (mp->bd_id);
1040 
1041  if (bd_id == 0)
1042  {
1043  rv = VNET_API_ERROR_BD_NOT_MODIFIABLE;
1044  goto out;
1045  }
1046 
1047  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
1048  if (p == 0)
1049  {
1050  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
1051  goto out;
1052  }
1053  bd_index = p[0];
1054 
1055  bd_flush_ip_mac (bd_index);
1056 
1057 out:
1058  REPLY_MACRO (VL_API_BD_IP_MAC_FLUSH_REPLY);
1059 }
1060 
1062  u32 sw_if_index, u8 enable);
1063 
1064 static void
1066  mp)
1067 {
1068  int rv;
1069  vl_api_l2_interface_efp_filter_reply_t *rmp;
1070  vnet_main_t *vnm = vnet_get_main ();
1071 
1072  VALIDATE_SW_IF_INDEX (mp);
1073 
1074  // enable/disable the feature
1075  l2_efp_filter_configure (vnm, ntohl (mp->sw_if_index), mp->enable_disable);
1076  rv = vnm->api_errno;
1077 
1079  REPLY_MACRO (VL_API_L2_INTERFACE_EFP_FILTER_REPLY);
1080 }
1081 
1082 static void
1084 {
1085  extern int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index,
1086  int is_add);
1087  vl_api_l2_patch_add_del_reply_t *rmp;
1088  int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index,
1089  int is_add);
1090  int rv = 0;
1091 
1094 
1095  rv = vnet_l2_patch_add_del (ntohl (mp->rx_sw_if_index),
1096  ntohl (mp->tx_sw_if_index),
1097  (int) (mp->is_add != 0));
1098 
1101 
1102  REPLY_MACRO (VL_API_L2_PATCH_ADD_DEL_REPLY);
1103 }
1104 
1105 static void
1107 {
1108  vl_api_sw_interface_set_vpath_reply_t *rmp;
1109  int rv = 0;
1110  u32 sw_if_index = ntohl (mp->sw_if_index);
1111 
1112  VALIDATE_SW_IF_INDEX (mp);
1113 
1114  l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_VPATH, mp->enable);
1115  vnet_feature_enable_disable ("ip4-unicast", "vpath-input-ip4",
1116  sw_if_index, mp->enable, 0, 0);
1117  vnet_feature_enable_disable ("ip4-multicast", "vpath-input-ip4",
1118  sw_if_index, mp->enable, 0, 0);
1119  vnet_feature_enable_disable ("ip6-unicast", "vpath-input-ip6",
1120  sw_if_index, mp->enable, 0, 0);
1121  vnet_feature_enable_disable ("ip6-multicast", "vpath-input-ip6",
1122  sw_if_index, mp->enable, 0, 0);
1123 
1125 
1126  REPLY_MACRO (VL_API_SW_INTERFACE_SET_VPATH_REPLY);
1127 }
1128 
1129 static void
1131 {
1134  u32 sw_if_index;
1135  int rv;
1136 
1137  mac_address_decode (mp->mac, &mac);
1138 
1139  rv = l2_bvi_create (ntohl (mp->user_instance), &mac, &sw_if_index);
1140 
1141  /* *INDENT-OFF* */
1142  REPLY_MACRO2(VL_API_BVI_CREATE_REPLY,
1143  ({
1144  rmp->sw_if_index = ntohl (sw_if_index);
1145  }));
1146  /* *INDENT-ON* */
1147 }
1148 
1149 static void
1151 {
1152  vl_api_bvi_delete_reply_t *rmp;
1153  int rv;
1154 
1155  rv = l2_bvi_delete (ntohl (mp->sw_if_index));
1156 
1157  REPLY_MACRO (VL_API_BVI_DELETE_REPLY);
1158 }
1159 
1160 static bool
1162  const l2_arp_term_publish_event_t * e2)
1163 {
1164  if (e1 == NULL || e2 == NULL)
1165  return false;
1166  return (ip46_address_is_equal (&e1->ip, &e2->ip) &&
1167  (e1->sw_if_index == e2->sw_if_index) &&
1168  (mac_address_equal (&e1->mac, &e2->mac)));
1169 }
1170 
1171 static uword
1173  vlib_frame_t * f)
1174 {
1175  /* These cross the longjmp boundary (vlib_process_wait_for_event)
1176  * and need to be volatile - to prevent them from being optimized into
1177  * a register - which could change during suspension */
1178  volatile f64 last = vlib_time_now (vm);
1179  volatile l2_arp_term_publish_event_t last_event = { };
1180 
1182 
1183  while (1)
1184  {
1185  uword event_type = L2_ARP_TERM_EVENT_PUBLISH;
1187  f64 now;
1188 
1190 
1191  vlib_process_get_event_data (vm, &event_type);
1192  now = vlib_time_now (vm);
1193 
1194  if (event_type == L2_ARP_TERM_EVENT_PUBLISH)
1195  {
1197 
1198  vec_foreach (event, l2am->publish_events)
1199  {
1200  /* dampen duplicate events - cast away volatile */
1202  (event, (l2_arp_term_publish_event_t *) & last_event) &&
1203  (now - last) < 10.0)
1204  {
1205  continue;
1206  }
1207  last_event = *event;
1208  last = now;
1209 
1210  pool_foreach (reg, vpe_api_main.l2_arp_term_events_registrations)
1211  {
1212  vl_api_registration_t *vl_reg;
1213  vl_reg =
1215  ALWAYS_ASSERT (vl_reg != NULL);
1216 
1217  if (vl_reg && vl_api_can_send_msg (vl_reg))
1218  {
1220  vevent = vl_msg_api_alloc (sizeof *vevent);
1221  clib_memset (vevent, 0, sizeof *vevent);
1222  vevent->_vl_msg_id = htons (VL_API_L2_ARP_TERM_EVENT);
1223  vevent->client_index = reg->client_index;
1224  vevent->pid = reg->client_pid;
1225  ip_address_encode (&event->ip, event->type, &vevent->ip);
1226  vevent->sw_if_index = htonl (event->sw_if_index);
1227  mac_address_encode (&event->mac, vevent->mac);
1228  vl_api_send_msg (vl_reg, (u8 *) vevent);
1229  }
1230  }
1231  }
1233  }
1234  }
1235 
1236  return 0;
1237 }
1238 
1239 /* *INDENT-OFF* */
1241  .function = l2_arp_term_process,
1242  .type = VLIB_NODE_TYPE_PROCESS,
1243  .name = "l2-arp-term-publisher",
1244 };
1245 /* *INDENT-ON* */
1246 
1247 static void
1249  mp)
1250 {
1251  vl_api_want_l2_arp_term_events_reply_t *rmp;
1254  int rv = 0;
1255  uword *p;
1256 
1257  p = hash_get (am->l2_arp_term_events_registration_hash, mp->client_index);
1258 
1259  if (p)
1260  {
1261  if (mp->enable)
1262  {
1263  clib_warning ("pid %d: already enabled...", mp->pid);
1264  rv = VNET_API_ERROR_INVALID_REGISTRATION;
1265  goto reply;
1266  }
1267  else
1268  {
1269  rp = pool_elt_at_index (am->l2_arp_term_events_registrations, p[0]);
1270  pool_put (am->l2_arp_term_events_registrations, rp);
1271  hash_unset (am->l2_arp_term_events_registration_hash,
1272  mp->client_index);
1273  if (pool_elts (am->l2_arp_term_events_registrations) == 0)
1275  goto reply;
1276  }
1277  }
1278  if (mp->enable == 0)
1279  {
1280  clib_warning ("pid %d: already disabled...", mp->pid);
1281  rv = VNET_API_ERROR_INVALID_REGISTRATION;
1282  goto reply;
1283  }
1284  pool_get (am->l2_arp_term_events_registrations, rp);
1285  rp->client_index = mp->client_index;
1286  rp->client_pid = mp->pid;
1287  hash_set (am->l2_arp_term_events_registration_hash, rp->client_index,
1288  rp - am->l2_arp_term_events_registrations);
1290 
1291 reply:
1292  REPLY_MACRO (VL_API_WANT_L2_ARP_TERM_EVENTS_REPLY);
1293 }
1294 
1295 static clib_error_t *
1297 {
1299  vpe_api_main_t *am;
1300  uword *p;
1301 
1302  am = &vpe_api_main;
1303 
1304  /* remove from the registration hash */
1305  p = hash_get (am->l2_arp_term_events_registration_hash, client_index);
1306 
1307  if (p)
1308  {
1309  rp = pool_elt_at_index (am->l2_arp_term_events_registrations, p[0]);
1310  pool_put (am->l2_arp_term_events_registrations, rp);
1311  hash_unset (am->l2_arp_term_events_registration_hash, client_index);
1312  if (pool_elts (am->l2_arp_term_events_registrations) == 0)
1314  }
1315  return (NULL);
1316 }
1317 
1319 
1320 /*
1321  * l2_api_hookup
1322  * Add vpe's API message handlers to the table.
1323  * vlib has already mapped shared memory and
1324  * added the client registration handlers.
1325  * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
1326  */
1327 #define vl_msg_name_crc_list
1328 #include <vnet/vnet_all_api_h.h>
1329 #undef vl_msg_name_crc_list
1330 
1331 static void
1333 {
1334 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
1335  foreach_vl_msg_name_crc_l2;
1336 #undef _
1337 }
1338 
1339 static clib_error_t *
1341 {
1343 
1344 #define _(N,n) \
1345  vl_msg_api_set_handlers(VL_API_##N, #n, \
1346  vl_api_##n##_t_handler, \
1347  vl_noop_handler, \
1348  vl_api_##n##_t_endian, \
1349  vl_api_##n##_t_print, \
1350  sizeof(vl_api_##n##_t), 1);
1352 #undef _
1353 
1354  /* Mark VL_API_BRIDGE_DOMAIN_DUMP as mp safe */
1355  am->is_mp_safe[VL_API_BRIDGE_DOMAIN_DUMP] = 1;
1356 
1357  /*
1358  * Set up the (msg_name, crc, message-id) table
1359  */
1361 
1362  return 0;
1363 }
1364 
1366 
1367 /*
1368  * fd.io coding-style-patch-verification: ON
1369  *
1370  * Local Variables:
1371  * eval: (c-set-style "gnu")
1372  * End:
1373  */
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:905
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:406
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:536
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:831
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:87
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
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:360
l2_arp_term_main
l2_arp_term_main_t l2_arp_term_main
Definition: l2_arp_term.c:33
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:1080
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:553
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:193
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:1031
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:606
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:1083
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:1106
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:1248
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:163
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:240
bd_flags_decode
static bd_flags_t bd_flags_decode(vl_api_bd_flags_t v)
Definition: l2_api.c:649
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:480
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:213
l2learn_main_t::client_index
u32 client_index
Definition: l2_learn.h:43
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:589
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:287
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:922
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:853
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:105
vl_api_l2_flags_t_handler
static void vl_api_l2_flags_t_handler(vl_api_l2_flags_t *mp)
Definition: l2_api.c:429
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
L2_ARP_TERM_EVENT_PUBLISH
@ L2_ARP_TERM_EVENT_PUBLISH
Definition: l2_arp_term.h:31
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:126
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:445
BRIDGE_API_FLAG_FLOOD
@ BRIDGE_API_FLAG_FLOOD
Definition: l2.api:399
l2fib_entry_result_t_::fields
struct l2fib_entry_result_t_::@463::@465 fields
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:283
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:186
vl_api_bridge_flags_reply_t::resulting_feature_bitmap
u32 resulting_feature_bitmap
Definition: l2.api:430
hash_set
#define hash_set(h, key, value)
Definition: hash.h:255
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:202
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
l2fib_entry_key_t::fields
struct l2fib_entry_key_t::@459::@461 fields
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
vnet_msg_enum.h
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
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:926
vl_api_bridge_domain_add_del_t::uu_flood
bool uu_flood
Definition: l2.api:326
setup_message_id_table
static void setup_message_id_table(api_main_t *am)
Definition: l2_api.c:1332
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:383
MODE_L3
#define MODE_L3
Definition: l2_input.h:282
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:469
hash_get
#define hash_get(h, key)
Definition: hash.h:249
tx_sw_if_index
vl_api_interface_index_t tx_sw_if_index
Definition: ip.api:548
bd_feature_uu_flood
static_always_inline u8 bd_feature_uu_flood(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:200
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
hash_foreach
#define hash_foreach(key_var, value_var, h, body)
Definition: hash.h:441
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:288
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:103
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:993
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:234
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:227
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:1340
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
want_l2_arp_term_events_reaper
static clib_error_t * want_l2_arp_term_events_reaper(u32 client_index)
Definition: l2_api.c:1296
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:708
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:899
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:915
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:790
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:386
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:310
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:40
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:54
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:1161
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:558
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:746
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
foreach_vpe_api_msg
#define foreach_vpe_api_msg
Definition: l2_api.c:53
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:34
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:207
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:672
vl_api_want_l2_arp_term_events_t::pid
u32 pid
Definition: l2.api:682
now
f64 now
Definition: nat44_ei_out2in.c:710
hash_unset
#define hash_unset(h, key)
Definition: hash.h:261
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:220
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:220
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:544
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:399
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:1172
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:265
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
vnet_all_api_h.h
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:1130
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:780
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:325
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:376
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:1150
hash_foreach_mem
#define hash_foreach_mem(key_var, value_var, h, body)
Definition: hash.h:460
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:508
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:133
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:138
MODE_L2_XC
#define MODE_L2_XC
Definition: l2_input.h:284
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:1240
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:750
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
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:55
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:1065
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:505