FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
l2_learn.c
Go to the documentation of this file.
1 /*
2  * l2_learn.c : layer 2 learning 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/ethernet/ethernet.h>
21 #include <vlib/cli.h>
22 
23 #include <vnet/l2/l2_input.h>
24 #include <vnet/l2/feat_bitmap.h>
25 #include <vnet/l2/l2_fib.h>
26 #include <vnet/l2/l2_learn.h>
27 
28 #include <vppinfra/error.h>
29 #include <vppinfra/hash.h>
30 
31 #ifndef CLIB_MARCH_VARIANT
33 #endif
34 
35 /**
36  * @file
37  * @brief Ethernet Bridge Learning.
38  *
39  * Populate the mac table with entries mapping the packet's source mac + bridge
40  * domain ID to the input sw_if_index.
41  *
42  * Note that learning and forwarding are separate graph nodes. This means that
43  * for a set of packets, all learning is performed first, then all nodes are
44  * forwarded. The forwarding is done based on the end-state of the mac table,
45  * instead of the state after each packet. Thus the forwarding results could
46  * differ in certain cases (mac move tests), but this not expected to cause
47  * problems in real-world networks. It is much simpler to separate learning
48  * and forwarding into separate nodes.
49  */
50 
51 
52 typedef struct
53 {
54  u8 src[6];
55  u8 dst[6];
59 
60 
61 /* packet trace format function */
62 static u8 *
63 format_l2learn_trace (u8 * s, va_list * args)
64 {
65  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
66  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
67  l2learn_trace_t *t = va_arg (*args, l2learn_trace_t *);
68 
69  s = format (s, "l2-learn: sw_if_index %d dst %U src %U bd_index %d",
70  t->sw_if_index,
73  return s;
74 }
75 
77 
78 #define foreach_l2learn_error \
79 _(L2LEARN, "L2 learn packets") \
80 _(MISS, "L2 learn misses") \
81 _(MAC_MOVE, "L2 mac moves") \
82 _(MAC_MOVE_VIOLATE, "L2 mac move violations") \
83 _(LIMIT, "L2 not learned due to limit") \
84 _(HIT_UPDATE, "L2 learn hit updates") \
85 _(FILTER_DROP, "L2 filter mac drops")
86 
87 typedef enum
88 {
89 #define _(sym,str) L2LEARN_ERROR_##sym,
91 #undef _
94 
95 static char *l2learn_error_strings[] = {
96 #define _(sym,string) string,
98 #undef _
99 };
100 
101 typedef enum
102 {
107 
108 
109 /** Perform learning on one packet based on the mac table lookup result. */
110 
113  l2learn_main_t * msm,
114  u64 * counter_base,
115  vlib_buffer_t * b0,
116  u32 sw_if_index0,
117  l2fib_entry_key_t * key0,
118  l2fib_entry_key_t * cached_key,
119  u32 * count,
120  l2fib_entry_result_t * result0, u16 * next0, u8 timestamp)
121 {
122  l2_bridge_domain_t *bd_config =
124  /* Set up the default next node (typically L2FWD) */
125  *next0 = vnet_l2_feature_next (b0, msm->feat_next_node_index,
126  L2INPUT_FEAT_LEARN);
127 
128  /* Check mac table lookup result */
129  if (PREDICT_TRUE (result0->fields.sw_if_index == sw_if_index0))
130  {
131  /* Entry in L2FIB with matching sw_if_index matched - normal fast path */
132  u32 dtime = timestamp - result0->fields.timestamp;
133  u32 dsn = (result0->fields.sn - vnet_buffer (b0)->l2.l2fib_sn);
134  u32 check = (dtime && vnet_buffer (b0)->l2.bd_age) || dsn;
135 
136  if (PREDICT_TRUE (check == 0))
137  return; /* MAC entry up to date */
138  if (l2fib_entry_result_is_set_AGE_NOT (result0))
139  return; /* Static MAC always age_not */
140  if (msm->global_learn_count > msm->global_learn_limit)
141  return; /* Above learn limit - do not update */
142  if (bd_config->learn_count > bd_config->learn_limit)
143  return; /* Above bridge domain learn limit - do not update */
144 
145  /* Limit updates per l2-learn node call to avoid prolonged update burst
146  * as dtime advance over 1 minute mark, unless more than 1 min behind
147  * or SN obsolete */
148  if ((*count > 2) && (dtime == 1) && (dsn == 0))
149  return;
150 
151  counter_base[L2LEARN_ERROR_HIT_UPDATE] += 1;
152  *count += 1;
153  }
154  else if (result0->raw == ~0)
155  {
156  /* Entry not in L2FIB - add it */
157  counter_base[L2LEARN_ERROR_MISS] += 1;
158 
159  if ((msm->global_learn_count >= msm->global_learn_limit) ||
160  (bd_config->learn_count >= bd_config->learn_limit))
161  {
162  /*
163  * Global limit reached. Do not learn the mac but forward the packet.
164  * In the future, limits could also be per-interface or bridge-domain.
165  */
166  counter_base[L2LEARN_ERROR_LIMIT] += 1;
167  return;
168  }
169 
170  /* Do not learn if mac is 0 */
171  l2fib_entry_key_t key = *key0;
172  key.fields.bd_index = 0;
173  if (key.raw == 0)
174  return;
175 
176  /* It is ok to learn */
177  /* learn_count variable may have little inaccuracy because they are not
178  * incremented/decremented with atomic operations */
179  /* l2fib_scan is call every 2sec fixing potential inaccuracy */
180  msm->global_learn_count++;
181  bd_config->learn_count++;
182  result0->raw = 0; /* clear all fields */
183  result0->fields.sw_if_index = sw_if_index0;
184  if (msm->client_pid != 0)
185  l2fib_entry_result_set_LRN_EVT (result0);
186  else
187  l2fib_entry_result_clear_LRN_EVT (result0);
188  }
189  else
190  {
191  /* Entry in L2FIB with different sw_if_index - mac move or filter */
192  if (l2fib_entry_result_is_set_FILTER (result0))
193  {
194  ASSERT (result0->fields.sw_if_index == ~0);
195  /* drop packet because lookup matched a filter mac entry */
196  b0->error = node->errors[L2LEARN_ERROR_FILTER_DROP];
197  *next0 = L2LEARN_NEXT_DROP;
198  return;
199  }
200 
201  if (l2fib_entry_result_is_set_STATIC (result0))
202  {
203  /*
204  * Don't overwrite a static mac
205  * TODO: Check violation policy. For now drop the packet
206  */
207  b0->error = node->errors[L2LEARN_ERROR_MAC_MOVE_VIOLATE];
208  *next0 = L2LEARN_NEXT_DROP;
209  return;
210  }
211 
212  /*
213  * TODO: may want to rate limit mac moves
214  * TODO: check global/bridge domain/interface learn limits
215  */
216  result0->fields.sw_if_index = sw_if_index0;
217  if (l2fib_entry_result_is_set_AGE_NOT (result0))
218  {
219  /* The mac was provisioned */
220  /* learn_count variable may have little inaccuracy because they are
221  * not incremented/decremented with atomic operations */
222  /* l2fib_scan is call every 2sec fixing potential inaccuracy */
223  msm->global_learn_count++;
224  bd_config->learn_count++;
225 
226  l2fib_entry_result_clear_AGE_NOT (result0);
227  }
228  if (msm->client_pid != 0)
230  (L2FIB_ENTRY_RESULT_FLAG_LRN_EVT |
231  L2FIB_ENTRY_RESULT_FLAG_LRN_MOV));
232  else
234  (L2FIB_ENTRY_RESULT_FLAG_LRN_EVT |
235  L2FIB_ENTRY_RESULT_FLAG_LRN_MOV));
236  counter_base[L2LEARN_ERROR_MAC_MOVE] += 1;
237  }
238 
239  /* Update the entry */
240  result0->fields.timestamp = timestamp;
241  result0->fields.sn = vnet_buffer (b0)->l2.l2fib_sn;
242 
243  BVT (clib_bihash_kv) kv;
244  kv.key = key0->raw;
245  kv.value = result0->raw;
246  BV (clib_bihash_add_del) (msm->mac_table, &kv, 1 /* is_add */ );
247 
248  /* Invalidate the cache */
249  cached_key->raw = ~0;
250 }
251 
252 
255  vlib_frame_t * frame, int do_trace)
256 {
257  u32 n_left, *from;
260  u32 node_counter_base_index = n->error_heap_index;
262  l2fib_entry_key_t cached_key;
263  l2fib_entry_result_t cached_result;
264  u8 timestamp = (u8) (vlib_time_now (vm) / 60);
265  u32 count = 0;
268 
270  n_left = frame->n_vectors; /* number of packets to process */
272  next = nexts;
273  b = bufs;
274 
275  /* Clear the one-entry cache in case mac table was updated */
276  cached_key.raw = ~0;
277  cached_result.raw = ~0; /* warning be gone */
278 
279  while (n_left > 8)
280  {
281  u32 sw_if_index0, sw_if_index1, sw_if_index2, sw_if_index3;
282  const ethernet_header_t *h0, *h1, *h2, *h3;
283  l2fib_entry_key_t key0, key1, key2, key3;
284  l2fib_entry_result_t result0, result1, result2, result3;
285 
286  /* Prefetch next iteration. */
287  {
288  /* buffer header is read and written, so use LOAD
289  * prefetch */
290  vlib_prefetch_buffer_header (b[4], LOAD);
291  vlib_prefetch_buffer_header (b[5], LOAD);
292  vlib_prefetch_buffer_header (b[6], LOAD);
293  vlib_prefetch_buffer_header (b[7], LOAD);
294 
299  }
300 
301  /* RX interface handles */
302  sw_if_index0 = vnet_buffer (b[0])->sw_if_index[VLIB_RX];
303  sw_if_index1 = vnet_buffer (b[1])->sw_if_index[VLIB_RX];
304  sw_if_index2 = vnet_buffer (b[2])->sw_if_index[VLIB_RX];
305  sw_if_index3 = vnet_buffer (b[3])->sw_if_index[VLIB_RX];
306 
307  /* Process 4 x pkts */
308 
309  h0 = vlib_buffer_get_current (b[0]);
310  h1 = vlib_buffer_get_current (b[1]);
311  h2 = vlib_buffer_get_current (b[2]);
312  h3 = vlib_buffer_get_current (b[3]);
313 
314  if (do_trace)
315  {
316  if (b[0]->flags & VLIB_BUFFER_IS_TRACED)
317  {
318  l2learn_trace_t *t =
319  vlib_add_trace (vm, node, b[0], sizeof (*t));
320  t->sw_if_index = sw_if_index0;
321  t->bd_index = vnet_buffer (b[0])->l2.bd_index;
322  clib_memcpy_fast (t->src, h0->src_address, 6);
323  clib_memcpy_fast (t->dst, h0->dst_address, 6);
324  }
325  if (b[1]->flags & VLIB_BUFFER_IS_TRACED)
326  {
327  l2learn_trace_t *t =
328  vlib_add_trace (vm, node, b[1], sizeof (*t));
329  t->sw_if_index = sw_if_index1;
330  t->bd_index = vnet_buffer (b[1])->l2.bd_index;
331  clib_memcpy_fast (t->src, h1->src_address, 6);
332  clib_memcpy_fast (t->dst, h1->dst_address, 6);
333  }
334  if (b[2]->flags & VLIB_BUFFER_IS_TRACED)
335  {
336  l2learn_trace_t *t =
337  vlib_add_trace (vm, node, b[2], sizeof (*t));
338  t->sw_if_index = sw_if_index2;
339  t->bd_index = vnet_buffer (b[2])->l2.bd_index;
340  clib_memcpy_fast (t->src, h2->src_address, 6);
341  clib_memcpy_fast (t->dst, h2->dst_address, 6);
342  }
343  if (b[3]->flags & VLIB_BUFFER_IS_TRACED)
344  {
345  l2learn_trace_t *t =
346  vlib_add_trace (vm, node, b[3], sizeof (*t));
347  t->sw_if_index = sw_if_index3;
348  t->bd_index = vnet_buffer (b[3])->l2.bd_index;
349  clib_memcpy_fast (t->src, h3->src_address, 6);
350  clib_memcpy_fast (t->dst, h3->dst_address, 6);
351  }
352  }
353 
354  /* process 4 pkts */
356  L2LEARN_ERROR_L2LEARN, 4);
357 
358  l2fib_lookup_4 (msm->mac_table, &cached_key, &cached_result,
359  h0->src_address,
360  h1->src_address,
361  h2->src_address,
362  h3->src_address,
363  vnet_buffer (b[0])->l2.bd_index,
364  vnet_buffer (b[1])->l2.bd_index,
365  vnet_buffer (b[2])->l2.bd_index,
366  vnet_buffer (b[3])->l2.bd_index,
367  &key0, &key1, &key2, &key3,
368  &result0, &result1, &result2, &result3);
369 
370  l2learn_process (node, msm, &em->counters[node_counter_base_index],
371  b[0], sw_if_index0, &key0, &cached_key,
372  &count, &result0, next, timestamp);
373 
374  l2learn_process (node, msm, &em->counters[node_counter_base_index],
375  b[1], sw_if_index1, &key1, &cached_key,
376  &count, &result1, next + 1, timestamp);
377 
378  l2learn_process (node, msm, &em->counters[node_counter_base_index],
379  b[2], sw_if_index2, &key2, &cached_key,
380  &count, &result2, next + 2, timestamp);
381 
382  l2learn_process (node, msm, &em->counters[node_counter_base_index],
383  b[3], sw_if_index3, &key3, &cached_key,
384  &count, &result3, next + 3, timestamp);
385 
386  next += 4;
387  b += 4;
388  n_left -= 4;
389  }
390 
391  while (n_left > 0)
392  {
393  u32 sw_if_index0;
394  ethernet_header_t *h0;
395  l2fib_entry_key_t key0;
396  l2fib_entry_result_t result0;
397 
398  sw_if_index0 = vnet_buffer (b[0])->sw_if_index[VLIB_RX];
399 
400  h0 = vlib_buffer_get_current (b[0]);
401 
402  if (do_trace && PREDICT_FALSE (b[0]->flags & VLIB_BUFFER_IS_TRACED))
403  {
404  l2learn_trace_t *t = vlib_add_trace (vm, node, b[0], sizeof (*t));
405  t->sw_if_index = sw_if_index0;
406  t->bd_index = vnet_buffer (b[0])->l2.bd_index;
407  clib_memcpy_fast (t->src, h0->src_address, 6);
408  clib_memcpy_fast (t->dst, h0->dst_address, 6);
409  }
410 
411  /* process 1 pkt */
413  L2LEARN_ERROR_L2LEARN, 1);
414 
415 
416  l2fib_lookup_1 (msm->mac_table, &cached_key, &cached_result,
417  h0->src_address, vnet_buffer (b[0])->l2.bd_index,
418  &key0, &result0);
419 
420  l2learn_process (node, msm, &em->counters[node_counter_base_index],
421  b[0], sw_if_index0, &key0, &cached_key,
422  &count, &result0, next, timestamp);
423 
424  next += 1;
425  b += 1;
426  n_left -= 1;
427  }
428 
430 
431  return frame->n_vectors;
432 }
433 
436 {
437  if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)))
438  return l2learn_node_inline (vm, node, frame, 1 /* do_trace */ );
439  return l2learn_node_inline (vm, node, frame, 0 /* do_trace */ );
440 }
441 
442 /* *INDENT-OFF* */
444  .name = "l2-learn",
445  .vector_size = sizeof (u32),
446  .format_trace = format_l2learn_trace,
448 
449  .n_errors = ARRAY_LEN(l2learn_error_strings),
450  .error_strings = l2learn_error_strings,
451 
452  .n_next_nodes = L2LEARN_N_NEXT,
453 
454  /* edit / add dispositions here */
455  .next_nodes = {
456  [L2LEARN_NEXT_DROP] = "error-drop",
457  [L2LEARN_NEXT_L2FWD] = "l2-fwd",
458  },
459 };
460 /* *INDENT-ON* */
461 
462 #ifndef CLIB_MARCH_VARIANT
463 clib_error_t *
465 {
467 
468  mp->vlib_main = vm;
469  mp->vnet_main = vnet_get_main ();
470 
471  /* Initialize the feature next-node indexes */
473  l2learn_node.index,
477 
478  /* init the hash table ptr */
479  mp->mac_table = get_mac_table ();
480 
481  /*
482  * Set the default number of dynamically learned macs to the number
483  * of buckets.
484  */
486 
487  /*
488  * Set the default number of dynamically learned macs to the number
489  * of buckets.
490  */
492  return 0;
493 }
494 
496 
497 
498 /**
499  * Set subinterface learn enable/disable.
500  * The CLI format is:
501  * set interface l2 learn <interface> [disable]
502  */
503 static clib_error_t *
505  unformat_input_t * input, vlib_cli_command_t * cmd)
506 {
507  vnet_main_t *vnm = vnet_get_main ();
508  clib_error_t *error = 0;
510  u32 enable;
511 
513  {
514  error = clib_error_return (0, "unknown interface `%U'",
515  format_unformat_error, input);
516  goto done;
517  }
518 
519  enable = 1;
520  if (unformat (input, "disable"))
521  {
522  enable = 0;
523  }
524 
525  /* set the interface flag */
526  l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_LEARN, enable);
527 
528 done:
529  return error;
530 }
531 
532 /*?
533  * Layer 2 learning can be enabled and disabled on each
534  * interface and on each bridge-domain. Use this command to
535  * manage interfaces. It is enabled by default.
536  *
537  * @cliexpar
538  * Example of how to enable learning:
539  * @cliexcmd{set interface l2 learn GigabitEthernet0/8/0}
540  * Example of how to disable learning:
541  * @cliexcmd{set interface l2 learn GigabitEthernet0/8/0 disable}
542 ?*/
543 /* *INDENT-OFF* */
545  .path = "set interface l2 learn",
546  .short_help = "set interface l2 learn <interface> [disable]",
547  .function = int_learn,
548 };
549 /* *INDENT-ON* */
550 
551 
552 static clib_error_t *
554 {
556 
558  {
559  if (unformat (input, "limit %d", &mp->global_learn_limit))
560  ;
561 
562  else
563  return clib_error_return (0, "unknown input `%U'",
564  format_unformat_error, input);
565  }
566 
567  return 0;
568 }
569 
571 
572 #endif
573 
574 
575 /*
576  * fd.io coding-style-patch-verification: ON
577  *
578  * Local Variables:
579  * eval: (c-set-style "gnu")
580  * End:
581  */
vlib.h
vlib_error_main_t
Definition: error.h:61
l2learn_node
vlib_node_registration_t l2learn_node
(constructor) VLIB_REGISTER_NODE (l2learn_node)
Definition: l2_learn.c:443
l2_bridge_domain_t
Definition: l2_bd.h:63
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
L2LEARN_NEXT_L2FWD
@ L2LEARN_NEXT_L2FWD
Definition: l2_learn.c:103
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
l2input_main
l2input_main_t l2input_main
Definition: l2_input_node.c:78
foreach_l2learn_error
#define foreach_l2learn_error
Definition: l2_learn.c:78
int_learn_cli
static vlib_cli_command_t int_learn_cli
(constructor) VLIB_CLI_COMMAND (int_learn_cli)
Definition: l2_learn.c:544
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)
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
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
u8
#define u8
Padding.
Definition: clib.h:121
vlib_cli_command_t::path
char * path
Definition: cli.h:96
format_l2learn_trace
static u8 * format_l2learn_trace(u8 *s, va_list *args)
Definition: l2_learn.c:63
vlib_main_t::error_main
vlib_error_main_t error_main
Definition: main.h:177
u16
unsigned short u16
Definition: types.h:57
l2learn_main_t::global_learn_count
u32 global_learn_count
Definition: l2_learn.h:33
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
VLIB_RX
@ VLIB_RX
Definition: defs.h:46
l2_learn.h
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
l2learn_trace_t::sw_if_index
u32 sw_if_index
Definition: l2_learn.c:56
l2fib_entry_result_clear_bits
static void l2fib_entry_result_clear_bits(l2fib_entry_result_t *r, l2fib_entry_result_flags_t bits)
Definition: l2_fib.h:207
l2learn_config
static clib_error_t * l2learn_config(vlib_main_t *vm, unformat_input_t *input)
Definition: l2_learn.c:553
ethernet.h
error
Definition: cJSON.c:88
L2LEARN_N_NEXT
@ L2LEARN_N_NEXT
Definition: l2_learn.c:105
l2fib_entry_result_t_::fields
struct l2fib_entry_result_t_::@463::@465 fields
l2_fib.h
key
typedef key
Definition: ipsec_types.api:88
int_learn
static clib_error_t * int_learn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Set subinterface learn enable/disable.
Definition: l2_learn.c:504
l2learn_main_t::bd_default_learn_limit
u32 bd_default_learn_limit
Definition: l2_learn.h:39
VLIB_CONFIG_FUNCTION
#define VLIB_CONFIG_FUNCTION(x, n,...)
Definition: init.h:181
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
l2_bridge_domain_t::learn_count
u32 learn_count
Definition: l2_bd.h:117
CLIB_PREFETCH
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:80
count
u8 count
Definition: dhcp.api:208
l2learn_main_t
Definition: l2_learn.h:26
vlib_buffer_t::error
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:145
l2learn_trace_t
Definition: l2_learn.c:52
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
l2learn_trace_t::src
u8 src[6]
Definition: l2_learn.c:54
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
vnet_buffer
#define vnet_buffer(b)
Definition: buffer.h:437
vec_elt_at_index
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Definition: vec_bootstrap.h:203
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
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
vlib_config_function_runtime_t
Definition: init.h:68
static_always_inline
#define static_always_inline
Definition: clib.h:112
uword
u64 uword
Definition: types.h:112
l2learn_trace_t::bd_index
u16 bd_index
Definition: l2_learn.c:57
ethernet_header_t
Definition: packet.h:52
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
l2learn_main_t::vnet_main
vnet_main_t * vnet_main
Definition: l2_learn.h:50
BVT
BVT(clib_bihash)
The table of adjacencies indexed by the rewrite string.
Definition: l2_fib.c:1069
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
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
L2LEARN_N_ERROR
@ L2LEARN_N_ERROR
Definition: l2_learn.c:92
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
l2learn_error_t
l2learn_error_t
Definition: l2_learn.c:87
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
src
vl_api_address_t src
Definition: gre.api:54
L2INPUT_N_FEAT
@ L2INPUT_N_FEAT
Definition: l2_input.h:163
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
l2learn_main_t::global_learn_limit
u32 global_learn_limit
Definition: l2_learn.h:36
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
l2_input.h
L2LEARN_NEXT_DROP
@ L2LEARN_NEXT_DROP
Definition: l2_learn.c:104
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
l2learn_main
l2learn_main_t l2learn_main
Definition: l2_learn.c:32
vnet_main_t
Definition: vnet.h:76
l2_bridge_domain_t::learn_limit
u32 learn_limit
Definition: l2_bd.h:114
L2LEARN_DEFAULT_LIMIT
#define L2LEARN_DEFAULT_LIMIT
Definition: l2_learn.h:53
l2learn_main_t::feat_next_node_index
u32 feat_next_node_index[32]
Definition: l2_learn.h:46
u64
unsigned long u64
Definition: types.h:89
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
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
dst
vl_api_ip4_address_t dst
Definition: pnat.api:41
cli.h
n_left
u32 n_left
Definition: interface_output.c:1078
clib_bihash_add_del
int clib_bihash_add_del(clib_bihash *h, clib_bihash_kv *add_v, int is_add)
Add or delete a (key,value) pair from a bi-hash table.
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
l2learn_node_inline
static_always_inline uword l2learn_node_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int do_trace)
Definition: l2_learn.c:254
vlib_node_t::error_heap_index
u32 error_heap_index
Definition: node.h:315
l2learn_trace_t::dst
u8 dst[6]
Definition: l2_learn.c:55
l2learn_process
static_always_inline void l2learn_process(vlib_node_runtime_t *node, l2learn_main_t *msm, u64 *counter_base, vlib_buffer_t *b0, u32 sw_if_index0, l2fib_entry_key_t *key0, l2fib_entry_key_t *cached_key, u32 *count, l2fib_entry_result_t *result0, u16 *next0, u8 timestamp)
Perform learning on one packet based on the mac table lookup result.
Definition: l2_learn.c:112
nexts
u16 nexts[VLIB_FRAME_SIZE]
Definition: nat44_ei_out2in.c:718
l2learn_init
clib_error_t * l2learn_init(vlib_main_t *vm)
Definition: l2_learn.c:464
l2learn_error_strings
static char * l2learn_error_strings[]
Definition: l2_learn.c:95
l2fib_entry_key_t
Definition: l2_fib.h:77
vlib_time_now
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:325
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
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
l2fib_entry_result_set_bits
static foreach_l2fib_entry_result_attr void l2fib_entry_result_set_bits(l2fib_entry_result_t *r, l2fib_entry_result_flags_t bits)
Definition: l2_fib.h:200
l2learn_next_t
l2learn_next_t
Definition: l2_learn.c:101
timestamp
f64 timestamp
Definition: vpe_types.api:28
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
l2input_main_t::bd_configs
l2_bridge_domain_t * bd_configs
Definition: l2_input.h:93
l2learn_main_t::client_pid
u32 client_pid
Definition: l2_learn.h:42
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
l2learn_main_t::vlib_main
vlib_main_t * vlib_main
Definition: l2_learn.h:49
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105