FD.io VPP  v16.12-rc0-308-g931be3a
Vector Packet Processing
interface.c
Go to the documentation of this file.
1 /*
2  * gre_interface.c: gre interfaces
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/pg/pg.h>
20 #include <vnet/gre/gre.h>
21 #include <vnet/ip/format.h>
22 #include <vnet/fib/ip4_fib.h>
23 #include <vnet/adj/adj_midchain.h>
24 #include <vnet/adj/adj_nbr.h>
25 #include <vnet/mpls/mpls.h>
26 
27 static inline u64
29  const ip4_address_t *dst,
30  u32 out_fib_index)
31 {
32  // FIXME. the fib index should be part of the key
33  return ((u64)src->as_u32 << 32 | (u64)dst->as_u32);
34 }
35 
36 static u8 *
37 format_gre_tunnel (u8 * s, va_list * args)
38 {
39  gre_tunnel_t * t = va_arg (*args, gre_tunnel_t *);
40  gre_main_t * gm = &gre_main;
41 
42  s = format (s,
43  "[%d] %U (src) %U (dst) payload %s outer_fib_index %d",
44  t - gm->tunnels,
47  (t->teb ? "teb" : "ip"),
48  t->outer_fib_index);
49 
50  return s;
51 }
52 
53 static gre_tunnel_t *
55  const ip4_address_t *dst,
56  u32 out_fib_index)
57 {
58  gre_main_t * gm = &gre_main;
59  uword * p;
60  u64 key;
61 
62  key = gre_mk_key(src, dst, out_fib_index);
63 
64  p = hash_get (gm->tunnel_by_key, key);
65 
66  if (NULL == p)
67  return (NULL);
68 
69  return (pool_elt_at_index (gm->tunnels, p[0]));
70 }
71 
72 static void
74 {
75  gre_main_t * gm = &gre_main;
76  u64 key;
77 
78  key = gre_mk_key(&t->tunnel_src, &t->tunnel_dst, t->outer_fib_index);
79  hash_set (gm->tunnel_by_key, key, t - gm->tunnels);
80 }
81 
82 static void
84 {
85  gre_main_t * gm = &gre_main;
86  u64 key;
87 
88  key = gre_mk_key(&t->tunnel_src, &t->tunnel_dst, t->outer_fib_index);
89  hash_unset (gm->tunnel_by_key, key);
90 }
91 
92 static gre_tunnel_t *
94 {
95 #if (CLIB_DEBUG > 0)
97 #endif
98  return ((gre_tunnel_t*) (((char*)node) -
100 }
101 
102 /**
103  * gre_tunnel_stack
104  *
105  * 'stack' (resolve the recursion for) the tunnel's midchain adjacency
106  */
107 void
109 {
110  gre_main_t * gm = &gre_main;
111  ip_adjacency_t *adj;
112  gre_tunnel_t *gt;
113  u32 sw_if_index;
114 
115  adj = adj_get(ai);
116  sw_if_index = adj->rewrite_header.sw_if_index;
117 
118  if ((vec_len(gm->tunnel_index_by_sw_if_index) < sw_if_index) ||
119  (~0 == gm->tunnel_index_by_sw_if_index[sw_if_index]))
120  return;
121 
122  gt = pool_elt_at_index(gm->tunnels,
123  gm->tunnel_index_by_sw_if_index[sw_if_index]);
124 
125  /*
126  * find the adjacency that is contributed by the FIB entry
127  * that this tunnel resovles via, and use it as the next adj
128  * in the midchain
129  */
131  gt->hw_if_index) &
133  {
135  ai,
137  }
138  else
139  {
141  }
142 }
143 
144 /**
145  * @brief Call back when restacking all adjacencies on a GRE interface
146  */
147 static adj_walk_rc_t
149  void *ctx)
150 {
151  gre_tunnel_stack(ai);
152 
153  return (ADJ_WALK_RC_CONTINUE);
154 }
155 
156 static void
158 {
159  fib_protocol_t proto;
160 
161  /*
162  * walk all the adjacencies on th GRE interface and restack them
163  */
165  {
167  proto,
169  NULL);
170  }
171 }
172 
173 /**
174  * Function definition to backwalk a FIB node
175  */
179 {
181 
183 }
184 
185 /**
186  * Function definition to get a FIB node from its index
187  */
188 static fib_node_t*
190 {
191  gre_tunnel_t * gt;
192  gre_main_t * gm;
193 
194  gm = &gre_main;
195  gt = pool_elt_at_index(gm->tunnels, index);
196 
197  return (&gt->node);
198 }
199 
200 /**
201  * Function definition to inform the FIB node that its last lock has gone.
202  */
203 static void
205 {
206  /*
207  * The MPLS GRE tunnel is a root of the graph. As such
208  * it never has children and thus is never locked.
209  */
210  ASSERT(0);
211 }
212 
213 /*
214  * Virtual function table registered by MPLS GRE tunnels
215  * for participation in the FIB object graph.
216  */
217 const static fib_node_vft_t gre_vft = {
219  .fnv_last_lock = gre_tunnel_last_lock_gone,
220  .fnv_back_walk = gre_tunnel_back_walk,
221 };
222 
223 static int
225  u32 * sw_if_indexp)
226 {
227  gre_main_t * gm = &gre_main;
228  vnet_main_t * vnm = gm->vnet_main;
229  ip4_main_t * im = &ip4_main;
230  gre_tunnel_t * t;
232  u32 hw_if_index, sw_if_index;
233  u32 outer_fib_index;
234  u8 address[6];
235  clib_error_t *error;
236 
237  outer_fib_index = ip4_fib_index_from_table_id(a->outer_fib_id);
238 
239  if (~0 == outer_fib_index)
240  return VNET_API_ERROR_NO_SUCH_FIB;
241 
242  t = gre_tunnel_db_find(&a->src, &a->dst, a->outer_fib_id);
243 
244  if (NULL != t)
245  return VNET_API_ERROR_INVALID_VALUE;
246 
248  memset (t, 0, sizeof (*t));
250 
251  if (vec_len (gm->free_gre_tunnel_hw_if_indices) > 0) {
253 
254  hw_if_index = gm->free_gre_tunnel_hw_if_indices
256  _vec_len (gm->free_gre_tunnel_hw_if_indices) -= 1;
257 
258  hi = vnet_get_hw_interface (vnm, hw_if_index);
259  hi->dev_instance = t - gm->tunnels;
260  hi->hw_instance = hi->dev_instance;
261 
262  /* clear old stats of freed tunnel before reuse */
263  sw_if_index = hi->sw_if_index;
270  (&im->sw_if_counters[VNET_INTERFACE_COUNTER_DROP], sw_if_index);
272  if (a->teb)
273  {
275  hi->tx_node_index,
276  "adj-l2-midchain");
277  }
278  } else {
279  if (a->teb)
280  {
281  /* Default MAC address (d00b:eed0:0000 + sw_if_index) */
282  memset (address, 0, sizeof (address));
283  address[0] = 0xd0;
284  address[1] = 0x0b;
285  address[2] = 0xee;
286  address[3] = 0xd0;
287  address[4] = t - gm->tunnels;
288 
289  error = ethernet_register_interface(vnm,
290  gre_device_class.index,
291  t - gm->tunnels, address,
292  &hw_if_index,
293  0);
294 
295  if (error)
296  {
297  clib_error_report (error);
298  return VNET_API_ERROR_INVALID_REGISTRATION;
299  }
300  hi = vnet_get_hw_interface (vnm, hw_if_index);
301 
303  hi->tx_node_index,
304  "adj-l2-midchain");
305  } else {
306  hw_if_index = vnet_register_interface(vnm,
307  gre_device_class.index,
308  t - gm->tunnels,
310  t - gm->tunnels);
311  }
312  hi = vnet_get_hw_interface (vnm, hw_if_index);
313  sw_if_index = hi->sw_if_index;
314  }
315 
316  t->hw_if_index = hw_if_index;
317  t->outer_fib_index = outer_fib_index;
318  t->sw_if_index = sw_if_index;
319  t->teb = a->teb;
320 
322  gm->tunnel_index_by_sw_if_index[sw_if_index] = t - gm->tunnels;
323 
324  vec_validate (im->fib_index_by_sw_if_index, sw_if_index);
325  im->fib_index_by_sw_if_index[sw_if_index] = t->outer_fib_index;
326  ip4_sw_interface_enable_disable(sw_if_index, 1);
327 
328  hi->min_packet_bytes = 64 + sizeof (gre_header_t) + sizeof (ip4_header_t);
330  /* preamble */ 8 + /* inter frame gap */ 12;
331 
332  /* Standard default gre MTU. */
334 
335  clib_memcpy (&t->tunnel_src, &a->src, sizeof (t->tunnel_src));
336  clib_memcpy (&t->tunnel_dst, &a->dst, sizeof (t->tunnel_dst));
337 
339 
340  /*
341  * source the FIB entry for the tunnel's destination
342  * and become a child thereof. The tunnel will then get poked
343  * when the forwarding for the entry updates, and the tunnel can
344  * re-stack accordingly
345  */
346  const fib_prefix_t tun_dst_pfx = {
347  .fp_len = 32,
348  .fp_proto = FIB_PROTOCOL_IP4,
349  .fp_addr = {
350  .ip4 = t->tunnel_dst,
351  }
352  };
353 
354  t->fib_entry_index =
355  fib_table_entry_special_add(outer_fib_index,
356  &tun_dst_pfx,
360  t->sibling_index =
363  t - gm->tunnels);
364 
365  clib_memcpy (&t->tunnel_src, &a->src, sizeof (t->tunnel_src));
366  clib_memcpy (&t->tunnel_dst, &a->dst, sizeof (t->tunnel_dst));
367 
368  if (t->teb)
369  {
372  &zero_addr,
373  sw_if_index);
374 
376  }
377 
378  if (sw_if_indexp)
379  *sw_if_indexp = sw_if_index;
380 
381  return 0;
382 }
383 
384 static int
386  u32 * sw_if_indexp)
387 {
388  gre_main_t * gm = &gre_main;
389  vnet_main_t * vnm = gm->vnet_main;
390  gre_tunnel_t * t;
391  u32 sw_if_index;
392 
393  t = gre_tunnel_db_find(&a->src, &a->dst, a->outer_fib_id);
394 
395  if (NULL == t)
396  return VNET_API_ERROR_NO_SUCH_ENTRY;
397 
398  sw_if_index = t->sw_if_index;
399  vnet_sw_interface_set_flags (vnm, sw_if_index, 0 /* down */);
400  /* make sure tunnel is removed from l2 bd or xconnect */
401  set_int_l2_mode(gm->vlib_main, vnm, MODE_L3, sw_if_index, 0, 0, 0, 0);
403  gm->tunnel_index_by_sw_if_index[sw_if_index] = ~0;
404  ip4_sw_interface_enable_disable(sw_if_index, 0);
405 
407  t->sibling_index);
409  FIB_SOURCE_RR);
410 
412  fib_node_deinit(&t->node);
413  pool_put (gm->tunnels, t);
414 
415  if (sw_if_indexp)
416  *sw_if_indexp = sw_if_index;
417 
418  return 0;
419 }
420 
421 int
423  u32 * sw_if_indexp)
424 {
425  if (a->is_add)
426  return (vnet_gre_tunnel_add(a, sw_if_indexp));
427  else
428  return (vnet_gre_tunnel_delete(a, sw_if_indexp));
429 }
430 
431 clib_error_t *
433 {
434  gre_main_t * gm = &gre_main;
436  gre_tunnel_t *t;
437  u32 ti;
438 
439  hi = vnet_get_hw_interface (vnm, hw_if_index);
440 
441  if (NULL == gm->tunnel_index_by_sw_if_index ||
443  return (NULL);
444 
446 
447  if (~0 == ti)
448  /* not one of ours */
449  return (NULL);
450 
451  t = pool_elt_at_index(gm->tunnels, ti);
452 
455  else
456  vnet_hw_interface_set_flags (vnm, hw_if_index, 0 /* down */);
457 
459 
460  return /* no error */ 0;
461 }
462 
463 static clib_error_t *
465  unformat_input_t * input,
466  vlib_cli_command_t * cmd)
467 {
468  unformat_input_t _line_input, * line_input = &_line_input;
469  vnet_gre_add_del_tunnel_args_t _a, * a = &_a;
470  ip4_address_t src, dst;
471  u32 outer_fib_id = 0;
472  u8 teb = 0;
473  int rv;
474  u32 num_m_args = 0;
475  u8 is_add = 1;
476  u32 sw_if_index;
477 
478  /* Get a line of input. */
479  if (! unformat_user (input, unformat_line_input, line_input))
480  return 0;
481 
482  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) {
483  if (unformat (line_input, "del"))
484  is_add = 0;
485  else if (unformat (line_input, "src %U", unformat_ip4_address, &src))
486  num_m_args++;
487  else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst))
488  num_m_args++;
489  else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
490  ;
491  else if (unformat (line_input, "teb"))
492  teb = 1;
493  else
494  return clib_error_return (0, "unknown input `%U'",
495  format_unformat_error, input);
496  }
497  unformat_free (line_input);
498 
499  if (num_m_args < 2)
500  return clib_error_return (0, "mandatory argument(s) missing");
501 
502  if (memcmp (&src, &dst, sizeof(src)) == 0)
503  return clib_error_return (0, "src and dst are identical");
504 
505  memset (a, 0, sizeof (*a));
506  a->outer_fib_id = outer_fib_id;
507  a->teb = teb;
508  clib_memcpy(&a->src, &src, sizeof(src));
509  clib_memcpy(&a->dst, &dst, sizeof(dst));
510 
511  if (is_add)
512  rv = vnet_gre_tunnel_add(a, &sw_if_index);
513  else
514  rv = vnet_gre_tunnel_delete(a, &sw_if_index);
515 
516  switch(rv)
517  {
518  case 0:
519  vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), sw_if_index);
520  break;
521  case VNET_API_ERROR_INVALID_VALUE:
522  return clib_error_return (0, "GRE tunnel already exists...");
523  case VNET_API_ERROR_NO_SUCH_FIB:
524  return clib_error_return (0, "outer fib ID %d doesn't exist\n",
525  outer_fib_id);
526  default:
527  return clib_error_return (0, "vnet_gre_add_del_tunnel returned %d", rv);
528  }
529 
530  return 0;
531 }
532 
533 VLIB_CLI_COMMAND (create_gre_tunnel_command, static) = {
534  .path = "create gre tunnel",
535  .short_help = "create gre tunnel src <addr> dst <addr> "
536  "[outer-fib-id <fib>] [teb] [del]",
537  .function = create_gre_tunnel_command_fn,
538 };
539 
540 static clib_error_t *
542  unformat_input_t * input,
543  vlib_cli_command_t * cmd)
544 {
545  gre_main_t * gm = &gre_main;
546  gre_tunnel_t * t;
547  u32 ti = ~0;
548 
549  if (pool_elts (gm->tunnels) == 0)
550  vlib_cli_output (vm, "No GRE tunnels configured...");
551 
553  {
554  if (unformat (input, "%d", &ti))
555  ;
556  else
557  break;
558  }
559 
560  if (~0 == ti)
561  {
562  pool_foreach (t, gm->tunnels,
563  ({
564  vlib_cli_output (vm, "%U", format_gre_tunnel, t);
565  }));
566  }
567  else
568  {
569  t = pool_elt_at_index(gm->tunnels, ti);
570 
571  vlib_cli_output (vm, "%U", format_gre_tunnel, t);
572  }
573 
574  return 0;
575 }
576 
577 VLIB_CLI_COMMAND (show_gre_tunnel_command, static) = {
578  .path = "show gre tunnel",
579  .function = show_gre_tunnel_command_fn,
580 };
581 
582 /* force inclusion from application's main.c */
584 {
586 
587  return 0;
588 }
vnet_main_t * vnet_main
Definition: gre.h:118
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:396
void gre_tunnel_stack(adj_index_t ai)
gre_tunnel_stack
Definition: interface.c:108
static void gre_tunnel_db_add(const gre_tunnel_t *t)
Definition: interface.c:73
vmrglw vmrglh hi
Recursive resolution source.
Definition: fib_entry.h:104
#define hash_set(h, key, value)
Definition: hash.h:254
Definition: gre.h:99
fib_node_index_t fib_entry_index
The FIB entry sourced by the tunnel for its destination prefix.
Definition: gre.h:78
u32 hw_if_index
Definition: gre.h:71
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:522
#define hash_unset(h, key)
Definition: hash.h:260
a
Definition: bitmap.h:516
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
static u8 * format_gre_tunnel(u8 *s, va_list *args)
Definition: interface.c:37
static int vnet_gre_tunnel_add(vnet_gre_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
Definition: interface.c:224
vnet_interface_main_t interface_main
Definition: vnet.h:72
void fib_node_init(fib_node_t *node, fib_node_type_t type)
Definition: fib_node.c:172
uword * tunnel_by_key
Definition: gre.h:108
u32 fib_entry_child_add(fib_node_index_t fib_entry_index, fib_node_type_t child_type, fib_node_index_t child_index)
Definition: fib_entry.c:550
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
static uword vlib_node_add_named_next(vlib_main_t *vm, uword node, char *name)
Definition: node_funcs.h:1075
static void gre_tunnel_restack(gre_tunnel_t *gt)
Definition: interface.c:157
#define NULL
Definition: clib.h:55
IP unicast adjacency.
Definition: lookup.h:174
enum fib_node_back_walk_rc_t_ fib_node_back_walk_rc_t
Return code from a back walk function.
const dpo_id_t * fib_entry_contribute_ip_forwarding(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:515
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
u32 outer_fib_index
The FIB in which the src.dst address are present.
Definition: gre.h:70
void fib_entry_child_remove(fib_node_index_t fib_entry_index, u32 sibling_index)
Definition: fib_entry.c:561
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:482
static adj_walk_rc_t gre_adj_walk_cb(adj_index_t ai, void *ctx)
Call back when restacking all adjacencies on a GRE interface.
Definition: interface.c:148
static gre_tunnel_t * gre_tunnel_db_find(const ip4_address_t *src, const ip4_address_t *dst, u32 out_fib_index)
Definition: interface.c:54
#define STRUCT_OFFSET_OF(t, f)
Definition: clib.h:62
void fib_node_deinit(fib_node_t *node)
Definition: fib_node.c:187
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
Definition: ip4.h:104
#define clib_error_report(e)
Definition: error.h:125
#define VNET_HW_INTERFACE_FLAG_LINK_UP
Definition: interface.h:348
format_function_t format_ip4_address
Definition: format.h:78
format_function_t format_vnet_sw_if_index_name
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
u32 * tunnel_index_by_sw_if_index
Definition: gre.h:114
void fib_node_register_type(fib_node_type_t type, const fib_node_vft_t *vft)
fib_node_register_type
Definition: fib_node.c:58
ip4_address_t tunnel_dst
The tunnel&#39;s destination/remote address.
Definition: gre.h:66
u32 sibling_index
The tunnel is a child of the FIB entry for its desintion.
Definition: gre.h:86
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
static ip_adjacency_t * adj_get(adj_index_t adj_index)
Get a pointer to an adjacency object from its index.
Definition: adj.h:117
u32 sw_if_index
Definition: gre.h:72
u32 * free_gre_tunnel_hw_if_indices
Definition: gre.h:111
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:348
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:111
vlib_combined_counter_main_t * combined_sw_if_counters
Definition: interface.h:577
enum adj_walk_rc_t_ adj_walk_rc_t
return codes from a adjacency walker callback function
clib_error_t * gre_interface_init(vlib_main_t *vm)
Definition: interface.c:583
Aggregrate type for a prefix.
Definition: fib_types.h:149
static void unformat_free(unformat_input_t *i)
Definition: format.h:161
unsigned long u64
Definition: types.h:89
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:977
static fib_node_t * gre_tunnel_fib_node_get(fib_node_index_t index)
Function definition to get a FIB node from its index.
Definition: interface.c:189
adj_index_t l2_adj_index
an L2 tunnel always rquires an L2 midchain.
Definition: gre.h:96
u16 fp_len
The mask length.
Definition: fib_types.h:153
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
Definition: interface.c:660
u32 set_int_l2_mode(vlib_main_t *vm, vnet_main_t *vnet_main, u32 mode, u32 sw_if_index, u32 bd_index, u32 bvi, u32 shg, u32 xc_sw_if_index)
Set the subinterface to run in l2 or l3 mode.
Definition: l2_input.c:555
Definition: fib_entry.h:215
unformat_function_t unformat_ip4_address
Definition: format.h:75
static clib_error_t * create_gre_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface.c:464
#define hash_get(h, key)
Definition: hash.h:248
#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
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:369
static void vlib_zero_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
Clear a combined counter Clears the set of per-thread u16 counters, and the shared vlib_counter_t...
Definition: counter.h:321
fib_node_index_t fib_table_entry_special_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, adj_index_t adj_index)
Add a &#39;special&#39; entry to the FIB that links to the adj passed A special entry is an entry that the FI...
Definition: fib_table.c:369
void ip4_sw_interface_enable_disable(u32 sw_if_index, u32 is_enable)
Definition: ip4_forward.c:709
static uword vnet_hw_interface_get_flags(vnet_main_t *vnm, u32 hw_if_index)
static void gre_tunnel_db_remove(const gre_tunnel_t *t)
Definition: interface.c:83
static gre_tunnel_t * gre_tunnel_from_fib_node(fib_node_t *node)
Definition: interface.c:93
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:214
void gre_update_adj(vnet_main_t *vnm, u32 sw_if_index, adj_index_t ai)
Definition: gre.c:236
vlib_simple_counter_main_t * sw_if_counters
Definition: interface.h:576
fib_node_type_t fn_type
The node&#39;s type.
Definition: fib_node.h:247
An node in the FIB graph.
Definition: fib_node.h:242
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:575
static u64 gre_mk_key(const ip4_address_t *src, const ip4_address_t *dst, u32 out_fib_index)
Definition: interface.c:28
clib_error_t * gre_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: interface.c:432
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P (general version).
Definition: pool.h:169
static clib_error_t * show_gre_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface.c:541
void fib_table_entry_delete_index(fib_node_index_t fib_entry_index, fib_source_t source)
Delete a FIB entry.
Definition: fib_table.c:816
fib_node_get_t fnv_get
Definition: fib_node.h:230
#define clib_memcpy(a, b, c)
Definition: string.h:64
ip4_address_t tunnel_src
The tunnel&#39;s source/local address.
Definition: gre.h:62
static void vnet_interface_counter_unlock(vnet_interface_main_t *im)
Definition: interface.h:600
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:28
static u32 ip4_fib_index_from_table_id(u32 table_id)
Definition: ip4_fib.h:101
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
void adj_nbr_walk(u32 sw_if_index, fib_protocol_t adj_nh_proto, adj_walk_cb_t cb, void *ctx)
Walk the neighbour Adjacencies on a given interface.
Definition: adj_nbr.c:438
Context passed between object during a back walk.
Definition: fib_node.h:160
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:154
static void vnet_interface_counter_lock(vnet_interface_main_t *im)
Definition: interface.h:592
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
Definition: interface.h:490
u32 max_l3_packet_bytes[VLIB_N_RX_TX]
Definition: interface.h:420
#define ASSERT(truth)
static fib_node_back_walk_rc_t gre_tunnel_back_walk(fib_node_t *node, fib_node_back_walk_ctx_t *ctx)
Function definition to backwalk a FIB node.
Definition: interface.c:177
void adj_nbr_midchain_stack(adj_index_t adj_index, const dpo_id_t *next)
adj_nbr_midchain_stack
Definition: adj_midchain.c:494
unsigned int u32
Definition: types.h:88
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
Definition: interface.c:205
gre_tunnel_t * tunnels
Definition: gre.h:101
IPv4 main type.
Definition: ip4.h:95
static void vlib_zero_simple_counter(vlib_simple_counter_main_t *cm, u32 index)
Clear a simple counter Clears the set of per-thread u16 counters, and the u64 counter.
Definition: counter.h:143
void adj_nbr_midchain_unstack(adj_index_t adj_index)
adj_nbr_midchain_unstack
Definition: adj_midchain.c:471
vnet_hw_interface_class_t gre_hw_interface_class
u64 uword
Definition: types.h:112
u32 l2_tx_arc
on a L2 tunnel this is the VLIB arc from the L2-tx to the l2-midchain
Definition: gre.h:91
u8 teb
Definition: gre.h:73
fib_node_t node
Linkage into the FIB object graph.
Definition: gre.h:57
Definition: defs.h:47
vnet_device_class_t gre_device_class
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
#define FOR_EACH_FIB_IP_PROTOCOL(_item)
Definition: fib_types.h:66
A FIB graph nodes virtual function table.
Definition: fib_node.h:229
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:169
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:418
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1060
adj_index_t adj_nbr_add_or_lock(fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index)
Neighbour Adjacency sub-type.
Definition: adj_nbr.c:173
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
Definition: interface.c:530
vlib_main_t * vlib_main
Definition: gre.h:117
u32 per_packet_overhead_bytes
Definition: interface.h:417
#define clib_error_return(e, args...)
Definition: error.h:111
struct _unformat_input_t unformat_input_t
u32 flags
Definition: vhost-user.h:75
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header, unspecified alignment)
Definition: vec.h:445
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:67
unformat_function_t unformat_line_input
Definition: format.h:281
int vnet_gre_add_del_tunnel(vnet_gre_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
Definition: interface.c:422
gre_main_t gre_main
Definition: gre.c:22
static int vnet_gre_tunnel_delete(vnet_gre_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
Definition: interface.c:385
const ip46_address_t zero_addr
Definition: lookup.c:309
Definition: defs.h:46
#define MODE_L3
Definition: l2_input.h:218
static void gre_tunnel_last_lock_gone(fib_node_t *node)
Function definition to inform the FIB node that its last lock has gone.
Definition: interface.c:204
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:109