FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
gbp_learn_node.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>
26 
27 #define GBP_LEARN_DBG(...) \
28  vlib_log_debug (gbp_learn_main.gl_logger, __VA_ARGS__);
29 
30 #define foreach_gbp_learn \
31  _(DROP, "drop")
32 
33 typedef enum
34 {
35 #define _(sym,str) GBP_LEARN_ERROR_##sym,
37 #undef _
40 
41 static char *gbp_learn_error_strings[] = {
42 #define _(sym,string) string,
44 #undef _
45 };
46 
47 typedef enum
48 {
49 #define _(sym,str) GBP_LEARN_NEXT_##sym,
51 #undef _
54 
55 typedef struct gbp_learn_l2_t_
56 {
57  ip46_address_t ip;
62  ip46_address_t outer_src;
63  ip46_address_t outer_dst;
65 
66 
67 static void
69 {
70  ip46_address_t *ips = NULL;
71 
72  GBP_LEARN_DBG ("L2 EP: %U %U, %d",
75 
76  if (!ip46_address_is_zero (&gl2->ip))
77  vec_add1 (ips, gl2->ip);
78 
79  /*
80  * flip the source and dst, since that's how it was received, this API
81  * takes how it's sent
82  */
83  gbp_endpoint_update_and_lock (GBP_ENDPOINT_SRC_DP,
84  gl2->sw_if_index, ips,
85  &gl2->mac, INDEX_INVALID,
86  INDEX_INVALID, gl2->sclass,
89  &gl2->outer_dst, &gl2->outer_src, NULL);
90  vec_free (ips);
91 }
92 
93 static void
95  u32 bd_index, u32 sw_if_index, sclass_t sclass,
96  const ip4_address_t * outer_src,
97  const ip4_address_t * outer_dst)
98 {
99  gbp_learn_l2_t gl2 = {
101  .bd_index = bd_index,
102  .sclass = sclass,
103  .ip.ip4 = *ip,
104  .outer_src.ip4 = *outer_src,
105  .outer_dst.ip4 = *outer_dst,
106  };
108 
109  vl_api_rpc_call_main_thread (gbp_learn_l2_cp, (u8 *) & gl2, sizeof (gl2));
110 }
111 
112 static void
113 gbp_learn_l2_ip6_dp (const u8 * mac, const ip6_address_t * ip,
114  u32 bd_index, u32 sw_if_index, sclass_t sclass,
115  const ip4_address_t * outer_src,
116  const ip4_address_t * outer_dst)
117 {
118  gbp_learn_l2_t gl2 = {
120  .bd_index = bd_index,
121  .sclass = sclass,
122  .ip.ip6 = *ip,
123  .outer_src.ip4 = *outer_src,
124  .outer_dst.ip4 = *outer_dst,
125  };
127 
128  vl_api_rpc_call_main_thread (gbp_learn_l2_cp, (u8 *) & gl2, sizeof (gl2));
129 }
130 
131 static void
132 gbp_learn_l2_dp (const u8 * mac, u32 bd_index, u32 sw_if_index,
134  const ip4_address_t * outer_src,
135  const ip4_address_t * outer_dst)
136 {
137  gbp_learn_l2_t gl2 = {
139  .bd_index = bd_index,
140  .sclass = sclass,
141  .outer_src.ip4 = *outer_src,
142  .outer_dst.ip4 = *outer_dst,
143  };
145 
146  vl_api_rpc_call_main_thread (gbp_learn_l2_cp, (u8 *) & gl2, sizeof (gl2));
147 }
148 
149 /**
150  * per-packet trace data
151  */
152 typedef struct gbp_learn_l2_trace_t_
153 {
154  /* per-pkt trace data */
157  u32 new;
163 
164 always_inline void
166  ip4_address_t * outer_src, ip4_address_t * outer_dst)
167 {
168  ip4_header_t *ip0;
169  u8 *buff;
170 
171  /* rewind back to the ivxlan header */
172  buff = (u8 *) eh0;
173  buff -= (sizeof (vxlan_gbp_header_t) +
174  sizeof (udp_header_t) + sizeof (ip4_header_t));
175 
176  ip0 = (ip4_header_t *) buff;
177 
178  *outer_src = ip0->src_address;
179  *outer_dst = ip0->dst_address;
180 }
181 
182 always_inline int
184  u32 rx_sw_if_index, sclass_t sclass)
185 {
186  /* Conditions for [re]learning this EP */
187 
188  /* 1. it doesn't have a dataplane source */
189  if (!gbp_endpoint_is_learnt (ge0))
190  return (!0);
191 
192  /* 2. has the input interface changed */
193  if (gbp_itf_get_sw_if_index (ge0->ge_fwd.gef_itf) != rx_sw_if_index)
194  return (!0);
195 
196  /* 3. has the sclass changed */
197  if (sclass != ge0->ge_fwd.gef_sclass)
198  return (!0);
199 
200  /* otherwise it's unchanged */
201  return (0);
202 }
203 
207 {
208  u32 n_left_from, *from, *to_next, next_index, thread_index, seed;
209  gbp_learn_main_t *glm;
210  f64 time_now;
211 
212  glm = &gbp_learn_main;
213  next_index = 0;
214  n_left_from = frame->n_vectors;
216  time_now = vlib_time_now (vm);
218 
219  seed = throttle_seed (&glm->gl_l2_throttle, thread_index, time_now);
220 
221  while (n_left_from > 0)
222  {
223  u32 n_left_to_next;
224 
225  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
226 
227  while (n_left_from > 0 && n_left_to_next > 0)
228  {
229  ip4_address_t outer_src, outer_dst;
230  const ethernet_header_t *eh0;
231  u32 bi0, sw_if_index0, t0;
232  gbp_bridge_domain_t *gb0;
233  gbp_learn_next_t next0;
234  gbp_endpoint_t *ge0;
235  vlib_buffer_t *b0;
236  sclass_t sclass0;
237 
238  next0 = GBP_LEARN_NEXT_DROP;
239  bi0 = from[0];
240  to_next[0] = bi0;
241  from += 1;
242  to_next += 1;
243  n_left_from -= 1;
244  n_left_to_next -= 1;
245 
246  b0 = vlib_get_buffer (vm, bi0);
247  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
248 
249  eh0 = vlib_buffer_get_current (b0);
250  sclass0 = vnet_buffer2 (b0)->gbp.sclass;
251 
253  L2INPUT_FEAT_GBP_LEARN);
254 
256  vnet_buffer (b0)->l2.bd_index);
257  gb0 =
259 
260  if ((vnet_buffer2 (b0)->gbp.flags & VXLAN_GBP_GPFLAGS_D) ||
262  {
263  t0 = 1;
264  goto trace;
265  }
266 
267  /*
268  * check for new EP or a moved EP
269  */
270  if (NULL == ge0 ||
271  gbp_endpoint_update_required (ge0, sw_if_index0, sclass0))
272  {
273  /*
274  * use the last 4 bytes of the mac address as the hash for the EP
275  */
277  *((u32 *) (eh0->src_address + 2)), seed);
278  if (!t0)
279  {
280  gbp_learn_get_outer (eh0, &outer_src, &outer_dst);
281 
282  if (outer_src.as_u32 == 0 || outer_dst.as_u32 == 0)
283  {
284  t0 = 2;
285  goto trace;
286  }
287 
288  switch (clib_net_to_host_u16 (eh0->type))
289  {
290  case ETHERNET_TYPE_IP4:
291  {
292  const ip4_header_t *ip0;
293 
294  ip0 = (ip4_header_t *) (eh0 + 1);
295 
297  &ip0->src_address,
298  vnet_buffer (b0)->l2.bd_index,
299  sw_if_index0, sclass0,
300  &outer_src, &outer_dst);
301 
302  break;
303  }
304  case ETHERNET_TYPE_IP6:
305  {
306  const ip6_header_t *ip0;
307 
308  ip0 = (ip6_header_t *) (eh0 + 1);
309 
311  &ip0->src_address,
312  vnet_buffer (b0)->l2.bd_index,
313  sw_if_index0, sclass0,
314  &outer_src, &outer_dst);
315 
316  break;
317  }
318  case ETHERNET_TYPE_ARP:
319  {
320  const ethernet_arp_header_t *arp0;
321 
322  arp0 = (ethernet_arp_header_t *) (eh0 + 1);
323 
325  &arp0->ip4_over_ethernet[0].ip4,
326  vnet_buffer (b0)->l2.bd_index,
327  sw_if_index0, sclass0,
328  &outer_src, &outer_dst);
329  break;
330  }
331  default:
333  vnet_buffer (b0)->l2.bd_index,
334  sw_if_index0, sclass0,
335  &outer_src, &outer_dst);
336  break;
337  }
338  }
339  }
340  else
341  {
342  /*
343  * this update could happen simultaneoulsy from multiple workers
344  * but that's ok we are not interested in being very accurate.
345  */
346  t0 = 0;
347  ge0->ge_last_time = time_now;
348  }
349  trace:
350  if (PREDICT_FALSE ((b0->flags & VLIB_BUFFER_IS_TRACED)))
351  {
353  vlib_add_trace (vm, node, b0, sizeof (*t));
354  clib_memcpy_fast (t->mac.bytes, eh0->src_address, 6);
355  t->new = (NULL == ge0);
356  t->throttled = t0;
357  t->sw_if_index = sw_if_index0;
358  t->sclass = sclass0;
359  t->gb_flags = gb0->gb_flags;
360  t->d_bit = ! !(vnet_buffer2 (b0)->gbp.flags &
361  VXLAN_GBP_GPFLAGS_D);
362  }
363 
364  /* verify speculative enqueue, maybe switch current next frame */
366  to_next, n_left_to_next,
367  bi0, next0);
368  }
369 
370  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
371  }
372 
373  return frame->n_vectors;
374 }
375 
376 /* packet trace format function */
377 static u8 *
378 format_gbp_learn_l2_trace (u8 * s, va_list * args)
379 {
380  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
381  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
382  gbp_learn_l2_trace_t *t = va_arg (*args, gbp_learn_l2_trace_t *);
383 
384  s = format (s, "new:%d throttled:%d d-bit:%d mac:%U itf:%d sclass:%d"
385  " gb-flags:%U",
386  t->new, t->throttled, t->d_bit,
389 
390  return s;
391 }
392 
393 /* *INDENT-OFF* */
395  .name = "gbp-learn-l2",
396  .vector_size = sizeof (u32),
397  .format_trace = format_gbp_learn_l2_trace,
399 
400  .n_errors = ARRAY_LEN(gbp_learn_error_strings),
401  .error_strings = gbp_learn_error_strings,
402 
403  .n_next_nodes = GBP_LEARN_N_NEXT,
404 
405  .next_nodes = {
406  [GBP_LEARN_NEXT_DROP] = "error-drop",
407  },
408 };
409 /* *INDENT-ON* */
410 
411 typedef struct gbp_learn_l3_t_
412 {
413  ip46_address_t ip;
417  ip46_address_t outer_src;
418  ip46_address_t outer_dst;
420 
421 static void
423 {
424  ip46_address_t *ips = NULL;
425 
426  GBP_LEARN_DBG ("L3 EP: %U, %d", format_ip46_address, &gl3->ip,
427  IP46_TYPE_ANY, gl3->sclass);
428 
429  vec_add1 (ips, gl3->ip);
430 
431  gbp_endpoint_update_and_lock (GBP_ENDPOINT_SRC_DP,
432  gl3->sw_if_index, ips, NULL,
436  &gl3->outer_dst, &gl3->outer_src, NULL);
437  vec_free (ips);
438 }
439 
440 static void
442  u32 fib_index, u32 sw_if_index, sclass_t sclass,
443  const ip4_address_t * outer_src,
444  const ip4_address_t * outer_dst)
445 {
446  /* *INDENT-OFF* */
447  gbp_learn_l3_t gl3 = {
448  .ip = {
449  .ip4 = *ip,
450  },
451  .sw_if_index = sw_if_index,
452  .fib_index = fib_index,
453  .sclass = sclass,
454  .outer_src.ip4 = *outer_src,
455  .outer_dst.ip4 = *outer_dst,
456  };
457  /* *INDENT-ON* */
458 
459  vl_api_rpc_call_main_thread (gbp_learn_l3_cp, (u8 *) & gl3, sizeof (gl3));
460 }
461 
462 static void
463 gbp_learn_ip6_dp (const ip6_address_t * ip,
464  u32 fib_index, u32 sw_if_index, sclass_t sclass,
465  const ip4_address_t * outer_src,
466  const ip4_address_t * outer_dst)
467 {
468  /* *INDENT-OFF* */
469  gbp_learn_l3_t gl3 = {
470  .ip = {
471  .ip6 = *ip,
472  },
473  .sw_if_index = sw_if_index,
474  .fib_index = fib_index,
475  .sclass = sclass,
476  .outer_src.ip4 = *outer_src,
477  .outer_dst.ip4 = *outer_dst,
478  };
479  /* *INDENT-ON* */
480 
481  vl_api_rpc_call_main_thread (gbp_learn_l3_cp, (u8 *) & gl3, sizeof (gl3));
482 }
483 
484 /**
485  * per-packet trace data
486  */
487 typedef struct gbp_learn_l3_trace_t_
488 {
489  /* per-pkt trace data */
490  ip46_address_t ip;
492  u32 new;
496 
497 static uword
500  fib_protocol_t fproto)
501 {
502  u32 n_left_from, *from, *to_next, next_index, thread_index, seed;
503  gbp_learn_main_t *glm;
504  f64 time_now;
505 
506  glm = &gbp_learn_main;
507  next_index = 0;
508  n_left_from = frame->n_vectors;
510  time_now = vlib_time_now (vm);
512 
513  seed = throttle_seed (&glm->gl_l3_throttle, thread_index, time_now);
514 
515  while (n_left_from > 0)
516  {
517  u32 n_left_to_next;
518 
519  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
520 
521  while (n_left_from > 0 && n_left_to_next > 0)
522  {
523  CLIB_UNUSED (const ip4_header_t *) ip4_0;
524  CLIB_UNUSED (const ip6_header_t *) ip6_0;
525  u32 bi0, sw_if_index0, t0, fib_index0;
526  ip4_address_t outer_src, outer_dst;
527  ethernet_header_t *eth0;
528  gbp_learn_next_t next0;
529  gbp_endpoint_t *ge0;
530  vlib_buffer_t *b0;
531  sclass_t sclass0;
532 
533  next0 = GBP_LEARN_NEXT_DROP;
534  bi0 = from[0];
535  to_next[0] = bi0;
536  from += 1;
537  to_next += 1;
538  n_left_from -= 1;
539  n_left_to_next -= 1;
540 
541  b0 = vlib_get_buffer (vm, bi0);
542  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
543  sclass0 = vnet_buffer2 (b0)->gbp.sclass;
544  ip6_0 = NULL;
545  ip4_0 = NULL;
546 
547  vnet_feature_next (&next0, b0);
548 
549  if (vnet_buffer2 (b0)->gbp.flags & VXLAN_GBP_GPFLAGS_D)
550  {
551  t0 = 1;
552  ge0 = NULL;
553  goto trace;
554  }
555 
556  fib_index0 = fib_table_get_index_for_sw_if_index (fproto,
557  sw_if_index0);
558 
559  if (FIB_PROTOCOL_IP6 == fproto)
560  {
561  ip6_0 = vlib_buffer_get_current (b0);
562  eth0 = (ethernet_header_t *) (((u8 *) ip6_0) - sizeof (*eth0));
563 
564  gbp_learn_get_outer (eth0, &outer_src, &outer_dst);
565 
566  ge0 = gbp_endpoint_find_ip6 (&ip6_0->src_address, fib_index0);
567 
568  if ((NULL == ge0) ||
569  gbp_endpoint_update_required (ge0, sw_if_index0, sclass0))
570  {
571  t0 = throttle_check (&glm->gl_l3_throttle,
572  thread_index,
574  (&ip6_0->src_address), seed);
575 
576  if (!t0)
577  {
578  gbp_learn_ip6_dp (&ip6_0->src_address,
579  fib_index0, sw_if_index0, sclass0,
580  &outer_src, &outer_dst);
581  }
582  }
583  else
584  {
585  /*
586  * this update could happen simultaneoulsy from multiple
587  * workers but that's ok we are not interested in being
588  * very accurate.
589  */
590  t0 = 0;
591  ge0->ge_last_time = time_now;
592  }
593  }
594  else
595  {
596  ip4_0 = vlib_buffer_get_current (b0);
597  eth0 = (ethernet_header_t *) (((u8 *) ip4_0) - sizeof (*eth0));
598 
599  gbp_learn_get_outer (eth0, &outer_src, &outer_dst);
600  ge0 = gbp_endpoint_find_ip4 (&ip4_0->src_address, fib_index0);
601 
602  if ((NULL == ge0) ||
603  gbp_endpoint_update_required (ge0, sw_if_index0, sclass0))
604  {
606  ip4_0->src_address.as_u32, seed);
607 
608  if (!t0)
609  {
610  gbp_learn_ip4_dp (&ip4_0->src_address,
611  fib_index0, sw_if_index0, sclass0,
612  &outer_src, &outer_dst);
613  }
614  }
615  else
616  {
617  /*
618  * this update could happen simultaneoulsy from multiple
619  * workers but that's ok we are not interested in being
620  * very accurate.
621  */
622  t0 = 0;
623  ge0->ge_last_time = time_now;
624  }
625  }
626  trace:
627  if (PREDICT_FALSE ((b0->flags & VLIB_BUFFER_IS_TRACED)))
628  {
630 
631  t = vlib_add_trace (vm, node, b0, sizeof (*t));
632  if (FIB_PROTOCOL_IP6 == fproto && ip6_0)
633  ip46_address_set_ip6 (&t->ip, &ip6_0->src_address);
634  if (FIB_PROTOCOL_IP4 == fproto && ip4_0)
635  ip46_address_set_ip4 (&t->ip, &ip4_0->src_address);
636  t->new = (NULL == ge0);
637  t->throttled = t0;
638  t->sw_if_index = sw_if_index0;
639  t->sclass = sclass0;
640  }
641 
643  to_next, n_left_to_next,
644  bi0, next0);
645  }
646 
647  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
648  }
649 
650  return frame->n_vectors;
651 }
652 
653 /* packet trace format function */
654 static u8 *
655 format_gbp_learn_l3_trace (u8 * s, va_list * args)
656 {
657  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
658  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
659  gbp_learn_l3_trace_t *t = va_arg (*args, gbp_learn_l3_trace_t *);
660 
661  s = format (s, "new:%d throttled:%d ip:%U itf:%d sclass:%d",
662  t->new, t->throttled,
664  t->sclass);
665 
666  return s;
667 }
668 
672 {
673  return (gbp_learn_l3 (vm, node, frame, FIB_PROTOCOL_IP4));
674 }
675 
679 {
680  return (gbp_learn_l3 (vm, node, frame, FIB_PROTOCOL_IP6));
681 }
682 
683 /* *INDENT-OFF* */
685  .name = "gbp-learn-ip4",
686  .vector_size = sizeof (u32),
687  .format_trace = format_gbp_learn_l3_trace,
689 };
690 
691 VNET_FEATURE_INIT (gbp_learn_ip4, static) =
692 {
693  .arc_name = "ip4-unicast",
694  .node_name = "gbp-learn-ip4",
695 };
696 
698  .name = "gbp-learn-ip6",
699  .vector_size = sizeof (u32),
700  .format_trace = format_gbp_learn_l3_trace,
702 };
703 
704 VNET_FEATURE_INIT (gbp_learn_ip6, static) =
705 {
706  .arc_name = "ip6-unicast",
707  .node_name = "gbp-learn-ip6",
708 };
709 
710 /* *INDENT-ON* */
711 
712 /*
713  * fd.io coding-style-patch-verification: ON
714  *
715  * Local Variables:
716  * eval: (c-set-style "gnu")
717  * End:
718  */
gbp_learn.h
GBP_BD_FLAG_DO_NOT_LEARN
@ GBP_BD_FLAG_DO_NOT_LEARN
Definition: gbp_bridge_domain.h:31
gbp_learn_next_t
gbp_learn_next_t
Definition: gbp_learn_node.c:47
trace
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
Definition: vlib_api_cli.c:899
api.h
gbp_learn_l2_cp
static void gbp_learn_l2_cp(const gbp_learn_l2_t *gl2)
Definition: gbp_learn_node.c:68
GBP_ENDPOINT_FLAG_LEARNT
@ GBP_ENDPOINT_FLAG_LEARNT
Definition: gbp_endpoint.h:47
mac
vl_api_mac_address_t mac
Definition: l2.api:559
thread_index
u32 thread_index
Definition: nat44_ei_hairpinning.c:492
gbp_endpoint_t_::ge_fwd
gbp_endpoint_fwd_t ge_fwd
Definition: gbp_endpoint.h:208
gbp_learn_l2_t_::sw_if_index
u32 sw_if_index
Definition: gbp_learn_node.c:59
frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: nat44_ei.c:3048
GBP_ENDPOINT_FLAG_REMOTE
@ GBP_ENDPOINT_FLAG_REMOTE
Definition: gbp_endpoint.h:46
gbp_endpoint_fwd_t_::gef_sclass
sclass_t gef_sclass
Endpoint Group's sclass.
Definition: gbp_endpoint.h:172
next_index
nat44_ei_hairpin_src_next_t next_index
Definition: nat44_ei_hairpinning.c:412
gbp_learn_l3_trace_t_::sclass
u32 sclass
Definition: gbp_learn_node.c:494
gbp_learn_l3_trace_t
struct gbp_learn_l3_trace_t_ gbp_learn_l3_trace_t
per-packet trace data
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
gbp_learn_main_t_
Grouping of global data for the GBP source EPG classification feature.
Definition: gbp_learn.h:31
gbp_learn_l3_t_::sclass
sclass_t sclass
Definition: gbp_learn_node.c:416
gbp_learn_l3_t_::outer_dst
ip46_address_t outer_dst
Definition: gbp_learn_node.c:418
ip46_address_set_ip4
static void ip46_address_set_ip4(ip46_address_t *ip46, const ip4_address_t *ip)
Definition: ip46_address.h:67
gbp_learn_l2_t_
Definition: gbp_learn_node.c:55
ethernet_header_t::src_address
u8 src_address[6]
Definition: packet.h:56
VLIB_NODE_TYPE_INTERNAL
@ VLIB_NODE_TYPE_INTERNAL
Definition: node.h:72
ip46_address_set_ip6
static_always_inline void ip46_address_set_ip6(ip46_address_t *dst, const ip6_address_t *src)
Definition: ip46_address.h:130
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
ip4_address_t::as_u32
u32 as_u32
Definition: ip4_packet.h:57
ethernet_arp_header_t::ip4_over_ethernet
ethernet_arp_ip4_over_ethernet_address_t ip4_over_ethernet[2]
Definition: arp_packet.h:142
gbp_learn_l3_t_::ip
ip46_address_t ip
Definition: gbp_learn_node.c:413
fib_table.h
gbp.h
gbp_learn_l2_t_::bd_index
u32 bd_index
Definition: gbp_learn_node.c:60
ethernet_header_t::type
u16 type
Definition: packet.h:59
gbp_learn_l3_t_::sw_if_index
u32 sw_if_index
Definition: gbp_learn_node.c:415
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
vnet_buffer2
#define vnet_buffer2(b)
Definition: buffer.h:499
gbp_learn_l2_t_::outer_src
ip46_address_t outer_src
Definition: gbp_learn_node.c:62
gbp_learn_l2_dp
static void gbp_learn_l2_dp(const u8 *mac, u32 bd_index, u32 sw_if_index, sclass_t sclass, const ip4_address_t *outer_src, const ip4_address_t *outer_dst)
Definition: gbp_learn_node.c:132
vlib_frame_t
Definition: node.h:372
gbp_learn_l3_trace_t_::ip
ip46_address_t ip
Definition: gbp_learn_node.c:490
gbp_learn_l2_trace_t_::throttled
u32 throttled
Definition: gbp_learn_node.c:158
clib_memcpy_fast
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
Definition: string.h:92
udp_header_t
Definition: udp_packet.h:45
ip4_header_t
Definition: ip4_packet.h:87
gbp_learn_l3_cp
static void gbp_learn_l3_cp(const gbp_learn_l3_t *gl3)
Definition: gbp_learn_node.c:422
gbp_learn_l2_trace_t
struct gbp_learn_l2_trace_t_ gbp_learn_l2_trace_t
per-packet trace data
gbp_learn_l3_t_::outer_src
ip46_address_t outer_src
Definition: gbp_learn_node.c:417
gbp_learn_l3_trace_t_
per-packet trace data
Definition: gbp_learn_node.c:487
gbp_learn_l2_ip4_dp
static void gbp_learn_l2_ip4_dp(const u8 *mac, const ip4_address_t *ip, u32 bd_index, u32 sw_if_index, sclass_t sclass, const ip4_address_t *outer_src, const ip4_address_t *outer_dst)
Definition: gbp_learn_node.c:94
gbp_endpoint_find_ip4
static_always_inline gbp_endpoint_t * gbp_endpoint_find_ip4(const ip4_address_t *ip, u32 fib_index)
Definition: gbp_endpoint.h:314
ips
vl_api_address_t ips[n_ips]
Definition: gbp.api:136
ethernet_arp_header_t
Definition: arp_packet.h:133
VLIB_NODE_FN
#define VLIB_NODE_FN(node)
Definition: node.h:202
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
gbp_endpoint_find_mac
static_always_inline gbp_endpoint_t * gbp_endpoint_find_mac(const u8 *mac, u32 bd_index)
Definition: gbp_endpoint.h:279
gbp_learn_l3_t_
Definition: gbp_learn_node.c:411
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
vnet_buffer
#define vnet_buffer(b)
Definition: buffer.h:437
gbp_learn_ip4_node
vlib_node_registration_t gbp_learn_ip4_node
(constructor) VLIB_REGISTER_NODE (gbp_learn_ip4_node)
Definition: gbp_learn_node.c:684
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
vnet_feature_next
static_always_inline void vnet_feature_next(u32 *next0, vlib_buffer_t *b0)
Definition: feature.h:322
ARRAY_LEN
#define ARRAY_LEN(x)
Definition: clib.h:70
format_mac_address_t
u8 * format_mac_address_t(u8 *s, va_list *args)
Definition: mac_address.c:27
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
gbp_learn_l2_t_::sclass
sclass_t sclass
Definition: gbp_learn_node.c:61
gbp_learn_l3_trace_t_::new
u32 new
Definition: gbp_learn_node.c:492
gbp_learn_ip6_node
vlib_node_registration_t gbp_learn_ip6_node
(constructor) VLIB_REGISTER_NODE (gbp_learn_ip6_node)
Definition: gbp_learn_node.c:697
uword
u64 uword
Definition: types.h:112
format_gbp_learn_l3_trace
static u8 * format_gbp_learn_l3_trace(u8 *s, va_list *args)
Definition: gbp_learn_node.c:655
gbp_itf_get_sw_if_index
u32 gbp_itf_get_sw_if_index(gbp_itf_hdl_t hdl)
Definition: gbp_itf.c:150
gbp_learn_ip4_dp
static void gbp_learn_ip4_dp(const ip4_address_t *ip, u32 fib_index, u32 sw_if_index, sclass_t sclass, const ip4_address_t *outer_src, const ip4_address_t *outer_dst)
Definition: gbp_learn_node.c:441
ethernet_header_t
Definition: packet.h:52
gbp_learn_main
gbp_learn_main_t gbp_learn_main
Definition: gbp_learn.c:22
GBP_LEARN_N_ERROR
@ GBP_LEARN_N_ERROR
Definition: gbp_learn_node.c:38
vlib_main_t::thread_index
u32 thread_index
Definition: main.h:213
f64
double f64
Definition: types.h:142
gbp_learn_l2_t_::mac
mac_address_t mac
Definition: gbp_learn_node.c:58
gbp_learn_l2_ip6_dp
static void gbp_learn_l2_ip6_dp(const u8 *mac, const ip6_address_t *ip, u32 bd_index, u32 sw_if_index, sclass_t sclass, const ip4_address_t *outer_src, const ip4_address_t *outer_dst)
Definition: gbp_learn_node.c:113
mac_address_t_::bytes
u8 bytes[6]
Definition: mac_address.h:25
gbp_endpoint_fwd_t_::gef_itf
gbp_itf_hdl_t gef_itf
The interface on which the EP is connected.
Definition: gbp_endpoint.h:162
throttle_seed
static u64 throttle_seed(throttle_t *t, u32 thread_index, f64 time_now)
Definition: throttle.h:41
fib_protocol_t
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
sclass
u16 sclass
Definition: gbp.api:131
ip4_address_t
Definition: ip4_packet.h:50
FIB_PROTOCOL_IP4
@ FIB_PROTOCOL_IP4
Definition: fib_types.h:36
vxlan_gbp_packet.h
gbp_endpoint_update_required
static int gbp_endpoint_update_required(const gbp_endpoint_t *ge0, u32 rx_sw_if_index, sclass_t sclass)
Definition: gbp_learn_node.c:183
gbp_learn_l2_trace_t_::new
u32 new
Definition: gbp_learn_node.c:157
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
gbp_bridge_domain.h
gbp_learn_l2_trace_t_::sclass
u32 sclass
Definition: gbp_learn_node.c:159
ip4_header_t::dst_address
ip4_address_t dst_address
Definition: ip4_packet.h:125
l2_input.h
ip46_address_is_zero
static u8 ip46_address_is_zero(const ip46_address_t *ip46)
Definition: ip46_address.h:87
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
gbp_learn_l2_trace_t_::sw_if_index
u32 sw_if_index
Definition: gbp_learn_node.c:156
ip6_address_hash_to_u32
static u32 ip6_address_hash_to_u32(const ip6_address_t *a)
Definition: ip6_packet.h:283
gbp_endpoint_is_learnt
int gbp_endpoint_is_learnt(const gbp_endpoint_t *ge)
Definition: gbp_endpoint.c:107
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
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
always_inline
#define always_inline
Definition: rdma_mlx5dv.h:23
ip4_header_t::src_address
ip4_address_t src_address
Definition: ip4_packet.h:125
vxlan_gbp_header_t
Definition: vxlan_gbp_packet.h:73
sclass_t
u16 sclass_t
Definition: gbp_types.h:25
gbp_learn_l3_t
struct gbp_learn_l3_t_ gbp_learn_l3_t
GBP_LEARN_N_NEXT
@ GBP_LEARN_N_NEXT
Definition: gbp_learn_node.c:52
gbp_endpoint_update_and_lock
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, sclass_t sclass, gbp_endpoint_flags_t flags, const ip46_address_t *tun_src, const ip46_address_t *tun_dst, u32 *handle)
Definition: gbp_endpoint.c:820
gbp_endpoint_t_::ge_last_time
f64 ge_last_time
The last time a packet from seen from this end point.
Definition: gbp_endpoint.h:213
throttle.h
format
description fragment has unexpected format
Definition: map.api:433
gbp_learn_l2_trace_t_::gb_flags
gbp_bridge_domain_flags_t gb_flags
Definition: gbp_learn_node.c:161
gbp_learn_l3
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_node.c:498
vlib_put_next_frame
vlib_put_next_frame(vm, node, next_index, 0)
throttle_check
static int throttle_check(throttle_t *t, u32 thread_index, u64 hash, u64 seed)
Definition: throttle.h:54
format_ip46_address
format_function_t format_ip46_address
Definition: ip46_address.h:50
gbp_learn_l2_t_::outer_dst
ip46_address_t outer_dst
Definition: gbp_learn_node.c:63
fib_table_get_index_for_sw_if_index
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:998
gbp_endpoint_find_ip6
static_always_inline gbp_endpoint_t * gbp_endpoint_find_ip6(const ip6_address_t *ip, u32 fib_index)
Definition: gbp_endpoint.h:339
gbp_learn_l2_trace_t_
per-packet trace data
Definition: gbp_learn_node.c:152
u32
unsigned int u32
Definition: types.h:88
gbp_learn_get_outer
static void gbp_learn_get_outer(const ethernet_header_t *eh0, ip4_address_t *outer_src, ip4_address_t *outer_dst)
Definition: gbp_learn_node.c:165
format_gbp_learn_l2_trace
static u8 * format_gbp_learn_l2_trace(u8 *s, va_list *args)
Definition: gbp_learn_node.c:378
gbp_learn_l2_trace_t_::d_bit
u32 d_bit
Definition: gbp_learn_node.c:160
FIB_PROTOCOL_IP6
@ FIB_PROTOCOL_IP6
Definition: fib_types.h:37
gbp_learn_l3_trace_t_::throttled
u32 throttled
Definition: gbp_learn_node.c:493
gbp_learn_error_strings
static char * gbp_learn_error_strings[]
Definition: gbp_learn_node.c:41
gbp_learn_main_t_::gl_l3_throttle
throttle_t gl_l3_throttle
Definition: gbp_learn.h:47
format_gbp_bridge_domain_flags
u8 * format_gbp_bridge_domain_flags(u8 *s, va_list *args)
Definition: gbp_bridge_domain.c:124
vl_api_rpc_call_main_thread
void vl_api_rpc_call_main_thread(void *fp, u8 *data, u32 data_length)
Definition: vlib_api.c:620
VNET_FEATURE_INIT
VNET_FEATURE_INIT(gbp_learn_ip4, static)
gbp_learn_l3_t_::fib_index
u32 fib_index
Definition: gbp_learn_node.c:414
gbp_bridge_domain_t_
A bridge Domain Representation.
Definition: gbp_bridge_domain.h:42
ip6_header_t
Definition: ip6_packet.h:294
mac_address_t_
Definition: mac_address.h:21
gbp_learn_l2_trace_t_::mac
mac_address_t mac
Definition: gbp_learn_node.c:155
ip6_header_t::src_address
ip6_address_t src_address
Definition: ip6_packet.h:310
vlib_main_t
Definition: main.h:102
vlib_node_t
Definition: node.h:247
gbp_learn_error_t
gbp_learn_error_t
Definition: gbp_learn_node.c:33
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
u8
unsigned char u8
Definition: types.h:56
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
ip
vl_api_address_t ip
Definition: l2.api:558
arp_packet.h
gbp_learn_l3_trace_t_::sw_if_index
u32 sw_if_index
Definition: gbp_learn_node.c:491
gbp_bridge_domain_flags_t
enum gbp_bridge_domain_flags_t_ gbp_bridge_domain_flags_t
Bridge Domain Flags.
foreach_gbp_learn
#define foreach_gbp_learn
Definition: gbp_learn_node.c:30
gbp_learn_main_t_::gl_l2_input_feat_next
u32 gl_l2_input_feat_next[32]
Next nodes for L2 output features.
Definition: gbp_learn.h:36
IP46_TYPE_ANY
@ IP46_TYPE_ANY
Definition: ip46_address.h:24
gbp_endpoint_t_
A Group Based Policy Endpoint.
Definition: gbp_endpoint.h:190
vlib_time_now
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:325
gbp_learn_l2_t
struct gbp_learn_l2_t_ gbp_learn_l2_t
GBP_LEARN_DBG
#define GBP_LEARN_DBG(...)
Definition: gbp_learn_node.c:27
vlib_node_runtime_t
Definition: node.h:454
from
from
Definition: nat44_ei_hairpinning.c:415
INDEX_INVALID
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
Definition: dpo.h:49
gbp_learn_ip6_dp
static void gbp_learn_ip6_dp(const ip6_address_t *ip, u32 fib_index, u32 sw_if_index, sclass_t sclass, const ip4_address_t *outer_src, const ip4_address_t *outer_dst)
Definition: gbp_learn_node.c:463
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
gbp_learn_l2_t_::ip
ip46_address_t ip
Definition: gbp_learn_node.c:57
gbp_bridge_domain_t_::gb_flags
gbp_bridge_domain_flags_t gb_flags
Flags conttrolling behaviour.
Definition: gbp_bridge_domain.h:59
n_left_from
n_left_from
Definition: nat44_ei_hairpinning.c:416
gbp_learn_l2_node
vlib_node_registration_t gbp_learn_l2_node
(constructor) VLIB_REGISTER_NODE (gbp_learn_l2_node)
Definition: gbp_learn_node.c:394
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
gbp_bridge_domain_get_by_bd_index
static gbp_bridge_domain_t * gbp_bridge_domain_get_by_bd_index(u32 bd_index)
Definition: gbp_bridge_domain.h:134
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
mac_address_from_bytes
static_always_inline void mac_address_from_bytes(mac_address_t *mac, const u8 *bytes)
Definition: mac_address.h:92
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
gbp_learn_main_t_::gl_l2_throttle
throttle_t gl_l2_throttle
throttles for the DP leanring
Definition: gbp_learn.h:46