FD.io VPP  v21.06-3-gbb25fbf28
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 dst_and_src[12];
69 
70 /* packet trace format function */
71 static u8 *
72 format_l2fwd_trace (u8 * s, va_list * args)
73 {
74  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
75  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
76  l2fwd_trace_t *t = va_arg (*args, l2fwd_trace_t *);
77 
78  s =
79  format (s,
80  "l2-fwd: sw_if_index %d dst %U src %U bd_index %d result [0x%llx, %d] %U",
83  t->bd_index, t->result.raw,
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 
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 = vnet_buffer (b0)->l2.l2fib_sn;
160  l2fib_seq_num_t expected_sn = l2_fib_update_seq_num (in_sn,
162  (result0->fields.sw_if_index));
163 
164  l2fib_seq_num_valid = expected_sn == result0->fields.sn;
165  }
166 
167  if (PREDICT_FALSE (!l2fib_seq_num_valid))
168  {
169  flood_error = L2FWD_ERROR_STALE_DROP;
170  try_flood = 1;
171  }
172  /* perform reflection check */
173  else if (PREDICT_FALSE (sw_if_index0 == result0->fields.sw_if_index))
174  {
175  b0->error = node->errors[L2FWD_ERROR_REFLECT_DROP];
176  *next0 = L2FWD_NEXT_DROP;
177  }
178  /* perform filter check */
179  else if (PREDICT_FALSE (l2fib_entry_result_is_set_FILTER (result0)))
180  {
181  b0->error = node->errors[L2FWD_ERROR_FILTER_DROP];
182  *next0 = L2FWD_NEXT_DROP;
183  }
184  /* perform BVI check */
185  else if (PREDICT_FALSE (l2fib_entry_result_is_set_BVI (result0)))
186  {
187  u32 rc;
188  rc = l2_to_bvi (vm,
189  msm->vnet_main,
190  b0,
192  &msm->l3_next, next0);
193 
194  if (PREDICT_FALSE (rc))
195  {
196  if (rc == TO_BVI_ERR_BAD_MAC)
197  {
198  b0->error = node->errors[L2FWD_ERROR_BVI_BAD_MAC];
199  *next0 = L2FWD_NEXT_DROP;
200  }
201  else if (rc == TO_BVI_ERR_ETHERTYPE)
202  {
203  b0->error = node->errors[L2FWD_ERROR_BVI_ETHERTYPE];
204  *next0 = L2FWD_NEXT_DROP;
205  }
206  }
207  }
208  }
209 
210  /* flood */
211  if (PREDICT_FALSE (try_flood))
212  {
213  /*
214  * lookup miss, so flood which is typically the next feature
215  * unless some other feature is inserted before uu_flood
216  */
217  if (vnet_buffer (b0)->l2.feature_bitmap &
218  (L2INPUT_FEAT_UU_FLOOD |
219  L2INPUT_FEAT_UU_FWD | L2INPUT_FEAT_GBP_FWD))
220  {
221  *next0 = vnet_l2_feature_next (b0, msm->feat_next_node_index,
222  L2INPUT_FEAT_FWD);
223  }
224  else
225  {
226  /* Flooding is disabled */
227  b0->error = node->errors[flood_error];
228  *next0 = L2FWD_NEXT_DROP;
229  }
230  }
231 }
232 
233 
236  vlib_frame_t * frame, int do_trace)
237 {
238  u32 n_left, *from;
239  l2fwd_main_t *msm = &l2fwd_main;
240  vlib_node_t *n = vlib_get_node (vm, l2fwd_node.index);
241  CLIB_UNUSED (u32 node_counter_base_index) = n->error_heap_index;
243  l2fib_entry_key_t cached_key;
244  l2fib_entry_result_t cached_result;
247 
248  /* Clear the one-entry cache in case mac table was updated */
249  cached_key.raw = ~0;
250  cached_result.raw = ~0;
251 
253  n_left = frame->n_vectors; /* number of packets to process */
255  next = nexts;
256  b = bufs;
257 
258  while (n_left >= 8)
259  {
260  u32 sw_if_index0, sw_if_index1, sw_if_index2, sw_if_index3;
261  const ethernet_header_t *h0, *h1, *h2, *h3;
262  l2fib_entry_key_t key0, key1, key2, key3;
263  l2fib_entry_result_t result0, result1, result2, result3;
264 
265  /* Prefetch next iteration. */
266  {
267  vlib_prefetch_buffer_header (b[4], LOAD);
268  vlib_prefetch_buffer_header (b[5], LOAD);
269  vlib_prefetch_buffer_header (b[6], LOAD);
270  vlib_prefetch_buffer_header (b[7], LOAD);
271 
276  }
277 
278  /* RX interface handles */
279  sw_if_index0 = vnet_buffer (b[0])->sw_if_index[VLIB_RX];
280  sw_if_index1 = vnet_buffer (b[1])->sw_if_index[VLIB_RX];
281  sw_if_index2 = vnet_buffer (b[2])->sw_if_index[VLIB_RX];
282  sw_if_index3 = vnet_buffer (b[3])->sw_if_index[VLIB_RX];
283 
284  h0 = vlib_buffer_get_current (b[0]);
285  h1 = vlib_buffer_get_current (b[1]);
286  h2 = vlib_buffer_get_current (b[2]);
287  h3 = vlib_buffer_get_current (b[3]);
288 
289 #ifdef COUNTERS
290  em->counters[node_counter_base_index + L2FWD_ERROR_L2FWD] += 4;
291 #endif
292  /* *INDENT-OFF* */
293  l2fib_lookup_4 (msm->mac_table, &cached_key, &cached_result,
294  h0->dst_address, h1->dst_address,
295  h2->dst_address, h3->dst_address,
296  vnet_buffer (b[0])->l2.bd_index,
297  vnet_buffer (b[1])->l2.bd_index,
298  vnet_buffer (b[2])->l2.bd_index,
299  vnet_buffer (b[3])->l2.bd_index,
300  &key0, /* not used */
301  &key1, /* not used */
302  &key2, /* not used */
303  &key3, /* not used */
304  &result0,
305  &result1,
306  &result2,
307  &result3);
308  /* *INDENT-ON* */
309  l2fwd_process (vm, node, msm, em, b[0], sw_if_index0, &result0, next);
310  l2fwd_process (vm, node, msm, em, b[1], sw_if_index1, &result1,
311  next + 1);
312  l2fwd_process (vm, node, msm, em, b[2], sw_if_index2, &result2,
313  next + 2);
314  l2fwd_process (vm, node, msm, em, b[3], sw_if_index3, &result3,
315  next + 3);
316 
317  /* verify speculative enqueues, maybe switch current next frame */
318  /* if next0==next1==next_index then nothing special needs to be done */
319  if (do_trace)
320  {
321  if (b[0]->flags & VLIB_BUFFER_IS_TRACED)
322  {
323  l2fwd_trace_t *t = vlib_add_trace (vm, node, b[0], sizeof (*t));
324  t->sw_if_index = sw_if_index0;
325  t->bd_index = vnet_buffer (b[0])->l2.bd_index;
327  sizeof (h0->dst_address) +
328  sizeof (h0->src_address));
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;
337  sizeof (h1->dst_address) +
338  sizeof (h1->src_address));
339  t->result = result1;
340  }
341  if (b[2]->flags & VLIB_BUFFER_IS_TRACED)
342  {
343  l2fwd_trace_t *t = vlib_add_trace (vm, node, b[2], sizeof (*t));
344  t->sw_if_index = sw_if_index2;
345  t->bd_index = vnet_buffer (b[2])->l2.bd_index;
347  sizeof (h2->dst_address) +
348  sizeof (h2->src_address));
349  t->result = result2;
350  }
351  if (b[3]->flags & VLIB_BUFFER_IS_TRACED)
352  {
353  l2fwd_trace_t *t = vlib_add_trace (vm, node, b[3], sizeof (*t));
354  t->sw_if_index = sw_if_index3;
355  t->bd_index = vnet_buffer (b[3])->l2.bd_index;
357  sizeof (h3->dst_address) +
358  sizeof (h3->src_address));
359  t->result = result3;
360  }
361  }
362 
363  next += 4;
364  b += 4;
365  n_left -= 4;
366  }
367 
368  while (n_left > 0)
369  {
370  u32 sw_if_index0;
371  ethernet_header_t *h0;
372  l2fib_entry_key_t key0;
373  l2fib_entry_result_t result0;
374 
375  sw_if_index0 = vnet_buffer (b[0])->sw_if_index[VLIB_RX];
376 
377  h0 = vlib_buffer_get_current (b[0]);
378 
379  /* process 1 pkt */
380 #ifdef COUNTERS
381  em->counters[node_counter_base_index + L2FWD_ERROR_L2FWD] += 1;
382 #endif
383  l2fib_lookup_1 (msm->mac_table, &cached_key, &cached_result,
384  h0->dst_address, vnet_buffer (b[0])->l2.bd_index, &key0,
385  /* not used */ &result0);
386  l2fwd_process (vm, node, msm, em, b[0], sw_if_index0, &result0, next);
387 
388  if (do_trace && PREDICT_FALSE (b[0]->flags & VLIB_BUFFER_IS_TRACED))
389  {
390  l2fwd_trace_t *t = vlib_add_trace (vm, node, b[0], sizeof (*t));
391  t->sw_if_index = sw_if_index0;
392  t->bd_index = vnet_buffer (b[0])->l2.bd_index;
394  sizeof (h0->dst_address) +
395  sizeof (h0->src_address));
396  t->result = result0;
397  }
398 
399  /* verify speculative enqueue, maybe switch current next frame */
400  next += 1;
401  b += 1;
402  n_left -= 1;
403  }
404 
406 
407  return frame->n_vectors;
408 }
409 
412 {
413  if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)))
414  return l2fwd_node_inline (vm, node, frame, 1 /* do_trace */ );
415  return l2fwd_node_inline (vm, node, frame, 0 /* do_trace */ );
416 }
417 
418 /* *INDENT-OFF* */
420  .name = "l2-fwd",
421  .vector_size = sizeof (u32),
422  .format_trace = format_l2fwd_trace,
424 
425  .n_errors = ARRAY_LEN(l2fwd_error_strings),
426  .error_strings = l2fwd_error_strings,
427 
428  .n_next_nodes = L2FWD_N_NEXT,
429 
430  /* edit / add dispositions here */
431  .next_nodes = {
432  [L2FWD_NEXT_L2_OUTPUT] = "l2-output",
433  [L2FWD_NEXT_DROP] = "error-drop",
434  },
435 };
436 /* *INDENT-ON* */
437 
438 #ifndef CLIB_MARCH_VARIANT
439 clib_error_t *
441 {
442  l2fwd_main_t *mp = &l2fwd_main;
443 
444  mp->vlib_main = vm;
445  mp->vnet_main = vnet_get_main ();
446 
447  /* Initialize the feature next-node indexes */
449  l2fwd_node.index,
452  mp->feat_next_node_index);
453 
454  /* init the hash table ptr */
455  mp->mac_table = get_mac_table ();
456 
457  /* Initialize the next nodes for each ethertype */
458  next_by_ethertype_init (&mp->l3_next);
459 
460  return 0;
461 }
462 
464 
465 
466 /** Add the L3 input node for this ethertype to the next nodes structure. */
467 void
470 {
471  l2fwd_main_t *mp = &l2fwd_main;
472  u32 next_index;
473 
475 
476  next_by_ethertype_register (&mp->l3_next, type, next_index);
477 }
478 
479 
480 /**
481  * Set subinterface forward enable/disable.
482  * The CLI format is:
483  * set interface l2 forward <interface> [disable]
484  */
485 static clib_error_t *
487 {
488  vnet_main_t *vnm = vnet_get_main ();
489  clib_error_t *error = 0;
491  u32 enable;
492 
494  {
495  error = clib_error_return (0, "unknown interface `%U'",
496  format_unformat_error, input);
497  goto done;
498  }
499 
500  enable = 1;
501  if (unformat (input, "disable"))
502  {
503  enable = 0;
504  }
505 
506  /* set the interface flag */
508  {
509  l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_XCONNECT, enable);
510  }
511  else
512  {
513  l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_FWD, enable);
514  }
515 
516 done:
517  return error;
518 }
519 
520 /*?
521  * Layer 2 unicast forwarding can be enabled and disabled on each
522  * interface and on each bridge-domain. Use this command to
523  * manage interfaces. It is enabled by default.
524  *
525  * @cliexpar
526  * Example of how to enable forwarding:
527  * @cliexcmd{set interface l2 forward GigabitEthernet0/8/0}
528  * Example of how to disable forwarding:
529  * @cliexcmd{set interface l2 forward GigabitEthernet0/8/0 disable}
530 ?*/
531 /* *INDENT-OFF* */
533  .path = "set interface l2 forward",
534  .short_help = "set interface l2 forward <interface> [disable]",
535  .function = int_fwd,
536 };
537 /* *INDENT-ON* */
538 
539 #endif
540 
541 /*
542  * fd.io coding-style-patch-verification: ON
543  *
544  * Local Variables:
545  * eval: (c-set-style "gnu")
546  * End:
547  */
vlib.h
next_by_ethertype_init
clib_error_t * next_by_ethertype_init(next_by_ethertype_t *l3_next)
Definition: node.c:2164
vlib_error_main_t
Definition: error.h:61
int_fwd_cli
static vlib_cli_command_t int_fwd_cli
(constructor) VLIB_CLI_COMMAND (int_fwd_cli)
Definition: l2_fwd.c:532
unformat_user
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:989
bufs
vlib_buffer_t * bufs[VLIB_FRAME_SIZE]
Definition: nat44_ei_out2in.c:717
vlib_prefetch_buffer_header
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Definition: buffer.h:231
frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: nat44_ei.c:3048
vlib_node_add_next
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
Definition: node_funcs.h:1177
format_l2fib_entry_result_flags
u8 * format_l2fib_entry_result_flags(u8 *s, va_list *args)
Definition: l2_fib.c:57
next_index
nat44_ei_hairpin_src_next_t next_index
Definition: nat44_ei_hairpinning.c:412
pg.h
l2fwd_init
clib_error_t * l2fwd_init(vlib_main_t *vm)
Definition: l2_fwd.c:440
TO_BVI_ERR_BAD_MAC
#define TO_BVI_ERR_BAD_MAC
Definition: l2_bvi.h:28
format_ethernet_address
u8 * format_ethernet_address(u8 *s, va_list *args)
Definition: format.c:44
ethernet_header_t::dst_address
u8 dst_address[6]
Definition: packet.h:55
vlib_get_buffers
vlib_get_buffers(vm, from, b, n_left_from)
l2input_intf_config
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:167
ethernet_header_t::src_address
u8 src_address[6]
Definition: packet.h:56
next
u16 * next
Definition: nat44_ei_out2in.c:718
VLIB_NODE_TYPE_INTERNAL
@ VLIB_NODE_TYPE_INTERNAL
Definition: node.h:72
l2fwd_trace_t::result
l2fib_entry_result_t result
Definition: l2_fwd.c:67
VLIB_FRAME_SIZE
#define VLIB_FRAME_SIZE
Definition: node.h:368
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
l2fib_lookup_1
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:283
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
vlib_cli_command_t::path
char * path
Definition: cli.h:96
TO_BVI_ERR_ETHERTYPE
#define TO_BVI_ERR_ETHERTYPE
Definition: l2_bvi.h:29
l2_fwd.h
L2FWD_N_ERROR
@ L2FWD_N_ERROR
Definition: l2_fwd.c:112
vlib_main_t::error_main
vlib_error_main_t error_main
Definition: main.h:177
u16
unsigned short u16
Definition: types.h:57
l2_fib_update_seq_num
static_always_inline l2fib_seq_num_t l2_fib_update_seq_num(l2fib_seq_num_t sn, u8 if_sn)
Definition: l2_fib.h:116
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
l2fwd_trace_t::bd_index
u16 bd_index
Definition: l2_fwd.c:66
VLIB_RX
@ VLIB_RX
Definition: defs.h:46
node_index
node node_index
Definition: interface_output.c:420
vlib_buffer_enqueue_to_next
vlib_buffer_enqueue_to_next(vm, node, from,(u16 *) nexts, frame->n_vectors)
unformat_input_t
struct _unformat_input_t unformat_input_t
vlib_frame_t
Definition: node.h:372
clib_memcpy_fast
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
Definition: string.h:92
next_by_ethertype_t
Definition: ethernet.h:265
ethernet.h
error
Definition: cJSON.c:88
l2fib_entry_result_t_::fields
struct l2fib_entry_result_t_::@463::@465 fields
l2_fib.h
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
l2fib_lookup_4
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:375
CLIB_PREFETCH
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:80
L2FWD_NEXT_DROP
@ L2FWD_NEXT_DROP
Definition: l2_fwd.c:124
l2fwd_main_t
Definition: l2_fwd.c:44
vlib_buffer_t::error
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:145
vlib_error_main_t::counters
u64 * counters
Definition: error.h:64
error.h
VLIB_NODE_FN
#define VLIB_NODE_FN(node)
Definition: node.h:202
l2fwd_node_inline
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:235
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
vnet_buffer
#define vnet_buffer(b)
Definition: buffer.h:437
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
VLIB_NODE_FLAG_TRACE
#define VLIB_NODE_FLAG_TRACE
Definition: node.h:291
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
ARRAY_LEN
#define ARRAY_LEN(x)
Definition: clib.h:70
vlib_frame_vector_args
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:301
static_always_inline
#define static_always_inline
Definition: clib.h:112
l2_bvi.h
uword
u64 uword
Definition: types.h:112
l2fwd_main
l2fwd_main_t l2fwd_main
Definition: l2_fwd.c:90
ethernet_header_t
Definition: packet.h:52
sparse_vec.h
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
l2input_get_feat_names
char ** l2input_get_feat_names(void)
Return an array of strings containing graph node names of each feature.
Definition: l2_input.c:59
ethernet_type_t
ethernet_type_t
Definition: packet.h:45
BVT
BVT(clib_bihash)
The table of adjacencies indexed by the rewrite string.
Definition: l2_fib.c:1069
vlib_get_node
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
Definition: node_funcs.h:86
l2fib_entry_key_t::raw
u64 raw
Definition: l2_fib.h:91
format_unformat_error
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
l2fib_entry_result_t_
Definition: l2_fib.h:160
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
L2FWD_NEXT_L2_OUTPUT
@ L2FWD_NEXT_L2_OUTPUT
Definition: l2_fwd.c:123
l2_input_seq_num
static_always_inline u8 l2_input_seq_num(u32 sw_if_index)
Definition: l2_input.h:252
l2fwd_node
vlib_node_registration_t l2fwd_node
(constructor) VLIB_REGISTER_NODE (l2fwd_node)
Definition: l2_fwd.c:419
int_fwd
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:486
l2fwd_process
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
L2INPUT_N_FEAT
@ L2INPUT_N_FEAT
Definition: l2_input.h:163
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
l2fwd_next_t
l2fwd_next_t
Definition: l2_fwd.c:121
l2_input.h
l2fwd_error_t
l2fwd_error_t
Definition: l2_fwd.c:107
vnet_l2_feature_next
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
data
u8 data[128]
Definition: ipsec_types.api:92
l2fib_entry_result_t_::raw
u64 raw
Definition: l2_fib.h:172
l2fwd_register_input_type
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:468
l2fwd_error_strings
static char * l2fwd_error_strings[]
Definition: l2_fwd.c:115
format_l2fwd_trace
static u8 * format_l2fwd_trace(u8 *s, va_list *args)
Definition: l2_fwd.c:72
vnet_main_t
Definition: vnet.h:76
foreach_l2fwd_error
#define foreach_l2fwd_error
Definition: l2_fwd.c:97
unformat_vnet_sw_interface
unformat_function_t unformat_vnet_sw_interface
Definition: interface_funcs.h:459
format
description fragment has unexpected format
Definition: map.api:433
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
l2fwd_trace_t
Definition: l2_fwd.c:61
cli.h
n_left
u32 n_left
Definition: interface_output.c:1078
l2fwd_trace_t::sw_if_index
u32 sw_if_index
Definition: l2_fwd.c:65
vnet_main
vnet_main_t vnet_main
Definition: misc.c:43
vlib_main_t
Definition: main.h:102
vlib_node_t
Definition: node.h:247
vlib_add_trace
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace.c:628
hash.h
b
vlib_buffer_t ** b
Definition: nat44_ei_out2in.c:717
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
vlib_buffer_get_current
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:257
feat_bitmap.h
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
L2FWD_N_NEXT
@ L2FWD_N_NEXT
Definition: l2_fwd.c:125
vlib_node_t::error_heap_index
u32 error_heap_index
Definition: node.h:315
l2fib_seq_num_t
u16 l2fib_seq_num_t
A combined representation of the sequence number associated with the interface and the BD.
Definition: l2_fib.h:107
nexts
u16 nexts[VLIB_FRAME_SIZE]
Definition: nat44_ei_out2in.c:718
next_by_ethertype_register
clib_error_t * next_by_ethertype_register(next_by_ethertype_t *l3_next, u32 ethertype, u32 next_index)
Definition: node.c:2194
l2fib_entry_key_t
Definition: l2_fib.h:77
vlib_main
int vlib_main(vlib_main_t *volatile vm, unformat_input_t *input)
Definition: main.c:1914
vnet.h
vlib_node_runtime_t
Definition: node.h:454
vlib_cli_command_t
Definition: cli.h:92
from
from
Definition: nat44_ei_hairpinning.c:415
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
VLIB_TX
@ VLIB_TX
Definition: defs.h:47
l2_to_bvi
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:59
feat_bitmap_init_next_nodes
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
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
l2fwd_trace_t::dst_and_src
u8 dst_and_src[12]
Definition: l2_fwd.c:64
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105