FD.io VPP  v19.01.1-17-ge106252
Vector Packet Processing
gbp_learn.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 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 <plugins/gbp/gbp.h>
17 #include <plugins/gbp/gbp_learn.h>
19 #include <vlibmemory/api.h>
20 
21 #include <vnet/util/throttle.h>
22 #include <vnet/l2/l2_input.h>
23 #include <vnet/fib/fib_table.h>
25 
26 /**
27  * Grouping of global data for the GBP source EPG classification feature
28  */
29 typedef struct gbp_learn_main_t_
30 {
31  /**
32  * Next nodes for L2 output features
33  */
35 
36  /**
37  * logger - VLIB log class
38  */
40 
41  /**
42  * throttles for the DP leanring
43  */
47 
48 /**
49  * The maximum learning rate per-hashed EP
50  */
51 #define GBP_ENDPOINT_HASH_LEARN_RATE (1e-2)
52 
54 
55 #define GBP_LEARN_DBG(...) \
56  vlib_log_debug (gbp_learn_main.gl_logger, __VA_ARGS__);
57 
58 #define foreach_gbp_learn \
59  _(DROP, "drop")
60 
61 typedef enum
62 {
63 #define _(sym,str) GBP_LEARN_ERROR_##sym,
65 #undef _
68 
69 static char *gbp_learn_error_strings[] = {
70 #define _(sym,string) string,
72 #undef _
73 };
74 
75 typedef enum
76 {
77 #define _(sym,str) GBP_LEARN_NEXT_##sym,
79 #undef _
82 
83 typedef struct gbp_learn_l2_t_
84 {
85  ip46_address_t ip;
90  ip46_address_t outer_src;
91  ip46_address_t outer_dst;
93 
94 
95 static void
97 {
98  ip46_address_t *ips = NULL;
99 
100  GBP_LEARN_DBG ("L2 EP: %U %U, %d",
101  format_mac_address_t, &gl2->mac,
102  format_ip46_address, &gl2->ip, IP46_TYPE_ANY, gl2->epg);
103 
104  vec_add1 (ips, gl2->ip);
105 
108 
109  /*
110  * flip the source and dst, since that's how it was received, this API
111  * takes how it's sent
112  */
113  gbp_endpoint_update_and_lock (GBP_ENDPOINT_SRC_DP,
114  gl2->sw_if_index, ips,
115  &gl2->mac, INDEX_INVALID,
116  INDEX_INVALID, gl2->epg,
119  &gl2->outer_dst, &gl2->outer_src, NULL);
120  vec_free (ips);
121 }
122 
123 static void
125  u32 bd_index, u32 sw_if_index, epg_id_t epg,
126  const ip4_address_t * outer_src,
127  const ip4_address_t * outer_dst)
128 {
129  gbp_learn_l2_t gl2 = {
131  .bd_index = bd_index,
132  .epg = epg,
133  .ip.ip4 = *ip,
134  .outer_src.ip4 = *outer_src,
135  .outer_dst.ip4 = *outer_dst,
136  };
137  mac_address_from_bytes (&gl2.mac, mac);
138 
141 
142  vl_api_rpc_call_main_thread (gbp_learn_l2_cp, (u8 *) & gl2, sizeof (gl2));
143 }
144 
145 static void
147  u32 bd_index, u32 sw_if_index, epg_id_t epg,
148  const ip4_address_t * outer_src,
149  const ip4_address_t * outer_dst)
150 {
151  gbp_learn_l2_t gl2 = {
153  .bd_index = bd_index,
154  .epg = epg,
155  .ip.ip6 = *ip,
156  .outer_src.ip4 = *outer_src,
157  .outer_dst.ip4 = *outer_dst,
158  };
159  mac_address_from_bytes (&gl2.mac, mac);
160 
161  vl_api_rpc_call_main_thread (gbp_learn_l2_cp, (u8 *) & gl2, sizeof (gl2));
162 }
163 
164 static void
165 gbp_learn_l2_dp (const u8 * mac, u32 bd_index, u32 sw_if_index,
166  epg_id_t epg,
167  const ip4_address_t * outer_src,
168  const ip4_address_t * outer_dst)
169 {
170  gbp_learn_l2_t gl2 = {
172  .bd_index = bd_index,
173  .epg = epg,
174  .outer_src.ip4 = *outer_src,
175  .outer_dst.ip4 = *outer_dst,
176  };
177  mac_address_from_bytes (&gl2.mac, mac);
178 
179  vl_api_rpc_call_main_thread (gbp_learn_l2_cp, (u8 *) & gl2, sizeof (gl2));
180 }
181 
182 /**
183  * per-packet trace data
184  */
185 typedef struct gbp_learn_l2_trace_t_
186 {
187  /* per-pkt trace data */
190  u32 new;
195 
196 always_inline void
198  ip4_address_t * outer_src, ip4_address_t * outer_dst)
199 {
200  ip4_header_t *ip0;
201  u8 *buff;
202 
203  /* rewind back to the ivxlan header */
204  buff = (u8 *) eh0;
205  buff -= (sizeof (vxlan_gbp_header_t) +
206  sizeof (udp_header_t) + sizeof (ip4_header_t));
207 
208  ip0 = (ip4_header_t *) buff;
209 
210  *outer_src = ip0->src_address;
211  *outer_dst = ip0->dst_address;
212 }
213 
214 static uword
216  vlib_node_runtime_t * node, vlib_frame_t * frame)
217 {
218  u32 n_left_from, *from, *to_next, next_index, thread_index, seed;
219  gbp_learn_main_t *glm;
220  f64 time_now;
221 
222  glm = &gbp_learn_main;
223  next_index = 0;
224  n_left_from = frame->n_vectors;
225  from = vlib_frame_vector_args (frame);
226  time_now = vlib_time_now (vm);
227  thread_index = vm->thread_index;
228 
229  seed = throttle_seed (&glm->gl_l2_throttle, thread_index, time_now);
230 
231  while (n_left_from > 0)
232  {
233  u32 n_left_to_next;
234 
235  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
236 
237  while (n_left_from > 0 && n_left_to_next > 0)
238  {
239  ip4_address_t outer_src, outer_dst;
240  u32 bi0, sw_if_index0, t0, epg0;
241  const ethernet_header_t *eh0;
242  gbp_bridge_domain_t *gb0;
243  gbp_learn_next_t next0;
244  gbp_endpoint_t *ge0;
245  vlib_buffer_t *b0;
246 
247  next0 = GBP_LEARN_NEXT_DROP;
248  bi0 = from[0];
249  to_next[0] = bi0;
250  from += 1;
251  to_next += 1;
252  n_left_from -= 1;
253  n_left_to_next -= 1;
254 
255  b0 = vlib_get_buffer (vm, bi0);
256  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
257 
258  eh0 = vlib_buffer_get_current (b0);
259  epg0 = vnet_buffer2 (b0)->gbp.src_epg;
260 
262  L2INPUT_FEAT_GBP_LEARN);
263 
265  vnet_buffer (b0)->l2.bd_index);
266  gb0 =
268 
269  if ((vnet_buffer2 (b0)->gbp.flags & VXLAN_GBP_GPFLAGS_D) ||
271  {
272  t0 = 1;
273  goto trace;
274  }
275 
276  /*
277  * check for new EP or a moved EP
278  */
279  if (NULL == ge0 || ge0->ge_fwd.gef_itf != sw_if_index0)
280 
281  {
282  /*
283  * use the last 4 bytes of the mac address as the hash for the EP
284  */
285  t0 = throttle_check (&glm->gl_l2_throttle, thread_index,
286  *((u32 *) (eh0->src_address + 2)), seed);
287  if (!t0)
288  {
289  gbp_learn_get_outer (eh0, &outer_src, &outer_dst);
290 
291  switch (clib_net_to_host_u16 (eh0->type))
292  {
293  case ETHERNET_TYPE_IP4:
294  {
295  const ip4_header_t *ip0;
296 
297  ip0 = (ip4_header_t *) (eh0 + 1);
298 
300  &ip0->src_address,
301  vnet_buffer (b0)->l2.bd_index,
302  sw_if_index0, epg0,
303  &outer_src, &outer_dst);
304 
305  break;
306  }
307  case ETHERNET_TYPE_IP6:
308  {
309  const ip6_header_t *ip0;
310 
311  ip0 = (ip6_header_t *) (eh0 + 1);
312 
314  &ip0->src_address,
315  vnet_buffer (b0)->l2.bd_index,
316  sw_if_index0, epg0,
317  &outer_src, &outer_dst);
318 
319  break;
320  }
321  default:
323  vnet_buffer (b0)->l2.bd_index,
324  sw_if_index0, epg0,
325  &outer_src, &outer_dst);
326  break;
327  }
328  }
329  }
330  else
331  {
332  /*
333  * this update could happen simultaneoulsy from multiple workers
334  * but that's ok we are not interested in being very accurate.
335  */
336  t0 = 0;
337  ge0->ge_last_time = time_now;
338  }
339  trace:
340  if (PREDICT_FALSE ((b0->flags & VLIB_BUFFER_IS_TRACED)))
341  {
343  vlib_add_trace (vm, node, b0, sizeof (*t));
344  clib_memcpy_fast (t->mac.bytes, eh0->src_address, 6);
345  t->new = (NULL == ge0);
346  t->throttled = t0;
347  t->sw_if_index = sw_if_index0;
348  t->epg = epg0;
349  t->d_bit = ! !(vnet_buffer2 (b0)->gbp.flags &
350  VXLAN_GBP_GPFLAGS_D);
351  }
352 
353  /* verify speculative enqueue, maybe switch current next frame */
354  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
355  to_next, n_left_to_next,
356  bi0, next0);
357  }
358 
359  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
360  }
361 
362  return frame->n_vectors;
363 }
364 
365 /* packet trace format function */
366 static u8 *
367 format_gbp_learn_l2_trace (u8 * s, va_list * args)
368 {
369  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
370  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
371  gbp_learn_l2_trace_t *t = va_arg (*args, gbp_learn_l2_trace_t *);
372 
373  s = format (s, "new:%d throttled:%d d-bit:%d mac:%U itf:%d epg:%d",
374  t->new, t->throttled, t->d_bit,
375  format_mac_address_t, &t->mac, t->sw_if_index, t->epg);
376 
377  return s;
378 }
379 
380 /* *INDENT-OFF* */
382  .function = gbp_learn_l2,
383  .name = "gbp-learn-l2",
384  .vector_size = sizeof (u32),
385  .format_trace = format_gbp_learn_l2_trace,
386  .type = VLIB_NODE_TYPE_INTERNAL,
387 
388  .n_errors = ARRAY_LEN(gbp_learn_error_strings),
389  .error_strings = gbp_learn_error_strings,
390 
391  .n_next_nodes = GBP_LEARN_N_NEXT,
392 
393  .next_nodes = {
394  [GBP_LEARN_NEXT_DROP] = "error-drop",
395  },
396 };
397 
399 /* *INDENT-ON* */
400 
401 typedef struct gbp_learn_l3_t_
402 {
403  ip46_address_t ip;
407  ip46_address_t outer_src;
408  ip46_address_t outer_dst;
410 
411 static void
413 {
414  ip46_address_t *ips = NULL;
415 
416  GBP_LEARN_DBG ("L3 EP: %U, %d", format_ip46_address, &gl3->ip,
417  IP46_TYPE_ANY, gl3->epg);
418 
419  vec_add1 (ips, gl3->ip);
420 
421  gbp_endpoint_update_and_lock (GBP_ENDPOINT_SRC_DP,
422  gl3->sw_if_index, ips, NULL,
426  &gl3->outer_dst, &gl3->outer_src, NULL);
427  vec_free (ips);
428 }
429 
430 static void
432  u32 fib_index, u32 sw_if_index, epg_id_t epg,
433  const ip4_address_t * outer_src,
434  const ip4_address_t * outer_dst)
435 {
436  /* *INDENT-OFF* */
437  gbp_learn_l3_t gl3 = {
438  .ip = {
439  .ip4 = *ip,
440  },
441  .sw_if_index = sw_if_index,
442  .fib_index = fib_index,
443  .epg = epg,
444  .outer_src.ip4 = *outer_src,
445  .outer_dst.ip4 = *outer_dst,
446  };
447  /* *INDENT-ON* */
448 
449  vl_api_rpc_call_main_thread (gbp_learn_l3_cp, (u8 *) & gl3, sizeof (gl3));
450 }
451 
452 static void
454  u32 fib_index, u32 sw_if_index, epg_id_t epg,
455  const ip4_address_t * outer_src,
456  const ip4_address_t * outer_dst)
457 {
458  /* *INDENT-OFF* */
459  gbp_learn_l3_t gl3 = {
460  .ip = {
461  .ip6 = *ip,
462  },
463  .sw_if_index = sw_if_index,
464  .fib_index = fib_index,
465  .epg = epg,
466  .outer_src.ip4 = *outer_src,
467  .outer_dst.ip4 = *outer_dst,
468  };
469  /* *INDENT-ON* */
470 
471  vl_api_rpc_call_main_thread (gbp_learn_l3_cp, (u8 *) & gl3, sizeof (gl3));
472 }
473 
474 /**
475  * per-packet trace data
476  */
477 typedef struct gbp_learn_l3_trace_t_
478 {
479  /* per-pkt trace data */
480  ip46_address_t ip;
482  u32 new;
486 
487 static uword
489  vlib_node_runtime_t * node, vlib_frame_t * frame,
490  fib_protocol_t fproto)
491 {
492  u32 n_left_from, *from, *to_next, next_index, thread_index, seed;
493  gbp_learn_main_t *glm;
494  f64 time_now;
495 
496  glm = &gbp_learn_main;
497  next_index = 0;
498  n_left_from = frame->n_vectors;
499  from = vlib_frame_vector_args (frame);
500  time_now = vlib_time_now (vm);
501  thread_index = vm->thread_index;
502 
503  seed = throttle_seed (&glm->gl_l3_throttle, thread_index, time_now);
504 
505  while (n_left_from > 0)
506  {
507  u32 n_left_to_next;
508 
509  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
510 
511  while (n_left_from > 0 && n_left_to_next > 0)
512  {
513  u32 bi0, sw_if_index0, t0, epg0, fib_index0;
514  CLIB_UNUSED (const ip4_header_t *) ip4_0;
515  CLIB_UNUSED (const ip6_header_t *) ip6_0;
516  ip4_address_t outer_src, outer_dst;
517  ethernet_header_t *eth0;
518  gbp_learn_next_t next0;
519  gbp_endpoint_t *ge0;
520  vlib_buffer_t *b0;
521 
522  next0 = GBP_LEARN_NEXT_DROP;
523  bi0 = from[0];
524  to_next[0] = bi0;
525  from += 1;
526  to_next += 1;
527  n_left_from -= 1;
528  n_left_to_next -= 1;
529 
530  b0 = vlib_get_buffer (vm, bi0);
531  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
532  epg0 = vnet_buffer2 (b0)->gbp.src_epg;
533  ip6_0 = NULL;
534  ip4_0 = NULL;
535 
536  vnet_feature_next (&next0, b0);
537 
538  if (vnet_buffer2 (b0)->gbp.flags & VXLAN_GBP_GPFLAGS_D)
539  {
540  t0 = 1;
541  ge0 = NULL;
542  goto trace;
543  }
544 
545  fib_index0 = fib_table_get_index_for_sw_if_index (fproto,
546  sw_if_index0);
547 
548  if (FIB_PROTOCOL_IP6 == fproto)
549  {
550  ip6_0 = vlib_buffer_get_current (b0);
551  eth0 = (ethernet_header_t *) (((u8 *) ip6_0) - sizeof (*eth0));
552 
553  gbp_learn_get_outer (eth0, &outer_src, &outer_dst);
554 
555  ge0 = gbp_endpoint_find_ip6 (&ip6_0->src_address, fib_index0);
556 
557  if (NULL == ge0)
558  {
559  t0 = throttle_check (&glm->gl_l3_throttle,
560  thread_index,
562  (&ip6_0->src_address), seed);
563 
564  if (!t0)
565  {
566  gbp_learn_ip6_dp (&ip6_0->src_address,
567  fib_index0, sw_if_index0, epg0,
568  &outer_src, &outer_dst);
569  }
570  }
571  else
572  {
573  /*
574  * this update could happen simultaneoulsy from multiple
575  * workers but that's ok we are not interested in being
576  * very accurate.
577  */
578  t0 = 0;
579  ge0->ge_last_time = time_now;
580  }
581  }
582  else
583  {
584  ip4_0 = vlib_buffer_get_current (b0);
585  eth0 = (ethernet_header_t *) (((u8 *) ip4_0) - sizeof (*eth0));
586 
587  gbp_learn_get_outer (eth0, &outer_src, &outer_dst);
588  ge0 = gbp_endpoint_find_ip4 (&ip4_0->src_address, fib_index0);
589 
590  if (NULL == ge0)
591  {
592  t0 = throttle_check (&glm->gl_l3_throttle, thread_index,
593  ip4_0->src_address.as_u32, seed);
594 
595  if (!t0)
596  {
597  gbp_learn_ip4_dp (&ip4_0->src_address,
598  fib_index0, sw_if_index0, epg0,
599  &outer_src, &outer_dst);
600  }
601  }
602  else
603  {
604  /*
605  * this update could happen simultaneoulsy from multiple
606  * workers but that's ok we are not interested in being
607  * very accurate.
608  */
609  t0 = 0;
610  ge0->ge_last_time = time_now;
611  }
612  }
613  trace:
614  if (PREDICT_FALSE ((b0->flags & VLIB_BUFFER_IS_TRACED)))
615  {
617 
618  t = vlib_add_trace (vm, node, b0, sizeof (*t));
619  if (FIB_PROTOCOL_IP6 == fproto && ip6_0)
620  ip46_address_set_ip6 (&t->ip, &ip6_0->src_address);
621  if (FIB_PROTOCOL_IP4 == fproto && ip4_0)
622  ip46_address_set_ip4 (&t->ip, &ip4_0->src_address);
623  t->new = (NULL == ge0);
624  t->throttled = t0;
625  t->sw_if_index = sw_if_index0;
626  t->epg = epg0;
627  }
628 
629  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
630  to_next, n_left_to_next,
631  bi0, next0);
632  }
633 
634  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
635  }
636 
637  return frame->n_vectors;
638 }
639 
640 /* packet trace format function */
641 static u8 *
642 format_gbp_learn_l3_trace (u8 * s, va_list * args)
643 {
644  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
645  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
646  gbp_learn_l3_trace_t *t = va_arg (*args, gbp_learn_l3_trace_t *);
647 
648  s = format (s, "new:%d throttled:%d ip:%U itf:%d epg:%d",
649  t->new, t->throttled,
651  t->epg);
652 
653  return s;
654 }
655 
656 static uword
658  vlib_node_runtime_t * node, vlib_frame_t * frame)
659 {
660  return (gbp_learn_l3 (vm, node, frame, FIB_PROTOCOL_IP4));
661 }
662 
663 static uword
665  vlib_node_runtime_t * node, vlib_frame_t * frame)
666 {
667  return (gbp_learn_l3 (vm, node, frame, FIB_PROTOCOL_IP6));
668 }
669 
670 /* *INDENT-OFF* */
672  .function = gbp_learn_ip4,
673  .name = "gbp-learn-ip4",
674  .vector_size = sizeof (u32),
675  .format_trace = format_gbp_learn_l3_trace,
676  .type = VLIB_NODE_TYPE_INTERNAL,
677 };
678 
680 
682 {
683  .arc_name = "ip4-unicast",
684  .node_name = "gbp-learn-ip4",
685 };
686 
688  .function = gbp_learn_ip6,
689  .name = "gbp-learn-ip6",
690  .vector_size = sizeof (u32),
691  .format_trace = format_gbp_learn_l3_trace,
692  .type = VLIB_NODE_TYPE_INTERNAL,
693 };
694 
696 
698 {
699  .arc_name = "ip6-unicast",
700  .node_name = "gbp-learn-ip6",
701 };
702 
703 /* *INDENT-ON* */
704 
705 void
707 {
708  if (GBP_LEARN_MODE_L2 == mode)
709  l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_GBP_LEARN, 1);
710  else
711  {
712  vnet_feature_enable_disable ("ip4-unicast",
713  "gbp-learn-ip4", sw_if_index, 1, 0, 0);
714  vnet_feature_enable_disable ("ip6-unicast",
715  "gbp-learn-ip6", sw_if_index, 1, 0, 0);
716  }
717 }
718 
719 void
721 {
722  if (GBP_LEARN_MODE_L2 == mode)
723  l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_GBP_LEARN, 0);
724  else
725  {
726  vnet_feature_enable_disable ("ip4-unicast",
727  "gbp-learn-ip4", sw_if_index, 0, 0, 0);
728  vnet_feature_enable_disable ("ip6-unicast",
729  "gbp-learn-ip6", sw_if_index, 0, 0, 0);
730  }
731 }
732 
733 static clib_error_t *
735 {
738 
739  /* Initialize the feature next-node indices */
741  gbp_learn_l2_node.index,
744  glm->gl_l2_input_feat_next);
745 
748 
751 
752  glm->gl_logger = vlib_log_register_class ("gbp", "learn");
753 
754  return 0;
755 }
756 
758 
759 /*
760  * fd.io coding-style-patch-verification: ON
761  *
762  * Local Variables:
763  * eval: (c-set-style "gnu")
764  * End:
765  */
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
Definition: log.c:227
struct gbp_learn_l3_trace_t_ gbp_learn_l3_trace_t
per-packet trace data
static void gbp_learn_l2_cp(const gbp_learn_l2_t *gl2)
Definition: gbp_learn.c:96
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
Definition: vlib_api_cli.c:862
u32 vlib_log_class_t
Definition: log.h:21
static gbp_bridge_domain_t * gbp_bridge_domain_get_by_bd_index(u32 bd_index)
u16 epg_id_t
Definition: gbp_types.h:21
f64 ge_last_time
The last time a packet from seen from this end point.
Definition: gbp_endpoint.h:205
A Group Based Policy Endpoint.
Definition: gbp_endpoint.h:182
#define CLIB_UNUSED(x)
Definition: clib.h:82
VNET_FEATURE_INIT(gbp_learn_ip4, static)
gbp_endpoint_fwd_t ge_fwd
Definition: gbp_endpoint.h:200
ip4_address_t src_address
Definition: ip4_packet.h:170
static uword gbp_learn_ip4(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: gbp_learn.c:657
#define vnet_buffer2(b)
Definition: buffer.h:413
mac_address_t mac
Definition: gbp_learn.c:86
struct gbp_learn_main_t_ gbp_learn_main_t
Grouping of global data for the GBP source EPG classification feature.
static u8 * format_gbp_learn_l2_trace(u8 *s, va_list *args)
Definition: gbp_learn.c:367
#define clib_memcpy_fast(a, b, c)
Definition: string.h:81
#define NULL
Definition: clib.h:58
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:232
index_t gef_itf
The interface on which the EP is connected.
Definition: gbp_endpoint.h:159
u32 fib_table_get_index_for_sw_if_index(fib_protocol_t proto, u32 sw_if_index)
Get the index of the FIB bound to the interface.
Definition: fib_table.c:956
static uword gbp_learn_ip6(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: gbp_learn.c:664
u8 src_address[6]
Definition: packet.h:56
A bridge Domain Representation.
u32 thread_index
Definition: main.h:179
void throttle_init(throttle_t *t, u32 n_threads, f64 time)
Definition: throttle.c:19
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:525
format_function_t format_ip46_address
Definition: format.h:61
Grouping of global data for the GBP source EPG classification feature.
Definition: gbp_learn.c:29
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
gbp_learn_next_t
Definition: gbp_learn.c:75
ip46_address_t outer_dst
Definition: gbp_learn.c:408
per-packet trace data
Definition: gbp_learn.c:477
static void gbp_learn_ip6_dp(const ip6_address_t *ip, u32 fib_index, u32 sw_if_index, epg_id_t epg, const ip4_address_t *outer_src, const ip4_address_t *outer_dst)
Definition: gbp_learn.c:453
ip6_address_t src_address
Definition: ip6_packet.h:378
static u32 ip6_address_hash_to_u32(const ip6_address_t *a)
Definition: ip6_packet.h:351
vlib_node_registration_t gbp_learn_ip4_node
(constructor) VLIB_REGISTER_NODE (gbp_learn_ip4_node)
Definition: gbp_learn.c:671
unsigned char u8
Definition: types.h:56
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
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
double f64
Definition: types.h:142
static gbp_learn_main_t gbp_learn_main
Definition: gbp_learn.c:53
throttle_t gl_l3_throttle
Definition: gbp_learn.c:45
static_always_inline gbp_endpoint_t * gbp_endpoint_find_ip4(const ip4_address_t *ip, u32 fib_index)
Definition: gbp_endpoint.h:307
static uword gbp_learn_l3(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, fib_protocol_t fproto)
Definition: gbp_learn.c:488
vlib_log_class_t gl_logger
logger - VLIB log class
Definition: gbp_learn.c:39
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:163
u32 sw_if_index
Definition: vxlan_gbp.api:37
#define always_inline
Definition: clib.h:98
u32 gl_l2_input_feat_next[32]
Next nodes for L2 output features.
Definition: gbp_learn.c:34
ip4_address_t dst_address
Definition: ip4_packet.h:170
static void gbp_learn_l2_ip6_dp(const u8 *mac, const ip6_address_t *ip, u32 bd_index, u32 sw_if_index, epg_id_t epg, const ip4_address_t *outer_src, const ip4_address_t *outer_dst)
Definition: gbp_learn.c:146
mac_address_t mac
Definition: gbp_learn.c:188
epg_id_t epg
Definition: gbp_learn.c:406
static_always_inline gbp_endpoint_t * gbp_endpoint_find_mac(const u8 *mac, u32 bd_index)
Definition: gbp_endpoint.h:272
void vl_api_rpc_call_main_thread(void *fp, u8 *data, u32 data_length)
Definition: vlib_api.c:623
unsigned int u32
Definition: types.h:88
static void gbp_learn_l2_dp(const u8 *mac, u32 bd_index, u32 sw_if_index, epg_id_t epg, const ip4_address_t *outer_src, const ip4_address_t *outer_dst)
Definition: gbp_learn.c:165
gbp_learn_error_t
Definition: gbp_learn.c:61
ip46_address_t outer_src
Definition: gbp_learn.c:90
int gbp_endpoint_update_and_lock(gbp_endpoint_src_t src, u32 sw_if_index, const ip46_address_t *ips, const mac_address_t *mac, index_t gbdi, index_t grdi, epg_id_t epg_id, gbp_endpoint_flags_t flags, const ip46_address_t *tun_src, const ip46_address_t *tun_dst, u32 *handle)
Definition: gbp_endpoint.c:804
void gbp_learn_enable(u32 sw_if_index, gbb_learn_mode_t mode)
Definition: gbp_learn.c:706
static_always_inline void mac_address_from_bytes(mac_address_t *mac, const u8 *bytes)
Definition: mac_address.h:40
static u8 * format_gbp_learn_l3_trace(u8 *s, va_list *args)
Definition: gbp_learn.c:642
ip46_address_t outer_src
Definition: gbp_learn.c:407
static uword gbp_learn_l2(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: gbp_learn.c:215
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:214
vlib_node_registration_t gbp_learn_ip6_node
(constructor) VLIB_REGISTER_NODE (gbp_learn_ip6_node)
Definition: gbp_learn.c:687
static u64 throttle_seed(throttle_t *t, u32 thread_index, f64 time_now)
Definition: throttle.h:41
#define PREDICT_FALSE(x)
Definition: clib.h:111
#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:368
A throttle Used in the data plane to decide if a given hash should be throttled, i.e.
Definition: throttle.h:28
vlib_thread_main_t vlib_thread_main
Definition: threads.c:37
gbp_bridge_domain_flags_t gb_flags
Flags conttrolling behaviour.
ip46_address_t ip
Definition: gbp_learn.c:480
#define GBP_LEARN_DBG(...)
Definition: gbp_learn.c:55
static_always_inline gbp_endpoint_t * gbp_endpoint_find_ip6(const ip6_address_t *ip, u32 fib_index)
Definition: gbp_endpoint.h:332
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
vlib_node_registration_t gbp_learn_l2_node
(constructor) VLIB_REGISTER_NODE (gbp_learn_l2_node)
Definition: gbp_learn.c:381
enum gbp_learn_mode_t_ gbb_learn_mode_t
u16 n_vectors
Definition: node.h:420
vlib_main_t * vm
Definition: buffer.c:301
static void gbp_learn_ip4_dp(const ip4_address_t *ip, u32 fib_index, u32 sw_if_index, epg_id_t epg, const ip4_address_t *outer_src, const ip4_address_t *outer_dst)
Definition: gbp_learn.c:431
epg_id_t epg
Definition: gbp_learn.c:89
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:341
static_always_inline void vnet_feature_next(u32 *next0, vlib_buffer_t *b0)
Definition: feature.h:295
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
per-packet trace data
Definition: gbp_learn.c:185
static clib_error_t * gbp_learn_init(vlib_main_t *vm)
Definition: gbp_learn.c:734
struct gbp_learn_l2_t_ gbp_learn_l2_t
#define ARRAY_LEN(x)
Definition: clib.h:62
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
char ** l2input_get_feat_names(void)
Return an array of strings containing graph node names of each feature.
Definition: l2_input.c:60
#define ASSERT(truth)
#define ip46_address_set_ip4(ip46, ip)
Definition: ip6_packet.h:90
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:530
throttle_t gl_l2_throttle
throttles for the DP leanring
Definition: gbp_learn.c:44
static void gbp_learn_l3_cp(const gbp_learn_l3_t *gl3)
Definition: gbp_learn.c:412
static_always_inline void ip46_address_set_ip6(ip46_address_t *dst, const ip6_address_t *src)
Definition: ip6_packet.h:106
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:57
VLIB_NODE_FUNCTION_MULTIARCH(gbp_learn_l2_node, gbp_learn_l2)
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
Definition: dpo.h:47
ip46_address_t ip
Definition: gbp_learn.c:403
u64 uword
Definition: types.h:112
ip46_address_t ip
Definition: gbp_learn.c:85
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:274
void gbp_learn_disable(u32 sw_if_index, gbb_learn_mode_t mode)
Definition: gbp_learn.c:720
struct gbp_learn_l3_t_ gbp_learn_l3_t
#define vnet_buffer(b)
Definition: buffer.h:368
vl_api_gbp_vxlan_tunnel_mode_t mode
Definition: gbp.api:349
struct gbp_learn_l2_trace_t_ gbp_learn_l2_trace_t
per-packet trace data
u8 * format_mac_address_t(u8 *s, va_list *args)
Definition: mac_address.c:27
vl_api_address_t ips[n_ips]
Definition: gbp.api:121
static void gbp_learn_l2_ip4_dp(const u8 *mac, const ip4_address_t *ip, u32 bd_index, u32 sw_if_index, epg_id_t epg, const ip4_address_t *outer_src, const ip4_address_t *outer_dst)
Definition: gbp_learn.c:124
static void gbp_learn_get_outer(const ethernet_header_t *eh0, ip4_address_t *outer_src, ip4_address_t *outer_dst)
Definition: gbp_learn.c:197
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:117
#define GBP_ENDPOINT_HASH_LEARN_RATE
The maximum learning rate per-hashed EP.
Definition: gbp_learn.c:51
#define ip46_address_is_zero(ip46)
Definition: ip6_packet.h:93
static char * gbp_learn_error_strings[]
Definition: gbp_learn.c:69
vl_api_mac_address_t mac
Definition: gbp.api:118
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:62
Definition: defs.h:46
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
Definition: feature.c:274
#define foreach_gbp_learn
Definition: gbp_learn.c:58
static int throttle_check(throttle_t *t, u32 thread_index, u64 hash, u64 seed)
Definition: throttle.h:54
ip46_address_t outer_dst
Definition: gbp_learn.c:91