FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
l2_output_classify.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <vnet/l2/l2_classify.h>
17 #include <vnet/api_errno.h>
18 
19 /**
20  * @file
21  * @brief Layer 2 Output Classifier.
22  *
23  * @sa @ref vnet/vnet/classify/vnet_classify.c
24  * @sa @ref vnet/vnet/classify/vnet_classify.h
25  */
26 
27 typedef struct
28 {
29  /** interface handle for the ith packet */
31  /** graph arc index selected for this packet */
33  /** classifier table which provided the final result */
35  /** offset in classifier heap of the corresponding session */
38 
39 typedef struct
40 {
41  /** use-case independent main object pointer */
43  /** l2 input classifier main object pointer */
46 
47 /** Packet trace format function. */
48 static u8 *
49 format_l2_output_classify_trace (u8 * s, va_list * args)
50 {
51  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
52  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
54  va_arg (*args, l2_output_classify_trace_t *);
55 
56  s = format (s, "l2-classify: sw_if_index %d, table %d, offset %x, next %d",
58  t->next_index);
59  return s;
60 }
61 
63 
64 #ifndef CLIB_MARCH_VARIANT
65 /** l2 output classifier main data structure. */
67 #endif /* CLIB_MARCH_VARIANT */
68 
69 #define foreach_l2_output_classify_error \
70 _(MISS, "Classify misses") \
71 _(HIT, "Classify hits") \
72 _(CHAIN_HIT, "Classify hits after chain walk") \
73 _(DROP, "L2 Classify Drops")
74 
75 typedef enum
76 {
77 #define _(sym,str) L2_OUTPUT_CLASSIFY_ERROR_##sym,
79 #undef _
82 
84 #define _(sym,string) string,
86 #undef _
87 };
88 
89 /**
90  * @brief l2 output classifier node.
91  * @node l2-output-classify
92  *
93  * This is the l2 output classifier dispatch node
94  *
95  * @param vm vlib_main_t corresponding to the current thread.
96  * @param node vlib_node_runtime_t data for this node.
97  * @param frame vlib_frame_t whose contents should be dispatched.
98  *
99  * @par Graph mechanics: buffer metadata, next index usage
100  *
101  * @em Uses:
102  * - <code>(l2_output_classify_runtime_t *)
103  * rt->classify_table_index_by_sw_if_index</code>
104  * Head of the per-interface, per-protocol classifier table chain
105  * for a specific interface. ~0 => send pkts to the next
106  * feature in the L2 feature chain.
107  * - <code>vnet_buffer(b)->sw_if_index[VLIB_TX]</code>
108  * - Indicates the @c sw_if_index value of the interface that the
109  * packet was received on.
110  * - <code>vnet_buffer (b0)->l2.feature_bitmap</code>
111  * - Used to steer packets across l2 features enabled on the interface
112  * - <code>(vnet_classify_entry_t) e0->next_index</code>
113  * - Used to steer traffic when the classifier hits on a session
114  * - <code>(vnet_classify_entry_t) e0->advance</code>
115  * - Signed quantity applied via <code>vlib_buffer_advance</code>
116  * when the classifier hits on a session
117  * - <code>(vnet_classify_table_t) t0->miss_next_index</code>
118  * - Used to steer traffic when the classifier misses
119  *
120  * @em Sets:
121  * - <code>vnet_buffer (b0)->l2_classify.table_index</code>
122  * - Classifier table index of the first classifier table in
123  * the classifier table chain
124  * - <code>vnet_buffer (b0)->l2_classify.hash</code>
125  * - Bounded-index extensible hash corresponding to the
126  * masked fields in the current packet
127  * - <code>vnet_buffer (b0)->l2.feature_bitmap</code>
128  * - Used to steer packets across l2 features enabled on the interface
129  * - <code>vnet_buffer (b0)->l2_classify.opaque_index</code>
130  * - Copied from the classifier session object upon classifier hit
131  *
132  * @em Counters:
133  * - <code>L2_OUTPUT_CLASSIFY_ERROR_MISS</code> Classifier misses
134  * - <code>L2_OUTPUT_CLASSIFY_ERROR_HIT</code> Classifier hits
135  * - <code>L2_OUTPUT_CLASSIFY_ERROR_CHAIN_HIT</code>
136  * Classifier hits in other than the first table
137  */
138 
142 {
143  u32 n_left_from, *from, *to_next;
146  vnet_classify_main_t *vcm = cm->vnet_classify_main;
148  (l2_output_classify_runtime_t *) node->runtime_data;
149  u32 hits = 0;
150  u32 misses = 0;
151  u32 chain_hits = 0;
152  f64 now;
153  u32 n_next_nodes;
154  u32 sw_if_index0;
155 
156  n_next_nodes = node->n_next_nodes;
157 
158  now = vlib_time_now (vm);
159 
160  n_left_from = frame->n_vectors;
162 
163  /* First pass: compute hash */
164 
165  while (n_left_from >= 4)
166  {
167  vlib_buffer_t *b0, *b1;
168  u32 bi0, bi1;
169  ethernet_header_t *h0, *h1;
170  u32 sw_if_index0, sw_if_index1;
171  u16 type0, type1;
172  int type_index0, type_index1;
173  vnet_classify_table_t *t0, *t1;
174  u32 table_index0, table_index1;
175  u64 hash0, hash1;
176 
177 
178  /* prefetch next iteration */
179  {
180  vlib_buffer_t *p2, *p3;
181 
182  p2 = vlib_get_buffer (vm, from[2]);
183  p3 = vlib_get_buffer (vm, from[3]);
184 
185  vlib_prefetch_buffer_header (p2, STORE);
187  vlib_prefetch_buffer_header (p3, STORE);
189  }
190 
191  bi0 = from[0];
192  b0 = vlib_get_buffer (vm, bi0);
193  h0 = vlib_buffer_get_current (b0);
194 
195  bi1 = from[1];
196  b1 = vlib_get_buffer (vm, bi1);
197  h1 = vlib_buffer_get_current (b1);
198 
199  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_TX];
200  vnet_buffer (b0)->l2_classify.table_index = ~0;
201 
202  sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_TX];
203  vnet_buffer (b1)->l2_classify.table_index = ~0;
204 
205  /* Select classifier table based on ethertype */
206  type0 = clib_net_to_host_u16 (h0->type);
207  type1 = clib_net_to_host_u16 (h1->type);
208 
209  type_index0 = (type0 == ETHERNET_TYPE_IP4)
211  type_index0 = (type0 == ETHERNET_TYPE_IP6)
212  ? L2_OUTPUT_CLASSIFY_TABLE_IP6 : type_index0;
213 
214  type_index1 = (type1 == ETHERNET_TYPE_IP4)
216  type_index1 = (type1 == ETHERNET_TYPE_IP6)
217  ? L2_OUTPUT_CLASSIFY_TABLE_IP6 : type_index1;
218 
219  vnet_buffer (b0)->l2_classify.table_index =
220  table_index0 =
221  rt->l2cm->classify_table_index_by_sw_if_index
222  [type_index0][sw_if_index0];
223 
224  if (table_index0 != ~0)
225  {
226  t0 = pool_elt_at_index (vcm->tables, table_index0);
227 
228  vnet_buffer (b0)->l2_classify.hash = hash0 =
229  vnet_classify_hash_packet (t0, (u8 *) h0);
230  vnet_classify_prefetch_bucket (t0, hash0);
231  }
232 
233  vnet_buffer (b1)->l2_classify.table_index =
234  table_index1 =
235  rt->l2cm->classify_table_index_by_sw_if_index
236  [type_index1][sw_if_index1];
237 
238  if (table_index1 != ~0)
239  {
240  t1 = pool_elt_at_index (vcm->tables, table_index1);
241 
242  vnet_buffer (b1)->l2_classify.hash = hash1 =
243  vnet_classify_hash_packet (t1, (u8 *) h1);
244  vnet_classify_prefetch_bucket (t1, hash1);
245  }
246 
247  from += 2;
248  n_left_from -= 2;
249  }
250 
251  while (n_left_from > 0)
252  {
253  vlib_buffer_t *b0;
254  u32 bi0;
255  ethernet_header_t *h0;
256  u16 type0;
257  u32 type_index0;
259  u32 table_index0;
260  u64 hash0;
261 
262  bi0 = from[0];
263  b0 = vlib_get_buffer (vm, bi0);
264  h0 = vlib_buffer_get_current (b0);
265 
266  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_TX];
267  vnet_buffer (b0)->l2_classify.table_index = ~0;
268 
269  /* Select classifier table based on ethertype */
270  type0 = clib_net_to_host_u16 (h0->type);
271 
272  type_index0 = (type0 == ETHERNET_TYPE_IP4)
274  type_index0 = (type0 == ETHERNET_TYPE_IP6)
275  ? L2_OUTPUT_CLASSIFY_TABLE_IP6 : type_index0;
276 
277  vnet_buffer (b0)->l2_classify.table_index =
278  table_index0 = rt->l2cm->classify_table_index_by_sw_if_index
279  [type_index0][sw_if_index0];
280 
281  if (table_index0 != ~0)
282  {
283  t0 = pool_elt_at_index (vcm->tables, table_index0);
284 
285  vnet_buffer (b0)->l2_classify.hash = hash0 =
286  vnet_classify_hash_packet (t0, (u8 *) h0);
287  vnet_classify_prefetch_bucket (t0, hash0);
288  }
289  from++;
290  n_left_from--;
291  }
292 
293  next_index = node->cached_next_index;
295  n_left_from = frame->n_vectors;
296 
297  while (n_left_from > 0)
298  {
299  u32 n_left_to_next;
300 
301  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
302 
303  /* Not enough load/store slots to dual loop... */
304  while (n_left_from > 0 && n_left_to_next > 0)
305  {
306  u32 bi0;
307  vlib_buffer_t *b0;
308  u32 next0 = ~0;
309  ethernet_header_t *h0;
310  u32 table_index0;
311  u64 hash0;
314 
315  if (PREDICT_TRUE (n_left_from > 2))
316  {
317  vlib_buffer_t *p2 = vlib_get_buffer (vm, from[2]);
318  u64 phash2;
319  u32 table_index2;
321 
322  /*
323  * Prefetch table entry two ahead. Buffer / data
324  * were prefetched above...
325  */
326  table_index2 = vnet_buffer (p2)->l2_classify.table_index;
327 
328  if (PREDICT_TRUE (table_index2 != ~0))
329  {
330  tp2 = pool_elt_at_index (vcm->tables, table_index2);
331  phash2 = vnet_buffer (p2)->l2_classify.hash;
332  vnet_classify_prefetch_entry (tp2, phash2);
333  }
334  }
335 
336  /* speculatively enqueue b0 to the current next frame */
337  bi0 = from[0];
338  to_next[0] = bi0;
339  from += 1;
340  to_next += 1;
341  n_left_from -= 1;
342  n_left_to_next -= 1;
343 
344  b0 = vlib_get_buffer (vm, bi0);
345  h0 = vlib_buffer_get_current (b0);
346  table_index0 = vnet_buffer (b0)->l2_classify.table_index;
347  e0 = 0;
348  vnet_buffer (b0)->l2_classify.opaque_index = ~0;
349 
350  if (PREDICT_TRUE (table_index0 != ~0))
351  {
352  hash0 = vnet_buffer (b0)->l2_classify.hash;
353  t0 = pool_elt_at_index (vcm->tables, table_index0);
354 
355  e0 = vnet_classify_find_entry (t0, (u8 *) h0, hash0, now);
356  if (e0)
357  {
358  vnet_buffer (b0)->l2_classify.opaque_index
359  = e0->opaque_index;
360  vlib_buffer_advance (b0, e0->advance);
361  next0 = (e0->next_index < n_next_nodes) ?
362  e0->next_index : next0;
363  hits++;
364  }
365  else
366  {
367  while (1)
368  {
369  if (t0->next_table_index != ~0)
370  t0 = pool_elt_at_index (vcm->tables,
371  t0->next_table_index);
372  else
373  {
374  next0 = (t0->miss_next_index < n_next_nodes) ?
375  t0->miss_next_index : next0;
376  misses++;
377  break;
378  }
379 
380  hash0 = vnet_classify_hash_packet (t0, (u8 *) h0);
381  e0 =
382  vnet_classify_find_entry (t0, (u8 *) h0, hash0, now);
383  if (e0)
384  {
385  vnet_buffer (b0)->l2_classify.opaque_index
386  = e0->opaque_index;
387  vlib_buffer_advance (b0, e0->advance);
388  next0 = (e0->next_index < n_next_nodes) ?
389  e0->next_index : next0;
390  hits++;
391  chain_hits++;
392  break;
393  }
394  }
395  }
396  }
397 
398  if (PREDICT_FALSE (next0 == 0))
399  b0->error = node->errors[L2_OUTPUT_CLASSIFY_ERROR_DROP];
400 
401  /* Determine the next node and remove ourself from bitmap */
402  if (PREDICT_FALSE (next0 == ~0))
403  next0 = vnet_l2_feature_next (b0, cm->l2_out_feat_next,
404  L2OUTPUT_FEAT_OUTPUT_CLASSIFY);
405  else
406  vnet_buffer (b0)->l2.feature_bitmap &=
407  ~L2OUTPUT_FEAT_OUTPUT_CLASSIFY;
408 
409  if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
410  && (b0->flags & VLIB_BUFFER_IS_TRACED)))
411  {
413  vlib_add_trace (vm, node, b0, sizeof (*t));
414  t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX];
415  t->table_index = table_index0;
416  t->next_index = next0;
417  t->session_offset = e0 ? vnet_classify_get_offset (t0, e0) : 0;
418  }
419 
420  /* verify speculative enqueue, maybe switch current next frame */
422  to_next, n_left_to_next,
423  bi0, next0);
424  }
425 
426  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
427  }
428 
429  vlib_node_increment_counter (vm, node->node_index,
430  L2_OUTPUT_CLASSIFY_ERROR_MISS, misses);
431  vlib_node_increment_counter (vm, node->node_index,
432  L2_OUTPUT_CLASSIFY_ERROR_HIT, hits);
433  vlib_node_increment_counter (vm, node->node_index,
434  L2_OUTPUT_CLASSIFY_ERROR_CHAIN_HIT,
435  chain_hits);
436  return frame->n_vectors;
437 }
438 
439 /* *INDENT-OFF* */
441  .name = "l2-output-classify",
442  .vector_size = sizeof (u32),
443  .format_trace = format_l2_output_classify_trace,
445 
447  .error_strings = l2_output_classify_error_strings,
448 
449  .runtime_data_bytes = sizeof (l2_output_classify_runtime_t),
450 
451  .n_next_nodes = L2_OUTPUT_CLASSIFY_N_NEXT,
452 
453  /* edit / add dispositions here */
454  .next_nodes = {
455  [L2_OUTPUT_CLASSIFY_NEXT_DROP] = "error-drop",
456  },
457 };
458 /* *INDENT-ON* */
459 
460 #ifndef CLIB_MARCH_VARIANT
461 /** l2 output classsifier feature initialization. */
462 clib_error_t *
464 {
467 
469 
470  cm->vlib_main = vm;
471  cm->vnet_main = vnet_get_main ();
472  cm->vnet_classify_main = &vnet_classify_main;
473 
474  /* Initialize the feature next-node indexes */
479  cm->l2_out_feat_next);
480  rt->l2cm = cm;
481  rt->vcm = cm->vnet_classify_main;
482 
483  return 0;
484 }
485 
487 
488 clib_error_t *
490 {
493 
495 
496  rt->l2cm = cm;
497  rt->vcm = cm->vnet_classify_main;
498 
499  return 0;
500 }
501 
503 
504 /** Enable/disable l2 input classification on a specific interface. */
505 void
507 {
508 
509  l2output_intf_bitmap_enable (sw_if_index, L2OUTPUT_FEAT_OUTPUT_CLASSIFY,
510  (u32) enable_disable);
511 }
512 
513 /** @brief Set l2 per-protocol, per-interface output classification tables.
514  *
515  * @param sw_if_index interface handle
516  * @param ip4_table_index ip4 classification table index, or ~0
517  * @param ip6_table_index ip6 classification table index, or ~0
518  * @param other_table_index non-ip4, non-ip6 classification table index,
519  * or ~0
520  * @returns 0 on success, VNET_API_ERROR_NO_SUCH_TABLE, TABLE2, TABLE3
521  * if the indicated (non-~0) table does not exist.
522  */
523 
524 int
526  u32 ip4_table_index,
527  u32 ip6_table_index,
528  u32 other_table_index)
529 {
531  vnet_classify_main_t *vcm = cm->vnet_classify_main;
532 
533  /* Assume that we've validated sw_if_index in the API layer */
534 
535  if (ip4_table_index != ~0 &&
536  pool_is_free_index (vcm->tables, ip4_table_index))
537  return VNET_API_ERROR_NO_SUCH_TABLE;
538 
539  if (ip6_table_index != ~0 &&
540  pool_is_free_index (vcm->tables, ip6_table_index))
541  return VNET_API_ERROR_NO_SUCH_TABLE2;
542 
543  if (other_table_index != ~0 &&
544  pool_is_free_index (vcm->tables, other_table_index))
545  return VNET_API_ERROR_NO_SUCH_TABLE3;
546 
548  (cm->classify_table_index_by_sw_if_index[L2_OUTPUT_CLASSIFY_TABLE_IP4],
549  sw_if_index);
550 
552  (cm->classify_table_index_by_sw_if_index[L2_OUTPUT_CLASSIFY_TABLE_IP6],
553  sw_if_index);
554 
556  (cm->classify_table_index_by_sw_if_index[L2_OUTPUT_CLASSIFY_TABLE_OTHER],
557  sw_if_index);
558 
559  cm->classify_table_index_by_sw_if_index[L2_OUTPUT_CLASSIFY_TABLE_IP4]
560  [sw_if_index] = ip4_table_index;
561 
562  cm->classify_table_index_by_sw_if_index[L2_OUTPUT_CLASSIFY_TABLE_IP6]
563  [sw_if_index] = ip6_table_index;
564 
565  cm->classify_table_index_by_sw_if_index[L2_OUTPUT_CLASSIFY_TABLE_OTHER]
566  [sw_if_index] = other_table_index;
567 
568  return 0;
569 }
570 #endif /* CLIB_MARCH_VARIANT */
571 
572 static clib_error_t *
574  unformat_input_t * input,
575  vlib_cli_command_t * cmd)
576 {
577  vnet_main_t *vnm = vnet_get_main ();
578  u32 sw_if_index = ~0;
579  u32 ip4_table_index = ~0;
580  u32 ip6_table_index = ~0;
581  u32 other_table_index = ~0;
582  int rv;
583 
585  {
586  if (unformat (input, "intfc %U", unformat_vnet_sw_interface,
587  vnm, &sw_if_index))
588  ;
589  else if (unformat (input, "ip4-table %d", &ip4_table_index))
590  ;
591  else if (unformat (input, "ip6-table %d", &ip6_table_index))
592  ;
593  else if (unformat (input, "other-table %d", &other_table_index))
594  ;
595  else
596  break;
597  }
598 
599  if (sw_if_index == ~0)
600  return clib_error_return (0, "interface must be specified");
601 
602 
603  if (ip4_table_index == ~0 && ip6_table_index == ~0
604  && other_table_index == ~0)
605  {
606  vlib_cli_output (vm, "L2 classification disabled");
608  return 0;
609  }
610 
612  ip6_table_index,
613  other_table_index);
614  switch (rv)
615  {
616  case 0:
618  break;
619 
620  default:
621  return clib_error_return (0, "vnet_l2_output_classify_set_tables: %d",
622  rv);
623  break;
624  }
625 
626  return 0;
627 }
628 
629 /*?
630  * Configure Layer 2 output classification.
631  *
632  * @cliexpar
633  * @cliexstart{set interface l2 output classify intfc <interface-name> [ip4-table <index>] [ip6-table <index>] [other-table <index>]}
634  * @cliexend
635  * @todo This is incomplete. This needs a detailed description and a
636  * practical example.
637 ?*/
638 /* *INDENT-OFF* */
640  .path = "set interface l2 output classify",
641  .short_help =
642  "set interface l2 output classify intfc <<interface-name>> [ip4-table <n>]\n"
643  " [ip6-table <n>] [other-table <n>]",
645 };
646 /* *INDENT-ON* */
647 
648 /*
649  * fd.io coding-style-patch-verification: ON
650  *
651  * Local Variables:
652  * eval: (c-set-style "gnu")
653  * End:
654  */
l2_output_classify_trace_t::next_index
u32 next_index
graph arc index selected for this packet
Definition: l2_output_classify.c:32
VLIB_WORKER_INIT_FUNCTION
VLIB_WORKER_INIT_FUNCTION(l2_output_classify_worker_init)
vnet_classify_entry_t
struct _vnet_classify_entry vnet_classify_entry_t
l2_output_classify_node
vlib_node_registration_t l2_output_classify_node
(constructor) VLIB_REGISTER_NODE (l2_output_classify_node)
Definition: l2_output_classify.c:440
vlib_node_get_runtime_data
static void * vlib_node_get_runtime_data(vlib_main_t *vm, u32 node_index)
Get node runtime private data by node index.
Definition: node_funcs.h:137
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
l2_output_classify_trace_t::session_offset
u32 session_offset
offset in classifier heap of the corresponding session
Definition: l2_output_classify.c:36
vnet_classify_table_t::miss_next_index
u32 miss_next_index
Definition: vnet_classify.h:176
next_index
nat44_ei_hairpin_src_next_t next_index
Definition: nat44_ei_hairpinning.c:412
l2_output_classify_main_t
struct _l2_classify_main l2_output_classify_main_t
Definition: l2_classify.h:83
l2_output_classify_worker_init
clib_error_t * l2_output_classify_worker_init(vlib_main_t *vm)
Definition: l2_output_classify.c:489
vlib_get_buffer
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:111
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:553
VLIB_NODE_TYPE_INTERNAL
@ VLIB_NODE_TYPE_INTERNAL
Definition: node.h:72
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
vnet_classify_main
vnet_classify_main_t vnet_classify_main
Definition: vnet_classify.c:32
l2_output_classify_runtime_t::l2cm
l2_output_classify_main_t * l2cm
l2 input classifier main object pointer
Definition: l2_output_classify.c:44
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
vlib_cli_command_t::path
char * path
Definition: cli.h:96
u16
unsigned short u16
Definition: types.h:57
L2_OUTPUT_CLASSIFY_NEXT_DROP
@ L2_OUTPUT_CLASSIFY_NEXT_DROP
Definition: l2_classify.h:56
ethernet_header_t::type
u16 type
Definition: packet.h:59
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
L2_OUTPUT_CLASSIFY_TABLE_IP4
@ L2_OUTPUT_CLASSIFY_TABLE_IP4
Definition: l2_classify.h:62
l2_output_classify_error_t
l2_output_classify_error_t
Definition: l2_output_classify.c:75
unformat_input_t
struct _unformat_input_t unformat_input_t
vnet_l2_output_classify_enable_disable
void vnet_l2_output_classify_enable_disable(u32 sw_if_index, int enable_disable)
Enable/disable l2 input classification on a specific interface.
Definition: l2_output_classify.c:506
vlib_frame_t
Definition: node.h:372
vnet_classify_find_entry
vnet_classify_entry_t * vnet_classify_find_entry(vnet_classify_table_t *t, u8 *h, u64 hash, f64 now)
Definition: vnet_classify.c:657
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
pool_is_free_index
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:302
CLIB_PREFETCH
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:80
l2_output_classify_trace_t
Definition: l2_output_classify.c:27
vlib_buffer_advance
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:276
vlib_buffer_t::error
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:145
VLIB_NODE_FN
#define VLIB_NODE_FN(node)
Definition: node.h:202
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
vnet_buffer
#define vnet_buffer(b)
Definition: buffer.h:437
l2output_get_feat_names
char ** l2output_get_feat_names(void)
Definition: l2_output.c:38
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
L2OUTPUT_N_FEAT
@ L2OUTPUT_N_FEAT
Definition: l2_output.h:105
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
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
vnet_classify_prefetch_entry
static void vnet_classify_prefetch_entry(vnet_classify_table_t *t, u64 hash)
Definition: vnet_classify.h:371
l2_output_classify_runtime_t
Definition: l2_output_classify.c:39
if
if(node->flags &VLIB_NODE_FLAG_TRACE) vnet_interface_output_trace(vm
ethernet_header_t
Definition: packet.h:52
vnet_classify_prefetch_bucket
static void vnet_classify_prefetch_bucket(vnet_classify_table_t *t, u64 hash)
Definition: vnet_classify.h:323
vlib_node_increment_counter
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1244
L2_OUTPUT_CLASSIFY_TABLE_OTHER
@ L2_OUTPUT_CLASSIFY_TABLE_OTHER
Definition: l2_classify.h:64
f64
double f64
Definition: types.h:142
vnet_l2_output_classify_set_tables
int vnet_l2_output_classify_set_tables(u32 sw_if_index, u32 ip4_table_index, u32 ip6_table_index, u32 other_table_index)
Set l2 per-protocol, per-interface output classification tables.
Definition: l2_output_classify.c:525
cm
vnet_feature_config_main_t * cm
Definition: nat44_ei_hairpinning.c:591
vec_validate
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
Definition: vec.h:523
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
int_l2_output_classify_command_fn
static clib_error_t * int_l2_output_classify_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: l2_output_classify.c:573
vnet_classify_table_t
Definition: vnet_classify.h:147
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
vlib_cli_output
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:716
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
l2_output_classify_init
clib_error_t * l2_output_classify_init(vlib_main_t *vm)
l2 output classsifier feature initialization.
Definition: l2_output_classify.c:463
vnet_classify_table_t::next_table_index
u32 next_table_index
Definition: vnet_classify.h:170
vnet_main_t
Definition: vnet.h:76
vlib_validate_buffer_enqueue_x1
#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:224
l2_output_classify_trace_t::sw_if_index
u32 sw_if_index
interface handle for the ith packet
Definition: l2_output_classify.c:30
int_l2_output_classify_cli
static vlib_cli_command_t int_l2_output_classify_cli
(constructor) VLIB_CLI_COMMAND (int_l2_output_classify_cli)
Definition: l2_output_classify.c:639
l2_output_classify_main
l2_output_classify_main_t l2_output_classify_main
l2 output classifier main data structure.
Definition: l2_output_classify.c:66
u64
unsigned long u64
Definition: types.h:89
l2output_intf_bitmap_enable
void l2output_intf_bitmap_enable(u32 sw_if_index, l2output_feat_masks_t feature_bitmap, u32 enable)
Enable (or disable) the feature in the bitmap for the given interface.
Definition: l2_output.c:625
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
vlib_put_next_frame
vlib_put_next_frame(vm, node, next_index, 0)
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
l2_classify.h
l2_output_classify_runtime_t::vcm
vnet_classify_main_t * vcm
use-case independent main object pointer
Definition: l2_output_classify.c:42
vnet_classify_main_t
struct _vnet_classify_main vnet_classify_main_t
Definition: vnet_classify.h:61
l2_output_classify_error_strings
static char * l2_output_classify_error_strings[]
Definition: l2_output_classify.c:83
vnet_classify_hash_packet
u64 vnet_classify_hash_packet(vnet_classify_table_t *t, u8 *h)
vnet_classify_get_offset
static uword vnet_classify_get_offset(vnet_classify_table_t *t, vnet_classify_entry_t *v)
Definition: vnet_classify.h:344
now
f64 now
Definition: nat44_ei_out2in.c:710
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
L2_OUTPUT_CLASSIFY_N_ERROR
@ L2_OUTPUT_CLASSIFY_N_ERROR
Definition: l2_output_classify.c:80
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
rt
vnet_interface_output_runtime_t * rt
Definition: interface_output.c:399
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
L2_OUTPUT_CLASSIFY_N_NEXT
@ L2_OUTPUT_CLASSIFY_N_NEXT
Definition: l2_classify.h:57
vlib_buffer_t::data
u8 data[]
Packet data.
Definition: buffer.h:204
l2_output_classify_next_t
l2_output_classify_next_t
Definition: l2_classify.h:54
foreach_l2_output_classify_error
#define foreach_l2_output_classify_error
Definition: l2_output_classify.c:69
format_l2_output_classify_trace
static u8 * format_l2_output_classify_trace(u8 *s, va_list *args)
Packet trace format function.
Definition: l2_output_classify.c:49
rv
int __clib_unused rv
Definition: application.c:491
l2_output_classify_trace_t::table_index
u32 table_index
classifier table which provided the final result
Definition: l2_output_classify.c:34
vlib_time_now
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:325
L2_OUTPUT_CLASSIFY_TABLE_IP6
@ L2_OUTPUT_CLASSIFY_TABLE_IP6
Definition: l2_classify.h:63
api_errno.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
PREDICT_TRUE
#define PREDICT_TRUE(x)
Definition: clib.h:125
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
vlib_get_next_frame
#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:395
VLIB_TX
@ VLIB_TX
Definition: defs.h:47
n_left_from
n_left_from
Definition: nat44_ei_hairpinning.c:416
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
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137
vlib_buffer_t::flags
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
Definition: buffer.h:133
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169