FD.io VPP  v18.01-8-g0eacf49
Vector Packet Processing
gtpu.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * Copyright (c) 2017 Intel and/or its affiliates.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *------------------------------------------------------------------
16  */
17 #include <stdint.h>
18 #include <net/if.h>
19 #include <sys/ioctl.h>
20 #include <inttypes.h>
21 
22 #include <vlib/vlib.h>
23 #include <vlib/unix/unix.h>
24 #include <vnet/ethernet/ethernet.h>
25 #include <vnet/fib/fib_entry.h>
26 #include <vnet/fib/fib_table.h>
27 #include <vnet/mfib/mfib_table.h>
28 #include <vnet/adj/adj_mcast.h>
29 #include <vnet/dpo/dpo.h>
30 #include <vnet/plugin/plugin.h>
31 #include <vpp/app/version.h>
32 #include <gtpu/gtpu.h>
33 
34 
36 
37 /* *INDENT-OFF* */
39  .arc_name = "ip4-unicast",
40  .node_name = "ip4-gtpu-bypass",
41  .runs_before = VNET_FEATURES ("ip4-lookup"),
42 };
43 
45  .arc_name = "ip6-unicast",
46  .node_name = "ip6-gtpu-bypass",
47  .runs_before = VNET_FEATURES ("ip6-lookup"),
48 };
49 /* *INDENT-on* */
50 
51 static u8 *
52 format_decap_next (u8 * s, va_list * args)
53 {
54  u32 next_index = va_arg (*args, u32);
55 
56  switch (next_index)
57  {
58  case GTPU_INPUT_NEXT_DROP:
59  return format (s, "drop");
60  case GTPU_INPUT_NEXT_L2_INPUT:
61  return format (s, "l2");
62  case GTPU_INPUT_NEXT_IP4_INPUT:
63  return format (s, "ip4");
64  case GTPU_INPUT_NEXT_IP6_INPUT:
65  return format (s, "ip6");
66  default:
67  return format (s, "index %d", next_index);
68  }
69  return s;
70 }
71 
72 u8 *
73 format_gtpu_tunnel (u8 * s, va_list * args)
74 {
75  gtpu_tunnel_t *t = va_arg (*args, gtpu_tunnel_t *);
76  gtpu_main_t *ngm = &gtpu_main;
77 
78  s = format (s, "[%d] src %U dst %U teid %d sw_if_index %d ",
79  t - ngm->tunnels,
82  t->teid, t->sw_if_index);
83 
85  s = format (s, "mcast_sw_if_index %d ", t->mcast_sw_if_index);
86 
87  s = format (s, "encap_fib_index %d fib_entry_index %d decap_next %U\n",
90  return s;
91 }
92 
93 static u8 *
94 format_gtpu_name (u8 * s, va_list * args)
95 {
96  u32 dev_instance = va_arg (*args, u32);
97  return format (s, "gtpu_tunnel%d", dev_instance);
98 }
99 
100 static clib_error_t *
102 {
103  u32 hw_flags = (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ?
105  vnet_hw_interface_set_flags (vnm, hw_if_index, hw_flags);
106 
107  return /* no error */ 0;
108 }
109 
110 /* *INDENT-OFF* */
111 VNET_DEVICE_CLASS (gtpu_device_class,static) = {
112  .name = "GTPU",
113  .format_device_name = format_gtpu_name,
114  .format_tx_trace = format_gtpu_encap_trace,
115  .admin_up_down_function = gtpu_interface_admin_up_down,
116 };
117 /* *INDENT-ON* */
118 
119 static u8 *
120 format_gtpu_header_with_length (u8 * s, va_list * args)
121 {
122  u32 dev_instance = va_arg (*args, u32);
123  s = format (s, "unimplemented dev %u", dev_instance);
124  return s;
125 }
126 
127 /* *INDENT-OFF* */
128 VNET_HW_INTERFACE_CLASS (gtpu_hw_class) =
129 {
130  .name = "GTPU",
131  .format_header = format_gtpu_header_with_length,
132  .build_rewrite = default_build_rewrite,
134 };
135 /* *INDENT-ON* */
136 
137 static void
139 {
140  dpo_id_t dpo = DPO_INVALID;
141  u32 encap_index = ip46_address_is_ip4 (&t->dst) ?
142  gtpu4_encap_node.index : gtpu6_encap_node.index;
145 
146  fib_entry_contribute_forwarding (t->fib_entry_index, forw_type, &dpo);
147  dpo_stack_from_node (encap_index, &t->next_dpo, &dpo);
148  dpo_reset (&dpo);
149 }
150 
151 static gtpu_tunnel_t *
153 {
154  return ((gtpu_tunnel_t *) (((char *) node) -
156 }
157 
158 /**
159  * Function definition to backwalk a FIB node -
160  * Here we will restack the new dpo of GTPU DIP to encap node.
161  */
164 {
167 }
168 
169 /**
170  * Function definition to get a FIB node from its index
171  */
172 static fib_node_t *
174 {
175  gtpu_tunnel_t *t;
176  gtpu_main_t *gtm = &gtpu_main;
177 
178  t = pool_elt_at_index (gtm->tunnels, index);
179 
180  return (&t->node);
181 }
182 
183 /**
184  * Function definition to inform the FIB node that its last lock has gone.
185  */
186 static void
188 {
189  /*
190  * The GTPU tunnel is a root of the graph. As such
191  * it never has children and thus is never locked.
192  */
193  ASSERT (0);
194 }
195 
196 /*
197  * Virtual function table registered by GTPU tunnels
198  * for participation in the FIB object graph.
199  */
200 const static fib_node_vft_t gtpu_vft = {
202  .fnv_last_lock = gtpu_tunnel_last_lock_gone,
203  .fnv_back_walk = gtpu_tunnel_back_walk,
204 };
205 
206 
207 #define foreach_copy_field \
208 _(teid) \
209 _(mcast_sw_if_index) \
210 _(encap_fib_index) \
211 _(decap_next_index) \
212 _(src) \
213 _(dst)
214 
215 static void
217 {
218  union
219  {
220  ip4_gtpu_header_t *h4;
221  ip6_gtpu_header_t *h6;
222  u8 *rw;
223  } r =
224  {
225  .rw = 0};
226  int len = is_ip6 ? sizeof *r.h6 : sizeof *r.h4;
227 
229 
230  udp_header_t *udp;
231  gtpu_header_t *gtpu;
232  /* Fixed portion of the (outer) ip header */
233  if (!is_ip6)
234  {
235  ip4_header_t *ip = &r.h4->ip4;
236  udp = &r.h4->udp;
237  gtpu = &r.h4->gtpu;
238  ip->ip_version_and_header_length = 0x45;
239  ip->ttl = 254;
240  ip->protocol = IP_PROTOCOL_UDP;
241 
242  ip->src_address = t->src.ip4;
243  ip->dst_address = t->dst.ip4;
244 
245  /* we fix up the ip4 header length and checksum after-the-fact */
246  ip->checksum = ip4_header_checksum (ip);
247  }
248  else
249  {
250  ip6_header_t *ip = &r.h6->ip6;
251  udp = &r.h6->udp;
252  gtpu = &r.h6->gtpu;
254  clib_host_to_net_u32 (6 << 28);
255  ip->hop_limit = 255;
256  ip->protocol = IP_PROTOCOL_UDP;
257 
258  ip->src_address = t->src.ip6;
259  ip->dst_address = t->dst.ip6;
260  }
261 
262  /* UDP header, randomize src port on something, maybe? */
263  udp->src_port = clib_host_to_net_u16 (2152);
264  udp->dst_port = clib_host_to_net_u16 (UDP_DST_PORT_GTPU);
265 
266  /* GTPU header */
268  gtpu->type = GTPU_TYPE_GTPU;
269  gtpu->teid = clib_host_to_net_u32 (t->teid);
270 
271  t->rewrite = r.rw;
272  /* Now only support 8-byte gtpu header. TBD */
273  _vec_len (t->rewrite) = sizeof (ip4_gtpu_header_t) - 4;
274 
275  return;
276 }
277 
278 static bool
279 gtpu_decap_next_is_valid (gtpu_main_t * gtm, u32 is_ip6, u32 decap_next_index)
280 {
281  vlib_main_t *vm = gtm->vlib_main;
282  u32 input_idx = (!is_ip6) ? gtpu4_input_node.index : gtpu6_input_node.index;
283  vlib_node_runtime_t *r = vlib_node_get_runtime (vm, input_idx);
284 
285  return decap_next_index < r->n_next_nodes;
286 }
287 
288 static uword
289 vtep_addr_ref (ip46_address_t * ip)
290 {
291  uword *vtep = ip46_address_is_ip4 (ip) ?
292  hash_get (gtpu_main.vtep4, ip->ip4.as_u32) :
293  hash_get_mem (gtpu_main.vtep6, &ip->ip6);
294  if (vtep)
295  return ++(*vtep);
296  ip46_address_is_ip4 (ip) ?
297  hash_set (gtpu_main.vtep4, ip->ip4.as_u32, 1) :
298  hash_set_mem_alloc (&gtpu_main.vtep6, &ip->ip6, 1);
299  return 1;
300 }
301 
302 static uword
303 vtep_addr_unref (ip46_address_t * ip)
304 {
305  uword *vtep = ip46_address_is_ip4 (ip) ?
306  hash_get (gtpu_main.vtep4, ip->ip4.as_u32) :
307  hash_get_mem (gtpu_main.vtep6, &ip->ip6);
308  ASSERT (vtep);
309  if (--(*vtep) != 0)
310  return *vtep;
311  ip46_address_is_ip4 (ip) ?
312  hash_unset (gtpu_main.vtep4, ip->ip4.as_u32) :
313  hash_unset_mem_free (&gtpu_main.vtep6, &ip->ip6);
314  return 0;
315 }
316 
317 typedef CLIB_PACKED (union
318  {
319  struct
320  {
321  fib_node_index_t mfib_entry_index;
322  adj_index_t mcast_adj_index;
323  }; u64 as_u64;
324  }) mcast_shared_t;
325 
326 static inline mcast_shared_t
327 mcast_shared_get (ip46_address_t * ip)
328 {
330  uword *p = hash_get_mem (gtpu_main.mcast_shared, ip);
331  ASSERT (p);
332  return (mcast_shared_t)
333  {
334  .as_u64 = *p};
335 }
336 
337 static inline void
338 mcast_shared_add (ip46_address_t * dst, fib_node_index_t mfei, adj_index_t ai)
339 {
340  mcast_shared_t new_ep = {
341  .mcast_adj_index = ai,
342  .mfib_entry_index = mfei,
343  };
344 
345  hash_set_mem_alloc (&gtpu_main.mcast_shared, dst, new_ep.as_u64);
346 }
347 
348 static inline void
349 mcast_shared_remove (ip46_address_t * dst)
350 {
351  mcast_shared_t ep = mcast_shared_get (dst);
352 
353  adj_unlock (ep.mcast_adj_index);
354  mfib_table_entry_delete_index (ep.mfib_entry_index, MFIB_SOURCE_GTPU);
355 
356  hash_unset_mem_free (&gtpu_main.mcast_shared, dst);
357 }
358 
359 static inline fib_protocol_t
360 fib_ip_proto (bool is_ip6)
361 {
362  return (is_ip6) ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4;
363 }
364 
366  (vnet_gtpu_add_del_tunnel_args_t * a, u32 * sw_if_indexp)
367 {
368  gtpu_main_t *gtm = &gtpu_main;
369  gtpu_tunnel_t *t = 0;
370  vnet_main_t *vnm = gtm->vnet_main;
371  uword *p;
372  u32 hw_if_index = ~0;
373  u32 sw_if_index = ~0;
374  gtpu4_tunnel_key_t key4;
375  gtpu6_tunnel_key_t key6;
376  u32 is_ip6 = a->is_ip6;
377 
378  if (!is_ip6)
379  {
380  key4.src = a->dst.ip4.as_u32; /* decap src in key is encap dst in config */
381  key4.teid = clib_host_to_net_u32 (a->teid);
382  p = hash_get (gtm->gtpu4_tunnel_by_key, key4.as_u64);
383  }
384  else
385  {
386  key6.src = a->dst.ip6;
387  key6.teid = clib_host_to_net_u32 (a->teid);
388  p = hash_get_mem (gtm->gtpu6_tunnel_by_key, &key6);
389  }
390 
391  if (a->is_add)
392  {
393  l2input_main_t *l2im = &l2input_main;
394 
395  /* adding a tunnel: tunnel must not already exist */
396  if (p)
397  return VNET_API_ERROR_TUNNEL_EXIST;
398 
399  /*if not set explicitly, default to l2 */
400  if (a->decap_next_index == ~0)
401  a->decap_next_index = GTPU_INPUT_NEXT_L2_INPUT;
402  if (!gtpu_decap_next_is_valid (gtm, is_ip6, a->decap_next_index))
403  return VNET_API_ERROR_INVALID_DECAP_NEXT;
404 
406  memset (t, 0, sizeof (*t));
407 
408  /* copy from arg structure */
409 #define _(x) t->x = a->x;
411 #undef _
412 
413  ip_udp_gtpu_rewrite (t, is_ip6);
414 
415  /* copy the key */
416  if (is_ip6)
418  t - gtm->tunnels);
419  else
420  hash_set (gtm->gtpu4_tunnel_by_key, key4.as_u64, t - gtm->tunnels);
421 
424  {
426  hw_if_index = gtm->free_gtpu_tunnel_hw_if_indices
428  _vec_len (gtm->free_gtpu_tunnel_hw_if_indices) -= 1;
429 
430  hi = vnet_get_hw_interface (vnm, hw_if_index);
431  hi->dev_instance = t - gtm->tunnels;
432  hi->hw_instance = hi->dev_instance;
433 
434  /* clear old stats of freed tunnel before reuse */
435  sw_if_index = hi->sw_if_index;
439  sw_if_index);
442  sw_if_index);
445  sw_if_index);
447  }
448  else
449  {
450  hw_if_index = vnet_register_interface
451  (vnm, gtpu_device_class.index, t - gtm->tunnels,
452  gtpu_hw_class.index, t - gtm->tunnels);
453  hi = vnet_get_hw_interface (vnm, hw_if_index);
454  }
455 
456  /* Set gtpu tunnel output node */
457  u32 encap_index = !is_ip6 ?
458  gtpu4_encap_node.index : gtpu6_encap_node.index;
459  vnet_set_interface_output_node (vnm, hw_if_index, encap_index);
460 
461  t->hw_if_index = hw_if_index;
462  t->sw_if_index = sw_if_index = hi->sw_if_index;
463 
465  ~0);
466  gtm->tunnel_index_by_sw_if_index[sw_if_index] = t - gtm->tunnels;
467 
468  /* setup l2 input config with l2 feature and bd 0 to drop packet */
469  vec_validate (l2im->configs, sw_if_index);
470  l2im->configs[sw_if_index].feature_bitmap = L2INPUT_FEAT_DROP;
471  l2im->configs[sw_if_index].bd_index = 0;
472 
473  vnet_sw_interface_t *si = vnet_get_sw_interface (vnm, sw_if_index);
475  vnet_sw_interface_set_flags (vnm, sw_if_index,
477 
478  fib_node_init (&t->node, gtm->fib_node_type);
479  fib_prefix_t tun_dst_pfx;
481 
482  fib_prefix_from_ip46_addr (&t->dst, &tun_dst_pfx);
483  if (!ip46_address_is_multicast (&t->dst))
484  {
485  /* Unicast tunnel -
486  * source the FIB entry for the tunnel's destination
487  * and become a child thereof. The tunnel will then get poked
488  * when the forwarding for the entry updates, and the tunnel can
489  * re-stack accordingly
490  */
491  vtep_addr_ref (&t->src);
493  (t->encap_fib_index, &tun_dst_pfx, FIB_SOURCE_RR,
496  (t->fib_entry_index, gtm->fib_node_type, t - gtm->tunnels);
498  }
499  else
500  {
501  /* Multicast tunnel -
502  * as the same mcast group can be used for mutiple mcast tunnels
503  * with different VNIs, create the output fib adjecency only if
504  * it does not already exist
505  */
506  fib_protocol_t fp = fib_ip_proto (is_ip6);
507 
508  if (vtep_addr_ref (&t->dst) == 1)
509  {
510  fib_node_index_t mfei;
511  adj_index_t ai;
512  fib_route_path_t path = {
513  .frp_proto = fib_proto_to_dpo (fp),
514  .frp_addr = zero_addr,
515  .frp_sw_if_index = 0xffffffff,
516  .frp_fib_index = ~0,
517  .frp_weight = 0,
518  .frp_flags = FIB_ROUTE_PATH_LOCAL,
519  };
520  const mfib_prefix_t mpfx = {
521  .fp_proto = fp,
522  .fp_len = (is_ip6 ? 128 : 32),
523  .fp_grp_addr = tun_dst_pfx.fp_addr,
524  };
525 
526  /*
527  * Setup the (*,G) to receive traffic on the mcast group
528  * - the forwarding interface is for-us
529  * - the accepting interface is that from the API
530  */
532  &mpfx,
534  &path, MFIB_ITF_FLAG_FORWARD);
535 
539  &mpfx,
541  &path,
543 
544  /*
545  * Create the mcast adjacency to send traffic to the group
546  */
547  ai = adj_mcast_add_or_lock (fp,
548  fib_proto_to_link (fp),
549  a->mcast_sw_if_index);
550 
551  /*
552  * create a new end-point
553  */
554  mcast_shared_add (&t->dst, mfei, ai);
555  }
556 
557  dpo_id_t dpo = DPO_INVALID;
558  mcast_shared_t ep = mcast_shared_get (&t->dst);
559 
560  /* Stack shared mcast dst mac addr rewrite on encap */
562  fib_proto_to_dpo (fp), ep.mcast_adj_index);
563 
564  dpo_stack_from_node (encap_index, &t->next_dpo, &dpo);
565 
566  dpo_reset (&dpo);
567  flood_class = VNET_FLOOD_CLASS_TUNNEL_MASTER;
568  }
569 
570  vnet_get_sw_interface (vnet_get_main (), sw_if_index)->flood_class =
571  flood_class;
572  }
573  else
574  {
575  /* deleting a tunnel: tunnel must exist */
576  if (!p)
577  return VNET_API_ERROR_NO_SUCH_ENTRY;
578 
579  t = pool_elt_at_index (gtm->tunnels, p[0]);
580  sw_if_index = t->sw_if_index;
581 
582  vnet_sw_interface_set_flags (vnm, t->sw_if_index, 0 /* down */ );
585 
586  /* make sure tunnel is removed from l2 bd or xconnect */
587  set_int_l2_mode (gtm->vlib_main, vnm, MODE_L3, t->sw_if_index, 0, 0, 0,
588  0);
590 
592 
593  if (!is_ip6)
594  hash_unset (gtm->gtpu4_tunnel_by_key, key4.as_u64);
595  else
597 
598  if (!ip46_address_is_multicast (&t->dst))
599  {
600  vtep_addr_unref (&t->src);
603  }
604  else if (vtep_addr_unref (&t->dst) == 0)
605  {
606  mcast_shared_remove (&t->dst);
607  }
608 
609  fib_node_deinit (&t->node);
610  vec_free (t->rewrite);
611  pool_put (gtm->tunnels, t);
612  }
613 
614  if (sw_if_indexp)
615  *sw_if_indexp = sw_if_index;
616 
617  return 0;
618 }
619 
620 static uword
621 get_decap_next_for_node (u32 node_index, u32 ipv4_set)
622 {
623  gtpu_main_t *gtm = &gtpu_main;
624  vlib_main_t *vm = gtm->vlib_main;
625  uword input_node = (ipv4_set) ? gtpu4_input_node.index :
626  gtpu6_input_node.index;
627 
628  return vlib_node_add_next (vm, input_node, node_index);
629 }
630 
631 static uword
632 unformat_decap_next (unformat_input_t * input, va_list * args)
633 {
634  u32 *result = va_arg (*args, u32 *);
635  u32 ipv4_set = va_arg (*args, int);
636  gtpu_main_t *gtm = &gtpu_main;
637  vlib_main_t *vm = gtm->vlib_main;
638  u32 node_index;
639  u32 tmp;
640 
641  if (unformat (input, "l2"))
642  *result = GTPU_INPUT_NEXT_L2_INPUT;
643  else if (unformat (input, "ip4"))
644  *result = GTPU_INPUT_NEXT_IP4_INPUT;
645  else if (unformat (input, "ip6"))
646  *result = GTPU_INPUT_NEXT_IP6_INPUT;
647  else if (unformat (input, "node %U", unformat_vlib_node, vm, &node_index))
648  *result = get_decap_next_for_node (node_index, ipv4_set);
649  else if (unformat (input, "%d", &tmp))
650  *result = tmp;
651  else
652  return 0;
653 
654  return 1;
655 }
656 
657 static clib_error_t *
659  unformat_input_t * input,
660  vlib_cli_command_t * cmd)
661 {
662  unformat_input_t _line_input, *line_input = &_line_input;
663  ip46_address_t src, dst;
664  u8 is_add = 1;
665  u8 src_set = 0;
666  u8 dst_set = 0;
667  u8 grp_set = 0;
668  u8 ipv4_set = 0;
669  u8 ipv6_set = 0;
670  u32 encap_fib_index = 0;
671  u32 mcast_sw_if_index = ~0;
672  u32 decap_next_index = GTPU_INPUT_NEXT_L2_INPUT;
673  u32 teid = 0;
674  u32 tmp;
675  int rv;
676  vnet_gtpu_add_del_tunnel_args_t _a, *a = &_a;
677  u32 tunnel_sw_if_index;
678  clib_error_t *error = NULL;
679 
680  /* Cant "universally zero init" (={0}) due to GCC bug 53119 */
681  memset (&src, 0, sizeof src);
682  memset (&dst, 0, sizeof dst);
683 
684  /* Get a line of input. */
685  if (!unformat_user (input, unformat_line_input, line_input))
686  return 0;
687 
688  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
689  {
690  if (unformat (line_input, "del"))
691  {
692  is_add = 0;
693  }
694  else if (unformat (line_input, "src %U",
695  unformat_ip4_address, &src.ip4))
696  {
697  src_set = 1;
698  ipv4_set = 1;
699  }
700  else if (unformat (line_input, "dst %U",
701  unformat_ip4_address, &dst.ip4))
702  {
703  dst_set = 1;
704  ipv4_set = 1;
705  }
706  else if (unformat (line_input, "src %U",
707  unformat_ip6_address, &src.ip6))
708  {
709  src_set = 1;
710  ipv6_set = 1;
711  }
712  else if (unformat (line_input, "dst %U",
713  unformat_ip6_address, &dst.ip6))
714  {
715  dst_set = 1;
716  ipv6_set = 1;
717  }
718  else if (unformat (line_input, "group %U %U",
719  unformat_ip4_address, &dst.ip4,
721  vnet_get_main (), &mcast_sw_if_index))
722  {
723  grp_set = dst_set = 1;
724  ipv4_set = 1;
725  }
726  else if (unformat (line_input, "group %U %U",
727  unformat_ip6_address, &dst.ip6,
729  vnet_get_main (), &mcast_sw_if_index))
730  {
731  grp_set = dst_set = 1;
732  ipv6_set = 1;
733  }
734  else if (unformat (line_input, "encap-vrf-id %d", &tmp))
735  {
736  encap_fib_index = fib_table_find (fib_ip_proto (ipv6_set), tmp);
737  if (encap_fib_index == ~0)
738  {
739  error =
740  clib_error_return (0, "nonexistent encap-vrf-id %d", tmp);
741  goto done;
742  }
743  }
744  else if (unformat (line_input, "decap-next %U", unformat_decap_next,
745  &decap_next_index, ipv4_set))
746  ;
747  else if (unformat (line_input, "teid %d", &teid))
748  ;
749  else
750  {
751  error = clib_error_return (0, "parse error: '%U'",
752  format_unformat_error, line_input);
753  goto done;
754  }
755  }
756 
757  if (src_set == 0)
758  {
759  error = clib_error_return (0, "tunnel src address not specified");
760  goto done;
761  }
762 
763  if (dst_set == 0)
764  {
765  error = clib_error_return (0, "tunnel dst address not specified");
766  goto done;
767  }
768 
769  if (grp_set && !ip46_address_is_multicast (&dst))
770  {
771  error = clib_error_return (0, "tunnel group address not multicast");
772  goto done;
773  }
774 
775  if (grp_set == 0 && ip46_address_is_multicast (&dst))
776  {
777  error = clib_error_return (0, "dst address must be unicast");
778  goto done;
779  }
780 
781  if (grp_set && mcast_sw_if_index == ~0)
782  {
783  error = clib_error_return (0, "tunnel nonexistent multicast device");
784  goto done;
785  }
786 
787  if (ipv4_set && ipv6_set)
788  {
789  error = clib_error_return (0, "both IPv4 and IPv6 addresses specified");
790  goto done;
791  }
792 
793  if (ip46_address_cmp (&src, &dst) == 0)
794  {
795  error = clib_error_return (0, "src and dst addresses are identical");
796  goto done;
797  }
798 
799  if (decap_next_index == ~0)
800  {
801  error = clib_error_return (0, "next node not found");
802  goto done;
803  }
804 
805  memset (a, 0, sizeof (*a));
806 
807  a->is_add = is_add;
808  a->is_ip6 = ipv6_set;
809 
810 #define _(x) a->x = x;
812 #undef _
813 
814  rv = vnet_gtpu_add_del_tunnel (a, &tunnel_sw_if_index);
815 
816  switch (rv)
817  {
818  case 0:
819  if (is_add)
821  vnet_get_main (), tunnel_sw_if_index);
822  break;
823 
824  case VNET_API_ERROR_TUNNEL_EXIST:
825  error = clib_error_return (0, "tunnel already exists...");
826  goto done;
827 
828  case VNET_API_ERROR_NO_SUCH_ENTRY:
829  error = clib_error_return (0, "tunnel does not exist...");
830  goto done;
831 
832  default:
833  error = clib_error_return
834  (0, "vnet_gtpu_add_del_tunnel returned %d", rv);
835  goto done;
836  }
837 
838 done:
839  unformat_free (line_input);
840 
841  return error;
842 }
843 
844 /*?
845  * Add or delete a GTPU Tunnel.
846  *
847  * GTPU provides the features needed to allow L2 bridge domains (BDs)
848  * to span multiple servers. This is done by building an L2 overlay on
849  * top of an L3 network underlay using GTPU tunnels.
850  *
851  * This makes it possible for servers to be co-located in the same data
852  * center or be separated geographically as long as they are reachable
853  * through the underlay L3 network.
854  *
855  * You can refer to this kind of L2 overlay bridge domain as a GTPU
856  * (Virtual eXtensible VLAN) segment.
857  *
858  * @cliexpar
859  * Example of how to create a GTPU Tunnel:
860  * @cliexcmd{create gtpu tunnel src 10.0.3.1 dst 10.0.3.3 teid 13 encap-vrf-id 7}
861  * Example of how to delete a GTPU Tunnel:
862  * @cliexcmd{create gtpu tunnel src 10.0.3.1 dst 10.0.3.3 teid 13 del}
863  ?*/
864 /* *INDENT-OFF* */
865 VLIB_CLI_COMMAND (create_gtpu_tunnel_command, static) = {
866  .path = "create gtpu tunnel",
867  .short_help =
868  "create gtpu tunnel src <local-vtep-addr>"
869  " {dst <remote-vtep-addr>|group <mcast-vtep-addr> <intf-name>} teid <nn>"
870  " [encap-vrf-id <nn>] [decap-next [l2|ip4|ip6|node <name>]] [del]",
871  .function = gtpu_add_del_tunnel_command_fn,
872 };
873 /* *INDENT-ON* */
874 
875 static clib_error_t *
877  unformat_input_t * input,
878  vlib_cli_command_t * cmd)
879 {
880  gtpu_main_t *gtm = &gtpu_main;
881  gtpu_tunnel_t *t;
882 
883  if (pool_elts (gtm->tunnels) == 0)
884  vlib_cli_output (vm, "No gtpu tunnels configured...");
885 
886  pool_foreach (t, gtm->tunnels, (
887  {
888  vlib_cli_output (vm, "%U",
889  format_gtpu_tunnel, t);
890  }
891  ));
892 
893  return 0;
894 }
895 
896 /*?
897  * Display all the GTPU Tunnel entries.
898  *
899  * @cliexpar
900  * Example of how to display the GTPU Tunnel entries:
901  * @cliexstart{show gtpu tunnel}
902  * [0] src 10.0.3.1 dst 10.0.3.3 teid 13 encap_fib_index 0 sw_if_index 5 decap_next l2
903  * @cliexend
904  ?*/
905 /* *INDENT-OFF* */
906 VLIB_CLI_COMMAND (show_gtpu_tunnel_command, static) = {
907  .path = "show gtpu tunnel",
908  .short_help = "show gtpu tunnel",
909  .function = show_gtpu_tunnel_command_fn,
910 };
911 /* *INDENT-ON* */
912 
913 void
914 vnet_int_gtpu_bypass_mode (u32 sw_if_index, u8 is_ip6, u8 is_enable)
915 {
916  if (is_ip6)
917  vnet_feature_enable_disable ("ip6-unicast", "ip6-gtpu-bypass",
918  sw_if_index, is_enable, 0, 0);
919  else
920  vnet_feature_enable_disable ("ip4-unicast", "ip4-gtpu-bypass",
921  sw_if_index, is_enable, 0, 0);
922 }
923 
924 static clib_error_t *
926  unformat_input_t * input, vlib_cli_command_t * cmd)
927 {
928  unformat_input_t _line_input, *line_input = &_line_input;
929  vnet_main_t *vnm = vnet_get_main ();
930  clib_error_t *error = 0;
931  u32 sw_if_index, is_enable;
932 
933  sw_if_index = ~0;
934  is_enable = 1;
935 
936  if (!unformat_user (input, unformat_line_input, line_input))
937  return 0;
938 
939  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
940  {
941  if (unformat_user
942  (line_input, unformat_vnet_sw_interface, vnm, &sw_if_index))
943  ;
944  else if (unformat (line_input, "del"))
945  is_enable = 0;
946  else
947  {
948  error = unformat_parse_error (line_input);
949  goto done;
950  }
951  }
952 
953  if (~0 == sw_if_index)
954  {
955  error = clib_error_return (0, "unknown interface `%U'",
956  format_unformat_error, line_input);
957  goto done;
958  }
959 
960  vnet_int_gtpu_bypass_mode (sw_if_index, is_ip6, is_enable);
961 
962 done:
963  unformat_free (line_input);
964 
965  return error;
966 }
967 
968 static clib_error_t *
970  unformat_input_t * input, vlib_cli_command_t * cmd)
971 {
972  return set_ip_gtpu_bypass (0, input, cmd);
973 }
974 
975 /*?
976  * This command adds the 'ip4-gtpu-bypass' graph node for a given interface.
977  * By adding the IPv4 gtpu-bypass graph node to an interface, the node checks
978  * for and validate input gtpu packet and bypass ip4-lookup, ip4-local,
979  * ip4-udp-lookup nodes to speedup gtpu packet forwarding. This node will
980  * cause extra overhead to for non-gtpu packets which is kept at a minimum.
981  *
982  * @cliexpar
983  * @parblock
984  * Example of graph node before ip4-gtpu-bypass is enabled:
985  * @cliexstart{show vlib graph ip4-gtpu-bypass}
986  * Name Next Previous
987  * ip4-gtpu-bypass error-drop [0]
988  * gtpu4-input [1]
989  * ip4-lookup [2]
990  * @cliexend
991  *
992  * Example of how to enable ip4-gtpu-bypass on an interface:
993  * @cliexcmd{set interface ip gtpu-bypass GigabitEthernet2/0/0}
994  *
995  * Example of graph node after ip4-gtpu-bypass is enabled:
996  * @cliexstart{show vlib graph ip4-gtpu-bypass}
997  * Name Next Previous
998  * ip4-gtpu-bypass error-drop [0] ip4-input
999  * gtpu4-input [1] ip4-input-no-checksum
1000  * ip4-lookup [2]
1001  * @cliexend
1002  *
1003  * Example of how to display the feature enabed on an interface:
1004  * @cliexstart{show ip interface features GigabitEthernet2/0/0}
1005  * IP feature paths configured on GigabitEthernet2/0/0...
1006  * ...
1007  * ipv4 unicast:
1008  * ip4-gtpu-bypass
1009  * ip4-lookup
1010  * ...
1011  * @cliexend
1012  *
1013  * Example of how to disable ip4-gtpu-bypass on an interface:
1014  * @cliexcmd{set interface ip gtpu-bypass GigabitEthernet2/0/0 del}
1015  * @endparblock
1016 ?*/
1017 /* *INDENT-OFF* */
1018 VLIB_CLI_COMMAND (set_interface_ip_gtpu_bypass_command, static) = {
1019  .path = "set interface ip gtpu-bypass",
1020  .function = set_ip4_gtpu_bypass,
1021  .short_help = "set interface ip gtpu-bypass <interface> [del]",
1022 };
1023 /* *INDENT-ON* */
1024 
1025 static clib_error_t *
1027  unformat_input_t * input, vlib_cli_command_t * cmd)
1028 {
1029  return set_ip_gtpu_bypass (1, input, cmd);
1030 }
1031 
1032 /*?
1033  * This command adds the 'ip6-gtpu-bypass' graph node for a given interface.
1034  * By adding the IPv6 gtpu-bypass graph node to an interface, the node checks
1035  * for and validate input gtpu packet and bypass ip6-lookup, ip6-local,
1036  * ip6-udp-lookup nodes to speedup gtpu packet forwarding. This node will
1037  * cause extra overhead to for non-gtpu packets which is kept at a minimum.
1038  *
1039  * @cliexpar
1040  * @parblock
1041  * Example of graph node before ip6-gtpu-bypass is enabled:
1042  * @cliexstart{show vlib graph ip6-gtpu-bypass}
1043  * Name Next Previous
1044  * ip6-gtpu-bypass error-drop [0]
1045  * gtpu6-input [1]
1046  * ip6-lookup [2]
1047  * @cliexend
1048  *
1049  * Example of how to enable ip6-gtpu-bypass on an interface:
1050  * @cliexcmd{set interface ip6 gtpu-bypass GigabitEthernet2/0/0}
1051  *
1052  * Example of graph node after ip6-gtpu-bypass is enabled:
1053  * @cliexstart{show vlib graph ip6-gtpu-bypass}
1054  * Name Next Previous
1055  * ip6-gtpu-bypass error-drop [0] ip6-input
1056  * gtpu6-input [1] ip4-input-no-checksum
1057  * ip6-lookup [2]
1058  * @cliexend
1059  *
1060  * Example of how to display the feature enabed on an interface:
1061  * @cliexstart{show ip interface features GigabitEthernet2/0/0}
1062  * IP feature paths configured on GigabitEthernet2/0/0...
1063  * ...
1064  * ipv6 unicast:
1065  * ip6-gtpu-bypass
1066  * ip6-lookup
1067  * ...
1068  * @cliexend
1069  *
1070  * Example of how to disable ip6-gtpu-bypass on an interface:
1071  * @cliexcmd{set interface ip6 gtpu-bypass GigabitEthernet2/0/0 del}
1072  * @endparblock
1073 ?*/
1074 /* *INDENT-OFF* */
1075 VLIB_CLI_COMMAND (set_interface_ip6_gtpu_bypass_command, static) = {
1076  .path = "set interface ip6 gtpu-bypass",
1077  .function = set_ip6_gtpu_bypass,
1078  .short_help = "set interface ip gtpu-bypass <interface> [del]",
1079 };
1080 /* *INDENT-ON* */
1081 
1082 clib_error_t *
1084 {
1085  gtpu_main_t *gtm = &gtpu_main;
1086 
1087  gtm->vnet_main = vnet_get_main ();
1088  gtm->vlib_main = vm;
1089 
1090  /* initialize the ip6 hash */
1092  sizeof (gtpu6_tunnel_key_t),
1093  sizeof (uword));
1094  gtm->vtep6 = hash_create_mem (0, sizeof (ip6_address_t), sizeof (uword));
1095  gtm->mcast_shared = hash_create_mem (0,
1096  sizeof (ip46_address_t),
1097  sizeof (mcast_shared_t));
1098 
1099  udp_register_dst_port (vm, UDP_DST_PORT_GTPU,
1100  gtpu4_input_node.index, /* is_ip4 */ 1);
1101  udp_register_dst_port (vm, UDP_DST_PORT_GTPU6,
1102  gtpu6_input_node.index, /* is_ip4 */ 0);
1103 
1104  gtm->fib_node_type = fib_node_register_new_type (&gtpu_vft);
1105 
1106  return 0;
1107 }
1108 
1110 
1111 /* *INDENT-OFF* */
1112 VLIB_PLUGIN_REGISTER () = {
1113  .version = VPP_BUILD_VER,
1114  .description = "GTPv1-U",
1115 };
1116 /* *INDENT-ON* */
1117 
1118 /*
1119  * fd.io coding-style-patch-verification: ON
1120  *
1121  * Local Variables:
1122  * eval: (c-set-style "gnu")
1123  * End:
1124  */
vlib_main_t * vlib_main
Definition: gtpu.h:227
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:432
vlib_node_registration_t gtpu4_encap_node
(constructor) VLIB_REGISTER_NODE (gtpu4_encap_node)
Definition: gtpu_encap.c:670
void vnet_set_interface_output_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)
Set interface output node - for interface registered without its output/tx nodes created because its ...
void dpo_stack_from_node(u32 child_node_index, dpo_id_t *dpo, const dpo_id_t *parent)
Stack one DPO object on another, and thus establish a child parent relationship.
Definition: dpo.c:485
vmrglw vmrglh hi
clib_error_t * gtpu_init(vlib_main_t *vm)
Definition: gtpu.c:1083
Recursive resolution source.
Definition: fib_entry.h:117
Contribute an object that is to be used to forward IP6 packets.
Definition: fib_types.h:92
#define hash_set(h, key, value)
Definition: hash.h:254
l2_input_config_t * configs
Definition: l2_input.h:66
vnet_main_t * vnet_main
Definition: gtpu.h:228
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: interface.c:538
#define hash_unset(h, key)
Definition: hash.h:260
static uword ip46_address_is_multicast(ip46_address_t *a)
Definition: ip6_packet.h:151
static uword get_decap_next_for_node(u32 node_index, u32 ipv4_set)
Definition: gtpu.c:621
A representation of a path as described by a route producer.
Definition: fib_types.h:377
ip4_address_t src_address
Definition: ip4_packet.h:164
vnet_main_t * vnet_get_main(void)
Definition: misc.c:47
u32 teid
Definition: gtpu.h:59
typedef CLIB_PACKED(union{struct{fib_node_index_t mfib_entry_index;adj_index_t mcast_adj_index;};u64 as_u64;})
Definition: gtpu.c:317
u32 teid
Definition: gtpu.h:133
#define GTPU_TYPE_GTPU
Definition: gtpu.h:75
vnet_interface_main_t interface_main
Definition: vnet.h:56
void fib_node_init(fib_node_t *node, fib_node_type_t type)
Definition: fib_node.c:185
u64 as_u64
Definition: bihash_doc.h:63
u32 fib_entry_child_add(fib_node_index_t fib_entry_index, fib_node_type_t child_type, fib_node_index_t child_index)
Definition: fib_entry.c:503
u32 * tunnel_index_by_sw_if_index
Definition: gtpu.h:216
#define NULL
Definition: clib.h:55
fib_node_type_t fib_node_type
Node type for registering to fib changes.
Definition: gtpu.h:221
enum fib_node_back_walk_rc_t_ fib_node_back_walk_rc_t
Return code from a back walk function.
#define foreach_copy_field
Definition: gtpu.c:207
void fib_entry_contribute_forwarding(fib_node_index_t fib_entry_index, fib_forward_chain_type_t fct, dpo_id_t *dpo)
Definition: fib_entry.c:408
static uword vtep_addr_unref(ip46_address_t *ip)
Definition: gtpu.c:303
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
void fib_entry_child_remove(fib_node_index_t fib_entry_index, u32 sibling_index)
Definition: fib_entry.c:514
#define GTPU_PT_GTP
Definition: gtpu.h:74
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:518
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:983
format_function_t format_ip46_address
Definition: format.h:61
Contribute an object that is to be used to forward IP4 packets.
Definition: fib_types.h:88
VNET_FEATURE_INIT(ip4_gtpu_bypass, static)
static void gtpu_tunnel_restack_dpo(gtpu_tunnel_t *t)
Definition: gtpu.c:138
#define STRUCT_OFFSET_OF(t, f)
Definition: clib.h:62
void fib_node_deinit(fib_node_t *node)
Definition: fib_node.c:197
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
dpo_proto_t frp_proto
The protocol of the address below.
Definition: fib_types.h:382
unformat_function_t unformat_vnet_sw_interface
static fib_protocol_t fib_ip_proto(bool is_ip6)
Definition: gtpu.c:360
#define VNET_HW_INTERFACE_FLAG_LINK_UP
Definition: interface.h:394
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:443
uword * vtep4
Definition: gtpu.h:206
ip6_address_t src_address
Definition: ip6_packet.h:341
#define ip46_address_cmp(ip46_1, ip46_2)
Definition: ip6_packet.h:80
format_function_t format_vnet_sw_if_index_name
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
Definition: node_funcs.h:1108
fib_node_type_t fib_node_register_new_type(const fib_node_vft_t *vft)
Create a new FIB node type and Register the function table for it.
Definition: fib_node.c:80
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
static u8 * format_decap_next(u8 *s, va_list *args)
Definition: gtpu.c:52
static fib_node_t * gtpu_tunnel_fib_node_get(fib_node_index_t index)
Function definition to get a FIB node from its index.
Definition: gtpu.c:173
VNET_DEVICE_CLASS(gtpu_device_class, static)
static u8 * format_gtpu_name(u8 *s, va_list *args)
Definition: gtpu.c:94
vnet_flood_class_t flood_class
Definition: interface.h:618
VNET_HW_INTERFACE_CLASS(gtpu_hw_class)
static gtpu_tunnel_t * gtpu_tunnel_from_fib_node(fib_node_t *node)
Definition: gtpu.c:152
dpo_id_t next_dpo
Definition: gtpu.h:130
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:438
unformat_function_t unformat_ip4_address
Definition: format.h:76
u32 frp_sw_if_index
The interface.
Definition: fib_types.h:412
int vnet_gtpu_add_del_tunnel(vnet_gtpu_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
Definition: gtpu.c:366
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:111
ip46_address_t src
Definition: gtpu.h:136
void mfib_table_entry_delete_index(fib_node_index_t mfib_entry_index, mfib_source_t source)
Delete a FIB entry.
Definition: mfib_table.c:380
ip4_address_t dst_address
Definition: ip4_packet.h:164
vlib_combined_counter_main_t * combined_sw_if_counters
Definition: interface.h:672
Aggregrate type for a prefix.
Definition: fib_types.h:172
static clib_error_t * show_gtpu_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: gtpu.c:876
#define clib_error_return(e, args...)
Definition: error.h:99
fib_node_index_t mfib_table_entry_path_update(u32 fib_index, const mfib_prefix_t *prefix, mfib_source_t source, const fib_route_path_t *rpath, mfib_itf_flags_t itf_flags)
Add n paths to an entry (aka route) in the FIB.
Definition: mfib_table.c:219
unsigned long u64
Definition: types.h:89
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
Definition: adj.c:239
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
Definition: fib_table.c:1028
gtpu_main_t gtpu_main
Definition: gtpu.c:35
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:689
static u8 * format_gtpu_header_with_length(u8 *s, va_list *args)
Definition: gtpu.c:120
u32 set_int_l2_mode(vlib_main_t *vm, vnet_main_t *vnet_main, u32 mode, u32 sw_if_index, u32 bd_index, u32 bvi, u32 shg, u32 xc_sw_if_index)
Set the subinterface to run in l2 or l3 mode.
Definition: l2_input.c:565
u8 * format_gtpu_tunnel(u8 *s, va_list *args)
Definition: gtpu.c:73
Definition: fib_entry.h:238
unformat_function_t unformat_line_input
Definition: format.h:281
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:166
#define hash_create_mem(elts, key_bytes, value_bytes)
Definition: hash.h:660
#define hash_get(h, key)
Definition: hash.h:248
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:459
static void vlib_zero_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
Clear a combined counter Clears the set of per-thread counters.
Definition: counter.h:276
u32 decap_next_index
Definition: gtpu.h:143
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:195
uword * vtep6
Definition: gtpu.h:207
struct _unformat_input_t unformat_input_t
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:271
#define GTPU_V1_VER
Definition: gtpu.h:72
static uword ip6_gtpu_bypass(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: gtpu_decap.c:1277
vlib_simple_counter_main_t * sw_if_counters
Definition: interface.h:671
static uword vtep_addr_ref(ip46_address_t *ip)
Definition: gtpu.c:289
static fib_node_back_walk_rc_t gtpu_tunnel_back_walk(fib_node_t *node, fib_node_back_walk_ctx_t *ctx)
Function definition to backwalk a FIB node - Here we will restack the new dpo of GTPU DIP to encap no...
Definition: gtpu.c:163
An node in the FIB graph.
Definition: fib_node.h:286
static clib_error_t * gtpu_add_del_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: gtpu.c:658
ip46_address_t dst
Definition: gtpu.h:137
#define ip46_address_is_ip4(ip46)
Definition: ip6_packet.h:76
unformat_function_t unformat_ip6_address
Definition: format.h:94
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P (general version).
Definition: pool.h:188
u8 type
Definition: gtpu.h:57
static void ip_udp_gtpu_rewrite(gtpu_tunnel_t *t, bool is_ip6)
Definition: gtpu.c:216
fib_node_index_t fib_table_entry_special_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags)
Add a &#39;special&#39; entry to the FIB.
Definition: fib_table.c:371
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
vlib_main_t * vm
Definition: buffer.c:283
void fib_table_entry_delete_index(fib_node_index_t fib_entry_index, fib_source_t source)
Delete a FIB entry.
Definition: fib_table.c:860
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:336
vnet_flood_class_t
Definition: interface.h:557
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
Definition: node_funcs.h:89
fib_node_get_t fnv_get
Definition: fib_node.h:274
static void vnet_interface_counter_unlock(vnet_interface_main_t *im)
Definition: interface.h:697
#define VNET_SW_INTERFACE_FLAG_HIDDEN
Definition: interface.h:588
static void mcast_shared_remove(ip46_address_t *dst)
Definition: gtpu.c:349
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:29
u32 sw_if_index
Definition: gtpu.h:149
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
void fib_prefix_from_ip46_addr(const ip46_address_t *addr, fib_prefix_t *pfx)
Host prefix from ip.
Definition: fib_types.c:54
void dpo_set(dpo_id_t *dpo, dpo_type_t type, dpo_proto_t proto, index_t index)
Set/create a DPO ID The DPO will be locked.
Definition: dpo.c:182
u32 sibling_index
The tunnel is a child of the FIB entry for its destination.
Definition: gtpu.h:170
Aggregrate type for a prefix.
Definition: mfib_types.h:24
static bool gtpu_decap_next_is_valid(gtpu_main_t *gtm, u32 is_ip6, u32 decap_next_index)
Definition: gtpu.c:279
u8 * default_build_rewrite(vnet_main_t *vnm, u32 sw_if_index, vnet_link_t link_type, const void *dst_address)
Return a complete, zero-length (aka dummy) rewrite.
Definition: interface.c:1424
Context passed between object during a back walk.
Definition: fib_node.h:199
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:154
u32 * free_gtpu_tunnel_hw_if_indices
Definition: gtpu.h:213
static void vnet_interface_counter_lock(vnet_interface_main_t *im)
Definition: interface.h:689
static clib_error_t * set_ip4_gtpu_bypass(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: gtpu.c:969
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
Definition: interface.h:576
#define ASSERT(truth)
fib_node_index_t fib_entry_index
Definition: gtpu.h:161
u8 * format_gtpu_encap_trace(u8 *s, va_list *args)
Definition: gtpu_encap.c:56
unsigned int u32
Definition: types.h:88
fib_node_t node
Linkage into the FIB object graph.
Definition: gtpu.h:155
long ctx[MAX_CONNS]
Definition: main.c:122
u32 hw_if_index
Definition: gtpu.h:150
static void gtpu_tunnel_last_lock_gone(fib_node_t *node)
Function definition to inform the FIB node that its last lock has gone.
Definition: gtpu.c:187
enum fib_forward_chain_type_t_ fib_forward_chain_type_t
FIB output chain type.
fib_route_path_flags_t frp_flags
flags on the path
Definition: fib_types.h:469
static void vlib_zero_simple_counter(vlib_simple_counter_main_t *cm, u32 index)
Clear a simple counter Clears the set of per-thread u16 counters, and the u64 counter.
Definition: counter.h:123
void vnet_int_gtpu_bypass_mode(u32 sw_if_index, u8 is_ip6, u8 is_enable)
Definition: gtpu.c:914
u32 encap_fib_index
Definition: gtpu.h:146
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
Definition: fib_types.c:211
#define VNET_FEATURES(...)
Definition: feature.h:368
uword * gtpu4_tunnel_by_key
Definition: gtpu.h:201
u64 uword
Definition: types.h:112
#define unformat_parse_error(input)
Definition: format.h:267
vlib_node_registration_t gtpu6_input_node
(constructor) VLIB_REGISTER_NODE (gtpu6_input_node)
Definition: gtpu_decap.c:833
static void mcast_shared_add(ip46_address_t *dst, fib_node_index_t mfei, adj_index_t ai)
Definition: gtpu.c:338
u32 ip_version_traffic_class_and_flow_label
Definition: ip6_packet.h:328
fib_protocol_t fp_proto
protocol type
Definition: mfib_types.h:33
l2input_main_t l2input_main
Definition: l2_input.c:113
uword * mcast_shared
Definition: gtpu.h:210
A for-us/local path.
Definition: fib_types.h:301
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
uword * gtpu6_tunnel_by_key
Definition: gtpu.h:202
static void unformat_free(unformat_input_t *i)
Definition: format.h:161
static void hash_set_mem_alloc(uword **h, void *key, uword v)
Definition: hash.h:278
static clib_error_t * set_ip6_gtpu_bypass(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: gtpu.c:1026
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
Definition: dpo.h:193
vlib_node_registration_t gtpu6_encap_node
(constructor) VLIB_REGISTER_NODE (gtpu6_encap_node)
Definition: gtpu_encap.c:688
a point 2 point interface
Definition: interface.h:289
unformat_function_t unformat_vlib_node
Definition: node_funcs.h:1155
Bits Octets 8 7 6 5 4 3 2 1 1 Version PT (*) E S PN 2 Message Type 3 Length (1st Octet) 4 Length...
Definition: gtpu.h:54
#define hash_get_mem(h, key)
Definition: hash.h:268
static void hash_unset_mem_free(uword **h, void *key)
Definition: hash.h:294
static clib_error_t * set_ip_gtpu_bypass(u32 is_ip6, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: gtpu.c:925
A FIB graph nodes virtual function table.
Definition: fib_node.h:273
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
gtpu_tunnel_t * tunnels
Definition: gtpu.h:198
adj_index_t adj_mcast_add_or_lock(fib_protocol_t proto, vnet_link_t link_type, u32 sw_if_index)
Mcast Adjacency.
Definition: adj_mcast.c:51
u8 * rewrite
Definition: gtpu.h:127
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
Definition: dpo.c:228
VLIB_PLUGIN_REGISTER()
u8 ver_flags
Definition: gtpu.h:56
vnet_link_t fib_proto_to_link(fib_protocol_t proto)
Convert from a protocol to a link type.
Definition: fib_types.c:245
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
Definition: interface.c:546
static uword ip4_gtpu_bypass(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: gtpu_decap.c:1246
void udp_register_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u32 node_index, u8 is_ip4)
Definition: udp_local.c:492
u8 ip_version_and_header_length
Definition: ip4_packet.h:132
static clib_error_t * gtpu_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: gtpu.c:101
u32 flags
Definition: vhost-user.h:77
#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:481
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:67
vlib_node_registration_t gtpu4_input_node
(constructor) VLIB_REGISTER_NODE (gtpu4_input_node)
Definition: gtpu_decap.c:810
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:680
static uword unformat_decap_next(unformat_input_t *input, va_list *args)
Definition: gtpu.c:632
static u16 ip4_header_checksum(ip4_header_t *i)
Definition: ip4_packet.h:239
const ip46_address_t zero_addr
Definition: lookup.c:359
u32 mcast_sw_if_index
Definition: gtpu.h:140
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972
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:229
ip6_address_t dst_address
Definition: ip6_packet.h:341
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:169
#define MODE_L3
Definition: l2_input.h:202
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:128