FD.io VPP  v19.01.3-6-g70449b9b9
Vector Packet Processing
gbp_vxlan.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_vxlan.h>
17 #include <plugins/gbp/gbp_itf.h>
18 #include <plugins/gbp/gbp_learn.h>
21 
23 #include <vlibmemory/api.h>
24 #include <vnet/fib/fib_table.h>
25 
26 /**
27  * A reference to a VXLAN-GBP tunnel created as a child/dependent tunnel
28  * of the tempplate GBP-VXLAN tunnel
29  */
30 typedef struct vxlan_tunnel_ref_t_
31 {
38 
39 /**
40  * DB of added tunnels
41  */
43 
44 /**
45  * Logger
46  */
48 
49 /**
50  * Pool of template tunnels
51  */
53 
54 /**
55  * Pool of child tunnels
56  */
58 
59 /**
60  * DB of template interfaces by SW interface index
61  */
63 
64 /**
65  * DB of child interfaces by SW interface index
66  */
68 
69 
71 #define _(n,s) [GBP_VXLAN_TUN_##n] = s,
73 #undef _
74 };
75 
76 #define GBP_VXLAN_TUN_DBG(...) \
77  vlib_log_debug (gt_logger, __VA_ARGS__);
78 
79 
80 
83 {
84  return (pool_elt_at_index (gbp_vxlan_tunnel_pool, gti));
85 }
86 
87 static vxlan_tunnel_ref_t *
89 {
90  return (pool_elt_at_index (vxlan_tunnel_ref_pool, vxri));
91 }
92 
93 static u8 *
94 format_vxlan_tunnel_ref (u8 * s, va_list * args)
95 {
96  index_t vxri = va_arg (*args, u32);
97  vxlan_tunnel_ref_t *vxr;
98 
99  vxr = vxlan_tunnel_ref_get (vxri);
100 
101  s = format (s, "[%U locks:%d]", format_vnet_sw_if_index_name,
102  vnet_get_main (), vxr->vxr_sw_if_index, vxr->vxr_locks);
103 
104  return (s);
105 }
106 
107 static u32
109  u32 vni,
110  const ip46_address_t * src, const ip46_address_t * dst)
111 {
113  .is_add = 1,
114  .is_ip6 = !ip46_address_is_ip4 (src),
115  .vni = vni,
116  .src = *src,
117  .dst = *dst,
118  .instance = ~0,
119  .mode = (GBP_VXLAN_TUN_L2 == gt->gt_layer ?
121  };
122  vxlan_tunnel_ref_t *vxr;
124  index_t vxri;
125  int rv;
126 
127  sw_if_index = ~0;
128  rv = vnet_vxlan_gbp_tunnel_add_del (&args, &sw_if_index);
129 
130  if (VNET_API_ERROR_TUNNEL_EXIST == rv)
131  {
133 
134  vxr = vxlan_tunnel_ref_get (vxri);
135  vxr->vxr_locks++;
136  }
137  else if (0 == rv)
138  {
139  ASSERT (~0 != sw_if_index);
140  GBP_VXLAN_TUN_DBG ("add-dep:%U %U %U %d", format_vnet_sw_if_index_name,
141  vnet_get_main (), sw_if_index,
144 
145  pool_get_zero (vxlan_tunnel_ref_pool, vxr);
146 
147  vxri = (vxr - vxlan_tunnel_ref_pool);
148  vxr->vxr_parent = gt - gbp_vxlan_tunnel_pool;
150  vxr->vxr_locks = 1;
151  vxr->vxr_layer = gt->gt_layer;
152 
153  /*
154  * store the child both on the parent's list and the global DB
155  */
156  vec_add1 (gt->gt_tuns, vxri);
157 
161 
162  if (GBP_VXLAN_TUN_L2 == vxr->vxr_layer)
163  {
165  gt->gt_bd_index);
166 
168  L2OUTPUT_FEAT_GBP_POLICY_MAC);
170  L2INPUT_FEAT_GBP_LEARN);
171  }
172  else
173  {
174  const gbp_route_domain_t *grd;
175  fib_protocol_t fproto;
176 
177  grd = gbp_route_domain_get (gt->gt_grd);
178 
179  FOR_EACH_FIB_IP_PROTOCOL (fproto)
180  ip_table_bind (fproto, vxr->vxr_sw_if_index,
181  grd->grd_table_id[fproto], 1);
182 
184  }
185  }
186 
187  return (sw_if_index);
188 }
189 
190 u32
192 {
193  ASSERT ((sw_if_index < vec_len (vxlan_tunnel_ref_db)) &&
194  (INDEX_INVALID != vxlan_tunnel_ref_db[sw_if_index]));
195 
196  gbp_vxlan_tunnel_t *gt;
197  vxlan_tunnel_ref_t *vxr;
198 
199  vxr = vxlan_tunnel_ref_get (vxlan_tunnel_ref_db[sw_if_index]);
200  gt = gbp_vxlan_tunnel_get (vxr->vxr_parent);
201 
202  return (gt->gt_sw_if_index);
203 }
204 
207 {
208  if (sw_if_index < vec_len (vxlan_tunnel_ref_db) &&
209  INDEX_INVALID != vxlan_tunnel_ref_db[sw_if_index])
210  {
211  return (VXLAN_GBP_TUNNEL);
212  }
213  else if (sw_if_index < vec_len (gbp_vxlan_tunnel_db) &&
214  INDEX_INVALID != gbp_vxlan_tunnel_db[sw_if_index])
215  {
216  return (GBP_VXLAN_TEMPLATE_TUNNEL);
217  }
218 
219  ASSERT (0);
220  return (GBP_VXLAN_TEMPLATE_TUNNEL);
221 }
222 
223 u32
225  const ip46_address_t * src,
226  const ip46_address_t * dst)
227 {
228  gbp_vxlan_tunnel_t *gt;
229  index_t gti;
230 
232 
233  if (INDEX_INVALID == gti)
234  return (~0);
235 
236  gt = pool_elt_at_index (gbp_vxlan_tunnel_pool, gti);
237 
238  return (gdb_vxlan_dep_add (gt, gt->gt_vni, src, dst));
239 }
240 
241 static void
243 {
244  vxlan_tunnel_ref_t *vxr;
245  gbp_vxlan_tunnel_t *gt;
246  u32 pos;
247 
248  vxr = vxlan_tunnel_ref_get (vxri);
249  gt = gbp_vxlan_tunnel_get (vxr->vxr_parent);
250 
251  GBP_VXLAN_TUN_DBG ("del-dep:%U", format_vxlan_tunnel_ref, vxri);
252 
254  pos = vec_search (gt->gt_tuns, vxri);
255 
256  ASSERT (~0 != pos);
257  vec_del1 (gt->gt_tuns, pos);
258 
259  if (GBP_VXLAN_TUN_L2 == vxr->vxr_layer)
260  {
265  gbp_itf_unlock (vxr->vxr_itf);
266  }
267  else
268  {
269  fib_protocol_t fproto;
270 
271  FOR_EACH_FIB_IP_PROTOCOL (fproto)
272  ip_table_bind (fproto, vxr->vxr_sw_if_index, 0, 0);
273  }
274 
276 
277  pool_put (vxlan_tunnel_ref_pool, vxr);
278 }
279 
280 void
282 {
283  vxlan_tunnel_ref_t *vxr;
284  index_t vxri;
285 
287 
288  ASSERT (vxri != INDEX_INVALID);
289 
290  vxr = vxlan_tunnel_ref_get (vxri);
291  vxr->vxr_locks--;
292 
293  if (0 == vxr->vxr_locks)
294  {
295  gdb_vxlan_dep_del (vxri);
296  }
297 }
298 
299 void
301 {
302  vxlan_tunnel_ref_t *vxr;
303  index_t vxri;
304 
306 
307  ASSERT (vxri != INDEX_INVALID);
308 
309  vxr = vxlan_tunnel_ref_get (vxri);
310  vxr->vxr_locks++;
311 }
312 
313 #define foreach_gbp_vxlan_input_next \
314  _(DROP, "error-drop") \
315  _(L2_INPUT, "l2-input") \
316  _(IP4_INPUT, "ip4-input") \
317  _(IP6_INPUT, "ip6-input")
318 
319 typedef enum
320 {
321 #define _(s,n) GBP_VXLAN_INPUT_NEXT_##s,
323 #undef _
326 
327 #define foreach_gbp_vxlan_error \
328  _(DECAPPED, "decapped") \
329  _(LEARNED, "learned")
330 
331 typedef enum
332 {
333 #define _(s,n) GBP_VXLAN_ERROR_##s,
335 #undef _
338 
339 static char *gbp_vxlan_error_strings[] = {
340 #define _(n,s) s,
342 #undef _
343 };
344 
345 typedef struct gbp_vxlan_trace_t_
346 {
353 
354 
355 static uword
357  vlib_node_runtime_t * node,
358  vlib_frame_t * from_frame, u8 is_ip4)
359 {
360  u32 n_left_to_next, n_left_from, next_index, *to_next, *from;
361 
362  next_index = 0;
363  from = vlib_frame_vector_args (from_frame);
364  n_left_from = from_frame->n_vectors;
365 
366  while (n_left_from > 0)
367  {
368 
369  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
370 
371  while (n_left_from > 0 && n_left_to_next > 0)
372  {
373  vxlan_gbp_header_t *vxlan_gbp0;
375  gbp_vxlan_tunnel_t *gt0;
376  vlib_buffer_t *b0;
377  u32 bi0, vni0;
378  uword *p;
379 
380  bi0 = to_next[0] = from[0];
381  from += 1;
382  to_next += 1;
383  n_left_from -= 1;
384  n_left_to_next -= 1;
385  next0 = GBP_VXLAN_INPUT_NEXT_DROP;
386 
387  b0 = vlib_get_buffer (vm, bi0);
388  vxlan_gbp0 =
390 
391  vni0 = vxlan_gbp_get_vni (vxlan_gbp0);
392  p = hash_get (gv_db, vni0);
393 
394  if (PREDICT_FALSE (NULL == p))
395  {
396  gt0 = NULL;
397  next0 = GBP_VXLAN_INPUT_NEXT_DROP;
398  }
399  else
400  {
401  gt0 = gbp_vxlan_tunnel_get (p[0]);
402 
403  vnet_buffer (b0)->sw_if_index[VLIB_RX] = gt0->gt_sw_if_index;
404 
405  if (GBP_VXLAN_TUN_L2 == gt0->gt_layer)
406  /*
407  * An L2 layer tunnel goes into the BD
408  */
409  next0 = GBP_VXLAN_INPUT_NEXT_L2_INPUT;
410  else
411  {
412  /*
413  * An L3 layer tunnel needs to strip the L2 header
414  * an inject into the RD
415  */
416  ethernet_header_t *e0;
417  u16 type0;
418 
419  e0 = vlib_buffer_get_current (b0);
420  type0 = clib_net_to_host_u16 (e0->type);
421  switch (type0)
422  {
423  case ETHERNET_TYPE_IP4:
424  next0 = GBP_VXLAN_INPUT_NEXT_IP4_INPUT;
425  break;
426  case ETHERNET_TYPE_IP6:
427  next0 = GBP_VXLAN_INPUT_NEXT_IP6_INPUT;
428  break;
429  default:
430  goto trace;
431  }
432  vlib_buffer_advance (b0, sizeof (*e0));
433  }
434  }
435 
436  trace:
437  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
438  {
439  gbp_vxlan_trace_t *tr;
440 
441  tr = vlib_add_trace (vm, node, b0, sizeof (*tr));
442  tr->dropped = (next0 == GBP_VXLAN_INPUT_NEXT_DROP);
443  tr->vni = vni0;
444  tr->sw_if_index = (gt0 ? gt0->gt_sw_if_index : ~0);
445  tr->flags = vxlan_gbp_get_gpflags (vxlan_gbp0);
446  tr->sclass = vxlan_gbp_get_sclass (vxlan_gbp0);
447  }
448 
449  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
450  to_next, n_left_to_next,
451  bi0, next0);
452  }
453 
454  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
455  }
456 
457  return from_frame->n_vectors;
458 }
459 
460 static u8 *
461 format_gbp_vxlan_rx_trace (u8 * s, va_list * args)
462 {
463  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
464  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
465  gbp_vxlan_trace_t *t = va_arg (*args, gbp_vxlan_trace_t *);
466 
467  s = format (s, "vni:%d dropped:%d rx:%d sclass:%d flags:%U",
468  t->vni, t->dropped, t->sw_if_index,
470 
471  return (s);
472 }
473 
474 static uword
476  vlib_node_runtime_t * node, vlib_frame_t * from_frame)
477 {
478  return gbp_vxlan_decap (vm, node, from_frame, 1);
479 }
480 
481 /* *INDENT-OFF* */
483 {
484  .function = gbp_vxlan4_decap,
485  .name = "gbp-vxlan4",
486  .vector_size = sizeof (u32),
487  .n_errors = GBP_VXLAN_N_ERROR,
488  .error_strings = gbp_vxlan_error_strings,
489  .n_next_nodes = GBP_VXLAN_INPUT_N_NEXT,
490  .format_trace = format_gbp_vxlan_rx_trace,
491  .next_nodes = {
492 #define _(s,n) [GBP_VXLAN_INPUT_NEXT_##s] = n,
494 #undef _
495  },
496 };
498 
499 /* *INDENT-ON* */
500 
501 void
503 {
504  gbp_vxlan_tunnel_t *gt;
505 
506  /* *INDENT-OFF* */
507  pool_foreach (gt, gbp_vxlan_tunnel_pool,
508  ({
509  if (WALK_CONTINUE != cb(gt, ctx))
510  break;
511  }));
512  /* *INDENT-ON* */
513 }
514 
515 static walk_rc_t
517 {
519  gt - gbp_vxlan_tunnel_pool);
520 
521  return (WALK_CONTINUE);
522 }
523 
524 static u8 *
525 format_gbp_vxlan_tunnel_name (u8 * s, va_list * args)
526 {
527  u32 dev_instance = va_arg (*args, u32);
528 
529  return format (s, "gbp-vxlan-%d", dev_instance);
530 }
531 
532 u8 *
533 format_gbp_vxlan_tunnel_layer (u8 * s, va_list * args)
534 {
536  s = format (s, "%s", gbp_vxlan_tunnel_layer_strings[gl]);
537 
538  return (s);
539 }
540 
541 u8 *
542 format_gbp_vxlan_tunnel (u8 * s, va_list * args)
543 {
544  u32 dev_instance = va_arg (*args, u32);
545  CLIB_UNUSED (int verbose) = va_arg (*args, int);
546  gbp_vxlan_tunnel_t *gt = gbp_vxlan_tunnel_get (dev_instance);
547  index_t *vxri;
548 
549  s = format (s, "GBP VXLAN tunnel: hw:%d sw:%d vni:%d %U",
550  gt->gt_hw_if_index, gt->gt_sw_if_index, gt->gt_vni,
552  if (GBP_VXLAN_TUN_L2 == gt->gt_layer)
553  s = format (s, " BD:%d bd-index:%d", gt->gt_bd_rd_id, gt->gt_bd_index);
554  else
555  s = format (s, " RD:%d fib-index:[%d,%d]",
556  gt->gt_bd_rd_id,
559 
560  s = format (s, " children:[");
561  vec_foreach (vxri, gt->gt_tuns)
562  {
563  s = format (s, "%U, ", format_vxlan_tunnel_ref, *vxri);
564  }
565  s = format (s, "]");
566 
567  return s;
568 }
569 
570 typedef struct gbp_vxlan_tx_trace_t_
571 {
574 
575 u8 *
576 format_gbp_vxlan_tx_trace (u8 * s, va_list * args)
577 {
578  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
579  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
580  gbp_vxlan_tx_trace_t *t = va_arg (*args, gbp_vxlan_tx_trace_t *);
581 
582  s = format (s, "GBP-VXLAN: vni:%d", t->vni);
583 
584  return (s);
585 }
586 
587 clib_error_t *
589  u32 hw_if_index, u32 flags)
590 {
592  u32 ti;
593 
594  hi = vnet_get_hw_interface (vnm, hw_if_index);
595 
596  if (NULL == gbp_vxlan_tunnel_db ||
598  return (NULL);
599 
601 
602  if (~0 == ti)
603  /* not one of ours */
604  return (NULL);
605 
607  vnet_hw_interface_set_flags (vnm, hw_if_index,
609  else
610  vnet_hw_interface_set_flags (vnm, hw_if_index, 0);
611 
612  return (NULL);
613 }
614 
615 static uword
617  vlib_node_runtime_t * node, vlib_frame_t * frame)
618 {
619  clib_warning ("you shouldn't be here, leaking buffers...");
620  return frame->n_vectors;
621 }
622 
623 /* *INDENT-OFF* */
624 VNET_DEVICE_CLASS (gbp_vxlan_device_class) = {
625  .name = "GBP VXLAN tunnel-template",
626  .format_device_name = format_gbp_vxlan_tunnel_name,
627  .format_device = format_gbp_vxlan_tunnel,
628  .format_tx_trace = format_gbp_vxlan_tx_trace,
629  .admin_up_down_function = gbp_vxlan_interface_admin_up_down,
630  .tx_function = gbp_vxlan_interface_tx,
631 };
632 
633 VNET_HW_INTERFACE_CLASS (gbp_vxlan_hw_interface_class) = {
634  .name = "GBP-VXLAN",
636 };
637 /* *INDENT-ON* */
638 
639 int
641  u32 bd_rd_id, u32 * sw_if_indexp)
642 {
643  gbp_vxlan_tunnel_t *gt;
644  index_t gti;
645  uword *p;
646  int rv;
647 
648  rv = 0;
649  p = hash_get (gv_db, vni);
650 
651  GBP_VXLAN_TUN_DBG ("add: %d %d %d", vni, layer, bd_rd_id);
652 
653  if (NULL == p)
654  {
657  index_t gbi, grdi;
658  vnet_main_t *vnm;
659 
660  gbi = grdi = INDEX_INVALID;
661 
662  if (layer == GBP_VXLAN_TUN_L2)
663  {
664  gbi = gbp_bridge_domain_find_and_lock (bd_rd_id);
665 
666  if (INDEX_INVALID == gbi)
667  {
668  return (VNET_API_ERROR_BD_NOT_MODIFIABLE);
669  }
670  }
671  else
672  {
673  grdi = gbp_route_domain_find_and_lock (bd_rd_id);
674 
675  if (INDEX_INVALID == grdi)
676  {
677  return (VNET_API_ERROR_NO_SUCH_FIB);
678  }
679  }
680 
681  vnm = vnet_get_main ();
682  pool_get (gbp_vxlan_tunnel_pool, gt);
683  gti = gt - gbp_vxlan_tunnel_pool;
684 
685  gt->gt_vni = vni;
686  gt->gt_layer = layer;
687  gt->gt_bd_rd_id = bd_rd_id;
689  gbp_vxlan_device_class.index,
690  gti,
691  gbp_vxlan_hw_interface_class.index,
692  gti);
693 
694  hi = vnet_get_hw_interface (vnm, gt->gt_hw_if_index);
695 
696  gt->gt_sw_if_index = hi->sw_if_index;
697 
698  /* don't flood packets in a BD to these interfaces */
699  si = vnet_get_sw_interface (vnm, gt->gt_sw_if_index);
701 
702  if (layer == GBP_VXLAN_TUN_L2)
703  {
705 
706  gb = gbp_bridge_domain_get (gbi);
707 
708  gt->gt_gbd = gbi;
709  gt->gt_bd_index = gb->gb_bd_id;
711  /* set it up as a GBP interface */
713  gt->gt_bd_index);
715  }
716  else
717  {
718  gbp_route_domain_t *grd;
719  fib_protocol_t fproto;
720 
721  grd = gbp_route_domain_get (grdi);
722 
723  gt->gt_grd = grdi;
725 
727 
730 
731  FOR_EACH_FIB_IP_PROTOCOL (fproto)
732  {
733  gt->gt_fib_index[fproto] = grd->grd_fib_index[fproto];
734 
735  ip_table_bind (fproto, gt->gt_sw_if_index,
736  grd->grd_table_id[fproto], 1);
737  }
738  }
739 
740  /*
741  * save the tunnel by VNI and by sw_if_index
742  */
743  hash_set (gv_db, vni, gti);
744 
747 
748  if (sw_if_indexp)
749  *sw_if_indexp = gt->gt_sw_if_index;
750 
752  }
753  else
754  {
755  gti = p[0];
756  rv = VNET_API_ERROR_IF_ALREADY_EXISTS;
757  }
758 
759  GBP_VXLAN_TUN_DBG ("add: %U", format_gbp_vxlan_tunnel, gti);
760 
761  return (rv);
762 }
763 
764 int
766 {
767  gbp_vxlan_tunnel_t *gt;
768  uword *p;
769 
770  p = hash_get (gv_db, vni);
771 
772  if (NULL != p)
773  {
774  vnet_main_t *vnm;
775 
776  vnm = vnet_get_main ();
777  gt = gbp_vxlan_tunnel_get (p[0]);
778 
780 
782  gt - gbp_vxlan_tunnel_pool);
783 
784  gbp_endpoint_flush (GBP_ENDPOINT_SRC_DP, gt->gt_sw_if_index);
785  ASSERT (0 == vec_len (gt->gt_tuns));
786  vec_free (gt->gt_tuns);
787 
788  if (GBP_VXLAN_TUN_L2 == gt->gt_layer)
789  {
791  gbp_itf_unlock (gt->gt_itf);
793  }
794  else
795  {
796  fib_protocol_t fproto;
797 
798  FOR_EACH_FIB_IP_PROTOCOL (fproto)
799  ip_table_bind (fproto, gt->gt_sw_if_index, 0, 0);
800 
803 
806  }
807 
810 
811  hash_unset (gv_db, vni);
813 
814  pool_put (gbp_vxlan_tunnel_pool, gt);
815  }
816  else
817  return VNET_API_ERROR_NO_SUCH_ENTRY;
818 
819  return (0);
820 }
821 
822 static clib_error_t *
824  unformat_input_t * input, vlib_cli_command_t * cmd)
825 {
827 
828  return (NULL);
829 }
830 
831 /*?
832  * Show Group Based Policy VXLAN tunnels
833  *
834  * @cliexpar
835  * @cliexstart{show gbp vxlan}
836  * @cliexend
837  ?*/
838 /* *INDENT-OFF* */
839 VLIB_CLI_COMMAND (gbp_vxlan_show_node, static) = {
840  .path = "show gbp vxlan",
841  .short_help = "show gbp vxlan\n",
842  .function = gbp_vxlan_show,
843 };
844 /* *INDENT-ON* */
845 
846 static clib_error_t *
848 {
849  u32 slot4;
850 
851  /*
852  * insert ourselves into the VXLAN-GBP arc to collect the no-tunnel
853  * packets.
854  */
855  slot4 = vlib_node_add_next_with_slot (vm,
856  vxlan4_gbp_input_node.index,
857  gbp_vxlan4_input_node.index,
858  VXLAN_GBP_INPUT_NEXT_NO_TUNNEL);
859  ASSERT (slot4 == VXLAN_GBP_INPUT_NEXT_NO_TUNNEL);
860 
861  /* slot6 = vlib_node_add_next_with_slot (vm, */
862  /* vxlan6_gbp_input_node.index, */
863  /* gbp_vxlan6_input_node.index, */
864  /* VXLAN_GBP_INPUT_NEXT_NO_TUNNEL); */
865  /* ASSERT (slot6 == VXLAN_GBP_INPUT_NEXT_NO_TUNNEL); */
866 
867  gt_logger = vlib_log_register_class ("gbp", "tun");
868 
869  return (NULL);
870 }
871 
873 
874 /*
875  * fd.io coding-style-patch-verification: ON
876  *
877  * Local Variables:
878  * eval: (c-set-style "gnu")
879  * End:
880  */
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
Definition: log.c:227
static char * gbp_vxlan_error_strings[]
Definition: gbp_vxlan.c:339
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:439
A real VXLAN-GBP tunnel (from vnet/vxlan-gbp/...)
Definition: gbp_vxlan.h:102
vmrglw vmrglh hi
u32 grd_table_id[FIB_PROTOCOL_IP_MAX]
VNET_DEVICE_CLASS(gbp_vxlan_device_class)
void gbp_itf_set_l2_input_feature(index_t gii, index_t useri, l2input_feat_masks_t feats)
Definition: gbp_itf.c:102
u32 gbp_vxlan_tunnel_clone_and_lock(u32 sw_if_index, const ip46_address_t *src, const ip46_address_t *dst)
Definition: gbp_vxlan.c:224
void gbp_route_domain_unlock(index_t index)
u32 grd_vni_sw_if_index
The RD&#39;s VNI interface on which packets from unkown endpoints arrive.
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
#define hash_set(h, key, value)
Definition: hash.h:255
u32 flags
Definition: vhost_user.h:115
vl_api_address_t src
Definition: vxlan_gbp.api:32
#define CLIB_UNUSED(x)
Definition: clib.h:82
static walk_rc_t gbp_vxlan_tunnel_show_one(gbp_vxlan_tunnel_t *gt, void *ctx)
Definition: gbp_vxlan.c:516
#define hash_unset(h, key)
Definition: hash.h:261
#define GBP_VXLAN_TUN_DBG(...)
Definition: gbp_vxlan.c:76
vnet_main_t * vnet_get_main(void)
Definition: misc.c:47
#define pool_get_zero(P, E)
Allocate an object E from a pool P and zero it.
Definition: pool.h:239
u8 * format_gbp_vxlan_tx_trace(u8 *s, va_list *args)
Definition: gbp_vxlan.c:576
#define NULL
Definition: clib.h:58
int vnet_vxlan_gbp_tunnel_add_del(vnet_vxlan_gbp_tunnel_add_del_args_t *a, u32 *sw_if_indexp)
Definition: vxlan_gbp.c:383
A bridge Domain Representation.
void vxlan_gbp_unregister_udp_ports(void)
Definition: vxlan_gbp.c:365
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Definition: dpo.h:41
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:525
vlib_node_registration_t gbp_vxlan4_input_node
(constructor) VLIB_REGISTER_NODE (gbp_vxlan4_input_node)
Definition: gbp_vxlan.c:482
void gbp_vxlan_walk(gbp_vxlan_cb_t cb, void *ctx)
Definition: gbp_vxlan.c:502
format_function_t format_ip46_address
Definition: format.h:61
static clib_error_t * gbp_vxlan_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: gbp_vxlan.c:823
static u8 * format_gbp_vxlan_tunnel_name(u8 *s, va_list *args)
Definition: gbp_vxlan.c:525
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
u8 * format_gbp_vxlan_tunnel(u8 *s, va_list *args)
Definition: gbp_vxlan.c:542
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:236
static gbp_bridge_domain_t * gbp_bridge_domain_get(index_t i)
format_function_t format_vnet_sw_if_index_name
unsigned char u8
Definition: types.h:56
gbp_vxlan_tunnel_t * gbp_vxlan_tunnel_pool
Pool of template tunnels.
Definition: gbp_vxlan.c:52
static u32 gdb_vxlan_dep_add(gbp_vxlan_tunnel_t *gt, u32 vni, const ip46_address_t *src, const ip46_address_t *dst)
Definition: gbp_vxlan.c:108
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
void gbp_itf_unlock(index_t gii)
Definition: gbp_itf.c:81
int ip_table_bind(fib_protocol_t fproto, u32 sw_if_index, u32 table_id, u8 is_api)
gbp_vxlan_tunnel_layer_t vxr_layer
Definition: gbp_vxlan.c:36
struct gbp_vxlan_trace_t_ gbp_vxlan_trace_t
enum walk_rc_t_ walk_rc_t
Walk return code.
index_t * gt_tuns
list of child vxlan-gbp tunnels built from this template
Definition: gbp_vxlan.h:84
void vxlan_gbp_tunnel_unlock(u32 sw_if_index)
Definition: gbp_vxlan.c:281
vnet_flood_class_t flood_class
Definition: interface.h:731
u8 * format_gbp_vxlan_tunnel_layer(u8 *s, va_list *args)
Definition: gbp_vxlan.c:533
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:490
#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
u8 * format_vxlan_gbp_header_gpflags(u8 *s, va_list *args)
static u8 * format_gbp_vxlan_rx_trace(u8 *s, va_list *args)
Definition: gbp_vxlan.c:461
static u8 * format_vxlan_tunnel_ref(u8 *s, va_list *args)
Definition: gbp_vxlan.c:94
index_t vxr_parent
Definition: gbp_vxlan.c:35
static gbp_vxlan_tunnel_t * gbp_vxlan_tunnel_get(index_t gti)
Definition: gbp_vxlan.c:82
uword vlib_node_add_next_with_slot(vlib_main_t *vm, uword node_index, uword next_node_index, uword slot)
Definition: node.c:205
gbp_vxlan_input_error_t
Definition: gbp_vxlan.c:331
static uword gbp_vxlan_decap(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, u8 is_ip4)
Definition: gbp_vxlan.c:356
unsigned int u32
Definition: types.h:88
#define vec_search(v, E)
Search a vector for the index of the entry that matches.
Definition: vec.h:944
#define foreach_gbp_vxlan_error
Definition: gbp_vxlan.c:327
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
Definition: interface.c:740
struct gbp_vxlan_tx_trace_t_ gbp_vxlan_tx_trace_t
gbp_vxlan_input_next_t
Definition: gbp_vxlan.c:319
static vxlan_gbp_gpflags_t vxlan_gbp_get_gpflags(vxlan_gbp_header_t *h)
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
Definition: node.h:223
#define hash_get(h, key)
Definition: hash.h:249
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:511
void gbp_learn_enable(u32 sw_if_index, gbb_learn_mode_t mode)
Definition: gbp_learn.c:706
u32 gt_bd_index
BD index (if L2)
Definition: gbp_vxlan.h:57
void ip4_sw_interface_enable_disable(u32 sw_if_index, u32 is_enable)
Definition: ip4_forward.c:524
walk_rc_t(* gbp_vxlan_cb_t)(gbp_vxlan_tunnel_t *gt, void *ctx)
Definition: gbp_vxlan.h:119
long ctx[MAX_CONNS]
Definition: main.c:144
struct _unformat_input_t unformat_input_t
unsigned short u16
Definition: types.h:57
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:214
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:286
This is the object type deifend above.
Definition: gbp_vxlan.h:97
#define PREDICT_FALSE(x)
Definition: clib.h:111
#define vec_del1(v, i)
Delete the element at index I.
Definition: vec.h:808
u32 bd_rd_id
Definition: gbp.api:350
u32 gb_bd_id
Bridge-domain ID.
void gbp_itf_set_l2_output_feature(index_t gii, index_t useri, l2output_feat_masks_t feats)
Definition: gbp_itf.c:146
#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:338
#define ip46_address_is_ip4(ip46)
Definition: ip6_packet.h:88
int gbp_vxlan_tunnel_add(u32 vni, gbp_vxlan_tunnel_layer_t layer, u32 bd_rd_id, u32 *sw_if_indexp)
Definition: gbp_vxlan.c:640
vlib_node_registration_t vxlan4_gbp_input_node
(constructor) VLIB_REGISTER_NODE (vxlan4_gbp_input_node)
Definition: decap.c:22
enum gbp_vxlan_tunnel_layer_t_ gbp_vxlan_tunnel_layer_t
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
static u16 vxlan_gbp_get_sclass(vxlan_gbp_header_t *h)
u16 n_vectors
Definition: node.h:420
vlib_main_t * vm
Definition: buffer.c:301
vl_api_address_t dst
Definition: vxlan_gbp.api:33
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:341
static u32 vxlan_gbp_get_vni(vxlan_gbp_header_t *h)
static uword gbp_vxlan4_decap(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: gbp_vxlan.c:475
u32 grd_fib_index[FIB_PROTOCOL_IP_MAX]
#define clib_warning(format, args...)
Definition: error.h:59
int gbp_vxlan_tunnel_del(u32 vni)
Definition: gbp_vxlan.c:765
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:452
index_t * gbp_vxlan_tunnel_db
DB of template interfaces by SW interface index.
Definition: gbp_vxlan.c:62
index_t gbp_bridge_domain_find_and_lock(u32 bd_id)
static clib_error_t * gbp_vxlan_init(vlib_main_t *vm)
Definition: gbp_vxlan.c:847
void gbp_endpoint_flush(gbp_endpoint_src_t src, u32 sw_if_index)
remove all learnt endpoints using the interface
void vxlan_gbp_register_udp_ports(void)
Definition: vxlan_gbp.c:347
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:155
gbp_vxlan_tunnel_layer_t gt_layer
Definition: gbp_vxlan.h:48
#define ASSERT(truth)
gbp_route_domain_t * gbp_route_domain_get(index_t i)
static vxlan_tunnel_ref_t * vxlan_tunnel_ref_get(index_t vxri)
Definition: gbp_vxlan.c:88
#define foreach_gbp_vxlan_input_next
Definition: gbp_vxlan.c:313
clib_error_t * gbp_vxlan_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: gbp_vxlan.c:588
int vnet_vxlan_gbp_tunnel_del(u32 sw_if_index)
Definition: vxlan_gbp.c:664
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:233
index_t gt_gbd
Reference to the GPB-BD.
Definition: gbp_vxlan.h:61
void vnet_delete_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
Definition: interface.c:950
vlib_log_class_t gt_logger
Logger.
Definition: gbp_vxlan.c:47
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
u32 vxlan_gbp_tunnel_get_parent(u32 sw_if_index)
Definition: gbp_vxlan.c:191
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
A route Domain Representation.
static void gdb_vxlan_dep_del(index_t vxri)
Definition: gbp_vxlan.c:242
enum gbp_vxlan_tunnel_type_t_ gbp_vxlan_tunnel_type_t
The different types of interfaces that endpoints are learned on.
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
Definition: dpo.h:47
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_interface_flags_t flags)
Definition: interface.c:504
u64 uword
Definition: types.h:112
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:244
u32 gb_vni_sw_if_index
The BD&#39;s VNI interface on which packets from unkown endpoints arrive.
u32 vni
Definition: vxlan_gbp.api:36
a point 2 point interface
Definition: interface.h:382
gbp_vxlan_tunnel_type_t gbp_vxlan_tunnel_get_type(u32 sw_if_index)
Definition: gbp_vxlan.c:206
#define FOR_EACH_FIB_IP_PROTOCOL(_item)
Definition: fib_types.h:70
void gbp_learn_disable(u32 sw_if_index, gbb_learn_mode_t mode)
Definition: gbp_learn.c:720
#define vnet_buffer(b)
Definition: buffer.h:368
GBP VXLAN (template) tunnel.
Definition: gbp_vxlan.h:38
index_t * vxlan_tunnel_ref_db
DB of child interfaces by SW interface index.
Definition: gbp_vxlan.c:67
A reference to a VXLAN-GBP tunnel created as a child/dependent tunnel of the tempplate GBP-VXLAN tunn...
Definition: gbp_vxlan.c:30
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, vnet_sw_interface_flags_t flags)
Definition: interface.c:513
#define vec_foreach(var, vec)
Vector iterator.
index_t gt_itf
gbp-itf config for this interface
Definition: gbp_vxlan.h:79
index_t gt_grd
References to the GBP-RD.
Definition: gbp_vxlan.h:72
u32 gt_bd_rd_id
The BD or RD value (depending on the layer) that the tunnel is bound to.
Definition: gbp_vxlan.h:47
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header, unspecified alignment)
Definition: vec.h:488
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
struct vxlan_tunnel_ref_t_ vxlan_tunnel_ref_t
A reference to a VXLAN-GBP tunnel created as a child/dependent tunnel of the tempplate GBP-VXLAN tunn...
void gbp_bridge_domain_unlock(index_t index)
index_t gbp_itf_add_and_lock(u32 sw_if_index, u32 bd_index)
Definition: gbp_itf.c:57
uword * gv_db
DB of added tunnels.
Definition: gbp_vxlan.c:42
static char * gbp_vxlan_tunnel_layer_strings[]
Definition: gbp_vxlan.c:70
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:762
static uword gbp_vxlan_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: gbp_vxlan.c:616
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
void ip6_sw_interface_enable_disable(u32 sw_if_index, u32 is_enable)
Definition: ip6_forward.c:142
VNET_HW_INTERFACE_CLASS(gbp_vxlan_hw_interface_class)
vxlan_tunnel_ref_t * vxlan_tunnel_ref_pool
Pool of child tunnels.
Definition: gbp_vxlan.c:57
u32 gt_fib_index[FIB_PROTOCOL_IP_MAX]
FIB inidices (if L3)
Definition: gbp_vxlan.h:68
index_t gbp_route_domain_find_and_lock(u32 rd_id)
Definition: defs.h:46
void vxlan_gbp_tunnel_lock(u32 sw_if_index)
Definition: gbp_vxlan.c:300