FD.io VPP  v17.07.01-10-g3be13f0
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 
29 #include <vppinfra/error.h>
30 #include <vppinfra/hash.h>
31 #include <vppinfra/sparse_vec.h>
32 
33 
34 /**
35  * @file
36  * @brief Ethernet Forwarding.
37  *
38  * Code in this file handles forwarding Layer 2 packets. This file calls
39  * the FIB lookup, packet learning and the packet flooding as necessary.
40  * Packet is then sent to the next graph node.
41  */
42 
43 typedef struct
44 {
45 
46  /* Hash table */
47  BVT (clib_bihash) * mac_table;
48 
49  /* next node index for the L3 input node of each ethertype */
50  next_by_ethertype_t l3_next;
51 
52  /* convenience variables */
55 } l2fwd_main_t;
56 
57 typedef struct
58 {
59  /* per-pkt trace data */
60  u8 src[6];
61  u8 dst[6];
65 
66 /* packet trace format function */
67 static u8 *
68 format_l2fwd_trace (u8 * s, va_list * args)
69 {
70  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
71  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
72  l2fwd_trace_t *t = va_arg (*args, l2fwd_trace_t *);
73 
74  s = format (s, "l2-fwd: sw_if_index %d dst %U src %U bd_index %d",
75  t->sw_if_index,
78  return s;
79 }
80 
82 
84 
85 #define foreach_l2fwd_error \
86 _(L2FWD, "L2 forward packets") \
87 _(FLOOD, "L2 forward misses") \
88 _(HIT, "L2 forward hits") \
89 _(BVI_BAD_MAC, "BVI L3 MAC mismatch") \
90 _(BVI_ETHERTYPE, "BVI packet with unhandled ethertype") \
91 _(FILTER_DROP, "Filter Mac Drop") \
92 _(REFLECT_DROP, "Reflection Drop") \
93 _(STALE_DROP, "Stale entry Drop")
94 
95 typedef enum
96 {
97 #define _(sym,str) L2FWD_ERROR_##sym,
99 #undef _
101 } l2fwd_error_t;
102 
103 static char *l2fwd_error_strings[] = {
104 #define _(sym,string) string,
106 #undef _
107 };
108 
109 typedef enum
110 {
115 } l2fwd_next_t;
116 
117 /** Forward one packet based on the mac table lookup result. */
118 
121  vlib_node_runtime_t * node,
122  l2fwd_main_t * msm,
123  vlib_error_main_t * em,
124  vlib_buffer_t * b0,
125  u32 sw_if_index0, l2fib_entry_result_t * result0, u32 * next0)
126 {
127  int try_flood = result0->raw == ~0;
128  int flood_error;
129 
130  if (PREDICT_FALSE (try_flood))
131  {
132  flood_error = L2FWD_ERROR_FLOOD;
133  }
134  else
135  {
136  /* lookup hit, forward packet */
137 #ifdef COUNTERS
138  em->counters[node_counter_base_index + L2FWD_ERROR_HIT] += 1;
139 #endif
140 
141  vnet_buffer (b0)->sw_if_index[VLIB_TX] = result0->fields.sw_if_index;
142  *next0 = L2FWD_NEXT_L2_OUTPUT;
143  int l2fib_seq_num_valid = 1;
144  /* check l2fib seq num for stale entries */
145  if (!result0->fields.static_mac)
146  {
147  l2fib_seq_num_t in_sn = {.as_u16 = vnet_buffer (b0)->l2.l2fib_sn };
148  l2fib_seq_num_t expected_sn = {
149  .bd = in_sn.bd,
150  .swif = *l2fib_swif_seq_num (result0->fields.sw_if_index),
151  };
152  l2fib_seq_num_valid =
153  expected_sn.as_u16 == result0->fields.sn.as_u16;
154  }
155 
156  if (PREDICT_FALSE (!l2fib_seq_num_valid))
157  {
158  flood_error = L2FWD_ERROR_STALE_DROP;
159  try_flood = 1;
160  }
161  /* perform reflection check */
162  else if (PREDICT_FALSE (sw_if_index0 == result0->fields.sw_if_index))
163  {
164  b0->error = node->errors[L2FWD_ERROR_REFLECT_DROP];
165  *next0 = L2FWD_NEXT_DROP;
166  }
167  /* perform filter check */
168  else if (PREDICT_FALSE (result0->fields.filter))
169  {
170  b0->error = node->errors[L2FWD_ERROR_FILTER_DROP];
171  *next0 = L2FWD_NEXT_DROP;
172  }
173  /* perform BVI check */
174  else if (PREDICT_FALSE (result0->fields.bvi))
175  {
176  u32 rc;
177  rc = l2_to_bvi (vm,
178  msm->vnet_main,
179  b0,
180  vnet_buffer (b0)->sw_if_index[VLIB_TX],
181  &msm->l3_next, next0);
182 
183  if (PREDICT_FALSE (rc))
184  {
185  if (rc == TO_BVI_ERR_BAD_MAC)
186  {
187  b0->error = node->errors[L2FWD_ERROR_BVI_BAD_MAC];
188  *next0 = L2FWD_NEXT_DROP;
189  }
190  else if (rc == TO_BVI_ERR_ETHERTYPE)
191  {
192  b0->error = node->errors[L2FWD_ERROR_BVI_ETHERTYPE];
193  *next0 = L2FWD_NEXT_DROP;
194  }
195  }
196  }
197  }
198 
199  /* flood */
200  if (PREDICT_FALSE (try_flood))
201  {
202  /*
203  * lookup miss, so flood
204  * TODO:replicate packet to each intf in bridge-domain
205  * For now just drop
206  */
207  if (vnet_buffer (b0)->l2.feature_bitmap & L2INPUT_FEAT_UU_FLOOD)
208  {
209  *next0 = L2FWD_NEXT_FLOOD;
210  }
211  else
212  {
213  /* Flooding is disabled */
214  b0->error = node->errors[flood_error];
215  *next0 = L2FWD_NEXT_DROP;
216  }
217  }
218 
219 }
220 
221 
224  vlib_frame_t * frame, int do_trace)
225 {
226  u32 n_left_from, *from, *to_next;
227  l2fwd_next_t next_index;
228  l2fwd_main_t *msm = &l2fwd_main;
229  vlib_node_t *n = vlib_get_node (vm, l2fwd_node.index);
230  CLIB_UNUSED (u32 node_counter_base_index) = n->error_heap_index;
231  vlib_error_main_t *em = &vm->error_main;
232  l2fib_entry_key_t cached_key;
233  l2fib_entry_result_t cached_result;
234 
235  /* Clear the one-entry cache in case mac table was updated */
236  cached_key.raw = ~0;
237  cached_result.raw = ~0;
238 
239  from = vlib_frame_vector_args (frame);
240  n_left_from = frame->n_vectors; /* number of packets to process */
241  next_index = node->cached_next_index;
242 
243  while (n_left_from > 0)
244  {
245  u32 n_left_to_next;
246 
247  /* get space to enqueue frame to graph node "next_index" */
248  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
249 
250  while (n_left_from >= 8 && n_left_to_next >= 4)
251  {
252  u32 bi0, bi1, bi2, bi3;
253  vlib_buffer_t *b0, *b1, *b2, *b3;
254  u32 next0, next1, next2, next3;
255  u32 sw_if_index0, sw_if_index1, sw_if_index2, sw_if_index3;
256  ethernet_header_t *h0, *h1, *h2, *h3;
257  l2fib_entry_key_t key0, key1, key2, key3;
258  l2fib_entry_result_t result0, result1, result2, result3;
259  u32 bucket0, bucket1, bucket2, bucket3;
260 
261  /* Prefetch next iteration. */
262  {
263  vlib_buffer_t *p4, *p5, *p6, *p7;
264 
265  p4 = vlib_get_buffer (vm, from[4]);
266  p5 = vlib_get_buffer (vm, from[5]);
267  p6 = vlib_get_buffer (vm, from[6]);
268  p7 = vlib_get_buffer (vm, from[7]);
269 
270  vlib_prefetch_buffer_header (p4, LOAD);
271  vlib_prefetch_buffer_header (p5, LOAD);
272  vlib_prefetch_buffer_header (p6, LOAD);
273  vlib_prefetch_buffer_header (p7, LOAD);
274 
279  }
280 
281  /* speculatively enqueue b0 and b1 to the current next frame */
282  /* bi is "buffer index", b is pointer to the buffer */
283  to_next[0] = bi0 = from[0];
284  to_next[1] = bi1 = from[1];
285  to_next[2] = bi2 = from[2];
286  to_next[3] = bi3 = from[3];
287  from += 4;
288  to_next += 4;
289  n_left_from -= 4;
290  n_left_to_next -= 4;
291 
292  b0 = vlib_get_buffer (vm, bi0);
293  b1 = vlib_get_buffer (vm, bi1);
294  b2 = vlib_get_buffer (vm, bi2);
295  b3 = vlib_get_buffer (vm, bi3);
296 
297  /* RX interface handles */
298  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
299  sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_RX];
300  sw_if_index2 = vnet_buffer (b2)->sw_if_index[VLIB_RX];
301  sw_if_index3 = vnet_buffer (b3)->sw_if_index[VLIB_RX];
302 
303  h0 = vlib_buffer_get_current (b0);
304  h1 = vlib_buffer_get_current (b1);
305  h2 = vlib_buffer_get_current (b2);
306  h3 = vlib_buffer_get_current (b3);
307 
308  if (do_trace)
309  {
310  if (b0->flags & VLIB_BUFFER_IS_TRACED)
311  {
312  l2fwd_trace_t *t =
313  vlib_add_trace (vm, node, b0, sizeof (*t));
314  t->sw_if_index = sw_if_index0;
315  t->bd_index = vnet_buffer (b0)->l2.bd_index;
316  clib_memcpy (t->src, h0->src_address, 6);
317  clib_memcpy (t->dst, h0->dst_address, 6);
318  }
319  if (b1->flags & VLIB_BUFFER_IS_TRACED)
320  {
321  l2fwd_trace_t *t =
322  vlib_add_trace (vm, node, b1, sizeof (*t));
323  t->sw_if_index = sw_if_index1;
324  t->bd_index = vnet_buffer (b1)->l2.bd_index;
325  clib_memcpy (t->src, h1->src_address, 6);
326  clib_memcpy (t->dst, h1->dst_address, 6);
327  }
328  if (b2->flags & VLIB_BUFFER_IS_TRACED)
329  {
330  l2fwd_trace_t *t =
331  vlib_add_trace (vm, node, b2, sizeof (*t));
332  t->sw_if_index = sw_if_index2;
333  t->bd_index = vnet_buffer (b2)->l2.bd_index;
334  clib_memcpy (t->src, h2->src_address, 6);
335  clib_memcpy (t->dst, h2->dst_address, 6);
336  }
337  if (b3->flags & VLIB_BUFFER_IS_TRACED)
338  {
339  l2fwd_trace_t *t =
340  vlib_add_trace (vm, node, b3, sizeof (*t));
341  t->sw_if_index = sw_if_index3;
342  t->bd_index = vnet_buffer (b3)->l2.bd_index;
343  clib_memcpy (t->src, h3->src_address, 6);
344  clib_memcpy (t->dst, h3->dst_address, 6);
345  }
346  }
347 
348  /* process 2 pkts */
349 #ifdef COUNTERS
350  em->counters[node_counter_base_index + L2FWD_ERROR_L2FWD] += 4;
351 #endif
352  /* *INDENT-OFF* */
353  l2fib_lookup_4 (msm->mac_table, &cached_key, &cached_result,
354  h0->dst_address, h1->dst_address,
355  h2->dst_address, h3->dst_address,
356  vnet_buffer (b0)->l2.bd_index,
357  vnet_buffer (b1)->l2.bd_index,
358  vnet_buffer (b2)->l2.bd_index,
359  vnet_buffer (b3)->l2.bd_index,
360  &key0, /* not used */
361  &key1, /* not used */
362  &key2, /* not used */
363  &key3, /* not used */
364  &bucket0, /* not used */
365  &bucket1, /* not used */
366  &bucket2, /* not used */
367  &bucket3, /* not used */
368  &result0,
369  &result1,
370  &result2,
371  &result3);
372  /* *INDENT-ON* */
373  l2fwd_process (vm, node, msm, em, b0, sw_if_index0, &result0,
374  &next0);
375  l2fwd_process (vm, node, msm, em, b1, sw_if_index1, &result1,
376  &next1);
377  l2fwd_process (vm, node, msm, em, b2, sw_if_index2, &result2,
378  &next2);
379  l2fwd_process (vm, node, msm, em, b3, sw_if_index3, &result3,
380  &next3);
381 
382  /* verify speculative enqueues, maybe switch current next frame */
383  /* if next0==next1==next_index then nothing special needs to be done */
384  vlib_validate_buffer_enqueue_x4 (vm, node, next_index,
385  to_next, n_left_to_next,
386  bi0, bi1, bi2, bi3,
387  next0, next1, next2, next3);
388  }
389 
390  while (n_left_from > 0 && n_left_to_next > 0)
391  {
392  u32 bi0;
393  vlib_buffer_t *b0;
394  u32 next0;
395  u32 sw_if_index0;
396  ethernet_header_t *h0;
397  l2fib_entry_key_t key0;
398  l2fib_entry_result_t result0;
399  u32 bucket0;
400 
401  /* speculatively enqueue b0 to the current next frame */
402  bi0 = from[0];
403  to_next[0] = bi0;
404  from += 1;
405  to_next += 1;
406  n_left_from -= 1;
407  n_left_to_next -= 1;
408 
409  b0 = vlib_get_buffer (vm, bi0);
410 
411  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
412 
413  h0 = vlib_buffer_get_current (b0);
414 
415  if (do_trace && PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
416  {
417  l2fwd_trace_t *t = vlib_add_trace (vm, node, b0, sizeof (*t));
418  t->sw_if_index = sw_if_index0;
419  t->bd_index = vnet_buffer (b0)->l2.bd_index;
420  clib_memcpy (t->src, h0->src_address, 6);
421  clib_memcpy (t->dst, h0->dst_address, 6);
422  }
423 
424  /* process 1 pkt */
425 #ifdef COUNTERS
426  em->counters[node_counter_base_index + L2FWD_ERROR_L2FWD] += 1;
427 #endif
428  l2fib_lookup_1 (msm->mac_table, &cached_key, &cached_result, h0->dst_address, vnet_buffer (b0)->l2.bd_index, &key0, /* not used */
429  &bucket0, /* not used */
430  &result0);
431  l2fwd_process (vm, node, msm, em, b0, sw_if_index0, &result0,
432  &next0);
433 
434  /* verify speculative enqueue, maybe switch current next frame */
435  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
436  to_next, n_left_to_next,
437  bi0, next0);
438  }
439 
440  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
441  }
442 
443  return frame->n_vectors;
444 }
445 
446 static uword
448  vlib_node_runtime_t * node, vlib_frame_t * frame)
449 {
450  if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)))
451  return l2fwd_node_inline (vm, node, frame, 1 /* do_trace */ );
452  return l2fwd_node_inline (vm, node, frame, 0 /* do_trace */ );
453 }
454 
455 /* *INDENT-OFF* */
456 VLIB_REGISTER_NODE (l2fwd_node,static) = {
457  .function = l2fwd_node_fn,
458  .name = "l2-fwd",
459  .vector_size = sizeof (u32),
460  .format_trace = format_l2fwd_trace,
461  .type = VLIB_NODE_TYPE_INTERNAL,
462 
463  .n_errors = ARRAY_LEN(l2fwd_error_strings),
464  .error_strings = l2fwd_error_strings,
465 
466  .n_next_nodes = L2FWD_N_NEXT,
467 
468  /* edit / add dispositions here */
469  .next_nodes = {
470  [L2FWD_NEXT_L2_OUTPUT] = "l2-output",
471  [L2FWD_NEXT_FLOOD] = "l2-flood",
472  [L2FWD_NEXT_DROP] = "error-drop",
473  },
474 };
475 /* *INDENT-ON* */
476 
479 {
480  l2fwd_main_t *mp = &l2fwd_main;
481 
482  mp->vlib_main = vm;
483  mp->vnet_main = vnet_get_main ();
484 
485  /* init the hash table ptr */
486  mp->mac_table = get_mac_table ();
487 
488  /* Initialize the next nodes for each ethertype */
489  next_by_ethertype_init (&mp->l3_next);
490 
491  return 0;
492 }
493 
495 
496 
497 /** Add the L3 input node for this ethertype to the next nodes structure. */
498 void
500  ethernet_type_t type, u32 node_index)
501 {
502  l2fwd_main_t *mp = &l2fwd_main;
503  u32 next_index;
504 
505  next_index = vlib_node_add_next (vm, l2fwd_node.index, node_index);
506 
507  next_by_ethertype_register (&mp->l3_next, type, next_index);
508 }
509 
510 
511 /**
512  * Set subinterface forward enable/disable.
513  * The CLI format is:
514  * set interface l2 forward <interface> [disable]
515  */
516 static clib_error_t *
518 {
519  vnet_main_t *vnm = vnet_get_main ();
520  clib_error_t *error = 0;
521  u32 sw_if_index;
522  u32 enable;
523 
524  if (!unformat_user (input, unformat_vnet_sw_interface, vnm, &sw_if_index))
525  {
526  error = clib_error_return (0, "unknown interface `%U'",
527  format_unformat_error, input);
528  goto done;
529  }
530 
531  enable = 1;
532  if (unformat (input, "disable"))
533  {
534  enable = 0;
535  }
536 
537  /* set the interface flag */
538  if (l2input_intf_config (sw_if_index)->xconnect)
539  {
540  l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_XCONNECT, enable);
541  }
542  else
543  {
544  l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_FWD, enable);
545  }
546 
547 done:
548  return error;
549 }
550 
551 /*?
552  * Layer 2 unicast forwarding can be enabled and disabled on each
553  * interface and on each bridge-domain. Use this command to
554  * manage interfaces. It is enabled by default.
555  *
556  * @cliexpar
557  * Example of how to enable fowarding:
558  * @cliexcmd{set interface l2 forward GigabitEthernet0/8/0}
559  * Example of how to disable fowarding:
560  * @cliexcmd{set interface l2 forward GigabitEthernet0/8/0 disable}
561 ?*/
562 /* *INDENT-OFF* */
563 VLIB_CLI_COMMAND (int_fwd_cli, static) = {
564  .path = "set interface l2 forward",
565  .short_help = "set interface l2 forward <interface> [disable]",
566  .function = int_fwd,
567 };
568 /* *INDENT-ON* */
569 
570 /*
571  * fd.io coding-style-patch-verification: ON
572  *
573  * Local Variables:
574  * eval: (c-set-style "gnu")
575  * End:
576  */
u32 error_heap_index
Definition: node.h:279
#define CLIB_UNUSED(x)
Definition: clib.h:79
u16 bd_index
Definition: l2_fwd.c:63
#define TO_BVI_ERR_BAD_MAC
Definition: l2_bvi.h:28
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
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:476
ethernet_type_t
Definition: packet.h:43
#define TO_BVI_ERR_ETHERTYPE
Definition: l2_bvi.h:29
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
Definition: main.c:459
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, u32 *next0)
Send a packet from L2 processing to L3 via the BVI interface.
Definition: l2_bvi.h:38
u8 src_address[6]
Definition: packet.h:54
static uword l2fwd_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: l2_fwd.c:447
clib_error_t * l2fwd_init(vlib_main_t *vm)
Definition: l2_fwd.c:478
#define vlib_validate_buffer_enqueue_x4(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, bi2, bi3, next0, next1, next2, next3)
Finish enqueueing four buffers forward in the graph.
Definition: buffer_node.h:138
struct _vlib_node_registration vlib_node_registration_t
static_always_inline u8 * l2fib_swif_seq_num(u32 sw_if_index)
Definition: l2_fib.h:383
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
Definition: l2_fib.h:86
vlib_error_t * errors
Vector of errors for this node.
Definition: node.h:419
static vlib_node_registration_t l2fwd_node
(constructor) VLIB_REGISTER_NODE (l2fwd_node)
Definition: l2_fwd.c:83
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
Definition: node_funcs.h:1081
#define static_always_inline
Definition: clib.h:85
u8 * format_ethernet_address(u8 *s, va_list *args)
Definition: format.c:44
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:111
u8 dst_address[6]
Definition: packet.h:53
static BVT(clib_bihash)
Definition: adj_nbr.c:26
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Definition: buffer.h:164
#define clib_error_return(e, args...)
Definition: error.h:99
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, u32 *next0)
Forward one packet based on the mac table lookup result.
Definition: l2_fwd.c:120
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:517
vlib_error_main_t error_main
Definition: main.h:124
struct _unformat_input_t unformat_input_t
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:499
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:188
static char * l2fwd_error_strings[]
Definition: l2_fwd.c:103
static u8 * format_l2fwd_trace(u8 *s, va_list *args)
Definition: l2_fwd.c:68
#define PREDICT_FALSE(x)
Definition: clib.h:97
vnet_main_t vnet_main
Definition: misc.c:43
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
Definition: buffer_node.h:216
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
Definition: node_funcs.h:366
l2fwd_main_t l2fwd_main
Definition: l2_fwd.c:81
u64 raw
Definition: l2_fib.h:101
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:113
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:223
u64 * counters
Definition: error.h:78
clib_error_t * next_by_ethertype_register(next_by_ethertype_t *l3_next, u32 ethertype, u32 next_index)
Definition: node.c:1226
u16 n_vectors
Definition: node.h:345
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:82
#define VLIB_BUFFER_IS_TRACED
Definition: buffer.h:85
#define clib_memcpy(a, b, c)
Definition: string.h:69
#define ARRAY_LEN(x)
Definition: clib.h:59
l2fwd_error_t
Definition: l2_fwd.c:95
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:154
u32 sw_if_index
Definition: l2_fwd.c:62
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
Definition: node.h:460
int vlib_main(vlib_main_t *volatile vm, unformat_input_t *input)
Definition: main.c:1692
unsigned int u32
Definition: types.h:88
Definition: l2_fib.h:49
#define foreach_l2fwd_error
Definition: l2_fwd.c:85
struct l2fib_entry_result_t::@184::@186 fields
#define VLIB_NODE_FLAG_TRACE
Definition: node.h:260
u8 src[6]
Definition: l2_fwd.c:60
l2fwd_next_t
Definition: l2_fwd.c:109
u64 uword
Definition: types.h:112
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:55
u32 l2input_intf_bitmap_enable(u32 sw_if_index, u32 feature_bitmap, u32 enable)
Enable (or disable) the feature in the bitmap for the given interface.
Definition: l2_input.c:486
Definition: defs.h:47
unsigned short u16
Definition: types.h:57
unsigned char u8
Definition: types.h:56
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:269
clib_error_t * next_by_ethertype_init(next_by_ethertype_t *l3_next)
Definition: node.c:1196
u8 dst[6]
Definition: l2_fwd.c:61
#define vnet_buffer(b)
Definition: buffer.h:304
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
Definition: node.h:159
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:144
u8 data[0]
Packet data.
Definition: buffer.h:152
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
Definition: node_funcs.h:58
static_always_inline void l2fib_lookup_4(BVT(clib_bihash)*mac_table, l2fib_entry_key_t *cached_key, l2fib_entry_result_t *cached_result, u8 *mac0, u8 *mac1, u8 *mac2, 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, u32 *bucket0, u32 *bucket1, u32 *bucket2, u32 *bucket3, l2fib_entry_result_t *result0, l2fib_entry_result_t *result1, l2fib_entry_result_t *result2, l2fib_entry_result_t *result3)
Definition: l2_fib.h:269
u16 flags
Copy of main node flags.
Definition: node.h:454
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, u32 *bucket0, l2fib_entry_result_t *result0)
Lookup the entry for mac and bd_index in the mac table for 1 packet.
Definition: l2_fib.h:170
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:67
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:74
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:57
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972
Definition: defs.h:46
u64 raw
Definition: l2_fib.h:63