FD.io VPP  v16.09
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 
22 
23 typedef CLIB_PACKED (struct {
24  ip4_header_t ip4;
25  gre_header_t gre;
26 }) ip4_and_gre_header_t;
27 
28 typedef struct {
29  union {
30  ip4_and_gre_header_t ip4_and_gre;
31  u64 as_u64[3];
32  };
34 
35 
36 /* Packet trace structure */
37 typedef struct {
38  /* Tunnel-id / index in tunnel vector */
40 
41  /* pkt length */
43 
44  /* tunnel ip4 addresses */
48 
49 u8 * format_gre_tx_trace (u8 * s, va_list * args)
50 {
51  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
52  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
53  gre_tx_trace_t * t = va_arg (*args, gre_tx_trace_t *);
54 
55  s = format (s, "GRE: tunnel %d len %d src %U dst %U",
56  t->tunnel_id, clib_net_to_host_u16 (t->length),
59  return s;
60 }
61 
62 u8 * format_gre_protocol (u8 * s, va_list * args)
63 {
64  gre_protocol_t p = va_arg (*args, u32);
65  gre_main_t * gm = &gre_main;
67 
68  if (pi)
69  s = format (s, "%s", pi->name);
70  else
71  s = format (s, "0x%04x", p);
72 
73  return s;
74 }
75 
76 u8 * format_gre_header_with_length (u8 * s, va_list * args)
77 {
78  gre_main_t * gm = &gre_main;
79  gre_header_t * h = va_arg (*args, gre_header_t *);
80  u32 max_header_bytes = va_arg (*args, u32);
81  gre_protocol_t p = clib_net_to_host_u16 (h->protocol);
82  uword indent, header_bytes;
83 
84  header_bytes = sizeof (h[0]);
85  if (max_header_bytes != 0 && header_bytes > max_header_bytes)
86  return format (s, "gre header truncated");
87 
88  indent = format_get_indent (s);
89 
90  s = format (s, "GRE %U", format_gre_protocol, p);
91 
92  if (max_header_bytes != 0 && header_bytes > max_header_bytes)
93  {
95  vlib_node_t * node = vlib_get_node (gm->vlib_main, pi->node_index);
96  if (node->format_buffer)
97  s = format (s, "\n%U%U",
98  format_white_space, indent,
99  node->format_buffer, (void *) (h + 1),
100  max_header_bytes - header_bytes);
101  }
102 
103  return s;
104 }
105 
106 u8 * format_gre_header (u8 * s, va_list * args)
107 {
108  gre_header_t * h = va_arg (*args, gre_header_t *);
109  return format (s, "%U", format_gre_header_with_length, h, 0);
110 }
111 
112 /* Returns gre protocol as an int in host byte order. */
113 uword
115  va_list * args)
116 {
117  u16 * result = va_arg (*args, u16 *);
118  gre_main_t * gm = &gre_main;
119  int i;
120 
121  /* Named type. */
123  gm->protocol_info_by_name, &i))
124  {
126  *result = pi->protocol;
127  return 1;
128  }
129 
130  return 0;
131 }
132 
133 uword
135  va_list * args)
136 {
137  u16 * result = va_arg (*args, u16 *);
139  return 0;
140  *result = clib_host_to_net_u16 ((u16) *result);
141  return 1;
142 }
143 
144 uword
145 unformat_gre_header (unformat_input_t * input, va_list * args)
146 {
147  u8 ** result = va_arg (*args, u8 **);
148  gre_header_t _h, * h = &_h;
149  u16 p;
150 
151  if (! unformat (input, "%U",
153  return 0;
154 
155  h->protocol = clib_host_to_net_u16 (p);
156 
157  /* Add header to result. */
158  {
159  void * p;
160  u32 n_bytes = sizeof (h[0]);
161 
162  vec_add2 (*result, p, n_bytes);
163  clib_memcpy (p, h, n_bytes);
164  }
165 
166  return 1;
167 }
168 
170  u32 sw_if_index,
171  u32 l3_type,
172  void * dst_address,
173  void * rewrite,
174  uword max_rewrite_bytes)
175 {
176  /*
177  * Conundrum: packets from tun/tap destined for the tunnel
178  * actually have this rewrite applied. Transit packets do not.
179  * To make the two cases equivalent, don't generate a
180  * rewrite here, build the entire header in the fast path.
181  */
182  return 0;
183 
184 #ifdef THINGS_WORKED_AS_ONE_MIGHT_LIKE
185  ip4_and_gre_header_t * h = rewrite;
186  gre_protocol_t protocol;
187 
188  if (max_rewrite_bytes < sizeof (h[0]))
189  return 0;
190 
191  switch (l3_type) {
192 #define _(a,b) case VNET_L3_PACKET_TYPE_##a: protocol = GRE_PROTOCOL_##b; break
193  _ (IP4, ip4);
194  _ (IP6, ip6);
195 #undef _
196  default:
197  return 0;
198  }
199 
200  memset (h, 0, sizeof (*h));
201  h->ip4.ip_version_and_header_length = 0x45;
202  h->ip4.ttl = 64;
203  h->ip4.protocol = IP_PROTOCOL_GRE;
204  h->gre.protocol = clib_host_to_net_u16 (protocol);
205 
206  return sizeof (h[0]);
207 #endif
208 }
209 
210 static uword
212  vlib_node_runtime_t * node,
213  vlib_frame_t * frame)
214 {
215  gre_main_t * gm = &gre_main;
216  u32 next_index;
217  u32 * from, * to_next, n_left_from, n_left_to_next;
218  vnet_interface_output_runtime_t * rd = (void *) node->runtime_data;
220 
221  /* Vector of buffer / pkt indices we're supposed to process */
222  from = vlib_frame_vector_args (frame);
223 
224  /* Number of buffers / pkts */
225  n_left_from = frame->n_vectors;
226 
227  /* Speculatively send the first buffer to the last disposition we used */
228  next_index = node->cached_next_index;
229 
230  while (n_left_from > 0)
231  {
232  /* set up to enqueue to our disposition with index = next_index */
233  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
234 
235  /*
236  * As long as we have enough pkts left to process two pkts
237  * and prefetch two pkts...
238  */
239  while (n_left_from >= 4 && n_left_to_next >= 2)
240  {
241  vlib_buffer_t * b0, * b1;
242  ip4_header_t * ip0, * ip1;
243  ip4_and_gre_union_t * h0, * h1;
244  u32 bi0, next0, bi1, next1;
245  __attribute__((unused)) u8 error0, error1;
246  u16 gre_protocol0, gre_protocol1;
247 
248  /* Prefetch the next iteration */
249  {
250  vlib_buffer_t * p2, * p3;
251 
252  p2 = vlib_get_buffer (vm, from[2]);
253  p3 = vlib_get_buffer (vm, from[3]);
254 
255  vlib_prefetch_buffer_header (p2, LOAD);
256  vlib_prefetch_buffer_header (p3, LOAD);
257 
258  /*
259  * Prefetch packet data. We expect to overwrite
260  * the inbound L2 header with an ip header and a
261  * gre header. Might want to prefetch the last line
262  * of rewrite space as well; need profile data
263  */
266  }
267 
268  /* Pick up the next two buffer indices */
269  bi0 = from[0];
270  bi1 = from[1];
271 
272  /* Speculatively enqueue them where we sent the last buffer */
273  to_next[0] = bi0;
274  to_next[1] = bi1;
275  from += 2;
276  to_next += 2;
277  n_left_to_next -= 2;
278  n_left_from -= 2;
279 
280  b0 = vlib_get_buffer (vm, bi0);
281  b1 = vlib_get_buffer (vm, bi1);
282 
283  vnet_buffer (b0)->sw_if_index[VLIB_TX] = t->outer_fib_index;
284  vnet_buffer (b1)->sw_if_index[VLIB_TX] = t->outer_fib_index;
285 
286  ip0 = vlib_buffer_get_current (b0);
287  gre_protocol0 = clib_net_to_host_u16 (0x800);
288  gre_protocol0 =
289  ((ip0->ip_version_and_header_length & 0xF0) == 0x60) ?
290  0x86DD : gre_protocol0;
291 
292  ip1 = vlib_buffer_get_current (b1);
293  gre_protocol1 = clib_net_to_host_u16 (0x800);
294  gre_protocol1 =
295  ((ip1->ip_version_and_header_length & 0xF0) == 0x60) ?
296  0x86DD : gre_protocol1;
297 
298  vlib_buffer_advance (b0, -sizeof(*h0));
299  vlib_buffer_advance (b1, -sizeof(*h1));
300 
301  h0 = vlib_buffer_get_current (b0);
302  h1 = vlib_buffer_get_current (b1);
303  h0->as_u64[0] = 0;
304  h0->as_u64[1] = 0;
305  h0->as_u64[2] = 0;
306 
307  h1->as_u64[0] = 0;
308  h1->as_u64[1] = 0;
309  h1->as_u64[2] = 0;
310 
311  ip0 = &h0->ip4_and_gre.ip4;
312  h0->ip4_and_gre.gre.protocol = gre_protocol0;
313  ip0->ip_version_and_header_length = 0x45;
314  ip0->ttl = 254;
315  ip0->protocol = IP_PROTOCOL_GRE;
316 
317  ip1 = &h1->ip4_and_gre.ip4;
318  h1->ip4_and_gre.gre.protocol = gre_protocol1;
319  ip1->ip_version_and_header_length = 0x45;
320  ip1->ttl = 254;
321  ip1->protocol = IP_PROTOCOL_GRE;
322 
323  ip0->length =
324  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0));
325  ip1->length =
326  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b1));
327  ip0->src_address.as_u32 = t->tunnel_src.as_u32;
328  ip1->src_address.as_u32 = t->tunnel_src.as_u32;
329  ip0->dst_address.as_u32 = t->tunnel_dst.as_u32;
330  ip1->dst_address.as_u32 = t->tunnel_dst.as_u32;
331  ip0->checksum = ip4_header_checksum (ip0);
332  ip1->checksum = ip4_header_checksum (ip1);
333 
334  /* ip4_lookup will route to the tunnel partner */
335  next0 = GRE_OUTPUT_NEXT_LOOKUP;
336  next1 = GRE_OUTPUT_NEXT_LOOKUP;
337  error0 = GRE_ERROR_NONE;
338  error1 = GRE_ERROR_NONE;
339 
340  /*
341  * Enqueue 2 pkts. This macro deals with next0 != next1,
342  * acquiring enqueue rights to the indicated next
343  * node input frame, etc.
344  */
345  vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
346  to_next, n_left_to_next,
347  bi0, bi1, next0, next1);
348  }
349 
350  while (n_left_from > 0 && n_left_to_next > 0)
351  {
352  vlib_buffer_t * b0;
353  ip4_header_t * ip0;
354  ip4_and_gre_union_t * h0;
355  u32 bi0, next0;
356  __attribute__((unused)) u8 error0;
357  u16 gre_protocol0;
358 
359  bi0 = to_next[0] = from[0];
360  from += 1;
361  n_left_from -= 1;
362  to_next += 1;
363  n_left_to_next -= 1;
364 
365  b0 = vlib_get_buffer (vm, bi0);
366 
367  vnet_buffer (b0)->sw_if_index[VLIB_TX] = t->outer_fib_index;
368  ip0 = vlib_buffer_get_current (b0);
369  gre_protocol0 = clib_net_to_host_u16 (0x800);
370  gre_protocol0 =
371  ((ip0->ip_version_and_header_length & 0xF0) == 0x60) ?
372  0x86DD : gre_protocol0;
373 
374  vlib_buffer_advance (b0, -sizeof(*h0));
375 
376  h0 = vlib_buffer_get_current (b0);
377  h0->as_u64[0] = 0;
378  h0->as_u64[1] = 0;
379  h0->as_u64[2] = 0;
380 
381  ip0 = &h0->ip4_and_gre.ip4;
382  h0->ip4_and_gre.gre.protocol = gre_protocol0;
383  ip0->ip_version_and_header_length = 0x45;
384  ip0->ttl = 254;
385  ip0->protocol = IP_PROTOCOL_GRE;
386  ip0->length =
387  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0));
388  ip0->src_address.as_u32 = t->tunnel_src.as_u32;
389  ip0->dst_address.as_u32 = t->tunnel_dst.as_u32;
390  ip0->checksum = ip4_header_checksum (ip0);
391 
392  next0 = GRE_OUTPUT_NEXT_LOOKUP;
393  error0 = GRE_ERROR_NONE;
394 
396  {
397  gre_tx_trace_t *tr = vlib_add_trace (vm, node,
398  b0, sizeof (*tr));
399  tr->tunnel_id = t - gm->tunnels;
400  tr->length = ip0->length;
401  tr->src.as_u32 = ip0->src_address.as_u32;
402  tr->dst.as_u32 = ip0->dst_address.as_u32;
403  }
404 
405  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
406  to_next, n_left_to_next,
407  bi0, next0);
408  }
409 
410  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
411  }
412 
414  GRE_ERROR_PKTS_ENCAP, frame->n_vectors);
415 
416  return frame->n_vectors;
417 }
418 
419 static clib_error_t *
421 {
424  else
425  vnet_hw_interface_set_flags (vnm, hw_if_index, 0 /* down */);
426 
427  return /* no error */ 0;
428 }
429 
430 static u8 * format_gre_tunnel_name (u8 * s, va_list * args)
431 {
432  u32 dev_instance = va_arg (*args, u32);
433  return format (s, "gre%d", dev_instance);
434 }
435 
436 static u8 * format_gre_device (u8 * s, va_list * args)
437 {
438  u32 dev_instance = va_arg (*args, u32);
439  CLIB_UNUSED (int verbose) = va_arg (*args, int);
440 
441  s = format (s, "GRE tunnel: id %d\n", dev_instance);
442  return s;
443 }
444 
446  .name = "GRE tunnel device",
447  .format_device_name = format_gre_tunnel_name,
448  .format_device = format_gre_device,
449  .format_tx_trace = format_gre_tx_trace,
450  .tx_function = gre_interface_tx,
451  .admin_up_down_function = gre_interface_admin_up_down,
452 #ifdef SOON
453  .clear counter = 0;
454 #endif
455 };
456 
459 
460 
462  .name = "GRE",
463  .format_header = format_gre_header_with_length,
464  .unformat_header = unformat_gre_header,
465  .set_rewrite = gre_set_rewrite,
466 };
467 
468 static void add_protocol (gre_main_t * gm,
469  gre_protocol_t protocol,
470  char * protocol_name)
471 {
472  gre_protocol_info_t * pi;
473  u32 i;
474 
475  vec_add2 (gm->protocol_infos, pi, 1);
476  i = pi - gm->protocol_infos;
477 
478  pi->name = protocol_name;
479  pi->protocol = protocol;
480  pi->next_index = pi->node_index = ~0;
481 
482  hash_set (gm->protocol_info_by_protocol, protocol, i);
484 }
485 
487 {
488  gre_main_t * gm = &gre_main;
489  clib_error_t * error;
490  ip_main_t * im = &ip_main;
491  ip_protocol_info_t * pi;
492 
493  memset (gm, 0, sizeof (gm[0]));
494  gm->vlib_main = vm;
495  gm->vnet_main = vnet_get_main();
496 
497  if ((error = vlib_call_init_function (vm, ip_main_init)))
498  return error;
499 
500  if ((error = vlib_call_init_function (vm, ip4_lookup_init)))
501  return error;
502 
503  /* Set up the ip packet generator */
504  pi = ip_get_protocol_info (im, IP_PROTOCOL_GRE);
507 
508  gm->protocol_info_by_name = hash_create_string (0, sizeof (uword));
509  gm->protocol_info_by_protocol = hash_create (0, sizeof (uword));
510  gm->tunnel_by_key = hash_create (0, sizeof (uword));
511 
512 #define _(n,s) add_protocol (gm, GRE_PROTOCOL_##s, #s);
514 #undef _
515 
517 }
518 
520 
522 {
524  return &gre_main;
525 }
526 
vnet_main_t * vnet_main
Definition: gre.h:79
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:457
ip4_address_t src
Definition: gre.c:45
static uword gre_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: gre.c:211
#define hash_set(h, key, value)
Definition: hash.h:254
Definition: gre.h:60
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
#define CLIB_UNUSED(x)
Definition: clib.h:79
uword unformat(unformat_input_t *i, char *fmt,...)
Definition: unformat.c:966
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: interface.c:513
ip4_address_t dst
Definition: gre.c:46
uword * protocol_info_by_protocol
Definition: gre.h:67
ip4_address_t src_address
Definition: ip4_packet.h:138
#define VNET_HW_INTERFACE_CLASS(x,...)
Definition: interface.h:252
u64 as_u64
Definition: bihash_doc.h:63
uword * tunnel_by_key
Definition: gre.h:69
u32 tunnel_id
Definition: gre.c:39
gre_protocol_t protocol
Definition: gre.h:43
ip4_and_gre_union_t
Definition: gre.c:33
char * name
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:521
#define hash_set_mem(h, key, value)
Definition: hash.h:274
Definition: ip.h:109
#define VNET_HW_INTERFACE_FLAG_LINK_UP
Definition: interface.h:273
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:112
format_function_t format_ip4_address
Definition: format.h:71
VNET_DEVICE_CLASS(gre_device_class)
vnet_main_t * vnet_get_main(void)
Definition: misc.c:45
unformat_function_t * unformat_pg_edit
Definition: ip.h:91
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:111
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:187
ip4_address_t dst_address
Definition: ip4_packet.h:138
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:113
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
unsigned long u64
Definition: types.h:89
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:977
#define vlib_call_init_function(vm, x)
Definition: init.h:161
uword unformat_gre_header(unformat_input_t *input, va_list *args)
Definition: gre.c:145
#define hash_create_string(elts, value_bytes)
Definition: hash.h:641
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:369
static uword format_get_indent(u8 *s)
Definition: format.h:72
static ip_protocol_info_t * ip_get_protocol_info(ip_main_t *im, u32 protocol)
Definition: ip.h:136
format_function_t * format_header
Definition: ip.h:82
u32 node_index
Definition: gre.h:46
#define PREDICT_FALSE(x)
Definition: clib.h:97
format_function_t * format_buffer
Definition: node.h:311
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
Finish enqueueing two buffers forward in the graph.
Definition: buffer_node.h:70
#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:130
#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:348
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1111
uword * protocol_info_by_name
Definition: gre.h:67
static u8 * format_gre_tunnel_name(u8 *s, va_list *args)
Definition: gre.c:430
static clib_error_t * gre_init(vlib_main_t *vm)
Definition: gre.c:486
gre_main_t * gre_get_main(vlib_main_t *vm)
Definition: gre.c:521
clib_error_t * ip_main_init(vlib_main_t *vm)
Definition: ip_init.c:45
u16 n_vectors
Definition: node.h:344
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:82
static u8 * format_gre_device(u8 *s, va_list *args)
Definition: gre.c:436
ip_main_t ip_main
Definition: ip_init.c:42
u16 protocol
Definition: packet.h:51
static uword gre_set_rewrite(vnet_main_t *vnm, u32 sw_if_index, u32 l3_type, void *dst_address, void *rewrite, uword max_rewrite_bytes)
Definition: gre.c:169
gre_protocol_t
Definition: packet.h:28
#define clib_memcpy(a, b, c)
Definition: string.h:63
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:200
uword unformat_vlib_number_by_name(unformat_input_t *input, va_list *args)
Definition: format.c:157
u8 * format_gre_header_with_length(u8 *s, va_list *args)
Definition: gre.c:76
static clib_error_t * gre_input_init(vlib_main_t *vm)
Definition: node.c:486
u8 * format_gre_tx_trace(u8 *s, va_list *args)
Definition: gre.c:49
#define hash_create(elts, value_bytes)
Definition: hash.h:647
u16 cached_next_index
Definition: node.h:462
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
Definition: interface.h:415
unsigned int u32
Definition: types.h:88
#define vnet_buffer(b)
Definition: buffer.h:335
u32 next_index
Definition: gre.h:49
typedef CLIB_PACKED(struct{ip4_header_t ip4;gre_header_t gre;})
Definition: gre.c:23
u8 * format(u8 *s, char *fmt,...)
Definition: format.c:418
gre_tunnel_t * tunnels
Definition: gre.h:62
clib_error_t * ip4_lookup_init(vlib_main_t *vm)
Definition: ip4_forward.c:1581
vnet_hw_interface_class_t gre_hw_interface_class
#define VLIB_BUFFER_IS_TRACED
Definition: buffer.h:93
vlib_node_registration_t gre_input_node
(constructor) VLIB_REGISTER_NODE (gre_input_node)
Definition: node.c:414
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:457
unsigned short u16
Definition: types.h:57
#define GRE_OUTPUT_NEXT_LOOKUP
Definition: gre.h:123
static void add_protocol(gre_main_t *gm, gre_protocol_t protocol, char *protocol_name)
Definition: gre.c:468
unsigned char u8
Definition: types.h:56
uword unformat_gre_protocol_host_byte_order(unformat_input_t *input, va_list *args)
Definition: gre.c:114
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:251
u8 * format_gre_header(u8 *s, va_list *args)
Definition: gre.c:106
unformat_function_t unformat_pg_gre_header
Definition: gre.h:115
Definition: lisp_types.h:24
u8 * format_gre_protocol(u8 *s, va_list *args)
Definition: gre.c:62
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Definition: buffer.h:163
u8 data[0]
Packet data.
Definition: buffer.h:151
static vlib_node_t * vlib_get_node(vlib_main_t *vm, u32 i)
Get vlib node by index.
Definition: node_funcs.h:58
static gre_protocol_info_t * gre_get_protocol_info(gre_main_t *em, gre_protocol_t protocol)
Definition: gre.h:83
gre_protocol_info_t * protocol_infos
Definition: gre.h:64
u32 length
Definition: gre.c:42
vlib_main_t * vlib_main
Definition: gre.h:78
u8 ip_version_and_header_length
Definition: ip4_packet.h:108
struct _unformat_input_t unformat_input_t
u32 flags
Definition: vhost-user.h:76
Definition: lisp_types.h:25
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:67
uword unformat_gre_protocol_net_byte_order(unformat_input_t *input, va_list *args)
Definition: gre.c:134
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:85
uword runtime_data[(128-1 *sizeof(vlib_node_function_t *)-1 *sizeof(vlib_error_t *)-11 *sizeof(u32)-5 *sizeof(u16))/sizeof(uword)]
Definition: node.h:472
gre_main_t gre_main
Definition: gre.c:21
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:69
static u16 ip4_header_checksum(ip4_header_t *i)
Definition: ip4_packet.h:194
static clib_error_t * gre_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: gre.c:420