FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
gre.c
Go to the documentation of this file.
1 /*
2  * gre.c: gre
3  *
4  * Copyright (c) 2012 Cisco and/or its affiliates.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #include <vnet/vnet.h>
19 #include <vnet/gre/gre.h>
20 #include <vnet/adj/adj_midchain.h>
21 #include <vnet/tunnel/tunnel_dp.h>
22 
23 extern gre_main_t gre_main;
24 
25 #ifndef CLIB_MARCH_VARIANT
27 
28 typedef struct
29 {
30  union
31  {
32  ip4_and_gre_header_t ip4_and_gre;
33  u64 as_u64[3];
34  };
36 
37 typedef struct
38 {
39  union
40  {
41  ip6_and_gre_header_t ip6_and_gre;
42  u64 as_u64[3];
43  };
45 #endif /* CLIB_MARCH_VARIANT */
46 
47 
48 /* Packet trace structure */
49 typedef struct
50 {
51  /* Tunnel-id / index in tunnel vector */
53 
54  /* pkt length */
56 
57  /* tunnel ip addresses */
58  ip46_address_t src;
59  ip46_address_t dst;
61 
62 extern u8 *format_gre_tx_trace (u8 * s, va_list * args);
63 
64 #ifndef CLIB_MARCH_VARIANT
65 u8 *
66 format_gre_tx_trace (u8 * s, va_list * args)
67 {
68  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
69  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
70  gre_tx_trace_t *t = va_arg (*args, gre_tx_trace_t *);
71 
72  s = format (s, "GRE: tunnel %d len %d src %U dst %U",
73  t->tunnel_id, t->length,
76  return s;
77 }
78 
79 u8 *
80 format_gre_protocol (u8 * s, va_list * args)
81 {
82  gre_protocol_t p = va_arg (*args, u32);
85 
86  if (pi)
87  s = format (s, "%s", pi->name);
88  else
89  s = format (s, "0x%04x", p);
90 
91  return s;
92 }
93 
94 u8 *
95 format_gre_header_with_length (u8 * s, va_list * args)
96 {
98  gre_header_t *h = va_arg (*args, gre_header_t *);
99  u32 max_header_bytes = va_arg (*args, u32);
100  gre_protocol_t p = clib_net_to_host_u16 (h->protocol);
101  u32 indent, header_bytes;
102 
103  header_bytes = sizeof (h[0]);
104  if (max_header_bytes != 0 && header_bytes > max_header_bytes)
105  return format (s, "gre header truncated");
106 
107  indent = format_get_indent (s);
108 
109  s = format (s, "GRE %U", format_gre_protocol, p);
110 
111  if (max_header_bytes != 0 && header_bytes < max_header_bytes)
112  {
114  vlib_node_t *node = vlib_get_node (gm->vlib_main, pi->node_index);
115  if (node->format_buffer)
116  s = format (s, "\n%U%U",
117  format_white_space, indent,
118  node->format_buffer, (void *) (h + 1),
119  max_header_bytes - header_bytes);
120  }
121 
122  return s;
123 }
124 
125 u8 *
126 format_gre_header (u8 * s, va_list * args)
127 {
128  gre_header_t *h = va_arg (*args, gre_header_t *);
129  return format (s, "%U", format_gre_header_with_length, h, 0);
130 }
131 
132 /* Returns gre protocol as an int in host byte order. */
133 uword
135  va_list * args)
136 {
137  u16 *result = va_arg (*args, u16 *);
138  gre_main_t *gm = &gre_main;
139  int i;
140 
141  /* Named type. */
143  gm->protocol_info_by_name, &i))
144  {
145  gre_protocol_info_t *pi = vec_elt_at_index (gm->protocol_infos, i);
146  *result = pi->protocol;
147  return 1;
148  }
149 
150  return 0;
151 }
152 
153 uword
155  va_list * args)
156 {
157  u16 *result = va_arg (*args, u16 *);
159  return 0;
160  *result = clib_host_to_net_u16 ((u16) * result);
161  return 1;
162 }
163 
164 uword
165 unformat_gre_header (unformat_input_t * input, va_list * args)
166 {
167  u8 **result = va_arg (*args, u8 **);
168  gre_header_t _h, *h = &_h;
169  u16 p;
170 
171  if (!unformat (input, "%U", unformat_gre_protocol_host_byte_order, &p))
172  return 0;
173 
174  h->protocol = clib_host_to_net_u16 (p);
175 
176  /* Add header to result. */
177  {
178  void *p;
179  u32 n_bytes = sizeof (h[0]);
180 
181  vec_add2 (*result, p, n_bytes);
182  clib_memcpy (p, h, n_bytes);
183  }
184 
185  return 1;
186 }
187 
188 static int
190 {
191  switch (link)
192  {
193  case VNET_LINK_IP4:
194  return (GRE_PROTOCOL_ip4);
195  case VNET_LINK_IP6:
196  return (GRE_PROTOCOL_ip6);
197  case VNET_LINK_MPLS:
198  return (GRE_PROTOCOL_mpls_unicast);
199  case VNET_LINK_ETHERNET:
200  return (GRE_PROTOCOL_teb);
201  case VNET_LINK_ARP:
202  return (GRE_PROTOCOL_arp);
203  case VNET_LINK_NSH:
204  ASSERT (0);
205  break;
206  }
207  ASSERT (0);
208  return (GRE_PROTOCOL_ip4);
209 }
210 
211 static u8 *
214  vnet_link_t link_type, const void *dst_address)
215 {
216  gre_main_t *gm = &gre_main;
217  const ip46_address_t *dst;
218  ip4_and_gre_header_t *h4;
219  ip6_and_gre_header_t *h6;
220  gre_header_t *gre;
221  u8 *rewrite = NULL;
222  gre_tunnel_t *t;
223  u32 ti;
224  u8 is_ipv6;
225 
226  dst = dst_address;
227  ti = gm->tunnel_index_by_sw_if_index[sw_if_index];
228 
229  if (~0 == ti)
230  /* not one of ours */
231  return (0);
232 
233  t = pool_elt_at_index (gm->tunnels, ti);
234 
236 
237  if (!is_ipv6)
238  {
239  vec_validate (rewrite, sizeof (*h4) - 1);
240  h4 = (ip4_and_gre_header_t *) rewrite;
241  gre = &h4->gre;
242  h4->ip4.ip_version_and_header_length = 0x45;
243  h4->ip4.ttl = 254;
244  h4->ip4.protocol = IP_PROTOCOL_GRE;
245  /* fixup ip4 header length and checksum after-the-fact */
246  h4->ip4.src_address.as_u32 = t->tunnel_src.ip4.as_u32;
247  h4->ip4.dst_address.as_u32 = dst->ip4.as_u32;
248  h4->ip4.checksum = ip4_header_checksum (&h4->ip4);
249  }
250  else
251  {
252  vec_validate (rewrite, sizeof (*h6) - 1);
253  h6 = (ip6_and_gre_header_t *) rewrite;
254  gre = &h6->gre;
255  h6->ip6.ip_version_traffic_class_and_flow_label =
256  clib_host_to_net_u32 (6 << 28);
257  h6->ip6.hop_limit = 255;
258  h6->ip6.protocol = IP_PROTOCOL_GRE;
259  /* fixup ip6 header length and checksum after-the-fact */
260  h6->ip6.src_address.as_u64[0] = t->tunnel_src.ip6.as_u64[0];
261  h6->ip6.src_address.as_u64[1] = t->tunnel_src.ip6.as_u64[1];
262  h6->ip6.dst_address.as_u64[0] = dst->ip6.as_u64[0];
263  h6->ip6.dst_address.as_u64[1] = dst->ip6.as_u64[1];
264  }
265 
266  if (PREDICT_FALSE (t->type == GRE_TUNNEL_TYPE_ERSPAN))
267  {
268  gre->protocol = clib_host_to_net_u16 (GRE_PROTOCOL_erspan);
269  gre->flags_and_version = clib_host_to_net_u16 (GRE_FLAGS_SEQUENCE);
270  }
271  else
272  gre->protocol =
273  clib_host_to_net_u16 (gre_proto_from_vnet_link (link_type));
274 
275  return (rewrite);
276 }
277 
278 static void
280  const ip_adjacency_t * adj, vlib_buffer_t * b0, const void *data)
281 {
283  ip4_and_gre_header_t *ip0;
284 
285  ip0 = vlib_buffer_get_current (b0);
287 
288  /* Fixup the checksum and len fields in the GRE tunnel encap
289  * that was applied at the midchain node */
290  ip0->ip4.length =
291  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0));
292  tunnel_encap_fixup_4o4 (flags, (ip4_header_t *) (ip0 + 1), &ip0->ip4);
293  ip0->ip4.checksum = ip4_header_checksum (&ip0->ip4);
294 }
295 
296 static void
298  const ip_adjacency_t * adj, vlib_buffer_t * b0, const void *data)
299 {
301  ip4_and_gre_header_t *ip0;
302 
303  ip0 = vlib_buffer_get_current (b0);
305 
306  /* Fixup the checksum and len fields in the GRE tunnel encap
307  * that was applied at the midchain node */
308  ip0->ip4.length =
309  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0));
310  tunnel_encap_fixup_6o4 (flags, (ip6_header_t *) (ip0 + 1), &ip0->ip4);
311  ip0->ip4.checksum = ip4_header_checksum (&ip0->ip4);
312 }
313 
314 static void
316  const ip_adjacency_t * adj, vlib_buffer_t * b0, const void *data)
317 {
318  ip4_header_t *ip0;
319 
320  ip0 = vlib_buffer_get_current (b0);
321 
322  /* Fixup the checksum and len fields in the GRE tunnel encap
323  * that was applied at the midchain node */
324  ip0->length = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0));
325  ip0->checksum = ip4_header_checksum (ip0);
326 }
327 
328 static void
330  const ip_adjacency_t * adj, vlib_buffer_t * b0, const void *data)
331 {
333  ip6_and_gre_header_t *ip0;
334 
335  ip0 = vlib_buffer_get_current (b0);
337 
338  /* Fixup the payload length field in the GRE tunnel encap that was applied
339  * at the midchain node */
340  ip0->ip6.payload_length =
341  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0) -
342  sizeof (ip0->ip6));
343  tunnel_encap_fixup_4o6 (flags, b0, (ip4_header_t *) (ip0 + 1), &ip0->ip6);
344 }
345 
346 static void
348  const ip_adjacency_t * adj, vlib_buffer_t * b0, const void *data)
349 {
351  ip6_and_gre_header_t *ip0;
352 
353  ip0 = vlib_buffer_get_current (b0);
355 
356  /* Fixup the payload length field in the GRE tunnel encap that was applied
357  * at the midchain node */
358  ip0->ip6.payload_length =
359  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0) -
360  sizeof (ip0->ip6));
361  tunnel_encap_fixup_6o6 (flags, (ip6_header_t *) (ip0 + 1), &ip0->ip6);
362 }
363 
364 static void
366  const ip_adjacency_t * adj, vlib_buffer_t * b0, const void *data)
367 {
368  ip6_and_gre_header_t *ip0;
369 
370  ip0 = vlib_buffer_get_current (b0);
371 
372  /* Fixup the payload length field in the GRE tunnel encap that was applied
373  * at the midchain node */
374  ip0->ip6.payload_length =
375  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0) -
376  sizeof (ip0->ip6));
377 }
378 
379 /**
380  * return the appropriate fixup function given the overlay (link-type) and
381  * underlay (fproto) combination
382  */
385 {
386  if (fproto == FIB_PROTOCOL_IP6 && lt == VNET_LINK_IP6)
387  return (gre66_fixup);
388  if (fproto == FIB_PROTOCOL_IP6 && lt == VNET_LINK_IP4)
389  return (gre46_fixup);
390  if (fproto == FIB_PROTOCOL_IP4 && lt == VNET_LINK_IP6)
391  return (gre64_fixup);
392  if (fproto == FIB_PROTOCOL_IP4 && lt == VNET_LINK_IP4)
393  return (gre44_fixup);
394  if (fproto == FIB_PROTOCOL_IP6)
395  return (grex6_fixup);
396  if (fproto == FIB_PROTOCOL_IP4)
397  return (grex4_fixup);
398 
399  ASSERT (0);
400  return (gre44_fixup);
401 }
402 
403 void
405 {
406  gre_main_t *gm = &gre_main;
407  gre_tunnel_t *t;
408  adj_flags_t af;
409  u32 ti;
410 
411  ti = gm->tunnel_index_by_sw_if_index[sw_if_index];
412  t = pool_elt_at_index (gm->tunnels, ti);
413  af = ADJ_FLAG_NONE;
414 
415  /*
416  * the user has not requested that the load-balancing be based on
417  * a flow hash of the inner packet. so use the stacking to choose
418  * a path.
419  */
420  if (!(t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_INNER_HASH))
422 
425 
428  adj_get_link_type (ai)),
429  uword_to_pointer (t->flags, void *), af,
431  &t->tunnel_dst.fp_addr));
432 
433  gre_tunnel_stack (ai);
434 }
435 
438 {
440  adj_flags_t af;
441 
442  af = ADJ_FLAG_NONE;
443 
444  /*
445  * the user has not requested that the load-balancing be based on
446  * a flow hash of the inner packet. so use the stacking to choose
447  * a path.
448  */
449  if (!(ctx->t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_INNER_HASH))
451 
453  (ai, gre_get_fixup (ctx->t->tunnel_dst.fp_proto,
454  adj_get_link_type (ai)),
455  uword_to_pointer (ctx->t->flags, void *),
456  af,
458  ctx->t->sw_if_index,
459  adj_get_link_type (ai),
460  &teib_entry_get_nh (ctx->ne)->fp_addr));
461 
462  teib_entry_adj_stack (ctx->ne, ai);
463 
464  return (ADJ_WALK_RC_CONTINUE);
465 }
466 
469 {
470  gre_tunnel_t *t = data;
471 
473  adj_get_link_type (ai)),
474  NULL, ADJ_FLAG_NONE, NULL);
475 
477 
478  return (ADJ_WALK_RC_CONTINUE);
479 }
480 
481 void
483 {
484  gre_main_t *gm = &gre_main;
485  ip_adjacency_t *adj;
486  teib_entry_t *ne;
487  gre_tunnel_t *t;
488  u32 ti;
489 
490  adj = adj_get (ai);
491  ti = gm->tunnel_index_by_sw_if_index[sw_if_index];
492  t = pool_elt_at_index (gm->tunnels, ti);
493 
495  adj->ia_nh_proto, &adj->sub_type.nbr.next_hop);
496 
497  if (NULL == ne)
498  {
499  // no TEIB entry to provide the next-hop
502  uword_to_pointer (t->flags, void *), ADJ_FLAG_NONE, NULL);
503  return;
504  }
505 
506  mgre_walk_ctx_t ctx = {
507  .t = t,
508  .ne = ne
509  };
511  adj->ia_nh_proto,
512  &adj->sub_type.nbr.next_hop, mgre_mk_complete_walk, &ctx);
513 }
514 #endif /* CLIB_MARCH_VARIANT */
515 
516 typedef enum
517 {
521 
522 /**
523  * @brief TX function. Only called for L2 payload including TEB or ERSPAN.
524  * L3 traffic uses the adj-midchains.
525  */
530 {
531  gre_main_t *gm = &gre_main;
532  u32 *from, n_left_from;
534  u32 sw_if_index[2] = { ~0, ~0 };
535  const gre_tunnel_t *gt[2] = { 0 };
536  adj_index_t adj_index[2] = { ADJ_INDEX_INVALID, ADJ_INDEX_INVALID };
537 
539  n_left_from = frame->n_vectors;
541 
542  while (n_left_from >= 2)
543  {
544 
545  if (PREDICT_FALSE
547  {
548  const vnet_hw_interface_t *hi;
549  sw_if_index[0] = vnet_buffer (b[0])->sw_if_index[VLIB_TX];
550  hi = vnet_get_sup_hw_interface (gm->vnet_main, sw_if_index[0]);
551  gt[0] = &gm->tunnels[hi->dev_instance];
552  adj_index[0] = gt[0]->l2_adj_index;
553  }
554  if (PREDICT_FALSE
556  {
557  const vnet_hw_interface_t *hi;
558  sw_if_index[1] = vnet_buffer (b[1])->sw_if_index[VLIB_TX];
559  hi = vnet_get_sup_hw_interface (gm->vnet_main, sw_if_index[1]);
560  gt[1] = &gm->tunnels[hi->dev_instance];
561  adj_index[1] = gt[1]->l2_adj_index;
562  }
563 
564  vnet_buffer (b[0])->ip.adj_index[VLIB_TX] = adj_index[0];
565  vnet_buffer (b[1])->ip.adj_index[VLIB_TX] = adj_index[1];
566 
567  if (type == GRE_TUNNEL_TYPE_ERSPAN)
568  {
569  /* Encap GRE seq# and ERSPAN type II header */
570  erspan_t2_t *h0;
571  u32 seq_num;
572  u64 hdr;
573  vlib_buffer_advance (b[0], -sizeof (erspan_t2_t));
574  h0 = vlib_buffer_get_current (b[0]);
575  seq_num = clib_atomic_fetch_add (&gt[0]->gre_sn->seq_num, 1);
576  hdr = clib_host_to_net_u64 (ERSPAN_HDR2);
577  h0->seq_num = clib_host_to_net_u32 (seq_num);
578  h0->t2_u64 = hdr;
579  h0->t2.cos_en_t_session |= clib_host_to_net_u16 (gt[0]->session_id);
580  }
581  if (type == GRE_TUNNEL_TYPE_ERSPAN)
582  {
583  /* Encap GRE seq# and ERSPAN type II header */
584  erspan_t2_t *h0;
585  u32 seq_num;
586  u64 hdr;
587  vlib_buffer_advance (b[1], -sizeof (erspan_t2_t));
588  h0 = vlib_buffer_get_current (b[1]);
589  seq_num = clib_atomic_fetch_add (&gt[1]->gre_sn->seq_num, 1);
590  hdr = clib_host_to_net_u64 (ERSPAN_HDR2);
591  h0->seq_num = clib_host_to_net_u32 (seq_num);
592  h0->t2_u64 = hdr;
593  h0->t2.cos_en_t_session |= clib_host_to_net_u16 (gt[1]->session_id);
594  }
595 
596  if (PREDICT_FALSE (b[0]->flags & VLIB_BUFFER_IS_TRACED))
597  {
599  b[0], sizeof (*tr));
600  tr->tunnel_id = gt[0] - gm->tunnels;
601  tr->src = gt[0]->tunnel_src;
602  tr->dst = gt[0]->tunnel_dst.fp_addr;
604  }
605  if (PREDICT_FALSE (b[1]->flags & VLIB_BUFFER_IS_TRACED))
606  {
608  b[1], sizeof (*tr));
609  tr->tunnel_id = gt[1] - gm->tunnels;
610  tr->src = gt[1]->tunnel_src;
611  tr->dst = gt[1]->tunnel_dst.fp_addr;
613  }
614 
615  b += 2;
616  n_left_from -= 2;
617  }
618 
619  while (n_left_from >= 1)
620  {
621 
622  if (PREDICT_FALSE
624  {
625  const vnet_hw_interface_t *hi;
626  sw_if_index[0] = vnet_buffer (b[0])->sw_if_index[VLIB_TX];
627  hi = vnet_get_sup_hw_interface (gm->vnet_main, sw_if_index[0]);
628  gt[0] = &gm->tunnels[hi->dev_instance];
629  adj_index[0] = gt[0]->l2_adj_index;
630  }
631 
632  vnet_buffer (b[0])->ip.adj_index[VLIB_TX] = adj_index[0];
633 
634  if (type == GRE_TUNNEL_TYPE_ERSPAN)
635  {
636  /* Encap GRE seq# and ERSPAN type II header */
637  erspan_t2_t *h0;
638  u32 seq_num;
639  u64 hdr;
640  ASSERT (gt[0]->type == GRE_TUNNEL_TYPE_ERSPAN);
641  vlib_buffer_advance (b[0], -sizeof (erspan_t2_t));
642  h0 = vlib_buffer_get_current (b[0]);
643  seq_num = clib_atomic_fetch_add (&gt[0]->gre_sn->seq_num, 1);
644  hdr = clib_host_to_net_u64 (ERSPAN_HDR2);
645  h0->seq_num = clib_host_to_net_u32 (seq_num);
646  h0->t2_u64 = hdr;
647  h0->t2.cos_en_t_session |= clib_host_to_net_u16 (gt[0]->session_id);
648  }
649 
650  if (PREDICT_FALSE (b[0]->flags & VLIB_BUFFER_IS_TRACED))
651  {
653  b[0], sizeof (*tr));
654  tr->tunnel_id = gt[0] - gm->tunnels;
655  tr->src = gt[0]->tunnel_src;
656  tr->dst = gt[0]->tunnel_dst.fp_addr;
658  }
659 
660  b += 1;
661  n_left_from -= 1;
662  }
663 
666  frame->n_vectors);
667 
668  vlib_node_increment_counter (vm, node->node_index,
669  GRE_ERROR_PKTS_ENCAP, frame->n_vectors);
670 
671  return frame->n_vectors;
672 }
673 
674 static char *gre_error_strings[] = {
675 #define gre_error(n,s) s,
676 #include "error.def"
677 #undef gre_error
678 };
679 
683 {
684  return (gre_encap_inline (vm, node, frame, GRE_TUNNEL_TYPE_TEB));
685 }
686 
690 {
691  return (gre_encap_inline (vm, node, frame, GRE_TUNNEL_TYPE_ERSPAN));
692 }
693 
694 /* *INDENT-OFF* */
696 {
697  .name = "gre-teb-encap",
698  .vector_size = sizeof (u32),
699  .format_trace = format_gre_tx_trace,
701  .n_errors = GRE_N_ERROR,
702  .error_strings = gre_error_strings,
703  .n_next_nodes = GRE_ENCAP_N_NEXT,
704  .next_nodes = {
705  [GRE_ENCAP_NEXT_L2_MIDCHAIN] = "adj-l2-midchain",
706  },
707 };
709 {
710  .name = "gre-erspan-encap",
711  .vector_size = sizeof (u32),
712  .format_trace = format_gre_tx_trace,
714  .n_errors = GRE_N_ERROR,
715  .error_strings = gre_error_strings,
716  .n_next_nodes = GRE_ENCAP_N_NEXT,
717  .next_nodes = {
718  [GRE_ENCAP_NEXT_L2_MIDCHAIN] = "adj-l2-midchain",
719  },
720 };
721 /* *INDENT-ON* */
722 
723 #ifndef CLIB_MARCH_VARIANT
724 static u8 *
725 format_gre_tunnel_name (u8 * s, va_list * args)
726 {
727  u32 dev_instance = va_arg (*args, u32);
728  gre_main_t *gm = &gre_main;
729  gre_tunnel_t *t;
730 
731  if (dev_instance >= vec_len (gm->tunnels))
732  return format (s, "<improperly-referenced>");
733 
734  t = pool_elt_at_index (gm->tunnels, dev_instance);
735  return format (s, "gre%d", t->user_instance);
736 }
737 
738 static u8 *
739 format_gre_device (u8 * s, va_list * args)
740 {
741  u32 dev_instance = va_arg (*args, u32);
742  CLIB_UNUSED (int verbose) = va_arg (*args, int);
743 
744  s = format (s, "GRE tunnel: id %d\n", dev_instance);
745  return s;
746 }
747 
748 static int
750  ip46_address_t * src, ip46_address_t * dst, u8 * is_l2)
751 {
752  gre_main_t *gm = &gre_main;
753  gre_tunnel_t *t;
754  u32 ti;
755 
756  ti = gm->tunnel_index_by_sw_if_index[sw_if_index];
757 
758  if (~0 == ti)
759  /* not one of ours */
760  return -1;
761 
762  t = pool_elt_at_index (gm->tunnels, ti);
763 
764  *src = t->tunnel_src;
765  *dst = t->tunnel_dst.fp_addr;
766  *is_l2 = t->type == GRE_TUNNEL_TYPE_TEB;
767 
768  return (0);
769 }
770 
771 /* *INDENT-OFF* */
773  .name = "GRE tunnel device",
774  .format_device_name = format_gre_tunnel_name,
775  .format_device = format_gre_device,
776  .format_tx_trace = format_gre_tx_trace,
777  .admin_up_down_function = gre_interface_admin_up_down,
778  .ip_tun_desc = gre_tunnel_desc,
779 #ifdef SOON
780  .clear counter = 0;
781 #endif
782 };
783 
785  .name = "GRE",
786  .format_header = format_gre_header_with_length,
787  .unformat_header = unformat_gre_header,
788  .build_rewrite = gre_build_rewrite,
789  .update_adjacency = gre_update_adj,
791 };
792 
794  .name = "mGRE",
795  .format_header = format_gre_header_with_length,
796  .unformat_header = unformat_gre_header,
797  .build_rewrite = gre_build_rewrite,
798  .update_adjacency = mgre_update_adj,
800 };
801 /* *INDENT-ON* */
802 #endif /* CLIB_MARCH_VARIANT */
803 
804 static void
806 {
808  u32 i;
809 
810  vec_add2 (gm->protocol_infos, pi, 1);
811  i = pi - gm->protocol_infos;
812 
813  pi->name = protocol_name;
814  pi->protocol = protocol;
815  pi->next_index = pi->node_index = ~0;
816 
817  hash_set (gm->protocol_info_by_protocol, protocol, i);
818  hash_set_mem (gm->protocol_info_by_name, pi->name, i);
819 }
820 
821 static clib_error_t *
823 {
824  gre_main_t *gm = &gre_main;
826  ip_main_t *im = &ip_main;
827  ip_protocol_info_t *pi;
828 
829  clib_memset (gm, 0, sizeof (gm[0]));
830  gm->vlib_main = vm;
831  gm->vnet_main = vnet_get_main ();
832 
834  return error;
835 
837  return error;
838 
840  return error;
841 
842  /* Set up the ip packet generator */
843  pi = ip_get_protocol_info (im, IP_PROTOCOL_GRE);
846 
847  gm->protocol_info_by_name = hash_create_string (0, sizeof (uword));
848  gm->protocol_info_by_protocol = hash_create (0, sizeof (uword));
849  gm->tunnel_by_key4 =
850  hash_create_mem (0, sizeof (gre_tunnel_key4_t), sizeof (uword));
851  gm->tunnel_by_key6 =
852  hash_create_mem (0, sizeof (gre_tunnel_key6_t), sizeof (uword));
853  gm->seq_num_by_key =
854  hash_create_mem (0, sizeof (gre_sn_key_t), sizeof (uword));
855 
856 #define _(n,s) add_protocol (gm, GRE_PROTOCOL_##s, #s);
858 #undef _
860 }
861 
863 
864 /*
865  * fd.io coding-style-patch-verification: ON
866  *
867  * Local Variables:
868  * eval: (c-set-style "gnu")
869  * End:
870  */
ADJ_FLAG_MIDCHAIN_NO_COUNT
@ ADJ_FLAG_MIDCHAIN_NO_COUNT
Definition: adj.h:217
ip4_and_gre_union_t
Definition: gre.c:28
ip6_and_gre_union_t
Definition: gre.c:37
format_gre_tunnel_name
static u8 * format_gre_tunnel_name(u8 *s, va_list *args)
Definition: gre.c:725
gre_tunnel_t::type
gre_tunnel_type_t type
Definition: gre.h:206
im
vnet_interface_main_t * im
Definition: interface_output.c:395
adj_midchain.h
ip_adjacency_t_::ia_nh_proto
fib_protocol_t ia_nh_proto
The protocol of the neighbor/peer.
Definition: adj.h:350
unformat_user
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:989
teib_entry_find_46
teib_entry_t * teib_entry_find_46(u32 sw_if_index, fib_protocol_t fproto, const ip46_address_t *peer)
Definition: teib.c:131
gre_tunnel_key6_t_
Key for a IPv6 GRE Tunnel We use a different type so that the V4 key hash is as small as possible.
Definition: gre.h:135
gre_protocol_info_t::name
char * name
Name (a c string).
Definition: gre.h:72
bufs
vlib_buffer_t * bufs[VLIB_FRAME_SIZE]
Definition: nat44_ei_out2in.c:717
tunnel_encap_decap_flags_t
enum tunnel_encap_decap_flags_t_ tunnel_encap_decap_flags_t
frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: nat44_ei.c:3048
format_gre_tx_trace
u8 * format_gre_tx_trace(u8 *s, va_list *args)
Definition: gre.c:66
mgre_update_adj
void mgre_update_adj(vnet_main_t *vnm, u32 sw_if_index, adj_index_t ai)
Definition: gre.c:482
is_ipv6
bool is_ipv6
Definition: dhcp.api:202
gre_main
gre_main_t gre_main
Definition: gre.c:26
clib_memcpy
#define clib_memcpy(d, s, n)
Definition: string.h:197
VNET_LINK_ETHERNET
@ VNET_LINK_ETHERNET
Definition: interface.h:350
gre_main_t
GRE related global data.
Definition: gre.h:242
pointer_to_uword
static uword pointer_to_uword(const void *p)
Definition: types.h:131
ADJ_INDEX_INVALID
#define ADJ_INDEX_INVALID
Invalid ADJ index - used when no adj is known likewise blazoned capitals INVALID speak volumes where ...
Definition: adj_types.h:36
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:553
GRE_FLAGS_SEQUENCE
#define GRE_FLAGS_SEQUENCE
Definition: packet.h:47
adj_midchain_fixup_t
void(* adj_midchain_fixup_t)(vlib_main_t *vm, const struct ip_adjacency_t_ *adj, vlib_buffer_t *b0, const void *data)
A function type for post-rewrite fixups on midchain adjacency.
Definition: adj.h:152
vlib_get_buffers
vlib_get_buffers(vm, from, b, n_left_from)
VLIB_NODE_TYPE_INTERNAL
@ VLIB_NODE_TYPE_INTERNAL
Definition: node.h:72
gre_build_rewrite
static u8 * gre_build_rewrite(vnet_main_t *vnm, u32 sw_if_index, vnet_link_t link_type, const void *dst_address)
Definition: gre.c:212
VLIB_FRAME_SIZE
#define VLIB_FRAME_SIZE
Definition: node.h:368
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
adj_walk_rc_t
enum adj_walk_rc_t_ adj_walk_rc_t
return codes from a adjacency walker callback function
ip_main
ip_main_t ip_main
Definition: ip_init.c:42
ip_get_protocol_info
static ip_protocol_info_t * ip_get_protocol_info(ip_main_t *im, u32 protocol)
Definition: ip.h:134
ip_protocol_info_t::format_header
format_function_t * format_header
Definition: ip.h:79
mgre_mk_incomplete_walk
adj_walk_rc_t mgre_mk_incomplete_walk(adj_index_t ai, void *data)
Definition: gre.c:468
gre_protocol_info_t
A GRE payload protocol registration.
Definition: gre.h:69
u16
unsigned short u16
Definition: types.h:57
gre_header_t::flags_and_version
u16 flags_and_version
Definition: packet.h:40
gre_protocol_info_t::protocol
gre_protocol_t protocol
GRE protocol type in host byte order.
Definition: gre.h:75
gre_tunnel_t::flags
tunnel_encap_decap_flags_t flags
Definition: gre.h:208
vlib_call_init_function
#define vlib_call_init_function(vm, x)
Definition: init.h:259
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
tunnel_encap_fixup_6o4
static_always_inline void tunnel_encap_fixup_6o4(tunnel_encap_decap_flags_t flags, const ip6_header_t *inner, ip4_header_t *outer)
Definition: tunnel_dp.h:95
hash_create_string
#define hash_create_string(elts, value_bytes)
Definition: hash.h:689
ERSPAN_HDR2
#define ERSPAN_HDR2
Definition: packet.h:164
VNET_LINK_ARP
@ VNET_LINK_ARP
Definition: interface.h:351
unformat_gre_protocol_net_byte_order
uword unformat_gre_protocol_net_byte_order(unformat_input_t *input, va_list *args)
Definition: gre.c:154
hi
vl_api_ip4_address_t hi
Definition: arp.api:37
gre66_fixup
static void gre66_fixup(vlib_main_t *vm, const ip_adjacency_t *adj, vlib_buffer_t *b0, const void *data)
Definition: gre.c:347
unformat_input_t
struct _unformat_input_t unformat_input_t
unformat_pg_gre_header
unformat_function_t unformat_pg_gre_header
Definition: gre.h:355
vlib_frame_t
Definition: node.h:372
hash_create
#define hash_create(elts, value_bytes)
Definition: hash.h:695
error.def
vlib_buffer_length_in_chain
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
Definition: buffer_funcs.h:433
GRE_N_ERROR
@ GRE_N_ERROR
Definition: gre.h:37
teib_entry_get_nh
const fib_prefix_t * teib_entry_get_nh(const teib_entry_t *te)
Definition: teib.c:96
ip4_header_t
Definition: ip4_packet.h:87
h
h
Definition: flowhash_template.h:372
error
Definition: cJSON.c:88
GRE_ENCAP_N_NEXT
@ GRE_ENCAP_N_NEXT
Definition: gre.c:519
ip4_header_t::length
u16 length
Definition: ip4_packet.h:99
gre_interface_admin_up_down
clib_error_t * gre_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: interface.c:605
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
hash_set
#define hash_set(h, key, value)
Definition: hash.h:255
gre_tunnel_t::tunnel_dst
fib_prefix_t tunnel_dst
The tunnel's destination/remote address.
Definition: gre.h:199
adj_flags_t
enum adj_flags_t_ adj_flags_t
Flags on an IP adjacency.
gre_encap_next_t
gre_encap_next_t
Definition: gre.c:516
ti
u32 ti
Definition: interface_output.c:405
gre_tx_trace_t::dst
ip46_address_t dst
Definition: gre.c:59
gre_get_fixup
static adj_midchain_fixup_t gre_get_fixup(fib_protocol_t fproto, vnet_link_t lt)
return the appropriate fixup function given the overlay (link-type) and underlay (fproto) combination
Definition: gre.c:384
vlib_buffer_enqueue_to_single_next
static_always_inline void vlib_buffer_enqueue_to_single_next(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, u16 next_index, u32 count)
Definition: buffer_node.h:348
tunnel_encap_fixup_6o6
static_always_inline void tunnel_encap_fixup_6o6(tunnel_encap_decap_flags_t flags, const ip6_header_t *inner, ip6_header_t *outer)
Definition: tunnel_dp.h:129
mgre_mk_complete_walk
adj_walk_rc_t mgre_mk_complete_walk(adj_index_t ai, void *data)
Definition: gre.c:437
teib_entry_t_
Definition: teib.c:33
vlib_buffer_advance
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:276
unformat_gre_protocol_host_byte_order
uword unformat_gre_protocol_host_byte_order(unformat_input_t *input, va_list *args)
Definition: gre.c:134
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
gre_init
static clib_error_t * gre_init(vlib_main_t *vm)
Definition: gre.c:822
gre_tunnel_t::l2_adj_index
adj_index_t l2_adj_index
an L2 tunnel always rquires an L2 midchain.
Definition: gre.h:213
VNET_LINK_IP4
@ VNET_LINK_IP4
Definition: interface.h:344
VLIB_NODE_FN
#define VLIB_NODE_FN(node)
Definition: node.h:202
vec_add2
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:644
gre_tunnel_type_t
enum gre_tunnel_type_t_ gre_tunnel_type_t
The GRE tunnel type.
ip6_and_gre_union_t::ip6_and_gre
ip6_and_gre_header_t ip6_and_gre
Definition: gre.c:41
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
vnet_buffer
#define vnet_buffer(b)
Definition: buffer.h:437
vec_elt_at_index
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Definition: vec_bootstrap.h:203
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
mgre_walk_ctx_t_
Definition: gre.h:329
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
vlib_frame_vector_args
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:301
static_always_inline
#define static_always_inline
Definition: clib.h:112
ip4_lookup_init
static clib_error_t * ip4_lookup_init(vlib_main_t *vm)
Definition: ip4_forward.c:1109
gre_protocol_t
gre_protocol_t
Definition: packet.h:30
format_gre_protocol
u8 * format_gre_protocol(u8 *s, va_list *args)
Definition: gre.c:80
VNET_LINK_NSH
@ VNET_LINK_NSH
Definition: interface.h:352
uword
u64 uword
Definition: types.h:112
hash_create_mem
#define hash_create_mem(elts, key_bytes, value_bytes)
Definition: hash.h:660
VNET_LINK_MPLS
@ VNET_LINK_MPLS
Definition: interface.h:349
gre_tunnel_t
A representation of a GRE tunnel.
Definition: gre.h:185
format_gre_header_with_length
u8 * format_gre_header_with_length(u8 *s, va_list *args)
Definition: gre.c:95
hash_set_mem
#define hash_set_mem(h, key, value)
Definition: hash.h:275
vlib_node_increment_counter
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1244
vlib_get_node
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
Definition: node_funcs.h:86
i
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261
gre_protocol_info_t::node_index
u32 node_index
Node which handles this type.
Definition: gre.h:81
gre_encap_inline
static_always_inline u32 gre_encap_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, gre_tunnel_type_t type)
TX function.
Definition: gre.c:527
session_id
u32 session_id
Definition: flow_types.api:131
unformat_gre_header
uword unformat_gre_header(unformat_input_t *input, va_list *args)
Definition: gre.c:165
tunnel_encap_fixup_4o4
static_always_inline void tunnel_encap_fixup_4o4(tunnel_encap_decap_flags_t flags, const ip4_header_t *inner, ip4_header_t *outer)
Definition: tunnel_dp.h:25
vec_validate
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
Definition: vec.h:523
ip4_header_t::checksum
u16 checksum
Definition: ip4_packet.h:118
src
vl_api_address_t src
Definition: gre.api:54
fib_protocol_t
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
gre_tunnel_t::tunnel_src
ip46_address_t tunnel_src
The tunnel's source/local address.
Definition: gre.h:195
gre_tunnel_stack
void gre_tunnel_stack(adj_index_t ai)
gre_tunnel_stack
Definition: interface.c:130
ip_adjacency_t_
IP unicast adjacency.
Definition: adj.h:235
FIB_PROTOCOL_IP4
@ FIB_PROTOCOL_IP4
Definition: fib_types.h:36
gre_teb_encap_node
vlib_node_registration_t gre_teb_encap_node
(constructor) VLIB_REGISTER_NODE (gre_teb_encap_node)
Definition: gre.c:695
gre_tunnel_key4_t_
Key for a IPv4 GRE Tunnel.
Definition: gre.h:110
ip6_lookup_init
static clib_error_t * ip6_lookup_init(vlib_main_t *vm)
Definition: ip6_forward.c:2791
ip_main_init
clib_error_t * ip_main_init(vlib_main_t *vm)
Definition: ip_init.c:45
add_protocol
static void add_protocol(gre_main_t *gm, gre_protocol_t protocol, char *protocol_name)
Definition: gre.c:805
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
grex6_fixup
static void grex6_fixup(vlib_main_t *vm, const ip_adjacency_t *adj, vlib_buffer_t *b0, const void *data)
Definition: gre.c:365
gre_header_t::protocol
u16 protocol
Definition: packet.h:55
fib_prefix_t_::fp_addr
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:225
ADJ_FLAG_NONE
@ ADJ_FLAG_NONE
Definition: adj.h:215
adj_midchain_delegate_unstack
void adj_midchain_delegate_unstack(adj_index_t ai)
unstack a midchain delegate (this stacks it on a drop)
Definition: adj_midchain_delegate.c:135
gm
#define gm
Definition: dlmalloc.c:1219
clib_atomic_fetch_add
#define clib_atomic_fetch_add(a, b)
Definition: atomics.h:23
data
u8 data[128]
Definition: ipsec_types.api:92
gre_protocol_info_t::next_index
u32 next_index
Next index for this type.
Definition: gre.h:84
vnet_hw_interface_t
Definition: interface.h:638
vnet_main_t
Definition: vnet.h:76
ip_adjacency_t_::sub_type
union ip_adjacency_t_::@144 sub_type
adj_nbr_midchain_update_rewrite
void adj_nbr_midchain_update_rewrite(adj_index_t adj_index, adj_midchain_fixup_t fixup, const void *fixup_data, adj_flags_t flags, u8 *rewrite)
adj_nbr_midchain_update_rewrite
Definition: adj_midchain.c:213
gre_hw_interface_class
vnet_hw_interface_class_t gre_hw_interface_class
gre_proto_from_vnet_link
static int gre_proto_from_vnet_link(vnet_link_t link)
Definition: gre.c:189
gre_tunnel_desc
static int gre_tunnel_desc(u32 sw_if_index, ip46_address_t *src, ip46_address_t *dst, u8 *is_l2)
Definition: gre.c:749
u64
unsigned long u64
Definition: types.h:89
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
format_get_indent
static u32 format_get_indent(u8 *s)
Definition: format.h:72
gre_input_init
static clib_error_t * gre_input_init(vlib_main_t *vm)
Definition: node.c:540
format_ip46_address
format_function_t format_ip46_address
Definition: ip46_address.h:50
adj_get_link_type
vnet_link_t adj_get_link_type(adj_index_t ai)
Return the link type of the adjacency.
Definition: adj.c:530
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
vnet_get_sup_hw_interface
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
Definition: interface_funcs.h:92
ip_protocol_info_t
Definition: ip.h:70
protocol
vl_api_ip_proto_t protocol
Definition: lb_types.api:72
n_bytes
u32 n_bytes
Definition: interface_output.c:401
gre_error_strings
static char * gre_error_strings[]
Definition: gre.c:674
FIB_PROTOCOL_IP6
@ FIB_PROTOCOL_IP6
Definition: fib_types.h:37
dst
vl_api_ip4_address_t dst
Definition: pnat.api:41
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
as_u64
u64 as_u64
Definition: bihash_doc.h:63
grex4_fixup
static void grex4_fixup(vlib_main_t *vm, const ip_adjacency_t *adj, vlib_buffer_t *b0, const void *data)
Definition: gre.c:315
fib_prefix_t_::fp_proto
fib_protocol_t fp_proto
protocol type
Definition: fib_types.h:211
gre_tx_trace_t
Definition: gre.c:49
ip6_header_t
Definition: ip6_packet.h:294
adj_index_t
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
gre_get_protocol_info
static gre_protocol_info_t * gre_get_protocol_info(gre_main_t *em, gre_protocol_t protocol)
Definition: gre.h:314
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
vnet_link_t
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
vlib_node_t
Definition: node.h:247
gre_header_t
Definition: packet.h:37
vlib_add_trace
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace.c:628
foreach_gre_protocol
@ foreach_gre_protocol
Definition: packet.h:33
gre46_fixup
static void gre46_fixup(vlib_main_t *vm, const ip_adjacency_t *adj, vlib_buffer_t *b0, const void *data)
Definition: gre.c:329
b
vlib_buffer_t ** b
Definition: nat44_ei_out2in.c:717
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
VNET_LINK_IP6
@ VNET_LINK_IP6
Definition: interface.h:348
vlib_buffer_get_current
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:257
gre_tx_trace_t::src
ip46_address_t src
Definition: gre.c:58
ip4_header_checksum
static u16 ip4_header_checksum(ip4_header_t *i)
Definition: ip4_packet.h:314
adj_nbr_walk_nh
void adj_nbr_walk_nh(u32 sw_if_index, fib_protocol_t adj_nh_proto, const ip46_address_t *nh, adj_walk_cb_t cb, void *ctx)
Walk adjacencies on a link with a given next-hop.
Definition: adj_nbr.c:684
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
uword_to_pointer
#define uword_to_pointer(u, type)
Definition: types.h:136
teib_entry_adj_stack
void teib_entry_adj_stack(const teib_entry_t *te, adj_index_t ai)
Definition: teib.c:102
ADJ_WALK_RC_CONTINUE
@ ADJ_WALK_RC_CONTINUE
Definition: adj_types.h:44
ip_adjacency_t_::nbr
struct ip_adjacency_t_::@144::@145 nbr
IP_LOOKUP_NEXT_ARP/IP_LOOKUP_NEXT_REWRITE.
VNET_HW_INTERFACE_CLASS_FLAG_P2P
@ VNET_HW_INTERFACE_CLASS_FLAG_P2P
a point 2 point interface
Definition: interface.h:394
GRE_ENCAP_NEXT_L2_MIDCHAIN
@ GRE_ENCAP_NEXT_L2_MIDCHAIN
Definition: gre.c:518
VNET_HW_INTERFACE_CLASS
VNET_HW_INTERFACE_CLASS(gre_hw_interface_class)
gre64_fixup
static void gre64_fixup(vlib_main_t *vm, const ip_adjacency_t *adj, vlib_buffer_t *b0, const void *data)
Definition: gre.c:297
gre_tx_trace_t::length
u32 length
Definition: gre.c:55
IP46_TYPE_ANY
@ IP46_TYPE_ANY
Definition: ip46_address.h:24
format_gre_device
static u8 * format_gre_device(u8 *s, va_list *args)
Definition: gre.c:739
ip_main_t
Definition: ip.h:107
VNET_HW_INTERFACE_CLASS_FLAG_NBMA
@ VNET_HW_INTERFACE_CLASS_FLAG_NBMA
a non-broadcast multiple access interface
Definition: interface.h:398
vnet.h
gre_sn_key_t
Hash key for GRE header seq number generation for ERSPAN encap.
Definition: gre.h:175
vlib_node_runtime_t
Definition: node.h:454
gre44_fixup
static void gre44_fixup(vlib_main_t *vm, const ip_adjacency_t *adj, vlib_buffer_t *b0, const void *data)
Definition: gre.c:279
tunnel_encap_fixup_4o6
static_always_inline void tunnel_encap_fixup_4o6(tunnel_encap_decap_flags_t flags, const vlib_buffer_t *b, const ip4_header_t *inner, ip6_header_t *outer)
Definition: tunnel_dp.h:145
VNET_DEVICE_CLASS
VNET_DEVICE_CLASS(gre_device_class)
gre_erspan_encap_node
vlib_node_registration_t gre_erspan_encap_node
(constructor) VLIB_REGISTER_NODE (gre_erspan_encap_node)
Definition: gre.c:708
from
from
Definition: nat44_ei_hairpinning.c:415
format_gre_header
u8 * format_gre_header(u8 *s, va_list *args)
Definition: gre.c:126
unformat_vlib_number_by_name
uword unformat_vlib_number_by_name(unformat_input_t *input, va_list *args)
Definition: format.c:157
ip4_and_gre_union_t::ip4_and_gre
ip4_and_gre_header_t ip4_and_gre
Definition: gre.c:32
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
gre_tunnel_t::user_instance
u32 user_instance
Definition: gre.h:230
rewrite
rewrite
Definition: pnat.api:158
ip_protocol_info_t::unformat_pg_edit
unformat_function_t * unformat_pg_edit
Definition: ip.h:88
VLIB_TX
@ VLIB_TX
Definition: defs.h:47
mgre_hw_interface_class
vnet_hw_interface_class_t mgre_hw_interface_class
ADJ_FLAG_MIDCHAIN_IP_STACK
@ ADJ_FLAG_MIDCHAIN_IP_STACK
Definition: adj.h:218
adj_get
static ip_adjacency_t * adj_get(adj_index_t adj_index)
Get a pointer to an adjacency object from its index.
Definition: adj.h:470
n_left_from
n_left_from
Definition: nat44_ei_hairpinning.c:416
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
gre_tx_trace_t::tunnel_id
u32 tunnel_id
Definition: gre.c:52
format_white_space
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:129
gre_update_adj
void gre_update_adj(vnet_main_t *vnm, u32 sw_if_index, adj_index_t ai)
Definition: gre.c:404
gre.h
tunnel_dp.h
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
gre_device_class
vnet_device_class_t gre_device_class
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105