FD.io VPP  v19.04.2-12-g66b1689
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
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  };
107  mac_address_from_bytes (&gl2.mac, mac);
108 
109  vl_api_rpc_call_main_thread (gbp_learn_l2_cp, (u8 *) & gl2, sizeof (gl2));
110 }
111 
112 static void
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  };
126  mac_address_from_bytes (&gl2.mac, mac);
127 
128  vl_api_rpc_call_main_thread (gbp_learn_l2_cp, (u8 *) & gl2, sizeof (gl2));
129 }
130 
131 static void
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  };
144  mac_address_from_bytes (&gl2.mac, mac);
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
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 
183  vlib_node_runtime_t * node,
184  vlib_frame_t * frame)
185 {
186  u32 n_left_from, *from, *to_next, next_index, thread_index, seed;
187  gbp_learn_main_t *glm;
188  f64 time_now;
189 
190  glm = &gbp_learn_main;
191  next_index = 0;
192  n_left_from = frame->n_vectors;
193  from = vlib_frame_vector_args (frame);
194  time_now = vlib_time_now (vm);
195  thread_index = vm->thread_index;
196 
197  seed = throttle_seed (&glm->gl_l2_throttle, thread_index, time_now);
198 
199  while (n_left_from > 0)
200  {
201  u32 n_left_to_next;
202 
203  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
204 
205  while (n_left_from > 0 && n_left_to_next > 0)
206  {
208  const ethernet_header_t *eh0;
209  u32 bi0, sw_if_index0, t0;
210  gbp_bridge_domain_t *gb0;
211  gbp_learn_next_t next0;
212  gbp_endpoint_t *ge0;
213  vlib_buffer_t *b0;
214  sclass_t sclass0;
215 
216  next0 = GBP_LEARN_NEXT_DROP;
217  bi0 = from[0];
218  to_next[0] = bi0;
219  from += 1;
220  to_next += 1;
221  n_left_from -= 1;
222  n_left_to_next -= 1;
223 
224  b0 = vlib_get_buffer (vm, bi0);
225  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
226 
227  eh0 = vlib_buffer_get_current (b0);
228  sclass0 = vnet_buffer2 (b0)->gbp.sclass;
229 
231  L2INPUT_FEAT_GBP_LEARN);
232 
234  vnet_buffer (b0)->l2.bd_index);
235  gb0 =
237 
238  if ((vnet_buffer2 (b0)->gbp.flags & VXLAN_GBP_GPFLAGS_D) ||
240  {
241  t0 = 1;
242  goto trace;
243  }
244 
245  /*
246  * check for new EP or a moved EP
247  */
248  if (NULL == ge0 || ge0->ge_fwd.gef_itf != sw_if_index0)
249 
250  {
251  /*
252  * use the last 4 bytes of the mac address as the hash for the EP
253  */
254  t0 = throttle_check (&glm->gl_l2_throttle, thread_index,
255  *((u32 *) (eh0->src_address + 2)), seed);
256  if (!t0)
257  {
258  gbp_learn_get_outer (eh0, &outer_src, &outer_dst);
259 
260  if (outer_src.as_u32 == 0 || outer_dst.as_u32 == 0)
261  {
262  t0 = 2;
263  goto trace;
264  }
265 
266  switch (clib_net_to_host_u16 (eh0->type))
267  {
268  case ETHERNET_TYPE_IP4:
269  {
270  const ip4_header_t *ip0;
271 
272  ip0 = (ip4_header_t *) (eh0 + 1);
273 
275  &ip0->src_address,
276  vnet_buffer (b0)->l2.bd_index,
277  sw_if_index0, sclass0,
278  &outer_src, &outer_dst);
279 
280  break;
281  }
282  case ETHERNET_TYPE_IP6:
283  {
284  const ip6_header_t *ip0;
285 
286  ip0 = (ip6_header_t *) (eh0 + 1);
287 
289  &ip0->src_address,
290  vnet_buffer (b0)->l2.bd_index,
291  sw_if_index0, sclass0,
292  &outer_src, &outer_dst);
293 
294  break;
295  }
296  case ETHERNET_TYPE_ARP:
297  {
298  const ethernet_arp_header_t *arp0;
299 
300  arp0 = (ethernet_arp_header_t *) (eh0 + 1);
301 
303  &arp0->ip4_over_ethernet[0].ip4,
304  vnet_buffer (b0)->l2.bd_index,
305  sw_if_index0, sclass0,
306  &outer_src, &outer_dst);
307  break;
308  }
309  default:
311  vnet_buffer (b0)->l2.bd_index,
312  sw_if_index0, sclass0,
313  &outer_src, &outer_dst);
314  break;
315  }
316  }
317  }
318  else
319  {
320  /*
321  * this update could happen simultaneoulsy from multiple workers
322  * but that's ok we are not interested in being very accurate.
323  */
324  t0 = 0;
325  ge0->ge_last_time = time_now;
326  }
327  trace:
328  if (PREDICT_FALSE ((b0->flags & VLIB_BUFFER_IS_TRACED)))
329  {
331  vlib_add_trace (vm, node, b0, sizeof (*t));
332  clib_memcpy_fast (t->mac.bytes, eh0->src_address, 6);
333  t->new = (NULL == ge0);
334  t->throttled = t0;
335  t->sw_if_index = sw_if_index0;
336  t->sclass = sclass0;
337  t->gb_flags = gb0->gb_flags;
338  t->d_bit = ! !(vnet_buffer2 (b0)->gbp.flags &
339  VXLAN_GBP_GPFLAGS_D);
340  }
341 
342  /* verify speculative enqueue, maybe switch current next frame */
343  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
344  to_next, n_left_to_next,
345  bi0, next0);
346  }
347 
348  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
349  }
350 
351  return frame->n_vectors;
352 }
353 
354 /* packet trace format function */
355 static u8 *
356 format_gbp_learn_l2_trace (u8 * s, va_list * args)
357 {
358  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
359  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
360  gbp_learn_l2_trace_t *t = va_arg (*args, gbp_learn_l2_trace_t *);
361 
362  s = format (s, "new:%d throttled:%d d-bit:%d mac:%U itf:%d sclass:%d"
363  " gb-flags:%U",
364  t->new, t->throttled, t->d_bit,
367 
368  return s;
369 }
370 
371 /* *INDENT-OFF* */
373  .name = "gbp-learn-l2",
374  .vector_size = sizeof (u32),
375  .format_trace = format_gbp_learn_l2_trace,
376  .type = VLIB_NODE_TYPE_INTERNAL,
377 
378  .n_errors = ARRAY_LEN(gbp_learn_error_strings),
379  .error_strings = gbp_learn_error_strings,
380 
381  .n_next_nodes = GBP_LEARN_N_NEXT,
382 
383  .next_nodes = {
384  [GBP_LEARN_NEXT_DROP] = "error-drop",
385  },
386 };
387 /* *INDENT-ON* */
388 
389 typedef struct gbp_learn_l3_t_
390 {
391  ip46_address_t ip;
395  ip46_address_t outer_src;
396  ip46_address_t outer_dst;
398 
399 static void
401 {
402  ip46_address_t *ips = NULL;
403 
404  GBP_LEARN_DBG ("L3 EP: %U, %d", format_ip46_address, &gl3->ip,
405  IP46_TYPE_ANY, gl3->sclass);
406 
407  vec_add1 (ips, gl3->ip);
408 
409  gbp_endpoint_update_and_lock (GBP_ENDPOINT_SRC_DP,
410  gl3->sw_if_index, ips, NULL,
414  &gl3->outer_dst, &gl3->outer_src, NULL);
415  vec_free (ips);
416 }
417 
418 static void
420  u32 fib_index, u32 sw_if_index, sclass_t sclass,
421  const ip4_address_t * outer_src,
422  const ip4_address_t * outer_dst)
423 {
424  /* *INDENT-OFF* */
425  gbp_learn_l3_t gl3 = {
426  .ip = {
427  .ip4 = *ip,
428  },
429  .sw_if_index = sw_if_index,
430  .fib_index = fib_index,
431  .sclass = sclass,
432  .outer_src.ip4 = *outer_src,
433  .outer_dst.ip4 = *outer_dst,
434  };
435  /* *INDENT-ON* */
436 
437  vl_api_rpc_call_main_thread (gbp_learn_l3_cp, (u8 *) & gl3, sizeof (gl3));
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  .ip6 = *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 /**
463  * per-packet trace data
464  */
465 typedef struct gbp_learn_l3_trace_t_
466 {
467  /* per-pkt trace data */
468  ip46_address_t ip;
470  u32 new;
474 
475 static uword
477  vlib_node_runtime_t * node, vlib_frame_t * frame,
478  fib_protocol_t fproto)
479 {
480  u32 n_left_from, *from, *to_next, next_index, thread_index, seed;
481  gbp_learn_main_t *glm;
482  f64 time_now;
483 
484  glm = &gbp_learn_main;
485  next_index = 0;
486  n_left_from = frame->n_vectors;
487  from = vlib_frame_vector_args (frame);
488  time_now = vlib_time_now (vm);
489  thread_index = vm->thread_index;
490 
491  seed = throttle_seed (&glm->gl_l3_throttle, thread_index, time_now);
492 
493  while (n_left_from > 0)
494  {
495  u32 n_left_to_next;
496 
497  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
498 
499  while (n_left_from > 0 && n_left_to_next > 0)
500  {
501  CLIB_UNUSED (const ip4_header_t *) ip4_0;
502  CLIB_UNUSED (const ip6_header_t *) ip6_0;
503  u32 bi0, sw_if_index0, t0, fib_index0;
505  ethernet_header_t *eth0;
506  gbp_learn_next_t next0;
507  gbp_endpoint_t *ge0;
508  vlib_buffer_t *b0;
509  sclass_t sclass0;
510 
511  next0 = GBP_LEARN_NEXT_DROP;
512  bi0 = from[0];
513  to_next[0] = bi0;
514  from += 1;
515  to_next += 1;
516  n_left_from -= 1;
517  n_left_to_next -= 1;
518 
519  b0 = vlib_get_buffer (vm, bi0);
520  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
521  sclass0 = vnet_buffer2 (b0)->gbp.sclass;
522  ip6_0 = NULL;
523  ip4_0 = NULL;
524 
525  vnet_feature_next (&next0, b0);
526 
527  if (vnet_buffer2 (b0)->gbp.flags & VXLAN_GBP_GPFLAGS_D)
528  {
529  t0 = 1;
530  ge0 = NULL;
531  goto trace;
532  }
533 
534  fib_index0 = fib_table_get_index_for_sw_if_index (fproto,
535  sw_if_index0);
536 
537  if (FIB_PROTOCOL_IP6 == fproto)
538  {
539  ip6_0 = vlib_buffer_get_current (b0);
540  eth0 = (ethernet_header_t *) (((u8 *) ip6_0) - sizeof (*eth0));
541 
542  gbp_learn_get_outer (eth0, &outer_src, &outer_dst);
543 
544  ge0 = gbp_endpoint_find_ip6 (&ip6_0->src_address, fib_index0);
545 
546  if (NULL == ge0)
547  {
548  t0 = throttle_check (&glm->gl_l3_throttle,
549  thread_index,
551  (&ip6_0->src_address), seed);
552 
553  if (!t0)
554  {
555  gbp_learn_ip6_dp (&ip6_0->src_address,
556  fib_index0, sw_if_index0, sclass0,
557  &outer_src, &outer_dst);
558  }
559  }
560  else
561  {
562  /*
563  * this update could happen simultaneoulsy from multiple
564  * workers but that's ok we are not interested in being
565  * very accurate.
566  */
567  t0 = 0;
568  ge0->ge_last_time = time_now;
569  }
570  }
571  else
572  {
573  ip4_0 = vlib_buffer_get_current (b0);
574  eth0 = (ethernet_header_t *) (((u8 *) ip4_0) - sizeof (*eth0));
575 
576  gbp_learn_get_outer (eth0, &outer_src, &outer_dst);
577  ge0 = gbp_endpoint_find_ip4 (&ip4_0->src_address, fib_index0);
578 
579  if (NULL == ge0)
580  {
581  t0 = throttle_check (&glm->gl_l3_throttle, thread_index,
582  ip4_0->src_address.as_u32, seed);
583 
584  if (!t0)
585  {
586  gbp_learn_ip4_dp (&ip4_0->src_address,
587  fib_index0, sw_if_index0, sclass0,
588  &outer_src, &outer_dst);
589  }
590  }
591  else
592  {
593  /*
594  * this update could happen simultaneoulsy from multiple
595  * workers but that's ok we are not interested in being
596  * very accurate.
597  */
598  t0 = 0;
599  ge0->ge_last_time = time_now;
600  }
601  }
602  trace:
603  if (PREDICT_FALSE ((b0->flags & VLIB_BUFFER_IS_TRACED)))
604  {
606 
607  t = vlib_add_trace (vm, node, b0, sizeof (*t));
608  if (FIB_PROTOCOL_IP6 == fproto && ip6_0)
609  ip46_address_set_ip6 (&t->ip, &ip6_0->src_address);
610  if (FIB_PROTOCOL_IP4 == fproto && ip4_0)
611  ip46_address_set_ip4 (&t->ip, &ip4_0->src_address);
612  t->new = (NULL == ge0);
613  t->throttled = t0;
614  t->sw_if_index = sw_if_index0;
615  t->sclass = sclass0;
616  }
617 
618  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
619  to_next, n_left_to_next,
620  bi0, next0);
621  }
622 
623  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
624  }
625 
626  return frame->n_vectors;
627 }
628 
629 /* packet trace format function */
630 static u8 *
631 format_gbp_learn_l3_trace (u8 * s, va_list * args)
632 {
633  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
634  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
635  gbp_learn_l3_trace_t *t = va_arg (*args, gbp_learn_l3_trace_t *);
636 
637  s = format (s, "new:%d throttled:%d ip:%U itf:%d sclass:%d",
638  t->new, t->throttled,
640  t->sclass);
641 
642  return s;
643 }
644 
646  vlib_node_runtime_t * node,
647  vlib_frame_t * frame)
648 {
649  return (gbp_learn_l3 (vm, node, frame, FIB_PROTOCOL_IP4));
650 }
651 
653  vlib_node_runtime_t * node,
654  vlib_frame_t * frame)
655 {
656  return (gbp_learn_l3 (vm, node, frame, FIB_PROTOCOL_IP6));
657 }
658 
659 /* *INDENT-OFF* */
661  .name = "gbp-learn-ip4",
662  .vector_size = sizeof (u32),
663  .format_trace = format_gbp_learn_l3_trace,
664  .type = VLIB_NODE_TYPE_INTERNAL,
665 };
666 
667 VNET_FEATURE_INIT (gbp_learn_ip4, static) =
668 {
669  .arc_name = "ip4-unicast",
670  .node_name = "gbp-learn-ip4",
671 };
672 
674  .name = "gbp-learn-ip6",
675  .vector_size = sizeof (u32),
676  .format_trace = format_gbp_learn_l3_trace,
677  .type = VLIB_NODE_TYPE_INTERNAL,
678 };
679 
680 VNET_FEATURE_INIT (gbp_learn_ip6, static) =
681 {
682  .arc_name = "ip6-unicast",
683  .node_name = "gbp-learn-ip6",
684 };
685 
686 /* *INDENT-ON* */
687 
688 /*
689  * fd.io coding-style-patch-verification: ON
690  *
691  * Local Variables:
692  * eval: (c-set-style "gnu")
693  * End:
694  */
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:124
static void gbp_learn_l2_cp(const gbp_learn_l2_t *gl2)
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
Definition: vlib_api_cli.c:862
static gbp_bridge_domain_t * gbp_bridge_domain_get_by_bd_index(u32 bd_index)
f64 ge_last_time
The last time a packet from seen from this end point.
Definition: gbp_endpoint.h:210
u16 sclass_t
Definition: gbp_types.h:24
A Group Based Policy Endpoint.
Definition: gbp_endpoint.h:187
#define CLIB_UNUSED(x)
Definition: clib.h:82
vlib_node_registration_t gbp_learn_l2_node
(constructor) VLIB_REGISTER_NODE (gbp_learn_l2_node)
gbp_endpoint_fwd_t ge_fwd
Definition: gbp_endpoint.h:205
ip4_address_t src_address
Definition: ip4_packet.h:170
struct gbp_learn_l2_trace_t_ gbp_learn_l2_trace_t
per-packet trace data
#define vnet_buffer2(b)
Definition: buffer.h:428
struct gbp_learn_l3_t_ gbp_learn_l3_t
mac_address_t mac
#define clib_memcpy_fast(a, b, c)
Definition: string.h:81
#define NULL
Definition: clib.h:58
gbp_learn_next_t
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:255
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
u8 src_address[6]
Definition: packet.h:56
A bridge Domain Representation.
u32 thread_index
Definition: main.h:197
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:522
format_function_t format_ip46_address
Definition: format.h:61
static void gbp_learn_l3_cp(const gbp_learn_l3_t *gl3)
Grouping of global data for the GBP source EPG classification feature.
Definition: gbp_learn.h:35
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
#define VLIB_NODE_FN(node)
Definition: node.h:201
ip46_address_t outer_dst
per-packet trace data
ip6_address_t src_address
Definition: ip6_packet.h:385
static u32 ip6_address_hash_to_u32(const ip6_address_t *a)
Definition: ip6_packet.h:358
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
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)
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
double f64
Definition: types.h:142
gbp_learn_main_t gbp_learn_main
Definition: gbp_learn.c:22
throttle_t gl_l3_throttle
Definition: gbp_learn.h:51
static_always_inline gbp_endpoint_t * gbp_endpoint_find_ip4(const ip4_address_t *ip, u32 fib_index)
Definition: gbp_endpoint.h:311
gbp_bridge_domain_flags_t gb_flags
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)
enum gbp_bridge_domain_flags_t_ gbp_bridge_domain_flags_t
Bridge Domain Flags.
ethernet_arp_ip4_over_ethernet_address_t ip4_over_ethernet[2]
Definition: arp_packet.h:141
#define always_inline
Definition: clib.h:98
u32 gl_l2_input_feat_next[32]
Next nodes for L2 output features.
Definition: gbp_learn.h:40
ip4_address_t dst_address
Definition: ip4_packet.h:170
struct gbp_learn_l3_trace_t_ gbp_learn_l3_trace_t
per-packet trace data
static_always_inline gbp_endpoint_t * gbp_endpoint_find_mac(const u8 *mac, u32 bd_index)
Definition: gbp_endpoint.h:276
void vl_api_rpc_call_main_thread(void *fp, u8 *data, u32 data_length)
Definition: vlib_api.c:623
vlib_node_registration_t gbp_learn_ip6_node
(constructor) VLIB_REGISTER_NODE (gbp_learn_ip6_node)
unsigned int u32
Definition: types.h:88
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)
ip46_address_t outer_src
static_always_inline void mac_address_from_bytes(mac_address_t *mac, const u8 *bytes)
Definition: mac_address.h:92
vlib_node_registration_t gbp_learn_ip4_node
(constructor) VLIB_REGISTER_NODE (gbp_learn_ip4_node)
ip46_address_t outer_src
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)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:229
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
static u8 * format_gbp_learn_l3_trace(u8 *s, va_list *args)
#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
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:824
gbp_bridge_domain_flags_t gb_flags
Flags conttrolling behaviour.
static_always_inline gbp_endpoint_t * gbp_endpoint_find_ip6(const ip6_address_t *ip, u32 fib_index)
Definition: gbp_endpoint.h:336
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
u16 n_vectors
Definition: node.h:395
vlib_main_t * vm
Definition: buffer.c:312
static void gbp_learn_get_outer(const ethernet_header_t *eh0, ip4_address_t *outer_src, ip4_address_t *outer_dst)
#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
per-packet trace data
#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:465
static uword gbp_learn_l3(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, fib_protocol_t fproto)
gbp_learn_error_t
#define ip46_address_set_ip4(ip46, ip)
Definition: ip6_packet.h:90
static char * gbp_learn_error_strings[]
u8 * format_gbp_bridge_domain_flags(u8 *s, va_list *args)
throttle_t gl_l2_throttle
throttles for the DP leanring
Definition: gbp_learn.h:50
static_always_inline void ip46_address_set_ip6(ip46_address_t *dst, const ip6_address_t *src)
Definition: ip6_packet.h:106
VNET_FEATURE_INIT(gbp_learn_ip4, static)
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
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)
#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
static u8 * format_gbp_learn_l2_trace(u8 *s, va_list *args)
VLIB buffer representation.
Definition: buffer.h:102
u64 uword
Definition: types.h:112
struct gbp_learn_l2_t_ gbp_learn_l2_t
ip46_address_t ip
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:274
#define foreach_gbp_learn
#define vnet_buffer(b)
Definition: buffer.h:369
#define GBP_LEARN_DBG(...)
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:123
#define ip46_address_is_zero(ip46)
Definition: ip6_packet.h:93
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:85
Definition: defs.h:46
static int throttle_check(throttle_t *t, u32 thread_index, u64 hash, u64 seed)
Definition: throttle.h:54
ip46_address_t outer_dst