FD.io VPP  v18.04-17-g3a0d853
Vector Packet Processing
l2_output.c
Go to the documentation of this file.
1 /*
2  * l2_output.c : layer 2 output packet processing
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 <vppinfra/error.h>
25 #include <vppinfra/hash.h>
26 #include <vnet/l2/feat_bitmap.h>
27 #include <vnet/l2/l2_output.h>
28 
29 
30 /* Feature graph node names */
31 static char *l2output_feat_names[] = {
32 #define _(sym,name) name,
34 #undef _
35 };
36 
37 char **
39 {
40  return l2output_feat_names;
41 }
42 
43 u8 *
44 format_l2_output_features (u8 * s, va_list * args)
45 {
46  static char *display_names[] = {
47 #define _(sym,name) #sym,
49 #undef _
50  };
51  u32 feature_bitmap = va_arg (*args, u32);
52 
53  if (feature_bitmap == 0)
54  {
55  s = format (s, " none configured");
56  return s;
57  }
58 
59  int i;
60  for (i = L2OUTPUT_N_FEAT - 1; i >= 0; i--)
61  if (feature_bitmap & (1 << i))
62  s = format (s, "%10s (%s)\n", display_names[i], l2output_feat_names[i]);
63  return s;
64 }
65 
67 
68 typedef struct
69 {
70  /* per-pkt trace data */
71  u8 src[6];
72  u8 dst[6];
74  u8 raw[12]; /* raw data */
76 
77 /* packet trace format function */
78 static u8 *
79 format_l2output_trace (u8 * s, va_list * args)
80 {
81  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
82  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
83  l2output_trace_t *t = va_arg (*args, l2output_trace_t *);
84 
85  s = format (s, "l2-output: sw_if_index %d dst %U src %U data "
86  "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
87  t->sw_if_index,
90  t->raw[0], t->raw[1], t->raw[2], t->raw[3], t->raw[4],
91  t->raw[5], t->raw[6], t->raw[7], t->raw[8], t->raw[9],
92  t->raw[10], t->raw[11]);
93 
94  return s;
95 }
96 
97 
98 static char *l2output_error_strings[] = {
99 #define _(sym,string) string,
101 #undef _
102 };
103 
104 /**
105  * Check for split horizon violations.
106  * Return 0 if split horizon check passes, otherwise return non-zero.
107  * Packets should not be transmitted out an interface with the same
108  * split-horizon group as the input interface, except if the @c shg is 0
109  * in which case the check always passes.
110  */
113 {
114  if (PREDICT_TRUE (shg1 == 0))
115  {
116  return 0;
117  }
118  else
119  {
120  return shg1 == shg2;
121  }
122 }
123 
124 /** Determine the next L2 node based on the output feature bitmap */
127  u32 * cached_sw_if_index, u32 * cached_next_index,
128  u32 sw_if_index, u32 feature_bitmap, u32 * next0)
129 {
130  /*
131  * The output feature bitmap always have at least the L2 output bit set
132  * for a normal L2 interface (or 0 if the interface is changed from L2
133  * to L3 mode). So if the feature bitmap is 0 or just have L2 output bits set,
134  * we know there is no more feature and will just output packets on interface.
135  * Otherwise, get the index of the next feature node.
136  */
137  if (PREDICT_FALSE ((feature_bitmap & ~L2OUTPUT_FEAT_OUTPUT) != 0))
138  {
139  /* Save bitmap for the next feature graph nodes */
140  vnet_buffer (b0)->l2.feature_bitmap = feature_bitmap;
141 
142  /* Determine the next node */
143  *next0 =
145  feature_bitmap);
146  }
147  else
148  {
149  /*
150  * There are no features. Send packet to TX node for sw_if_index0
151  * This is a little tricky in that the output interface next node indexes
152  * are not precomputed at init time.
153  */
154 
155  if (sw_if_index == *cached_sw_if_index)
156  {
157  /* We hit in the one-entry cache. Use it. */
158  *next0 = *cached_next_index;
159  }
160  else
161  {
162  /* Look up the output TX node for the sw_if_index */
163  *next0 = vec_elt (l2output_main.output_node_index_vec, sw_if_index);
164 
165  if (PREDICT_FALSE (*next0 == L2OUTPUT_NEXT_DROP))
166  b0->error = node->errors[L2OUTPUT_ERROR_MAPPING_DROP];
167 
168  /* Update the one-entry cache */
169  *cached_sw_if_index = sw_if_index;
170  *cached_next_index = *next0;
171  }
172  }
173 }
174 
177  u32 feature_bitmap, vlib_buffer_t * b, u32 * next)
178 {
179  if (PREDICT_FALSE (config->out_vtr_flag))
180  {
181  /* Perform pre-vtr EFP filter check if configured */
182  if (config->output_vtr.push_and_pop_bytes)
183  {
184  /*
185  * Perform output vlan tag rewrite and the pre-vtr EFP filter check.
186  * The EFP Filter only needs to be run if there is an output VTR
187  * configured. The flag for the post-vtr EFP Filter node is used
188  * to trigger the pre-vtr check as well.
189  */
190  u32 failed1 = (feature_bitmap & L2OUTPUT_FEAT_EFP_FILTER)
191  && (l2_efp_filter_process (b, &(config->input_vtr)));
192  u32 failed2 = l2_vtr_process (b, &(config->output_vtr));
193 
194  if (PREDICT_FALSE (failed1 | failed2))
195  {
196  *next = L2OUTPUT_NEXT_DROP;
197  if (failed2)
198  {
199  b->error = node->errors[L2OUTPUT_ERROR_VTR_DROP];
200  }
201  if (failed1)
202  {
203  b->error = node->errors[L2OUTPUT_ERROR_EFP_DROP];
204  }
205  }
206  }
207  // perform the PBB rewrite
208  else if (config->output_pbb_vtr.push_and_pop_bytes)
209  {
210  u32 failed = l2_pbb_process (b, &(config->output_pbb_vtr));
211  if (PREDICT_FALSE (failed))
212  {
213  *next = L2OUTPUT_NEXT_DROP;
214  b->error = node->errors[L2OUTPUT_ERROR_VTR_DROP];
215  }
216  }
217  }
218 }
219 
220 
223  vlib_frame_t * frame, int do_trace)
224 {
225  u32 n_left_from, *from, *to_next;
226  l2output_next_t next_index;
228  u32 cached_sw_if_index;
229  u32 cached_next_index;
230 
231  /* Invalidate cache */
232  cached_sw_if_index = ~0;
233  cached_next_index = ~0; /* warning be gone */
234 
235  from = vlib_frame_vector_args (frame);
236  n_left_from = frame->n_vectors; /* number of packets to process */
237  next_index = node->cached_next_index;
238 
239  while (n_left_from > 0)
240  {
241  u32 n_left_to_next;
242 
243  /* get space to enqueue frame to graph node "next_index" */
244  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
245 
246  while (n_left_from >= 8 && n_left_to_next >= 4)
247  {
248  u32 bi0, bi1, bi2, bi3;
249  vlib_buffer_t *b0, *b1, *b2, *b3;
250  u32 next0, next1, next2, next3;
251  u32 sw_if_index0, sw_if_index1, sw_if_index2, sw_if_index3;
252  ethernet_header_t *h0, *h1, *h2, *h3;
253  l2_output_config_t *config0, *config1, *config2, *config3;
254  u32 feature_bitmap0, feature_bitmap1;
255  u32 feature_bitmap2, feature_bitmap3;
256 
257  /* Prefetch next iteration. */
258  {
259  vlib_buffer_t *p4, *p5, *p6, *p7;
260 
261  p4 = vlib_get_buffer (vm, from[4]);
262  p5 = vlib_get_buffer (vm, from[5]);
263  p6 = vlib_get_buffer (vm, from[6]);
264  p7 = vlib_get_buffer (vm, from[7]);
265 
266  /* Prefetch the buffer header for the N+2 loop iteration */
267  vlib_prefetch_buffer_header (p4, LOAD);
268  vlib_prefetch_buffer_header (p5, LOAD);
269  vlib_prefetch_buffer_header (p6, LOAD);
270  vlib_prefetch_buffer_header (p7, LOAD);
271  }
272 
273  /* speculatively enqueue b0 and b1 to the current next frame */
274  /* bi is "buffer index", b is pointer to the buffer */
275  to_next[0] = bi0 = from[0];
276  to_next[1] = bi1 = from[1];
277  to_next[2] = bi2 = from[2];
278  to_next[3] = bi3 = from[3];
279  from += 4;
280  to_next += 4;
281  n_left_from -= 4;
282  n_left_to_next -= 4;
283 
284  b0 = vlib_get_buffer (vm, bi0);
285  b1 = vlib_get_buffer (vm, bi1);
286  b2 = vlib_get_buffer (vm, bi2);
287  b3 = vlib_get_buffer (vm, bi3);
288 
289  /* TX interface handles */
290  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_TX];
291  sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_TX];
292  sw_if_index2 = vnet_buffer (b2)->sw_if_index[VLIB_TX];
293  sw_if_index3 = vnet_buffer (b3)->sw_if_index[VLIB_TX];
294 
296  L2OUTPUT_ERROR_L2OUTPUT, 4);
297 
298  /* Get config for the output interface */
299  config0 = vec_elt_at_index (msm->configs, sw_if_index0);
300  config1 = vec_elt_at_index (msm->configs, sw_if_index1);
301  config2 = vec_elt_at_index (msm->configs, sw_if_index2);
302  config3 = vec_elt_at_index (msm->configs, sw_if_index3);
303 
304  /*
305  * Get features from the config
306  * TODO: mask out any non-applicable features
307  */
308  feature_bitmap0 = config0->feature_bitmap;
309  feature_bitmap1 = config1->feature_bitmap;
310  feature_bitmap2 = config2->feature_bitmap;
311  feature_bitmap3 = config3->feature_bitmap;
312 
313  /* Determine next node */
314  l2_output_dispatch (b0, node, &cached_sw_if_index,
315  &cached_next_index, sw_if_index0,
316  feature_bitmap0, &next0);
317  l2_output_dispatch (b1, node, &cached_sw_if_index,
318  &cached_next_index, sw_if_index1,
319  feature_bitmap1, &next1);
320  l2_output_dispatch (b2, node, &cached_sw_if_index,
321  &cached_next_index, sw_if_index2,
322  feature_bitmap2, &next2);
323  l2_output_dispatch (b3, node, &cached_sw_if_index,
324  &cached_next_index, sw_if_index3,
325  feature_bitmap3, &next3);
326 
327  l2output_vtr (node, config0, feature_bitmap0, b0, &next0);
328  l2output_vtr (node, config1, feature_bitmap1, b1, &next1);
329  l2output_vtr (node, config2, feature_bitmap2, b2, &next2);
330  l2output_vtr (node, config3, feature_bitmap3, b3, &next3);
331 
332  if (do_trace)
333  {
334  h0 = vlib_buffer_get_current (b0);
335  h1 = vlib_buffer_get_current (b1);
336  h2 = vlib_buffer_get_current (b2);
337  h3 = vlib_buffer_get_current (b3);
338  if (b0->flags & VLIB_BUFFER_IS_TRACED)
339  {
340  l2output_trace_t *t =
341  vlib_add_trace (vm, node, b0, sizeof (*t));
342  t->sw_if_index = sw_if_index0;
343  clib_memcpy (t->src, h0->src_address, 6);
344  clib_memcpy (t->dst, h0->dst_address, 6);
345  clib_memcpy (t->raw, &h0->type, sizeof (t->raw));
346  }
347  if (b1->flags & VLIB_BUFFER_IS_TRACED)
348  {
349  l2output_trace_t *t =
350  vlib_add_trace (vm, node, b1, sizeof (*t));
351  t->sw_if_index = sw_if_index1;
352  clib_memcpy (t->src, h1->src_address, 6);
353  clib_memcpy (t->dst, h1->dst_address, 6);
354  clib_memcpy (t->raw, &h1->type, sizeof (t->raw));
355  }
356  if (b2->flags & VLIB_BUFFER_IS_TRACED)
357  {
358  l2output_trace_t *t =
359  vlib_add_trace (vm, node, b2, sizeof (*t));
360  t->sw_if_index = sw_if_index2;
361  clib_memcpy (t->src, h2->src_address, 6);
362  clib_memcpy (t->dst, h2->dst_address, 6);
363  clib_memcpy (t->raw, &h2->type, sizeof (t->raw));
364  }
365  if (b3->flags & VLIB_BUFFER_IS_TRACED)
366  {
367  l2output_trace_t *t =
368  vlib_add_trace (vm, node, b3, sizeof (*t));
369  t->sw_if_index = sw_if_index3;
370  clib_memcpy (t->src, h3->src_address, 6);
371  clib_memcpy (t->dst, h3->dst_address, 6);
372  clib_memcpy (t->raw, &h3->type, sizeof (t->raw));
373  }
374  }
375 
376  /*
377  * Perform the split horizon check
378  * The check can only fail for non-zero shg's
379  */
380  if (PREDICT_FALSE (config0->shg + config1->shg +
381  config2->shg + config3->shg))
382  {
383  /* one of the checks might fail, check both */
385  (config0->shg, vnet_buffer (b0)->l2.shg))
386  {
387  next0 = L2OUTPUT_NEXT_DROP;
388  b0->error = node->errors[L2OUTPUT_ERROR_SHG_DROP];
389  }
391  (config1->shg, vnet_buffer (b1)->l2.shg))
392  {
393  next1 = L2OUTPUT_NEXT_DROP;
394  b1->error = node->errors[L2OUTPUT_ERROR_SHG_DROP];
395  }
397  (config2->shg, vnet_buffer (b2)->l2.shg))
398  {
399  next2 = L2OUTPUT_NEXT_DROP;
400  b2->error = node->errors[L2OUTPUT_ERROR_SHG_DROP];
401  }
403  (config3->shg, vnet_buffer (b3)->l2.shg))
404  {
405  next3 = L2OUTPUT_NEXT_DROP;
406  b3->error = node->errors[L2OUTPUT_ERROR_SHG_DROP];
407  }
408  }
409 
410  /* verify speculative enqueues, maybe switch current next frame */
411  /* if next0==next1==next_index then nothing special needs to be done */
412  vlib_validate_buffer_enqueue_x4 (vm, node, next_index,
413  to_next, n_left_to_next,
414  bi0, bi1, bi2, bi3,
415  next0, next1, next2, next3);
416  }
417 
418  while (n_left_from > 0 && n_left_to_next > 0)
419  {
420  u32 bi0;
421  vlib_buffer_t *b0;
422  u32 next0;
423  u32 sw_if_index0;
424  ethernet_header_t *h0;
425  l2_output_config_t *config0;
426  u32 feature_bitmap0;
427 
428  /* speculatively enqueue b0 to the current next frame */
429  bi0 = from[0];
430  to_next[0] = bi0;
431  from += 1;
432  to_next += 1;
433  n_left_from -= 1;
434  n_left_to_next -= 1;
435 
436  b0 = vlib_get_buffer (vm, bi0);
437 
438  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_TX];
439 
441  L2OUTPUT_ERROR_L2OUTPUT, 1);
442 
443  /* Get config for the output interface */
444  config0 = vec_elt_at_index (msm->configs, sw_if_index0);
445 
446  /*
447  * Get features from the config
448  * TODO: mask out any non-applicable features
449  */
450  feature_bitmap0 = config0->feature_bitmap;
451 
452  /* Determine next node */
453  l2_output_dispatch (b0, node, &cached_sw_if_index,
454  &cached_next_index, sw_if_index0,
455  feature_bitmap0, &next0);
456 
457  l2output_vtr (node, config0, feature_bitmap0, b0, &next0);
458 
459  if (do_trace && PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
460  {
461  l2output_trace_t *t =
462  vlib_add_trace (vm, node, b0, sizeof (*t));
463  t->sw_if_index = sw_if_index0;
464  h0 = vlib_buffer_get_current (b0);
465  clib_memcpy (t->src, h0->src_address, 6);
466  clib_memcpy (t->dst, h0->dst_address, 6);
467  clib_memcpy (t->raw, &h0->type, sizeof (t->raw));
468  }
469 
470  /* Perform the split horizon check */
471  if (PREDICT_FALSE
473  (config0->shg, vnet_buffer (b0)->l2.shg)))
474  {
475  next0 = L2OUTPUT_NEXT_DROP;
476  b0->error = node->errors[L2OUTPUT_ERROR_SHG_DROP];
477  }
478 
479  /* verify speculative enqueue, maybe switch current next frame */
480  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
481  to_next, n_left_to_next,
482  bi0, next0);
483  }
484 
485  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
486  }
487 
488  return frame->n_vectors;
489 }
490 
491 static uword
493  vlib_node_runtime_t * node, vlib_frame_t * frame)
494 {
495  if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)))
496  return l2output_node_inline (vm, node, frame, 1 /* do_trace */ );
497  return l2output_node_inline (vm, node, frame, 0 /* do_trace */ );
498 }
499 
500 /* *INDENT-OFF* */
502  .function = l2output_node_fn,
503  .name = "l2-output",
504  .vector_size = sizeof (u32),
505  .format_trace = format_l2output_trace,
506  .type = VLIB_NODE_TYPE_INTERNAL,
507 
508  .n_errors = ARRAY_LEN(l2output_error_strings),
509  .error_strings = l2output_error_strings,
510 
511  .n_next_nodes = L2OUTPUT_N_NEXT,
512 
513  /* edit / add dispositions here */
514  .next_nodes = {
515  [L2OUTPUT_NEXT_DROP] = "error-drop",
516  [L2OUTPUT_NEXT_BAD_INTF] = "l2-output-bad-intf",
517  },
518 };
519 
521 /* *INDENT-ON* */
522 
523 
524 #define foreach_l2output_bad_intf_error \
525 _(DROP, "L2 output to interface not in L2 mode or deleted")
526 
528 #define _(sym,string) string,
530 #undef _
531 };
532 
533 typedef enum
534 {
535 #define _(sym,str) L2OUTPUT_BAD_INTF_ERROR_##sym,
537 #undef _
540 
541 
542 /**
543  * Output node for interfaces/tunnels which was in L2 mode but were changed
544  * to L3 mode or possibly deleted thereafter. On changing forwarding mode
545  * of any tunnel/interface from L2 to L3, its entry in l2_output_main table
546  * next_nodes.output_node_index_vec[sw_if_index] MUST be set to the value of
547  * L2OUTPUT_NEXT_BAD_INTF. Thus, if there are stale entries in the L2FIB for
548  * this sw_if_index, l2-output will send packets for this sw_if_index to the
549  * l2-output-bad-intf node which just setup the proper drop reason before
550  * sending packets to the error-drop node to drop the packet. Then, stale L2FIB
551  * entries for delted tunnels won't cause possible packet or memory corrpution.
552  */
554 
555 static uword
557  vlib_node_runtime_t * node, vlib_frame_t * frame)
558 {
559  u32 n_left_from, *from, *to_next;
560  l2output_next_t next_index = 0;
561 
562  from = vlib_frame_vector_args (frame);
563  n_left_from = frame->n_vectors; /* number of packets to process */
564 
565  while (n_left_from > 0)
566  {
567  u32 n_left_to_next;
568 
569  /* get space to enqueue frame to graph node "next_index" */
570  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
571 
572  while (n_left_from >= 4 && n_left_to_next >= 2)
573  {
574  u32 bi0, bi1;
575  vlib_buffer_t *b0, *b1;
576 
577  to_next[0] = bi0 = from[0];
578  to_next[1] = bi1 = from[1];
579  from += 2;
580  to_next += 2;
581  n_left_from -= 2;
582  n_left_to_next -= 2;
583  b0 = vlib_get_buffer (vm, bi0);
584  b1 = vlib_get_buffer (vm, bi1);
585  b0->error = node->errors[L2OUTPUT_BAD_INTF_ERROR_DROP];
586  b1->error = node->errors[L2OUTPUT_BAD_INTF_ERROR_DROP];
587  }
588 
589  while (n_left_from > 0 && n_left_to_next > 0)
590  {
591  u32 bi0;
592  vlib_buffer_t *b0;
593 
594  bi0 = from[0];
595  to_next[0] = bi0;
596  from += 1;
597  to_next += 1;
598  n_left_from -= 1;
599  n_left_to_next -= 1;
600  b0 = vlib_get_buffer (vm, bi0);
601  b0->error = node->errors[L2OUTPUT_BAD_INTF_ERROR_DROP];
602  }
603 
604  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
605  }
606 
607  return frame->n_vectors;
608 }
609 
610 /* *INDENT-OFF* */
612  .function = l2output_bad_intf_node_fn,
613  .name = "l2-output-bad-intf",
614  .vector_size = sizeof (u32),
615  .type = VLIB_NODE_TYPE_INTERNAL,
616 
618  .error_strings = l2output_bad_intf_error_strings,
619 
620  .n_next_nodes = 1,
621 
622  /* edit / add dispositions here */
623  .next_nodes = {
624  [0] = "error-drop",
625  },
626 };
627 
629 /* *INDENT-ON* */
630 
631 static clib_error_t *
633 {
635 
636  mp->vlib_main = vm;
637  mp->vnet_main = vnet_get_main ();
638 
639  /* Create the config vector */
640  vec_validate (mp->configs, 100);
641  /* Until we hook up the CLI config, just create 100 sw interface entries and zero them */
642 
643  /* Initialize the feature next-node indexes */
645  l2output_node.index,
648  mp->l2_out_feat_next);
649 
650  /* Initialize the output node mapping table */
653 
654  return 0;
655 }
656 
658 
659 
660 /** Create a mapping in the next node mapping table for the given sw_if_index. */
661 void
663  vnet_main_t * vnet_main, u32 sw_if_index)
664 {
665  vnet_hw_interface_t *hw0 =
666  vnet_get_sup_hw_interface (vnet_main, sw_if_index);
667 
668  /* dynamically create graph node arc */
669  u32 next = vlib_node_add_next (vlib_main, l2output_node.index,
670  hw0->output_node_index);
671  l2output_main.output_node_index_vec[sw_if_index] = next;
672 }
673 
674 /* Get a pointer to the config for the given interface */
677 {
679 
680  vec_validate (mp->configs, sw_if_index);
681  return vec_elt_at_index (mp->configs, sw_if_index);
682 }
683 
684 /** Enable (or disable) the feature in the bitmap for the given interface. */
685 void
686 l2output_intf_bitmap_enable (u32 sw_if_index, u32 feature_bitmap, u32 enable)
687 {
689  l2_output_config_t *config;
690 
691  vec_validate (mp->configs, sw_if_index);
692  config = vec_elt_at_index (mp->configs, sw_if_index);
693 
694  if (enable)
695  {
696  config->feature_bitmap |= feature_bitmap;
697  }
698  else
699  {
700  config->feature_bitmap &= ~feature_bitmap;
701  }
702 }
703 
704 /*
705  * fd.io coding-style-patch-verification: ON
706  *
707  * Local Variables:
708  * eval: (c-set-style "gnu")
709  * End:
710  */
l2output_bad_intf_error_t
Definition: l2_output.c:533
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:434
#define foreach_l2output_error
Definition: l2_output.h:118
#define CLIB_UNUSED(x)
Definition: clib.h:79
char ** l2output_get_feat_names(void)
Definition: l2_output.c:38
vnet_main_t * vnet_get_main(void)
Definition: misc.c:47
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
u8 * format_l2_output_features(u8 *s, va_list *args)
Definition: l2_output.c:44
vlib_node_registration_t l2output_node
(constructor) VLIB_REGISTER_NODE (l2output_node)
Definition: l2_output.c:501
l2output_next_t
Definition: l2_output.h:126
#define PREDICT_TRUE(x)
Definition: clib.h:106
static uword l2output_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: l2_output.c:492
u8 src_address[6]
Definition: packet.h:56
#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
int i
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
static u32 l2_pbb_process(vlib_buffer_t *b0, ptr_config_t *config)
Definition: l2_vtr.h:201
u32 * output_node_index_vec
Definition: l2_output.h:62
vlib_error_t * errors
Vector of errors for this node.
Definition: node.h:415
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
Definition: node_funcs.h:1110
static clib_error_t * l2output_init(vlib_main_t *vm)
Definition: l2_output.c:632
u16 push_and_pop_bytes
Definition: l2_vtr.h:64
void l2output_create_output_node_mapping(vlib_main_t *vlib_main, vnet_main_t *vnet_main, u32 sw_if_index)
Create a mapping in the next node mapping table for the given sw_if_index.
Definition: l2_output.c:662
static_always_inline u32 split_horizon_violation(u8 shg1, u8 shg2)
Check for split horizon violations.
Definition: l2_output.c:112
u16 push_and_pop_bytes
Definition: l2_vtr.h:196
#define static_always_inline
Definition: clib.h:93
u8 * format_ethernet_address(u8 *s, va_list *args)
Definition: format.c:44
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:111
ptr_config_t output_pbb_vtr
Definition: l2_output.h:41
u8 dst_address[6]
Definition: packet.h:55
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Definition: buffer.h:191
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
void l2output_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_output.c:686
static_always_inline uword l2output_node_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int do_trace)
Definition: l2_output.c:222
static_always_inline void l2_output_dispatch(vlib_buffer_t *b0, vlib_node_runtime_t *node, u32 *cached_sw_if_index, u32 *cached_next_index, u32 sw_if_index, u32 feature_bitmap, u32 *next0)
Determine the next L2 node based on the output feature bitmap.
Definition: l2_output.c:126
static u32 l2_vtr_process(vlib_buffer_t *b0, vtr_config_t *config)
Perform the configured tag rewrite on the packet.
Definition: l2_vtr.h:75
l2_output_config_t * l2output_intf_config(u32 sw_if_index)
Get a pointer to the config for the given interface.
Definition: l2_output.c:676
static uword l2output_bad_intf_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: l2_output.c:556
vtr_config_t input_vtr
Definition: l2_output.h:38
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:209
#define PREDICT_FALSE(x)
Definition: clib.h:105
vnet_main_t vnet_main
Definition: misc.c:43
#define foreach_l2output_bad_intf_error
Definition: l2_output.c:524
l2output_main_t l2output_main
Definition: l2_output.c:66
static u32 feat_bitmap_get_next_node_index(u32 *next_nodes, u32 bitmap)
Return the graph node index for the feature corresponding to the first set bit in the bitmap...
Definition: feat_bitmap.h:79
#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:218
#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:364
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:130
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1166
vlib_main_t * vlib_main
Definition: l2_output.h:74
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:143
u16 n_vectors
Definition: node.h:344
vlib_main_t * vm
Definition: buffer.c:294
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
static u8 l2_efp_filter_process(vlib_buffer_t *b0, vtr_config_t *in_config)
Definition: l2_vtr.h:141
#define clib_memcpy(a, b, c)
Definition: string.h:75
static char * l2output_feat_names[]
Definition: l2_output.c:31
#define ARRAY_LEN(x)
Definition: clib.h:59
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:454
vtr_config_t output_vtr
Definition: l2_output.h:39
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
Definition: node.h:456
unsigned int u32
Definition: types.h:88
static_always_inline void l2output_vtr(vlib_node_runtime_t *node, l2_output_config_t *config, u32 feature_bitmap, vlib_buffer_t *b, u32 *next)
Definition: l2_output.c:176
static char * l2output_error_strings[]
Definition: l2_output.c:98
static vlib_node_registration_t l2output_bad_intf_node
Output node for interfaces/tunnels which was in L2 mode but were changed to L3 mode or possibly delet...
Definition: l2_output.c:553
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
#define vec_elt(v, i)
Get vector value at index i.
int vlib_main(vlib_main_t *volatile vm, unformat_input_t *input)
Definition: main.c:1681
struct _vlib_node_registration vlib_node_registration_t
Definition: defs.h:47
static char * l2output_bad_intf_error_strings[]
Definition: l2_output.c:527
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:267
l2_output_config_t * configs
Definition: l2_output.h:71
#define vnet_buffer(b)
Definition: buffer.h:372
u16 flags
Copy of main node flags.
Definition: node.h:450
static u8 * format_l2output_trace(u8 *s, va_list *args)
Definition: l2_output.c:79
u32 l2_out_feat_next[32]
Definition: l2_output.h:68
#define VLIB_NODE_FLAG_TRACE
Definition: node.h:259
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header, unspecified alignment)
Definition: vec.h:483
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:111
vnet_main_t * vnet_main
Definition: l2_output.h:75
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
VLIB_NODE_FUNCTION_MULTIARCH(l2output_node, l2output_node_fn)