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