FD.io VPP  v19.01.3-6-g70449b9b9
Vector Packet Processing
l2_fwd.c
Go to the documentation of this file.
1 /*
2  * l2_fwd.c : layer 2 forwarding using l2fib
3  *
4  * Copyright (c) 2013 Cisco and/or its affiliates.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #include <vlib/vlib.h>
19 #include <vnet/vnet.h>
20 #include <vnet/pg/pg.h>
21 #include <vnet/ethernet/ethernet.h>
22 #include <vlib/cli.h>
23 
24 #include <vnet/l2/l2_input.h>
25 #include <vnet/l2/l2_bvi.h>
26 #include <vnet/l2/l2_fwd.h>
27 #include <vnet/l2/l2_fib.h>
28 #include <vnet/l2/feat_bitmap.h>
29 
30 #include <vppinfra/error.h>
31 #include <vppinfra/hash.h>
32 #include <vppinfra/sparse_vec.h>
33 
34 
35 /**
36  * @file
37  * @brief Ethernet Forwarding.
38  *
39  * Code in this file handles forwarding Layer 2 packets. This file calls
40  * the FIB lookup, packet learning and the packet flooding as necessary.
41  * Packet is then sent to the next graph node.
42  */
43 
44 typedef struct
45 {
46 
47  /* Hash table */
48  BVT (clib_bihash) * mac_table;
49 
50  /* next node index for the L3 input node of each ethertype */
51  next_by_ethertype_t l3_next;
52 
53  /* Next nodes for each feature */
54  u32 feat_next_node_index[32];
55 
56  /* convenience variables */
59 } l2fwd_main_t;
60 
61 typedef struct
62 {
63  /* per-pkt trace data */
64  u8 src[6];
65  u8 dst[6];
70 
71 /* packet trace format function */
72 static u8 *
73 format_l2fwd_trace (u8 * s, va_list * args)
74 {
75  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
76  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
77  l2fwd_trace_t *t = va_arg (*args, l2fwd_trace_t *);
78 
79  s =
80  format (s,
81  "l2-fwd: sw_if_index %d dst %U src %U bd_index %d result [0x%llx, %d] %U",
85  t->result.fields.flags);
86  return s;
87 }
88 
89 #ifndef CLIB_MARCH_VARIANT
91 #else
93 #endif
94 
96 
97 #define foreach_l2fwd_error \
98 _(L2FWD, "L2 forward packets") \
99 _(FLOOD, "L2 forward misses") \
100 _(HIT, "L2 forward hits") \
101 _(BVI_BAD_MAC, "BVI L3 MAC mismatch") \
102 _(BVI_ETHERTYPE, "BVI packet with unhandled ethertype") \
103 _(FILTER_DROP, "Filter Mac Drop") \
104 _(REFLECT_DROP, "Reflection Drop") \
105 _(STALE_DROP, "Stale entry Drop")
106 
107 typedef enum
108 {
109 #define _(sym,str) L2FWD_ERROR_##sym,
111 #undef _
113 } l2fwd_error_t;
114 
115 static char *l2fwd_error_strings[] = {
116 #define _(sym,string) string,
118 #undef _
119 };
120 
121 typedef enum
122 {
126 } l2fwd_next_t;
127 
128 /** Forward one packet based on the mac table lookup result. */
129 
132  vlib_node_runtime_t * node,
133  l2fwd_main_t * msm,
134  vlib_error_main_t * em,
135  vlib_buffer_t * b0,
136  u32 sw_if_index0, l2fib_entry_result_t * result0, u16 * next0)
137 {
138  int try_flood = result0->raw == ~0;
139  int flood_error;
140 
141  if (PREDICT_FALSE (try_flood))
142  {
143  flood_error = L2FWD_ERROR_FLOOD;
144  }
145  else
146  {
147  /* lookup hit, forward packet */
148 #ifdef COUNTERS
149  em->counters[node_counter_base_index + L2FWD_ERROR_HIT] += 1;
150 #endif
151 
152  vnet_buffer (b0)->sw_if_index[VLIB_TX] = result0->fields.sw_if_index;
153  *next0 = L2FWD_NEXT_L2_OUTPUT;
154  int l2fib_seq_num_valid = 1;
155 
156  /* check l2fib seq num for stale entries */
157  if (!l2fib_entry_result_is_set_AGE_NOT (result0))
158  {
159  l2fib_seq_num_t in_sn = {.as_u16 = vnet_buffer (b0)->l2.l2fib_sn };
160  l2fib_seq_num_t expected_sn = {
161  .bd = in_sn.bd,
162  .swif = *l2fib_swif_seq_num (result0->fields.sw_if_index),
163  };
164  l2fib_seq_num_valid =
165  expected_sn.as_u16 == result0->fields.sn.as_u16;
166  }
167 
168  if (PREDICT_FALSE (!l2fib_seq_num_valid))
169  {
170  flood_error = L2FWD_ERROR_STALE_DROP;
171  try_flood = 1;
172  }
173  /* perform reflection check */
174  else if (PREDICT_FALSE (sw_if_index0 == result0->fields.sw_if_index))
175  {
176  b0->error = node->errors[L2FWD_ERROR_REFLECT_DROP];
177  *next0 = L2FWD_NEXT_DROP;
178  }
179  /* perform filter check */
180  else if (PREDICT_FALSE (l2fib_entry_result_is_set_FILTER (result0)))
181  {
182  b0->error = node->errors[L2FWD_ERROR_FILTER_DROP];
183  *next0 = L2FWD_NEXT_DROP;
184  }
185  /* perform BVI check */
186  else if (PREDICT_FALSE (l2fib_entry_result_is_set_BVI (result0)))
187  {
188  u32 rc;
189  rc = l2_to_bvi (vm,
190  msm->vnet_main,
191  b0,
193  &msm->l3_next, next0);
194 
195  if (PREDICT_FALSE (rc))
196  {
197  if (rc == TO_BVI_ERR_BAD_MAC)
198  {
199  b0->error = node->errors[L2FWD_ERROR_BVI_BAD_MAC];
200  *next0 = L2FWD_NEXT_DROP;
201  }
202  else if (rc == TO_BVI_ERR_ETHERTYPE)
203  {
204  b0->error = node->errors[L2FWD_ERROR_BVI_ETHERTYPE];
205  *next0 = L2FWD_NEXT_DROP;
206  }
207  }
208  }
209  }
210 
211  /* flood */
212  if (PREDICT_FALSE (try_flood))
213  {
214  /*
215  * lookup miss, so flood which is typically the next feature
216  * unless some other feature is inserted before uu_flood
217  */
218  if (vnet_buffer (b0)->l2.feature_bitmap &
219  (L2INPUT_FEAT_UU_FLOOD |
220  L2INPUT_FEAT_UU_FWD | L2INPUT_FEAT_GBP_FWD))
221  {
222  *next0 = vnet_l2_feature_next (b0, msm->feat_next_node_index,
223  L2INPUT_FEAT_FWD);
224  }
225  else
226  {
227  /* Flooding is disabled */
228  b0->error = node->errors[flood_error];
229  *next0 = L2FWD_NEXT_DROP;
230  }
231  }
232 }
233 
234 
237  vlib_frame_t * frame, int do_trace)
238 {
239  u32 n_left, *from;
240  l2fwd_main_t *msm = &l2fwd_main;
241  vlib_node_t *n = vlib_get_node (vm, l2fwd_node.index);
242  CLIB_UNUSED (u32 node_counter_base_index) = n->error_heap_index;
243  vlib_error_main_t *em = &vm->error_main;
244  l2fib_entry_key_t cached_key;
245  l2fib_entry_result_t cached_result;
246  vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b;
247  u16 nexts[VLIB_FRAME_SIZE], *next;
248 
249  /* Clear the one-entry cache in case mac table was updated */
250  cached_key.raw = ~0;
251  cached_result.raw = ~0;
252 
253  from = vlib_frame_vector_args (frame);
254  n_left = frame->n_vectors; /* number of packets to process */
255  vlib_get_buffers (vm, from, bufs, n_left);
256  next = nexts;
257  b = bufs;
258 
259  while (n_left >= 8)
260  {
261  u32 sw_if_index0, sw_if_index1, sw_if_index2, sw_if_index3;
262  const ethernet_header_t *h0, *h1, *h2, *h3;
263  l2fib_entry_key_t key0, key1, key2, key3;
264  l2fib_entry_result_t result0, result1, result2, result3;
265 
266  /* Prefetch next iteration. */
267  {
268  vlib_prefetch_buffer_header (b[4], LOAD);
269  vlib_prefetch_buffer_header (b[5], LOAD);
270  vlib_prefetch_buffer_header (b[6], LOAD);
271  vlib_prefetch_buffer_header (b[7], LOAD);
272 
273  CLIB_PREFETCH (b[4]->data, CLIB_CACHE_LINE_BYTES, LOAD);
274  CLIB_PREFETCH (b[5]->data, CLIB_CACHE_LINE_BYTES, LOAD);
275  CLIB_PREFETCH (b[6]->data, CLIB_CACHE_LINE_BYTES, LOAD);
276  CLIB_PREFETCH (b[7]->data, CLIB_CACHE_LINE_BYTES, LOAD);
277  }
278 
279  /* RX interface handles */
280  sw_if_index0 = vnet_buffer (b[0])->sw_if_index[VLIB_RX];
281  sw_if_index1 = vnet_buffer (b[1])->sw_if_index[VLIB_RX];
282  sw_if_index2 = vnet_buffer (b[2])->sw_if_index[VLIB_RX];
283  sw_if_index3 = vnet_buffer (b[3])->sw_if_index[VLIB_RX];
284 
285  h0 = vlib_buffer_get_current (b[0]);
286  h1 = vlib_buffer_get_current (b[1]);
287  h2 = vlib_buffer_get_current (b[2]);
288  h3 = vlib_buffer_get_current (b[3]);
289 
290 #ifdef COUNTERS
291  em->counters[node_counter_base_index + L2FWD_ERROR_L2FWD] += 4;
292 #endif
293  /* *INDENT-OFF* */
294  l2fib_lookup_4 (msm->mac_table, &cached_key, &cached_result,
295  h0->dst_address, h1->dst_address,
296  h2->dst_address, h3->dst_address,
297  vnet_buffer (b[0])->l2.bd_index,
298  vnet_buffer (b[1])->l2.bd_index,
299  vnet_buffer (b[2])->l2.bd_index,
300  vnet_buffer (b[3])->l2.bd_index,
301  &key0, /* not used */
302  &key1, /* not used */
303  &key2, /* not used */
304  &key3, /* not used */
305  &result0,
306  &result1,
307  &result2,
308  &result3);
309  /* *INDENT-ON* */
310  l2fwd_process (vm, node, msm, em, b[0], sw_if_index0, &result0, next);
311  l2fwd_process (vm, node, msm, em, b[1], sw_if_index1, &result1,
312  next + 1);
313  l2fwd_process (vm, node, msm, em, b[2], sw_if_index2, &result2,
314  next + 2);
315  l2fwd_process (vm, node, msm, em, b[3], sw_if_index3, &result3,
316  next + 3);
317 
318  /* verify speculative enqueues, maybe switch current next frame */
319  /* if next0==next1==next_index then nothing special needs to be done */
320  if (do_trace)
321  {
322  if (b[0]->flags & VLIB_BUFFER_IS_TRACED)
323  {
324  l2fwd_trace_t *t = vlib_add_trace (vm, node, b[0], sizeof (*t));
325  t->sw_if_index = sw_if_index0;
326  t->bd_index = vnet_buffer (b[0])->l2.bd_index;
327  clib_memcpy_fast (t->src, h0->src_address, 6);
328  clib_memcpy_fast (t->dst, h0->dst_address, 6);
329  t->result = result0;
330  }
331  if (b[1]->flags & VLIB_BUFFER_IS_TRACED)
332  {
333  l2fwd_trace_t *t = vlib_add_trace (vm, node, b[1], sizeof (*t));
334  t->sw_if_index = sw_if_index1;
335  t->bd_index = vnet_buffer (b[1])->l2.bd_index;
336  clib_memcpy_fast (t->src, h1->src_address, 6);
337  clib_memcpy_fast (t->dst, h1->dst_address, 6);
338  t->result = result1;
339  }
340  if (b[2]->flags & VLIB_BUFFER_IS_TRACED)
341  {
342  l2fwd_trace_t *t = vlib_add_trace (vm, node, b[2], sizeof (*t));
343  t->sw_if_index = sw_if_index2;
344  t->bd_index = vnet_buffer (b[2])->l2.bd_index;
345  clib_memcpy_fast (t->src, h2->src_address, 6);
346  clib_memcpy_fast (t->dst, h2->dst_address, 6);
347  t->result = result2;
348  }
349  if (b[3]->flags & VLIB_BUFFER_IS_TRACED)
350  {
351  l2fwd_trace_t *t = vlib_add_trace (vm, node, b[3], sizeof (*t));
352  t->sw_if_index = sw_if_index3;
353  t->bd_index = vnet_buffer (b[3])->l2.bd_index;
354  clib_memcpy_fast (t->src, h3->src_address, 6);
355  clib_memcpy_fast (t->dst, h3->dst_address, 6);
356  t->result = result3;
357  }
358  }
359 
360  next += 4;
361  b += 4;
362  n_left -= 4;
363  }
364 
365  while (n_left > 0)
366  {
367  u32 sw_if_index0;
368  ethernet_header_t *h0;
369  l2fib_entry_key_t key0;
370  l2fib_entry_result_t result0;
371 
372  sw_if_index0 = vnet_buffer (b[0])->sw_if_index[VLIB_RX];
373 
374  h0 = vlib_buffer_get_current (b[0]);
375 
376  /* process 1 pkt */
377 #ifdef COUNTERS
378  em->counters[node_counter_base_index + L2FWD_ERROR_L2FWD] += 1;
379 #endif
380  l2fib_lookup_1 (msm->mac_table, &cached_key, &cached_result,
381  h0->dst_address, vnet_buffer (b[0])->l2.bd_index, &key0,
382  /* not used */ &result0);
383  l2fwd_process (vm, node, msm, em, b[0], sw_if_index0, &result0, next);
384 
385  if (do_trace && PREDICT_FALSE (b[0]->flags & VLIB_BUFFER_IS_TRACED))
386  {
387  l2fwd_trace_t *t = vlib_add_trace (vm, node, b[0], sizeof (*t));
388  t->sw_if_index = sw_if_index0;
389  t->bd_index = vnet_buffer (b[0])->l2.bd_index;
390  clib_memcpy_fast (t->src, h0->src_address, 6);
391  clib_memcpy_fast (t->dst, h0->dst_address, 6);
392  t->result = result0;
393  }
394 
395  /* verify speculative enqueue, maybe switch current next frame */
396  next += 1;
397  b += 1;
398  n_left -= 1;
399  }
400 
401  vlib_buffer_enqueue_to_next (vm, node, from, nexts, frame->n_vectors);
402 
403  return frame->n_vectors;
404 }
405 
407  vlib_node_runtime_t * node, vlib_frame_t * frame)
408 {
409  if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)))
410  return l2fwd_node_inline (vm, node, frame, 1 /* do_trace */ );
411  return l2fwd_node_inline (vm, node, frame, 0 /* do_trace */ );
412 }
413 
414 /* *INDENT-OFF* */
415 VLIB_REGISTER_NODE (l2fwd_node,static) = {
416  .name = "l2-fwd",
417  .vector_size = sizeof (u32),
418  .format_trace = format_l2fwd_trace,
419  .type = VLIB_NODE_TYPE_INTERNAL,
420 
421  .n_errors = ARRAY_LEN(l2fwd_error_strings),
422  .error_strings = l2fwd_error_strings,
423 
424  .n_next_nodes = L2FWD_N_NEXT,
425 
426  /* edit / add dispositions here */
427  .next_nodes = {
428  [L2FWD_NEXT_L2_OUTPUT] = "l2-output",
429  [L2FWD_NEXT_DROP] = "error-drop",
430  },
431 };
432 /* *INDENT-ON* */
433 
434 #ifndef CLIB_MARCH_VARIANT
435 clib_error_t *
437 {
438  l2fwd_main_t *mp = &l2fwd_main;
439 
440  mp->vlib_main = vm;
441  mp->vnet_main = vnet_get_main ();
442 
443  /* Initialize the feature next-node indexes */
445  l2fwd_node.index,
448  mp->feat_next_node_index);
449 
450  /* init the hash table ptr */
451  mp->mac_table = get_mac_table ();
452 
453  /* Initialize the next nodes for each ethertype */
454  next_by_ethertype_init (&mp->l3_next);
455 
456  return 0;
457 }
458 
460 
461 
462 /** Add the L3 input node for this ethertype to the next nodes structure. */
463 void
465  ethernet_type_t type, u32 node_index)
466 {
467  l2fwd_main_t *mp = &l2fwd_main;
468  u32 next_index;
469 
470  next_index = vlib_node_add_next (vm, l2fwd_node.index, node_index);
471 
472  next_by_ethertype_register (&mp->l3_next, type, next_index);
473 }
474 
475 
476 /**
477  * Set subinterface forward enable/disable.
478  * The CLI format is:
479  * set interface l2 forward <interface> [disable]
480  */
481 static clib_error_t *
483 {
484  vnet_main_t *vnm = vnet_get_main ();
485  clib_error_t *error = 0;
487  u32 enable;
488 
489  if (!unformat_user (input, unformat_vnet_sw_interface, vnm, &sw_if_index))
490  {
491  error = clib_error_return (0, "unknown interface `%U'",
492  format_unformat_error, input);
493  goto done;
494  }
495 
496  enable = 1;
497  if (unformat (input, "disable"))
498  {
499  enable = 0;
500  }
501 
502  /* set the interface flag */
503  if (l2input_intf_config (sw_if_index)->xconnect)
504  {
505  l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_XCONNECT, enable);
506  }
507  else
508  {
509  l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_FWD, enable);
510  }
511 
512 done:
513  return error;
514 }
515 
516 /*?
517  * Layer 2 unicast forwarding can be enabled and disabled on each
518  * interface and on each bridge-domain. Use this command to
519  * manage interfaces. It is enabled by default.
520  *
521  * @cliexpar
522  * Example of how to enable forwarding:
523  * @cliexcmd{set interface l2 forward GigabitEthernet0/8/0}
524  * Example of how to disable forwarding:
525  * @cliexcmd{set interface l2 forward GigabitEthernet0/8/0 disable}
526 ?*/
527 /* *INDENT-OFF* */
528 VLIB_CLI_COMMAND (int_fwd_cli, static) = {
529  .path = "set interface l2 forward",
530  .short_help = "set interface l2 forward <interface> [disable]",
531  .function = int_fwd,
532 };
533 /* *INDENT-ON* */
534 
535 #endif
536 
537 /*
538  * fd.io coding-style-patch-verification: ON
539  *
540  * Local Variables:
541  * eval: (c-set-style "gnu")
542  * End:
543  */
u32 error_heap_index
Definition: node.h:348
u32 flags
Definition: vhost_user.h:115
vl_api_address_t src
Definition: vxlan_gbp.api:32
#define CLIB_UNUSED(x)
Definition: clib.h:82
u16 bd_index
Definition: l2_fwd.c:67
#define TO_BVI_ERR_BAD_MAC
Definition: l2_bvi.h:28
vnet_main_t * vnet_get_main(void)
Definition: misc.c:47
u64 raw
Definition: l2_fib.h:149
l2_input_config_t * l2input_intf_config(u32 sw_if_index)
Get a pointer to the config for the given interface.
Definition: l2_input.c:520
#define clib_memcpy_fast(a, b, c)
Definition: string.h:81
ethernet_type_t
Definition: packet.h:45
#define TO_BVI_ERR_ETHERTYPE
Definition: l2_bvi.h:29
u8 src_address[6]
Definition: packet.h:56
clib_error_t * l2fwd_init(vlib_main_t *vm)
Definition: l2_fwd.c:436
static_always_inline u8 * l2fib_swif_seq_num(u32 sw_if_index)
Definition: l2_fib.h:457
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:983
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
unformat_function_t unformat_vnet_sw_interface
#define VLIB_NODE_FN(node)
Definition: node.h:201
vlib_error_t * errors
Vector of errors for this node.
Definition: node.h:493
static vlib_node_registration_t l2fwd_node
(constructor) VLIB_REGISTER_NODE (l2fwd_node)
Definition: l2_fwd.c:95
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
Definition: node_funcs.h:1092
unsigned char u8
Definition: types.h:56
static u32 vnet_l2_feature_next(vlib_buffer_t *b, u32 *next_nodes, u32 feat_bit)
Return the graph node index for the feature corresponding to the next set bit after clearing the curr...
Definition: feat_bitmap.h:94
u8 * format_l2fib_entry_result_flags(u8 *s, va_list *args)
Definition: l2_fib.c:58
Definition: l2_fib.h:137
#define static_always_inline
Definition: clib.h:99
u8 * format_ethernet_address(u8 *s, va_list *args)
Definition: format.c:44
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:163
u32 sw_if_index
Definition: vxlan_gbp.api:37
struct l2fib_entry_result_t_::@243::@245 fields
static_always_inline void l2fib_lookup_1(BVT(clib_bihash) *mac_table, l2fib_entry_key_t *cached_key, l2fib_entry_result_t *cached_result, u8 *mac0, u16 bd_index0, l2fib_entry_key_t *key0, l2fib_entry_result_t *result0)
Lookup the entry for mac and bd_index in the mac table for 1 packet.
Definition: l2_fib.h:265
u8 dst_address[6]
Definition: packet.h:55
static BVT(clib_bihash)
Definition: adj_nbr.c:28
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Definition: buffer.h:188
#define clib_error_return(e, args...)
Definition: error.h:99
unsigned int u32
Definition: types.h:88
#define VLIB_FRAME_SIZE
Definition: node.h:401
static clib_error_t * int_fwd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Set subinterface forward enable/disable.
Definition: l2_fwd.c:482
vlib_error_main_t error_main
Definition: main.h:143
struct _unformat_input_t unformat_input_t
unsigned short u16
Definition: types.h:57
void l2fwd_register_input_type(vlib_main_t *vm, ethernet_type_t type, u32 node_index)
Add the L3 input node for this ethertype to the next nodes structure.
Definition: l2_fwd.c:464
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:214
static char * l2fwd_error_strings[]
Definition: l2_fwd.c:115
static u8 * format_l2fwd_trace(u8 *s, va_list *args)
Definition: l2_fwd.c:73
#define PREDICT_FALSE(x)
Definition: clib.h:111
vnet_main_t vnet_main
Definition: misc.c:43
static_always_inline void l2fib_lookup_4(BVT(clib_bihash) *mac_table, l2fib_entry_key_t *cached_key, l2fib_entry_result_t *cached_result, const u8 *mac0, const u8 *mac1, const u8 *mac2, const u8 *mac3, u16 bd_index0, u16 bd_index1, u16 bd_index2, u16 bd_index3, l2fib_entry_key_t *key0, l2fib_entry_key_t *key1, l2fib_entry_key_t *key2, l2fib_entry_key_t *key3, l2fib_entry_result_t *result0, l2fib_entry_result_t *result1, l2fib_entry_result_t *result2, l2fib_entry_result_t *result3)
Definition: l2_fib.h:357
static_always_inline void l2fwd_process(vlib_main_t *vm, vlib_node_runtime_t *node, l2fwd_main_t *msm, vlib_error_main_t *em, vlib_buffer_t *b0, u32 sw_if_index0, l2fib_entry_result_t *result0, u16 *next0)
Forward one packet based on the mac table lookup result.
Definition: l2_fwd.c:131
l2fwd_main_t l2fwd_main
Definition: l2_fwd.c:90
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:139
static_always_inline uword l2fwd_node_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int do_trace)
Definition: l2_fwd.c:236
u64 * counters
Definition: error.h:48
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
clib_error_t * next_by_ethertype_register(next_by_ethertype_t *l3_next, u32 ethertype, u32 next_index)
Definition: node.c:1961
u16 n_vectors
Definition: node.h:420
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:79
vlib_main_t * vm
Definition: buffer.c:301
static_always_inline void vlib_buffer_enqueue_to_next(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, u16 *nexts, uword count)
Definition: buffer_node.h:332
vl_api_address_t dst
Definition: vxlan_gbp.api:33
static void feat_bitmap_init_next_nodes(vlib_main_t *vm, u32 node_index, u32 num_features, char **feat_names, u32 *next_nodes)
Initialize the feature next-node indexes of a graph node.
Definition: feat_bitmap.h:43
#define ARRAY_LEN(x)
Definition: clib.h:62
char ** l2input_get_feat_names(void)
Return an array of strings containing graph node names of each feature.
Definition: l2_input.c:60
l2fwd_error_t
Definition: l2_fwd.c:107
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:155
u32 sw_if_index
Definition: l2_fwd.c:66
Definition: l2_fib.h:71
#define foreach_l2fwd_error
Definition: l2_fwd.c:97
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:530
u8 src[6]
Definition: l2_fwd.c:64
l2fwd_next_t
Definition: l2_fwd.c:121
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace_funcs.h:57
int vlib_main(vlib_main_t *volatile vm, unformat_input_t *input)
Definition: main.c:1901
struct _vlib_node_registration vlib_node_registration_t
Definition: defs.h:47
u64 uword
Definition: types.h:112
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:244
clib_error_t * next_by_ethertype_init(next_by_ethertype_t *l3_next)
Definition: node.c:1931
u8 dst[6]
Definition: l2_fwd.c:65
#define vnet_buffer(b)
Definition: buffer.h:368
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
Definition: node_funcs.h:59
static_always_inline void vlib_get_buffers(vlib_main_t *vm, u32 *bi, vlib_buffer_t **b, int count)
Translate array of buffer indices into buffer pointers.
Definition: buffer_funcs.h:145
#define VLIB_NODE_FLAG_TRACE
Definition: node.h:326
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972
Definition: defs.h:46
u64 raw
Definition: l2_fib.h:85
l2fib_entry_result_t result
Definition: l2_fwd.c:68
static_always_inline u32 l2_to_bvi(vlib_main_t *vlib_main, vnet_main_t *vnet_main, vlib_buffer_t *b0, u32 bvi_sw_if_index, next_by_ethertype_t *l3_next, u16 *next0)
Send a packet from L2 processing to L3 via the BVI interface.
Definition: l2_bvi.h:38