FD.io VPP  v17.07.01-10-g3be13f0
Vector Packet Processing
l2_input_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  * l2_classify.c
17  */
18 
19 #include <vnet/l2/l2_classify.h>
20 #include <vnet/api_errno.h>
21 
22 /**
23  * @file
24  * @brief L2 input classifier.
25  *
26  * @sa @ref vnet/vnet/classify/vnet_classify.c
27  * @sa @ref vnet/vnet/classify/vnet_classify.h
28  */
29 
30 /**
31  * @brief l2_input_classifier packet trace record.
32  */
33 typedef struct
34 {
35  /** interface handle for the ith packet */
37  /** graph arc index selected for this packet */
39  /** classifier table which provided the final result */
41  /** offset in classifier heap of the corresponding session */
44 
45 /**
46  * @brief vlib node runtime.
47  */
48 typedef struct
49 {
50  /** use-case independent main object pointer */
52  /** l2 input classifier main object pointer */
55 
56 /** Packet trace format function. */
57 static u8 *
58 format_l2_input_classify_trace (u8 * s, va_list * args)
59 {
60  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
61  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
63 
64  s = format (s, "l2-classify: sw_if_index %d, table %d, offset %x, next %d",
66  t->next_index);
67  return s;
68 }
69 
70 /** l2 input classifier main data structure. */
72 
74 
75 #define foreach_l2_input_classify_error \
76 _(MISS, "Classify misses") \
77 _(HIT, "Classify hits") \
78 _(CHAIN_HIT, "Classify hits after chain walk") \
79 _(DROP, "L2 Classify Drops")
80 
81 typedef enum
82 {
83 #define _(sym,str) L2_INPUT_CLASSIFY_ERROR_##sym,
85 #undef _
88 
90 #define _(sym,string) string,
92 #undef _
93 };
94 
95 /**
96  * @brief l2 input classifier node.
97  * @node l2-input-classify
98  *
99  * This is the l2 input classifier dispatch node
100  *
101  * @param vm vlib_main_t corresponding to the current thread.
102  * @param node vlib_node_runtime_t data for this node.
103  * @param frame vlib_frame_t whose contents should be dispatched.
104  *
105  * @par Graph mechanics: buffer metadata, next index usage
106  *
107  * @em Uses:
108  * - <code>(l2_input_classify_runtime_t *)
109  * rt->classify_table_index_by_sw_if_index</code>
110  * - Head of the per-interface, per-protocol classifier table chain
111  * for a specific interface.
112  * - @c ~0 => send pkts to the next feature in the L2 feature chain.
113  * - <code>vnet_buffer(b)->sw_if_index[VLIB_RX]</code>
114  * - Indicates the @c sw_if_index value of the interface that the
115  * packet was received on.
116  * - <code>vnet_buffer(b0)->l2.feature_bitmap</code>
117  * - Used to steer packets across l2 features enabled on the interface
118  * - <code>(vnet_classify_entry_t) e0->next_index</code>
119  * - Used to steer traffic when the classifier hits on a session
120  * - <code>(vnet_classify_entry_t) e0->advance</code>
121  * - Signed quantity applied via <code>vlib_buffer_advance</code>
122  * when the classifier hits on a session
123  * - <code>(vnet_classify_table_t) t0->miss_next_index</code>
124  * - Used to steer traffic when the classifier misses
125  *
126  * @em Sets:
127  * - <code>vnet_buffer (b0)->l2_classify.table_index</code>
128  * - Classifier table index of the first classifier table in
129  * the classifier table chain
130  * - <code>vnet_buffer (b0)->l2_classify.hash</code>
131  * - Bounded-index extensible hash corresponding to the
132  * masked fields in the current packet
133  * - <code>vnet_buffer (b0)->l2.feature_bitmap</code>
134  * - Used to steer packets across l2 features enabled on the interface
135  * - <code>vnet_buffer (b0)->l2_classify.opaque_index</code>
136  * - Copied from the classifier session object upon classifier hit
137  *
138  * @em Counters:
139  * - <code>L2_INPUT_CLASSIFY_ERROR_MISS</code> Classifier misses
140  * - <code>L2_INPUT_CLASSIFY_ERROR_HIT</code> Classifier hits
141  * - <code>L2_INPUT_CLASSIFY_ERROR_CHAIN_HIT</code>
142  * Classifier hits in other than the first table
143  */
144 
145 static uword
147  vlib_node_runtime_t * node, vlib_frame_t * frame)
148 {
149  u32 n_left_from, *from, *to_next;
150  l2_input_classify_next_t next_index;
152  vnet_classify_main_t *vcm = cm->vnet_classify_main;
155  u32 feature_bitmap;
156  u32 hits = 0;
157  u32 misses = 0;
158  u32 chain_hits = 0;
159  f64 now;
160  u32 n_next_nodes;
161 
162  n_next_nodes = node->n_next_nodes;
163 
164  now = vlib_time_now (vm);
165 
166  n_left_from = frame->n_vectors;
167  from = vlib_frame_vector_args (frame);
168 
169  /* First pass: compute hash */
170 
171  while (n_left_from > 2)
172  {
173  vlib_buffer_t *b0, *b1;
174  u32 bi0, bi1;
175  ethernet_header_t *h0, *h1;
176  u32 sw_if_index0, sw_if_index1;
177  u16 type0, type1;
178  int type_index0, type_index1;
179  vnet_classify_table_t *t0, *t1;
180  u32 table_index0, table_index1;
181  u64 hash0, hash1;
182 
183 
184  /* prefetch next iteration */
185  {
186  vlib_buffer_t *p1, *p2;
187 
188  p1 = vlib_get_buffer (vm, from[1]);
189  p2 = vlib_get_buffer (vm, from[2]);
190 
191  vlib_prefetch_buffer_header (p1, STORE);
193  vlib_prefetch_buffer_header (p2, STORE);
195  }
196 
197  bi0 = from[0];
198  b0 = vlib_get_buffer (vm, bi0);
199  h0 = vlib_buffer_get_current (b0);
200 
201  bi1 = from[1];
202  b1 = vlib_get_buffer (vm, bi1);
203  h1 = vlib_buffer_get_current (b1);
204 
205  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
206  vnet_buffer (b0)->l2_classify.table_index = ~0;
207 
208  sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_RX];
209  vnet_buffer (b1)->l2_classify.table_index = ~0;
210 
211  /* Select classifier table based on ethertype */
212  type0 = clib_net_to_host_u16 (h0->type);
213  type1 = clib_net_to_host_u16 (h1->type);
214 
215  type_index0 = (type0 == ETHERNET_TYPE_IP4)
217  type_index0 = (type0 == ETHERNET_TYPE_IP6)
218  ? L2_INPUT_CLASSIFY_TABLE_IP6 : type_index0;
219 
220  type_index1 = (type1 == ETHERNET_TYPE_IP4)
222  type_index1 = (type1 == ETHERNET_TYPE_IP6)
223  ? L2_INPUT_CLASSIFY_TABLE_IP6 : type_index1;
224 
225  vnet_buffer (b0)->l2_classify.table_index =
226  table_index0 =
227  rt->l2cm->classify_table_index_by_sw_if_index
228  [type_index0][sw_if_index0];
229 
230  if (table_index0 != ~0)
231  {
232  t0 = pool_elt_at_index (vcm->tables, table_index0);
233 
234  vnet_buffer (b0)->l2_classify.hash = hash0 =
235  vnet_classify_hash_packet (t0, (u8 *) h0);
236  vnet_classify_prefetch_bucket (t0, hash0);
237  }
238 
239  vnet_buffer (b1)->l2_classify.table_index =
240  table_index1 =
241  rt->l2cm->classify_table_index_by_sw_if_index
242  [type_index1][sw_if_index1];
243 
244  if (table_index1 != ~0)
245  {
246  t1 = pool_elt_at_index (vcm->tables, table_index1);
247 
248  vnet_buffer (b1)->l2_classify.hash = hash1 =
249  vnet_classify_hash_packet (t1, (u8 *) h1);
250  vnet_classify_prefetch_bucket (t1, hash1);
251  }
252 
253  from += 2;
254  n_left_from -= 2;
255  }
256 
257  while (n_left_from > 0)
258  {
259  vlib_buffer_t *b0;
260  u32 bi0;
261  ethernet_header_t *h0;
262  u32 sw_if_index0;
263  u16 type0;
264  u32 type_index0;
266  u32 table_index0;
267  u64 hash0;
268 
269  bi0 = from[0];
270  b0 = vlib_get_buffer (vm, bi0);
271  h0 = vlib_buffer_get_current (b0);
272 
273  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
274  vnet_buffer (b0)->l2_classify.table_index = ~0;
275 
276  /* Select classifier table based on ethertype */
277  type0 = clib_net_to_host_u16 (h0->type);
278 
279  type_index0 = (type0 == ETHERNET_TYPE_IP4)
281  type_index0 = (type0 == ETHERNET_TYPE_IP6)
282  ? L2_INPUT_CLASSIFY_TABLE_IP6 : type_index0;
283 
284  vnet_buffer (b0)->l2_classify.table_index =
285  table_index0 = rt->l2cm->classify_table_index_by_sw_if_index
286  [type_index0][sw_if_index0];
287 
288  if (table_index0 != ~0)
289  {
290  t0 = pool_elt_at_index (vcm->tables, table_index0);
291 
292  vnet_buffer (b0)->l2_classify.hash = hash0 =
293  vnet_classify_hash_packet (t0, (u8 *) h0);
294  vnet_classify_prefetch_bucket (t0, hash0);
295  }
296  from++;
297  n_left_from--;
298  }
299 
300  next_index = node->cached_next_index;
301  from = vlib_frame_vector_args (frame);
302  n_left_from = frame->n_vectors;
303 
304  while (n_left_from > 0)
305  {
306  u32 n_left_to_next;
307 
308  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
309 
310  /* Not enough load/store slots to dual loop... */
311  while (n_left_from > 0 && n_left_to_next > 0)
312  {
313  u32 bi0;
314  vlib_buffer_t *b0;
315  u32 next0 = ~0; /* next l2 input feature, please... */
316  ethernet_header_t *h0;
317  u32 table_index0;
318  u64 hash0;
320  vnet_classify_entry_t *e0;
321 
322  if (PREDICT_TRUE (n_left_from > 2))
323  {
324  vlib_buffer_t *p2 = vlib_get_buffer (vm, from[2]);
325  u64 phash2;
326  u32 table_index2;
328 
329  /*
330  * Prefetch table entry two ahead. Buffer / data
331  * were prefetched above...
332  */
333  table_index2 = vnet_buffer (p2)->l2_classify.table_index;
334 
335  if (PREDICT_TRUE (table_index2 != ~0))
336  {
337  tp2 = pool_elt_at_index (vcm->tables, table_index2);
338  phash2 = vnet_buffer (p2)->l2_classify.hash;
339  vnet_classify_prefetch_entry (tp2, phash2);
340  }
341  }
342 
343  /* speculatively enqueue b0 to the current next frame */
344  bi0 = from[0];
345  to_next[0] = bi0;
346  from += 1;
347  to_next += 1;
348  n_left_from -= 1;
349  n_left_to_next -= 1;
350 
351  b0 = vlib_get_buffer (vm, bi0);
352  h0 = vlib_buffer_get_current (b0);
353  table_index0 = vnet_buffer (b0)->l2_classify.table_index;
354  e0 = 0;
355  vnet_buffer (b0)->l2_classify.opaque_index = ~0;
356 
357  /* Remove ourself from the feature bitmap */
358  feature_bitmap = vnet_buffer (b0)->l2.feature_bitmap
359  & ~L2INPUT_FEAT_INPUT_CLASSIFY;
360 
361  /* save for next feature graph nodes */
362  vnet_buffer (b0)->l2.feature_bitmap = feature_bitmap;
363 
364  if (PREDICT_TRUE (table_index0 != ~0))
365  {
366  hash0 = vnet_buffer (b0)->l2_classify.hash;
367  t0 = pool_elt_at_index (vcm->tables, table_index0);
368 
369  e0 = vnet_classify_find_entry (t0, (u8 *) h0, hash0, now);
370  if (e0)
371  {
372  vnet_buffer (b0)->l2_classify.opaque_index
373  = e0->opaque_index;
374  vlib_buffer_advance (b0, e0->advance);
375  next0 = (e0->next_index < n_next_nodes) ?
376  e0->next_index : next0;
377  hits++;
378  }
379  else
380  {
381  while (1)
382  {
383  if (t0->next_table_index != ~0)
384  t0 = pool_elt_at_index (vcm->tables,
385  t0->next_table_index);
386  else
387  {
388  next0 = (t0->miss_next_index < n_next_nodes) ?
389  t0->miss_next_index : next0;
390  misses++;
391  break;
392  }
393 
394  hash0 = vnet_classify_hash_packet (t0, (u8 *) h0);
395  e0 =
396  vnet_classify_find_entry (t0, (u8 *) h0, hash0, now);
397  if (e0)
398  {
399  vnet_buffer (b0)->l2_classify.opaque_index
400  = e0->opaque_index;
401  vlib_buffer_advance (b0, e0->advance);
402  next0 = (e0->next_index < n_next_nodes) ?
403  e0->next_index : next0;
404  hits++;
405  chain_hits++;
406  break;
407  }
408  }
409  }
410  }
411 
412  if (PREDICT_FALSE (next0 == 0))
413  b0->error = node->errors[L2_INPUT_CLASSIFY_ERROR_DROP];
414 
415  if (PREDICT_TRUE (next0 == ~0))
416  {
417  // Determine the next node
418  next0 =
419  feat_bitmap_get_next_node_index (cm->feat_next_node_index,
420  feature_bitmap);
421  }
422 
424  && (b0->flags & VLIB_BUFFER_IS_TRACED)))
425  {
427  vlib_add_trace (vm, node, b0, sizeof (*t));
428  t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX];
429  t->table_index = table_index0;
430  t->next_index = next0;
431  t->session_offset = e0 ? vnet_classify_get_offset (t0, e0) : 0;
432  }
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 
444  L2_INPUT_CLASSIFY_ERROR_MISS, misses);
446  L2_INPUT_CLASSIFY_ERROR_HIT, hits);
448  L2_INPUT_CLASSIFY_ERROR_CHAIN_HIT, chain_hits);
449  return frame->n_vectors;
450 }
451 
452 /* *INDENT-OFF* */
454  .function = l2_input_classify_node_fn,
455  .name = "l2-input-classify",
456  .vector_size = sizeof (u32),
457  .format_trace = format_l2_input_classify_trace,
458  .type = VLIB_NODE_TYPE_INTERNAL,
459 
461  .error_strings = l2_input_classify_error_strings,
462 
463  .runtime_data_bytes = sizeof (l2_input_classify_runtime_t),
464 
465  .n_next_nodes = L2_INPUT_CLASSIFY_N_NEXT,
466 
467  /* edit / add dispositions here */
468  .next_nodes = {
469  [L2_INPUT_CLASSIFY_NEXT_DROP] = "error-drop",
470  [L2_INPUT_CLASSIFY_NEXT_ETHERNET_INPUT] = "ethernet-input-not-l2",
471  [L2_INPUT_CLASSIFY_NEXT_IP4_INPUT] = "ip4-input",
472  [L2_INPUT_CLASSIFY_NEXT_IP6_INPUT] = "ip6-input",
473  [L2_INPUT_CLASSIFY_NEXT_LI] = "li-hit",
474  },
475 };
476 /* *INDENT-ON* */
477 
480 
481 /** l2 input classsifier feature initialization. */
482 clib_error_t *
484 {
487 
489 
490  cm->vlib_main = vm;
491  cm->vnet_main = vnet_get_main ();
492  cm->vnet_classify_main = &vnet_classify_main;
493 
494  /* Initialize the feature next-node indexes */
499  cm->feat_next_node_index);
500  rt->l2cm = cm;
501  rt->vcm = cm->vnet_classify_main;
502 
503  return 0;
504 }
505 
507 
508 clib_error_t *
510 {
513 
515 
516  rt->l2cm = cm;
517  rt->vcm = cm->vnet_classify_main;
518 
519  return 0;
520 }
521 
523 
524 /** Enable/disable l2 input classification on a specific interface. */
525 void
526 vnet_l2_input_classify_enable_disable (u32 sw_if_index, int enable_disable)
527 {
528  l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_INPUT_CLASSIFY,
529  (u32) enable_disable);
530 }
531 
532 /** @brief Set l2 per-protocol, per-interface input classification tables.
533  *
534  * @param sw_if_index interface handle
535  * @param ip4_table_index ip4 classification table index, or ~0
536  * @param ip6_table_index ip6 classification table index, or ~0
537  * @param other_table_index non-ip4, non-ip6 classification table index,
538  * or ~0
539  * @returns 0 on success, VNET_API_ERROR_NO_SUCH_TABLE, TABLE2, TABLE3
540  * if the indicated (non-~0) table does not exist.
541  */
542 
543 int
545  u32 ip4_table_index,
546  u32 ip6_table_index, u32 other_table_index)
547 {
549  vnet_classify_main_t *vcm = cm->vnet_classify_main;
550 
551  /* Assume that we've validated sw_if_index in the API layer */
552 
553  if (ip4_table_index != ~0 &&
554  pool_is_free_index (vcm->tables, ip4_table_index))
555  return VNET_API_ERROR_NO_SUCH_TABLE;
556 
557  if (ip6_table_index != ~0 &&
558  pool_is_free_index (vcm->tables, ip6_table_index))
559  return VNET_API_ERROR_NO_SUCH_TABLE2;
560 
561  if (other_table_index != ~0 &&
562  pool_is_free_index (vcm->tables, other_table_index))
563  return VNET_API_ERROR_NO_SUCH_TABLE3;
564 
566  (cm->classify_table_index_by_sw_if_index[L2_INPUT_CLASSIFY_TABLE_IP4],
567  sw_if_index);
568 
570  (cm->classify_table_index_by_sw_if_index[L2_INPUT_CLASSIFY_TABLE_IP6],
571  sw_if_index);
572 
574  (cm->classify_table_index_by_sw_if_index[L2_INPUT_CLASSIFY_TABLE_OTHER],
575  sw_if_index);
576 
577  cm->classify_table_index_by_sw_if_index[L2_INPUT_CLASSIFY_TABLE_IP4]
578  [sw_if_index] = ip4_table_index;
579 
580  cm->classify_table_index_by_sw_if_index[L2_INPUT_CLASSIFY_TABLE_IP6]
581  [sw_if_index] = ip6_table_index;
582 
583  cm->classify_table_index_by_sw_if_index[L2_INPUT_CLASSIFY_TABLE_OTHER]
584  [sw_if_index] = other_table_index;
585 
586  return 0;
587 }
588 
589 static clib_error_t *
591  unformat_input_t * input,
592  vlib_cli_command_t * cmd)
593 {
594  vnet_main_t *vnm = vnet_get_main ();
595  u32 sw_if_index = ~0;
596  u32 ip4_table_index = ~0;
597  u32 ip6_table_index = ~0;
598  u32 other_table_index = ~0;
599  int rv;
600 
602  {
603  if (unformat (input, "intfc %U", unformat_vnet_sw_interface,
604  vnm, &sw_if_index))
605  ;
606  else if (unformat (input, "ip4-table %d", &ip4_table_index))
607  ;
608  else if (unformat (input, "ip6-table %d", &ip6_table_index))
609  ;
610  else if (unformat (input, "other-table %d", &other_table_index))
611  ;
612  else
613  break;
614  }
615 
616  if (sw_if_index == ~0)
617  return clib_error_return (0, "interface must be specified");
618 
619 
620  if (ip4_table_index == ~0 && ip6_table_index == ~0
621  && other_table_index == ~0)
622  {
623  vlib_cli_output (vm, "L2 classification disabled");
624  vnet_l2_input_classify_enable_disable (sw_if_index, 0 /* enable */ );
625  return 0;
626  }
627 
628  rv = vnet_l2_input_classify_set_tables (sw_if_index, ip4_table_index,
629  ip6_table_index, other_table_index);
630  switch (rv)
631  {
632  case 0:
633  vnet_l2_input_classify_enable_disable (sw_if_index, 1 /* enable */ );
634  break;
635 
636  default:
637  return clib_error_return (0, "vnet_l2_input_classify_set_tables: %d",
638  rv);
639  break;
640  }
641 
642  return 0;
643 }
644 
645 /*?
646  * Configure l2 input classification.
647  *
648  * @cliexpar
649  * @cliexstart{set interface l2 input classify intfc <interface-name> [ip4-table <index>] [ip6-table <index>] [other-table <index>]}
650  * @cliexend
651  * @todo This is incomplete. This needs a detailed description and a
652  * practical example.
653  ?*/
654 /* *INDENT-OFF* */
655 VLIB_CLI_COMMAND (int_l2_input_classify_cli, static) = {
656  .path = "set interface l2 input classify",
657  .short_help =
658  "set interface l2 input classify intfc <interface-name> [ip4-table <n>]\n"
659  " [ip6-table <n>] [other-table <n>]",
661 };
662 /* *INDENT-ON* */
663 
664 /*
665  * fd.io coding-style-patch-verification: ON
666  *
667  * Local Variables:
668  * eval: (c-set-style "gnu")
669  * End:
670  */
u64 vnet_classify_hash_packet(vnet_classify_table_t *t, u8 *h)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:436
vlib_node_registration_t l2_input_classify_node
(constructor) VLIB_REGISTER_NODE (l2_input_classify_node)
u32 table_index
classifier table which provided the final result
static u8 * format_l2_input_classify_trace(u8 *s, va_list *args)
Packet trace format function.
clib_error_t * l2_input_classify_init(vlib_main_t *vm)
l2 input classsifier feature initialization.
#define CLIB_UNUSED(x)
Definition: clib.h:79
static uword l2_input_classify_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
l2 input classifier node.
VLIB_WORKER_INIT_FUNCTION(l2_input_classify_worker_init)
u8 runtime_data[0]
Function dependent node-runtime data.
Definition: node.h:468
static char * l2_input_classify_error_strings[]
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
#define PREDICT_TRUE(x)
Definition: clib.h:98
#define foreach_l2_input_classify_error
clib_error_t * l2_input_classify_worker_init(vlib_main_t *vm)
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:192
static clib_error_t * int_l2_input_classify_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
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
struct _vlib_node_registration vlib_node_registration_t
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
unformat_function_t unformat_vnet_sw_interface
l2_input_classify_error_t
vlib_error_t * errors
Vector of errors for this node.
Definition: node.h:419
l2_input_classify_main_t * l2cm
l2 input classifier main object pointer
void vnet_l2_input_classify_enable_disable(u32 sw_if_index, int enable_disable)
Enable/disable l2 input classification on a specific interface.
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:111
l2_input_classify_main_t l2_input_classify_main
l2 input classifier main data structure.
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Definition: buffer.h:164
#define clib_error_return(e, args...)
Definition: error.h:99
unsigned long u64
Definition: types.h:89
static void vnet_classify_prefetch_bucket(vnet_classify_table_t *t, u64 hash)
static void vnet_classify_prefetch_entry(vnet_classify_table_t *t, u64 hash)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:397
l2_input_classifier packet trace record.
int vnet_l2_input_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 input classification tables.
struct _unformat_input_t unformat_input_t
u32 next_index
graph arc index selected for this packet
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:188
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:109
#define PREDICT_FALSE(x)
Definition: clib.h:97
u32 node_index
Node index.
Definition: node.h:441
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: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
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:113
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1131
static uword vnet_classify_get_offset(vnet_classify_table_t *t, vnet_classify_entry_t *v)
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
u16 n_vectors
Definition: node.h:345
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:82
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
vnet_classify_main_t * vcm
use-case independent main object pointer
#define VLIB_BUFFER_IS_TRACED
Definition: buffer.h:85
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:238
#define ARRAY_LEN(x)
Definition: clib.h:59
u32 sw_if_index
interface handle for the ith packet
char ** l2input_get_feat_names(void)
Return an array of strings containing graph node names of each feature.
Definition: l2_input.c:58
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:154
struct _vnet_classify_main vnet_classify_main_t
Definition: vnet_classify.h:72
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
Definition: node.h:460
unsigned int u32
Definition: types.h:88
l2_input_classify_next_t
Definition: l2_classify.h:37
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:201
#define VLIB_NODE_FLAG_TRACE
Definition: node.h:260
vnet_classify_main_t vnet_classify_main
Definition: vnet_classify.c:22
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
unsigned short u16
Definition: types.h:57
struct _l2_classify_main l2_input_classify_main_t
double f64
Definition: types.h:142
unsigned char u8
Definition: types.h:56
u32 session_offset
offset in classifier heap of the corresponding session
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:269
VLIB_NODE_FUNCTION_MULTIARCH(l2_input_classify_node, l2_input_classify_node_fn)
#define vnet_buffer(b)
Definition: buffer.h:304
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:144
u8 data[0]
Packet data.
Definition: buffer.h:152
u16 flags
Copy of main node flags.
Definition: node.h:454
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:67
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:74
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:680
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
vnet_classify_entry_t * vnet_classify_find_entry(vnet_classify_table_t *t, u8 *h, u64 hash, f64 now)
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972
Definition: defs.h:46
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:169