FD.io VPP  v18.01.2-1-g9b554f3
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 
23 
24 typedef struct
25 {
26  union
27  {
28  ip4_and_gre_header_t ip4_and_gre;
29  u64 as_u64[3];
30  };
32 
33 typedef struct
34 {
35  union
36  {
37  ip6_and_gre_header_t ip6_and_gre;
38  u64 as_u64[3];
39  };
41 
42 
43 /* Packet trace structure */
44 typedef struct
45 {
46  /* Tunnel-id / index in tunnel vector */
48 
49  /* pkt length */
51 
52  /* tunnel ip addresses */
53  ip46_address_t src;
54  ip46_address_t dst;
56 
57 u8 *
58 format_gre_tx_trace (u8 * s, va_list * args)
59 {
60  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
61  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
62  gre_tx_trace_t *t = va_arg (*args, gre_tx_trace_t *);
63 
64  s = format (s, "GRE: tunnel %d len %d src %U dst %U",
65  t->tunnel_id, clib_net_to_host_u16 (t->length),
68  return s;
69 }
70 
71 u8 *
72 format_gre_protocol (u8 * s, va_list * args)
73 {
74  gre_protocol_t p = va_arg (*args, u32);
75  gre_main_t *gm = &gre_main;
77 
78  if (pi)
79  s = format (s, "%s", pi->name);
80  else
81  s = format (s, "0x%04x", p);
82 
83  return s;
84 }
85 
86 u8 *
87 format_gre_header_with_length (u8 * s, va_list * args)
88 {
89  gre_main_t *gm = &gre_main;
90  gre_header_t *h = va_arg (*args, gre_header_t *);
91  u32 max_header_bytes = va_arg (*args, u32);
92  gre_protocol_t p = clib_net_to_host_u16 (h->protocol);
93  u32 indent, header_bytes;
94 
95  header_bytes = sizeof (h[0]);
96  if (max_header_bytes != 0 && header_bytes > max_header_bytes)
97  return format (s, "gre header truncated");
98 
99  indent = format_get_indent (s);
100 
101  s = format (s, "GRE %U", format_gre_protocol, p);
102 
103  if (max_header_bytes != 0 && header_bytes > max_header_bytes)
104  {
106  vlib_node_t *node = vlib_get_node (gm->vlib_main, pi->node_index);
107  if (node->format_buffer)
108  s = format (s, "\n%U%U",
109  format_white_space, indent,
110  node->format_buffer, (void *) (h + 1),
111  max_header_bytes - header_bytes);
112  }
113 
114  return s;
115 }
116 
117 u8 *
118 format_gre_header (u8 * s, va_list * args)
119 {
120  gre_header_t *h = va_arg (*args, gre_header_t *);
121  return format (s, "%U", format_gre_header_with_length, h, 0);
122 }
123 
124 /* Returns gre protocol as an int in host byte order. */
125 uword
127  va_list * args)
128 {
129  u16 *result = va_arg (*args, u16 *);
130  gre_main_t *gm = &gre_main;
131  int i;
132 
133  /* Named type. */
135  gm->protocol_info_by_name, &i))
136  {
138  *result = pi->protocol;
139  return 1;
140  }
141 
142  return 0;
143 }
144 
145 uword
147  va_list * args)
148 {
149  u16 *result = va_arg (*args, u16 *);
151  return 0;
152  *result = clib_host_to_net_u16 ((u16) * result);
153  return 1;
154 }
155 
156 uword
157 unformat_gre_header (unformat_input_t * input, va_list * args)
158 {
159  u8 **result = va_arg (*args, u8 **);
160  gre_header_t _h, *h = &_h;
161  u16 p;
162 
163  if (!unformat (input, "%U", unformat_gre_protocol_host_byte_order, &p))
164  return 0;
165 
166  h->protocol = clib_host_to_net_u16 (p);
167 
168  /* Add header to result. */
169  {
170  void *p;
171  u32 n_bytes = sizeof (h[0]);
172 
173  vec_add2 (*result, p, n_bytes);
174  clib_memcpy (p, h, n_bytes);
175  }
176 
177  return 1;
178 }
179 
180 static int
182 {
183  switch (link)
184  {
185  case VNET_LINK_IP4:
186  return (GRE_PROTOCOL_ip4);
187  case VNET_LINK_IP6:
188  return (GRE_PROTOCOL_ip6);
189  case VNET_LINK_MPLS:
190  return (GRE_PROTOCOL_mpls_unicast);
191  case VNET_LINK_ETHERNET:
192  return (GRE_PROTOCOL_teb);
193  case VNET_LINK_ARP:
194  return (GRE_PROTOCOL_arp);
195  case VNET_LINK_NSH:
196  ASSERT (0);
197  break;
198  }
199  ASSERT (0);
200  return (GRE_PROTOCOL_ip4);
201 }
202 
203 static u8 *
205  u32 sw_if_index,
206  vnet_link_t link_type, const void *dst_address)
207 {
208  gre_main_t *gm = &gre_main;
209  ip4_and_gre_header_t *h4;
210  ip6_and_gre_header_t *h6;
211  u8 *rewrite = NULL;
212  gre_tunnel_t *t;
213  u32 ti;
214  u8 is_ipv6;
215 
216  ti = gm->tunnel_index_by_sw_if_index[sw_if_index];
217 
218  if (~0 == ti)
219  /* not one of ours */
220  return (0);
221 
222  t = pool_elt_at_index (gm->tunnels, ti);
223 
224  is_ipv6 = t->tunnel_dst.fp_proto == FIB_PROTOCOL_IP6 ? 1 : 0;
225 
226  if (!is_ipv6)
227  {
228  vec_validate (rewrite, sizeof (*h4) - 1);
229  h4 = (ip4_and_gre_header_t *) rewrite;
230  h4->gre.protocol =
231  clib_host_to_net_u16 (gre_proto_from_vnet_link (link_type));
232 
233  h4->ip4.ip_version_and_header_length = 0x45;
234  h4->ip4.ttl = 254;
235  h4->ip4.protocol = IP_PROTOCOL_GRE;
236  /* fixup ip4 header length and checksum after-the-fact */
237  h4->ip4.src_address.as_u32 = t->tunnel_src.ip4.as_u32;
238  h4->ip4.dst_address.as_u32 = t->tunnel_dst.fp_addr.ip4.as_u32;
239  h4->ip4.checksum = ip4_header_checksum (&h4->ip4);
240  }
241  else
242  {
243  vec_validate (rewrite, sizeof (*h6) - 1);
244  h6 = (ip6_and_gre_header_t *) rewrite;
245  h6->gre.protocol =
246  clib_host_to_net_u16 (gre_proto_from_vnet_link (link_type));
247 
248  h6->ip6.ip_version_traffic_class_and_flow_label =
249  clib_host_to_net_u32 (6 << 28);
250  h6->ip6.hop_limit = 255;
251  h6->ip6.protocol = IP_PROTOCOL_GRE;
252  /* fixup ip6 header length and checksum after-the-fact */
253  h6->ip6.src_address.as_u64[0] = t->tunnel_src.ip6.as_u64[0];
254  h6->ip6.src_address.as_u64[1] = t->tunnel_src.ip6.as_u64[1];
255  h6->ip6.dst_address.as_u64[0] = t->tunnel_dst.fp_addr.ip6.as_u64[0];
256  h6->ip6.dst_address.as_u64[1] = t->tunnel_dst.fp_addr.ip6.as_u64[1];
257  }
258 
259  return (rewrite);
260 }
261 
262 #define is_v4_packet(_h) ((*(u8*) _h) & 0xF0) == 0x40
263 
264 void
266 {
267  ip4_header_t *ip0;
268 
269  ip0 = vlib_buffer_get_current (b0);
270 
271  /* Fixup the checksum and len fields in the GRE tunnel encap
272  * that was applied at the midchain node */
273  ip0->length = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0));
274  ip0->checksum = ip4_header_checksum (ip0);
275 }
276 
277 void
279 {
280  ip6_header_t *ip0;
281 
282  ip0 = vlib_buffer_get_current (b0);
283 
284  /* Fixup the payload length field in the GRE tunnel encap that was applied
285  * at the midchain node */
286  ip0->payload_length =
287  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0))
288  - sizeof (*ip0);
289 }
290 
291 void
292 gre_update_adj (vnet_main_t * vnm, u32 sw_if_index, adj_index_t ai)
293 {
294  gre_main_t *gm = &gre_main;
295  gre_tunnel_t *t;
296  u32 ti;
297  u8 is_ipv6;
298 
299  ti = gm->tunnel_index_by_sw_if_index[sw_if_index];
300  t = pool_elt_at_index (gm->tunnels, ti);
301  is_ipv6 = t->tunnel_dst.fp_proto == FIB_PROTOCOL_IP6 ? 1 : 0;
302 
305  adj_get_link_type (ai) ?
308  sw_if_index,
310  (ai),
311  NULL));
312 
313  gre_tunnel_stack (ai);
314 }
315 
316 /**
317  * @brief TX function. Only called L2. L3 traffic uses the adj-midchains
318  */
319 static uword
321  vlib_node_runtime_t * node, vlib_frame_t * frame)
322 {
323  gre_main_t *gm = &gre_main;
324  u32 next_index;
325  u32 *from, *to_next, n_left_from, n_left_to_next;
326  vnet_interface_output_runtime_t *rd = (void *) node->runtime_data;
327  const gre_tunnel_t *gt = pool_elt_at_index (gm->tunnels, rd->dev_instance);
328  u8 is_ipv6 = gt->tunnel_dst.fp_proto == FIB_PROTOCOL_IP6 ? 1 : 0;
329 
330  /* Vector of buffer / pkt indices we're supposed to process */
331  from = vlib_frame_vector_args (frame);
332 
333  /* Number of buffers / pkts */
334  n_left_from = frame->n_vectors;
335 
336  /* Speculatively send the first buffer to the last disposition we used */
337  next_index = node->cached_next_index;
338 
339  while (n_left_from > 0)
340  {
341  /* set up to enqueue to our disposition with index = next_index */
342  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
343 
344  /*
345  * FIXME DUAL LOOP
346  */
347 
348  while (n_left_from > 0 && n_left_to_next > 0)
349  {
350  vlib_buffer_t *b0;
351  u32 bi0;
352 
353  bi0 = from[0];
354  to_next[0] = bi0;
355  from += 1;
356  to_next += 1;
357  n_left_from -= 1;
358  n_left_to_next -= 1;
359 
360  b0 = vlib_get_buffer (vm, bi0);
361 
362  vnet_buffer (b0)->ip.adj_index[VLIB_TX] = gt->l2_adj_index;
363 
365  {
366  gre_tx_trace_t *tr = vlib_add_trace (vm, node,
367  b0, sizeof (*tr));
368  tr->tunnel_id = gt - gm->tunnels;
369  tr->src = gt->tunnel_src;
370  tr->dst = gt->tunnel_src;
371  tr->length = vlib_buffer_length_in_chain (vm, b0);
372  }
373 
374  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
375  to_next, n_left_to_next,
376  bi0, gt->l2_tx_arc);
377  }
378 
379  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
380  }
381 
382  vlib_node_increment_counter (vm, !is_ipv6 ? gre4_input_node.index :
383  gre6_input_node.index,
384  GRE_ERROR_PKTS_ENCAP, frame->n_vectors);
385 
386  return frame->n_vectors;
387 }
388 
389 static uword
391  vlib_node_runtime_t * node, vlib_frame_t * frame)
392 {
393  return (gre_interface_tx_inline (vm, node, frame));
394 }
395 
396 static uword
398  vlib_node_runtime_t * node, vlib_frame_t * frame)
399 {
400  return (gre_interface_tx_inline (vm, node, frame));
401 }
402 
403 static u8 *
404 format_gre_tunnel_name (u8 * s, va_list * args)
405 {
406  u32 dev_instance = va_arg (*args, u32);
407  return format (s, "gre%d", dev_instance);
408 }
409 
410 static u8 *
411 format_gre_tunnel_teb_name (u8 * s, va_list * args)
412 {
413  u32 dev_instance = va_arg (*args, u32);
414  return format (s, "teb-gre%d", dev_instance);
415 }
416 
417 static u8 *
418 format_gre_device (u8 * s, va_list * args)
419 {
420  u32 dev_instance = va_arg (*args, u32);
421  CLIB_UNUSED (int verbose) = va_arg (*args, int);
422 
423  s = format (s, "GRE tunnel: id %d\n", dev_instance);
424  return s;
425 }
426 
427 /* *INDENT-OFF* */
429  .name = "GRE tunnel device",
430  .format_device_name = format_gre_tunnel_name,
431  .format_device = format_gre_device,
432  .format_tx_trace = format_gre_tx_trace,
433  .tx_function = gre_interface_tx,
434  .admin_up_down_function = gre_interface_admin_up_down,
435 #ifdef SOON
436  .clear counter = 0;
437 #endif
438 };
439 /* *INDENT-ON* */
440 
441 
442 /* *INDENT-OFF* */
445 
447  .name = "GRE TEB tunnel device",
448  .format_device_name = format_gre_tunnel_teb_name,
449  .format_device = format_gre_device,
450  .format_tx_trace = format_gre_tx_trace,
451  .tx_function = gre_teb_interface_tx,
452  .admin_up_down_function = gre_interface_admin_up_down,
453 #ifdef SOON
454  .clear counter = 0;
455 #endif
456 };
457 
458 /* *INDENT-ON* */
459 
460 /* *INDENT-OFF* */
463 
465  .name = "GRE",
466  .format_header = format_gre_header_with_length,
467  .unformat_header = unformat_gre_header,
468  .build_rewrite = gre_build_rewrite,
469  .update_adjacency = gre_update_adj,
471 };
472 /* *INDENT-ON* */
473 
474 static void
475 add_protocol (gre_main_t * gm, gre_protocol_t protocol, char *protocol_name)
476 {
478  u32 i;
479 
480  vec_add2 (gm->protocol_infos, pi, 1);
481  i = pi - gm->protocol_infos;
482 
483  pi->name = protocol_name;
484  pi->protocol = protocol;
485  pi->next_index = pi->node_index = ~0;
486 
487  hash_set (gm->protocol_info_by_protocol, protocol, i);
489 }
490 
491 static clib_error_t *
493 {
494  gre_main_t *gm = &gre_main;
495  clib_error_t *error;
496  ip_main_t *im = &ip_main;
497  ip_protocol_info_t *pi;
498 
499  memset (gm, 0, sizeof (gm[0]));
500  gm->vlib_main = vm;
501  gm->vnet_main = vnet_get_main ();
502 
503  if ((error = vlib_call_init_function (vm, ip_main_init)))
504  return error;
505 
506  if ((error = vlib_call_init_function (vm, ip4_lookup_init)))
507  return error;
508 
509  if ((error = vlib_call_init_function (vm, ip6_lookup_init)))
510  return error;
511 
512  /* Set up the ip packet generator */
513  pi = ip_get_protocol_info (im, IP_PROTOCOL_GRE);
516 
517  gm->protocol_info_by_name = hash_create_string (0, sizeof (uword));
518  gm->protocol_info_by_protocol = hash_create (0, sizeof (uword));
519  gm->tunnel_by_key4 =
520  hash_create_mem (0, sizeof (gre_tunnel_key4_t), sizeof (uword));
521  gm->tunnel_by_key6 =
522  hash_create_mem (0, sizeof (gre_tunnel_key6_t), sizeof (uword));
523 
524 #define _(n,s) add_protocol (gm, GRE_PROTOCOL_##s, #s);
526 #undef _
528 }
529 
531 
532 gre_main_t *
534 {
536  return &gre_main;
537 }
538 
539 
540 /*
541  * fd.io coding-style-patch-verification: ON
542  *
543  * Local Variables:
544  * eval: (c-set-style "gnu")
545  * End:
546  */
vnet_main_t * vnet_main
Definition: gre.h:237
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:432
fib_protocol_t fp_proto
protocol type
Definition: fib_types.h:181
ip46_address_t src
Definition: gre.c:53
vlib_node_registration_t gre4_input_node
(constructor) VLIB_REGISTER_NODE (gre4_input_node)
Definition: node.c:575
static uword gre_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: gre.c:390
#define hash_set(h, key, value)
Definition: hash.h:254
uword * tunnel_by_key6
Hash mapping ipv6 src/dst addr pair to tunnel.
Definition: gre.h:217
void gre4_fixup(vlib_main_t *vm, ip_adjacency_t *adj, vlib_buffer_t *b0)
Definition: gre.c:265
GRE related global data.
Definition: gre.h:192
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:337
#define CLIB_UNUSED(x)
Definition: clib.h:79
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:108
u8 runtime_data[0]
Function dependent node-runtime data.
Definition: node.h:464
uword * protocol_info_by_protocol
Definition: gre.h:207
vnet_main_t * vnet_get_main(void)
Definition: misc.c:47
#define VNET_HW_INTERFACE_CLASS(x,...)
Definition: interface.h:373
u64 as_u64
Definition: bihash_doc.h:63
u32 tunnel_id
Definition: gre.c:47
static u8 * format_gre_tunnel_teb_name(u8 *s, va_list *args)
Definition: gre.c:411
vnet_link_t adj_get_link_type(adj_index_t ai)
Return the link type of the adjacency.
Definition: adj.c:365
#define NULL
Definition: clib.h:55
gre_protocol_t protocol
GRE protocol type in host byte order.
Definition: gre.h:47
char * name
Name (a c string).
Definition: gre.h:44
IP unicast adjacency.
Definition: adj.h:174
A GRE payload protocol registration.
Definition: gre.h:41
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:557
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
static u32 format_get_indent(u8 *s)
Definition: format.h:72
#define hash_set_mem(h, key, value)
Definition: hash.h:274
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
Definition: ip.h:106
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:107
u32 * tunnel_index_by_sw_if_index
Mapping from sw_if_index to tunnel index.
Definition: gre.h:229
VNET_DEVICE_CLASS(gre_device_class)
void adj_nbr_midchain_update_rewrite(adj_index_t adj_index, adj_midchain_fixup_t fixup, adj_flags_t flags, u8 *rewrite)
adj_nbr_midchain_update_rewrite
Definition: adj_midchain.c:504
unformat_function_t * unformat_pg_edit
Definition: ip.h:87
ip4_and_gre_header_t ip4_and_gre
Definition: gre.c:28
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:111
IPv4 and GRE header union.
Definition: gre.c:24
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:113
void gre_tunnel_stack(adj_index_t ai)
gre_tunnel_stack
Definition: interface.c:138
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
ip6_and_gre_header_t ip6_and_gre
Definition: gre.c:37
unsigned long u64
Definition: types.h:89
static uword gre_interface_tx_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
TX function.
Definition: gre.c:320
#define vlib_call_init_function(vm, x)
Definition: init.h:162
ip46_address_t tunnel_src
The tunnel&#39;s source/local address.
Definition: gre.h:152
uword unformat_gre_header(unformat_input_t *input, va_list *args)
Definition: gre.c:157
#define hash_create_string(elts, value_bytes)
Definition: hash.h:675
#define hash_create_mem(elts, key_bytes, value_bytes)
Definition: hash.h:660
uword * tunnel_by_key4
Hash mapping ipv4 src/dst addr pair to tunnel.
Definition: gre.h:212
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:459
A representation of a GRE tunnel.
Definition: gre.h:136
static ip_protocol_info_t * ip_get_protocol_info(ip_main_t *im, u32 protocol)
Definition: ip.h:133
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:195
format_function_t * format_header
Definition: ip.h:78
struct _unformat_input_t unformat_input_t
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:195
u32 node_index
Node which handles this type.
Definition: gre.h:50
void gre_update_adj(vnet_main_t *vnm, u32 sw_if_index, adj_index_t ai)
Definition: gre.c:292
vnet_device_class_t gre_device_teb_class
#define PREDICT_FALSE(x)
Definition: clib.h:105
format_function_t * format_buffer
Definition: node.h:311
#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:364
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1158
uword * protocol_info_by_name
Hash tables mapping name/protocol to protocol info index.
Definition: gre.h:207
static u8 * format_gre_tunnel_name(u8 *s, va_list *args)
Definition: gre.c:404
static clib_error_t * gre_input_init(vlib_main_t *vm)
Definition: node.c:663
static clib_error_t * gre_init(vlib_main_t *vm)
Definition: gre.c:492
Key for a IPv4 GRE Tunnel.
Definition: gre.h:81
gre_main_t * gre_get_main(vlib_main_t *vm)
Definition: gre.c:533
clib_error_t * ip_main_init(vlib_main_t *vm)
Definition: ip_init.c:45
u16 n_vectors
Definition: node.h:344
vlib_main_t * vm
Definition: buffer.c:283
vec_header_t h
Definition: buffer.c:282
static u8 * format_gre_device(u8 *s, va_list *args)
Definition: gre.c:418
ip_main_t ip_main
Definition: ip_init.c:42
void gre6_fixup(vlib_main_t *vm, ip_adjacency_t *adj, vlib_buffer_t *b0)
Definition: gre.c:278
u16 protocol
Definition: packet.h:54
#define VLIB_BUFFER_IS_TRACED
Definition: buffer.h:93
gre_protocol_t
Definition: packet.h:29
#define clib_memcpy(a, b, c)
Definition: string.h:75
Packets TX through the midchain do not increment the interface counters.
Definition: adj.h:165
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
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:454
u8 * format_gre_header_with_length(u8 *s, va_list *args)
Definition: gre.c:87
u8 * format_gre_tx_trace(u8 *s, va_list *args)
Definition: gre.c:58
#define hash_create(elts, value_bytes)
Definition: hash.h:681
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
Definition: node.h:456
#define ASSERT(truth)
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:204
unsigned int u32
Definition: types.h:88
u32 next_index
Next index for this type.
Definition: gre.h:53
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
static int gre_proto_from_vnet_link(vnet_link_t link)
Definition: gre.c:181
gre_tunnel_t * tunnels
pool of tunnel instances
Definition: gre.h:197
uword unformat_vlib_number_by_name(unformat_input_t *input, va_list *args)
Definition: format.c:157
clib_error_t * ip4_lookup_init(vlib_main_t *vm)
Definition: ip4_forward.c:1184
vnet_hw_interface_class_t gre_hw_interface_class
u64 uword
Definition: types.h:112
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:55
Definition: defs.h:47
vnet_device_class_t gre_device_class
VLIB_DEVICE_TX_FUNCTION_MULTIARCH(gre_device_class, gre_interface_tx)
Definition: gre.c:443
clib_error_t * gre_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: interface.c:482
ip46_address_t dst
Definition: gre.c:54
unsigned short u16
Definition: types.h:57
u16 payload_length
Definition: ip6_packet.h:332
static void add_protocol(gre_main_t *gm, gre_protocol_t protocol, char *protocol_name)
Definition: gre.c:475
unsigned char u8
Definition: types.h:56
uword unformat_gre_protocol_host_byte_order(unformat_input_t *input, va_list *args)
Definition: gre.c:126
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:267
a point 2 point interface
Definition: interface.h:289
u8 * format_gre_header(u8 *s, va_list *args)
Definition: gre.c:118
unformat_function_t unformat_pg_gre_header
Definition: gre.h:297
u8 * format_gre_protocol(u8 *s, va_list *args)
Definition: gre.c:72
#define vnet_buffer(b)
Definition: buffer.h:326
vlib_node_registration_t gre6_input_node
(constructor) VLIB_REGISTER_NODE (gre6_input_node)
Definition: node.c:598
fib_prefix_t tunnel_dst
The tunnel&#39;s destination/remote address.
Definition: gre.h:156
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
Definition: node_funcs.h:59
static uword gre_teb_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: gre.c:397
static gre_protocol_info_t * gre_get_protocol_info(gre_main_t *em, gre_protocol_t protocol)
Definition: gre.h:261
gre_protocol_info_t * protocol_infos
GRE payload protocol registrations.
Definition: gre.h:202
u32 length
Definition: gre.c:50
vlib_main_t * vlib_main
Definition: gre.h:236
static clib_error_t * ip6_lookup_init(vlib_main_t *vm)
Definition: ip6_forward.c:3012
uword unformat_gre_protocol_net_byte_order(unformat_input_t *input, va_list *args)
Definition: gre.c:146
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:75
gre_main_t gre_main
Definition: gre.c:22
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:57
static u16 ip4_header_checksum(ip4_header_t *i)
Definition: ip4_packet.h:239
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972