FD.io VPP  v19.01.2-3-gf61a1a8
Vector Packet Processing
ipip.c
Go to the documentation of this file.
1 /*
2  * ipip.c: ipip
3  *
4  * Copyright (c) 2018 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 aipiped 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 <stddef.h>
19 #include <vnet/adj/adj_midchain.h>
20 #include <vnet/ipip/ipip.h>
21 #include <vnet/vnet.h>
22 #include <vnet/adj/adj_nbr.h>
23 #include <vnet/fib/ip4_fib.h>
24 #include <vnet/fib/ip6_fib.h>
25 #include <vnet/ip/format.h>
26 #include <vnet/ipip/ipip.h>
27 
29 
30 /* Packet trace structure */
31 typedef struct
32 {
35  ip46_address_t src;
36  ip46_address_t dst;
38 
39 u8 *
40 format_ipip_tx_trace (u8 * s, va_list * args)
41 {
42  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
43  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
44  ipip_tx_trace_t *t = va_arg (*args, ipip_tx_trace_t *);
45 
46  s =
47  format (s, "IPIP: tunnel %d len %d src %U dst %U", t->tunnel_id,
50  return s;
51 }
52 
53 static u8 *
55  vnet_link_t link_type, const void *dst_address)
56 {
57  ip4_header_t *ip4;
58  ip6_header_t *ip6;
59  u8 *rewrite = NULL;
61 
62  if (!t)
63  /* not one of ours */
64  return (0);
65 
66  switch (t->transport)
67  {
68  case IPIP_TRANSPORT_IP4:
69  vec_validate (rewrite, sizeof (*ip4) - 1);
70  ip4 = (ip4_header_t *) rewrite;
71  ip4->ip_version_and_header_length = 0x45;
72  ip4->ttl = 64;
73  /* fixup ip4 header length, protocol and checksum after-the-fact */
74  ip4->src_address.as_u32 = t->tunnel_src.ip4.as_u32;
75  ip4->dst_address.as_u32 = t->tunnel_dst.ip4.as_u32;
76  ip4->checksum = ip4_header_checksum (ip4);
77  if (t->tc_tos != 0xFF)
78  ip4->tos = t->tc_tos;
79  break;
80 
81  case IPIP_TRANSPORT_IP6:
82  vec_validate (rewrite, sizeof (*ip6) - 1);
83  ip6 = (ip6_header_t *) rewrite;
85  clib_host_to_net_u32 (6 << 28);
86  if (t->tc_tos != 0xFF)
88  ip6->hop_limit = 64;
89  /* fixup ip6 header length and protocol after-the-fact */
90  ip6->src_address.as_u64[0] = t->tunnel_src.ip6.as_u64[0];
91  ip6->src_address.as_u64[1] = t->tunnel_src.ip6.as_u64[1];
92  ip6->dst_address.as_u64[0] = t->tunnel_dst.ip6.as_u64[0];
93  ip6->dst_address.as_u64[1] = t->tunnel_dst.ip6.as_u64[1];
94  break;
95 
96  default:
97  /* pass through */
98  ;
99  }
100  return (rewrite);
101 }
102 
103 static void
105  const void *data)
106 {
107  ip4_header_t *ip4;
108  const ipip_tunnel_t *t = data;
109 
110  ip4 = vlib_buffer_get_current (b);
111  ip4->length = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b));
112  switch (adj->ia_link)
113  {
114  case VNET_LINK_IP6:
115  ip4->protocol = IP_PROTOCOL_IPV6;
116  if (t->tc_tos == 0xFF)
117  ip4->tos =
118  ip6_traffic_class_network_order ((const ip6_header_t *) (ip4 + 1));
119  break;
120 
121  case VNET_LINK_IP4:
122  ip4->protocol = IP_PROTOCOL_IP_IN_IP;
123  if (t->tc_tos == 0xFF)
124  ip4->tos = ((ip4_header_t *) (ip4 + 1))->tos;
125  break;
126 
127  default:
128  break;
129  }
130 
131  ip4->checksum = ip4_header_checksum (ip4);
132 }
133 
134 static void
136  const void *data)
137 {
138  ip6_header_t *ip6;
139  const ipip_tunnel_t *t = data;
140 
141  /* Must set locally originated otherwise we're not allowed to
142  fragment the packet later */
143  b->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
144 
145  ip6 = vlib_buffer_get_current (b);
146  ip6->payload_length =
147  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b) -
148  sizeof (*ip6));
149  switch (adj->ia_link)
150  {
151  case VNET_LINK_IP6:
152  ip6->protocol = IP_PROTOCOL_IPV6;
153  if (t->tc_tos == 0xFF)
155  ip6_traffic_class_network_order ((const ip6_header_t *) (ip6 + 1)));
156  break;
157 
158  case VNET_LINK_IP4:
159  ip6->protocol = IP_PROTOCOL_IP_IN_IP;
160  if (t->tc_tos == 0xFF)
162  ((ip4_header_t *) (ip6 +
163  1))->tos);
164  break;
165 
166  default:
167  break;
168  }
169 }
170 
171 static void
173 {
174  ip_adjacency_t *adj;
175  ipip_tunnel_t *t;
177 
178  adj = adj_get (ai);
179  sw_if_index = adj->rewrite_header.sw_if_index;
180 
181  t = ipip_tunnel_db_find_by_sw_if_index (sw_if_index);
182  if (!t)
183  return;
184 
187  {
189  }
190  else
191  {
193  (ai,
194  t->p2p.fib_entry_index,
195  (t->transport == IPIP_TRANSPORT_IP6) ?
197  }
198 }
199 
200 static adj_walk_rc_t
202 {
203  ipip_tunnel_stack (ai);
204 
205  return (ADJ_WALK_RC_CONTINUE);
206 }
207 
208 static void
210 {
211  fib_protocol_t proto;
212 
213  /*
214  * walk all the adjacencies on th IPIP interface and restack them
215  */
217  {
219  }
220 }
221 
222 void
224 {
226  ipip_tunnel_t *t;
227  adj_flags_t af;
228 
229  t = ipip_tunnel_db_find_by_sw_if_index (sw_if_index);
230  if (!t)
231  return;
232 
237 
238  adj_nbr_midchain_update_rewrite (ai, f, t, af,
239  ipip_build_rewrite (vnm,
240  sw_if_index,
242  (ai), NULL));
243  ipip_tunnel_stack (ai);
244 }
245 
246 static u8 *
247 format_ipip_tunnel_name (u8 * s, va_list * args)
248 {
249  u32 dev_instance = va_arg (*args, u32);
251  ipip_tunnel_t *t;
252 
253  if (dev_instance >= vec_len (gm->tunnels))
254  return format (s, "<improperly-referenced>");
255 
256  t = pool_elt_at_index (gm->tunnels, dev_instance);
257  return format (s, "ipip%d", t->user_instance);
258 }
259 
260 static u8 *
261 format_ipip_device (u8 * s, va_list * args)
262 {
263  u32 dev_instance = va_arg (*args, u32);
264  CLIB_UNUSED (int verbose) = va_arg (*args, int);
265 
266  s = format (s, "IPIP tunnel: id %d\n", dev_instance);
267  return s;
268 }
269 
270 static clib_error_t *
272 {
274  ipip_tunnel_t *t;
275 
276  hi = vnet_get_hw_interface (vnm, hw_if_index);
277 
279  if (!t)
280  return 0;
281 
283  vnet_hw_interface_set_flags (vnm, hw_if_index,
285  else
286  vnet_hw_interface_set_flags (vnm, hw_if_index, 0 /* down */ );
287 
289 
290  return /* no error */ 0;
291 }
292 
293 /* *INDENT-OFF* */
294 VNET_DEVICE_CLASS(ipip_device_class) = {
295  .name = "IPIP tunnel device",
296  .format_device_name = format_ipip_tunnel_name,
297  .format_device = format_ipip_device,
298  .format_tx_trace = format_ipip_tx_trace,
299  .admin_up_down_function = ipip_interface_admin_up_down,
300 #ifdef SOON
301  .clear counter = 0;
302 #endif
303 };
304 
306  .name = "IPIP",
307  //.format_header = format_ipip_header_with_length,
308  //.unformat_header = unformat_ipip_header,
309  .build_rewrite = ipip_build_rewrite,
310  .update_adjacency = ipip_update_adj,
312 };
313 /* *INDENT-ON* */
314 
317 {
319  uword *p;
320 
321  p = hash_get_mem (gm->tunnel_by_key, key);
322  if (!p)
323  return (NULL);
324  return (pool_elt_at_index (gm->tunnels, p[0]));
325 }
326 
329 {
331  if (vec_len (gm->tunnel_index_by_sw_if_index) <= sw_if_index)
332  return NULL;
334  if (ti == ~0)
335  return NULL;
336  return pool_elt_at_index (gm->tunnels, ti);
337 }
338 
339 void
341 {
343 
344  t->key = clib_mem_alloc (sizeof (*t->key));
345  clib_memcpy (t->key, key, sizeof (*key));
347 }
348 
349 void
351 {
353 
354  hash_unset_mem (gm->tunnel_by_key, t->key);
355  clib_mem_free (t->key);
356  t->key = NULL;
357 }
358 
359 static ipip_tunnel_t *
361 {
363  ASSERT (gm->fib_node_type == node->fn_type);
364  return ((ipip_tunnel_t *) (((char *) node) -
365  offsetof (ipip_tunnel_t, p2p.node)));
366 }
367 
370 {
372 
374 }
375 
376 static fib_node_t *
378 {
379  ipip_tunnel_t *gt;
380  ipip_main_t *gm;
381 
382  gm = &ipip_main;
383  gt = pool_elt_at_index (gm->tunnels, index);
384 
385  return (&gt->p2p.node);
386 }
387 
388 static void
390 {
391  /*
392  * The MPLS IPIP tunnel is a root of the graph. As such
393  * it never has children and thus is never locked.
394  */
395  ASSERT (0);
396 }
397 
398 /*
399  * Virtual function table registered by IPIP tunnels
400  * for participation in the FIB object graph.
401  */
402 const static fib_node_vft_t ipip_vft = {
404  .fnv_last_lock = ipip_tunnel_last_lock_gone,
405  .fnv_back_walk = ipip_tunnel_back_walk,
406 };
407 
408 static void
410 {
412  fib_prefix_t dst = {.fp_len = t->transport == IPIP_TRANSPORT_IP6 ? 128 : 32,
413  .fp_proto =
414  t->transport ==
416  .fp_addr = t->tunnel_dst
417  };
418 
419  t->p2p.fib_entry_index =
422  t->p2p.sibling_index =
423  fib_entry_child_add (t->p2p.fib_entry_index, gm->fib_node_type,
424  t->dev_instance);
425 }
426 
427 static void
429 {
430  fib_entry_child_remove (t->p2p.fib_entry_index, t->p2p.sibling_index);
431  fib_table_entry_delete_index (t->p2p.fib_entry_index, FIB_SOURCE_RR);
432  fib_node_deinit (&t->p2p.node);
433 }
434 
435 int
437  u32 instance, ip46_address_t * src, ip46_address_t * dst,
438  u32 fib_index, u8 tc_tos, u32 * sw_if_indexp)
439 {
441  vnet_main_t *vnm = gm->vnet_main;
442  ip4_main_t *im4 = &ip4_main;
443  ip6_main_t *im6 = &ip6_main;
444  ipip_tunnel_t *t;
446  u32 hw_if_index, sw_if_index;
447  ipip_tunnel_key_t key = {.transport = transport,
448  .fib_index = fib_index,
449  .src = *src,
450  .dst = *dst
451  };
452  t = ipip_tunnel_db_find (&key);
453  if (t)
454  return VNET_API_ERROR_IF_ALREADY_EXISTS;
455 
457  clib_memset (t, 0, sizeof (*t));
458 
459  /* Reconcile the real dev_instance and a possible requested instance */
460  u32 t_idx = t - gm->tunnels; /* tunnel index (or instance) */
461  u32 u_idx = instance; /* user specified instance */
462  if (u_idx == ~0)
463  u_idx = t_idx;
464  if (hash_get (gm->instance_used, u_idx))
465  {
466  pool_put (gm->tunnels, t);
467  return VNET_API_ERROR_INSTANCE_IN_USE;
468  }
469  hash_set (gm->instance_used, u_idx, 1);
470 
471  t->dev_instance = t_idx; /* actual */
472  t->user_instance = u_idx; /* name */
473  fib_node_init (&t->p2p.node, gm->fib_node_type);
474 
475  hw_if_index = vnet_register_interface (vnm, ipip_device_class.index, t_idx,
477  t_idx);
478 
479  hi = vnet_get_hw_interface (vnm, hw_if_index);
480  sw_if_index = hi->sw_if_index;
481 
482  t->hw_if_index = hw_if_index;
483  t->fib_index = fib_index;
485  t->tc_tos = tc_tos;
486 
487  t->transport = transport;
490 
491  if (t->transport == IPIP_TRANSPORT_IP4)
492  {
493  vec_validate (im4->fib_index_by_sw_if_index, sw_if_index);
494  hi->min_packet_bytes = 64 + sizeof (ip4_header_t);
495  }
496  else
497  {
498  vec_validate (im6->fib_index_by_sw_if_index, sw_if_index);
499  hi->min_packet_bytes = 64 + sizeof (ip6_header_t);
500  }
501 
502  /* Standard default ipip MTU. */
503  vnet_sw_interface_set_mtu (vnm, sw_if_index, 9000);
504 
505  t->tunnel_src = *src;
506  t->tunnel_dst = *dst;
507 
508  ipip_tunnel_db_add (t, &key);
509 
510  /*
511  * Source the FIB entry for the tunnel's destination and become a
512  * child thereof. The tunnel will then get poked when the forwarding
513  * for the entry updates, and the tunnel can re-stack accordingly
514  */
515  ipip_fib_add (t);
516  if (sw_if_indexp)
517  *sw_if_indexp = sw_if_index;
518 
520  {
521  ip6_register_protocol (IP_PROTOCOL_IP_IN_IP, ipip6_input_node.index);
522  ip6_register_protocol (IP_PROTOCOL_IPV6, ipip6_input_node.index);
523  gm->ip6_protocol_registered = true;
524  }
526  {
527  ip4_register_protocol (IP_PROTOCOL_IP_IN_IP, ipip4_input_node.index);
528  ip4_register_protocol (IP_PROTOCOL_IPV6, ipip4_input_node.index);
529  gm->ip4_protocol_registered = true;
530  }
531  return 0;
532 }
533 
534 int
536 {
538  vnet_main_t *vnm = gm->vnet_main;
539  ipip_tunnel_t *t;
540 
541 
542  t = ipip_tunnel_db_find_by_sw_if_index (sw_if_index);
543  if (t == NULL)
544  return VNET_API_ERROR_NO_SUCH_ENTRY;
545 
546  vnet_sw_interface_set_flags (vnm, sw_if_index, 0 /* down */ );
549  ipip_fib_delete (t);
552  pool_put (gm->tunnels, t);
553 
554  return 0;
555 }
556 
557 static clib_error_t *
559 {
561 
562  clib_memset (gm, 0, sizeof (gm[0]));
563  gm->vlib_main = vm;
564  gm->vnet_main = vnet_get_main ();
565  gm->tunnel_by_key =
566  hash_create_mem (0, sizeof (ipip_tunnel_key_t), sizeof (uword));
567  gm->fib_node_type = fib_node_register_new_type (&ipip_vft);
568 
569  return 0;
570 }
571 
573 
574 /*
575  * fd.io coding-style-patch-verification: ON
576  *
577  * Local Variables:
578  * eval: (c-set-style "gnu")
579  * End:
580  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:439
vmrglw vmrglh hi
void ipip_tunnel_db_remove(ipip_tunnel_t *t)
Definition: ipip.c:350
Recursive resolution source.
Definition: fib_entry.h:125
Contribute an object that is to be used to forward IP6 packets.
Definition: fib_types.h:113
#define hash_set(h, key, value)
Definition: hash.h:255
u32 flags
Definition: vhost_user.h:115
vl_api_address_t src
Definition: vxlan_gbp.api:32
#define CLIB_UNUSED(x)
Definition: clib.h:82
#define hash_unset(h, key)
Definition: hash.h:261
void ip6_register_protocol(u32 protocol, u32 node_index)
Definition: ip6_forward.c:1461
ip4_address_t src_address
Definition: ip4_packet.h:170
static fib_node_t * ipip_tunnel_fib_node_get(fib_node_index_t index)
Definition: ipip.c:377
fib_node_t node
Definition: ipip.h:91
A representation of a IPIP tunnel.
Definition: ipip.h:70
struct ipip_tunnel_t::@227::@229 p2p
vnet_main_t * vnet_get_main(void)
Definition: misc.c:47
int ipip_add_tunnel(ipip_transport_t transport, u32 instance, ip46_address_t *src, ip46_address_t *dst, u32 fib_index, u8 tc_tos, u32 *sw_if_indexp)
Definition: ipip.c:436
void fib_node_init(fib_node_t *node, fib_node_type_t type)
Definition: fib_node.c:185
ip46_address_t tunnel_src
Definition: ipip.h:78
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:555
static clib_error_t * ipip_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: ipip.c:271
u64 as_u64[2]
Definition: ip6_packet.h:51
u32 length
Definition: ipip.c:34
vnet_hw_interface_class_t ipip_hw_interface_class
vnet_link_t adj_get_link_type(adj_index_t ai)
Return the link type of the adjacency.
Definition: adj.c:468
#define NULL
Definition: clib.h:58
IP unicast adjacency.
Definition: adj.h:221
enum fib_node_back_walk_rc_t_ fib_node_back_walk_rc_t
Return code from a back walk function.
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
u8 tc_tos
Definition: ipip.h:85
void fib_entry_child_remove(fib_node_index_t fib_entry_index, u32 sibling_index)
Definition: fib_entry.c:566
static u8 * format_ipip_device(u8 *s, va_list *args)
Definition: ipip.c:261
format_function_t format_ip46_address
Definition: format.h:61
Contribute an object that is to be used to forward IP4 packets.
Definition: fib_types.h:109
#define hash_set_mem(h, key, value)
Definition: hash.h:275
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
void fib_node_deinit(fib_node_t *node)
Definition: fib_node.c:197
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
Definition: ip4.h:112
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
void ip4_register_protocol(u32 protocol, u32 node_index)
Definition: ip4_forward.c:1700
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:267
u32 hw_if_index
Definition: ipip.h:81
ip6_address_t src_address
Definition: ip6_packet.h:378
bool ip4_protocol_registered
Definition: ipip.h:122
unsigned char u8
Definition: types.h:56
fib_node_type_t fib_node_register_new_type(const fib_node_vft_t *vft)
Create a new FIB node type and Register the function table for it.
Definition: fib_node.c:80
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
vnet_link_t ia_link
link/ether-type 1 bytes
Definition: adj.h:242
#define clib_memcpy(d, s, n)
Definition: string.h:180
static void ipip_tunnel_last_lock_gone(fib_node_t *node)
Definition: ipip.c:389
static ip_adjacency_t * adj_get(adj_index_t adj_index)
Get a pointer to an adjacency object from its index.
Definition: adj.h:433
static void ipip4_fixup(vlib_main_t *vm, ip_adjacency_t *adj, vlib_buffer_t *b, const void *data)
Definition: ipip.c:104
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:163
u32 user_instance
Definition: ipip.h:84
u32 sw_if_index
Definition: vxlan_gbp.api:37
ip4_address_t dst_address
Definition: ip4_packet.h:170
enum adj_walk_rc_t_ adj_walk_rc_t
return codes from a adjacency walker callback function
static_always_inline void ip6_set_traffic_class_network_order(ip6_header_t *ip6, u8 dscp)
Definition: ip6_packet.h:395
static_always_inline u8 ip6_traffic_class_network_order(const ip6_header_t *ip6)
Definition: ip6_packet.h:388
static void ipip_tunnel_restack(ipip_tunnel_t *gt)
Definition: ipip.c:209
Aggregrate type for a prefix.
Definition: fib_types.h:203
u32 tunnel_id
Definition: ipip.c:33
void adj_nbr_midchain_stack_on_fib_entry(adj_index_t ai, fib_node_index_t fei, fib_forward_chain_type_t fct)
[re]stack a midchain.
Definition: adj_midchain.c:584
u32 * tunnel_index_by_sw_if_index
Definition: ipip.h:112
unsigned int u32
Definition: types.h:88
ipip_transport_t transport
Definition: ipip.h:57
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:740
Definition: fib_entry.h:275
ip46_address_t dst
Definition: ipip.c:36
#define hash_create_mem(elts, key_bytes, value_bytes)
Definition: hash.h:661
#define hash_get(h, key)
Definition: hash.h:249
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:511
#define hash_unset_mem(h, key)
Definition: hash.h:291
void ipip_tunnel_db_add(ipip_tunnel_t *t, ipip_tunnel_key_t *key)
Definition: ipip.c:340
static void ipip_tunnel_stack(adj_index_t ai)
Definition: ipip.c:172
static u8 * ipip_build_rewrite(vnet_main_t *vnm, u32 sw_if_index, vnet_link_t link_type, const void *dst_address)
Definition: ipip.c:54
static uword vnet_hw_interface_get_flags(vnet_main_t *vnm, u32 hw_if_index)
ipip_tunnel_t * ipip_tunnel_db_find(ipip_tunnel_key_t *key)
Definition: ipip.c:316
#define gm
Definition: dlmalloc.c:1217
long ctx[MAX_CONNS]
Definition: main.c:144
ipip_tunnel_t * ipip_tunnel_db_find_by_sw_if_index(u32 sw_if_index)
Definition: ipip.c:328
ipip_tunnel_t * tunnels
Definition: ipip.h:110
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:214
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:286
fib_node_type_t fn_type
The node&#39;s type.
Definition: fib_node.h:295
An node in the FIB graph.
Definition: fib_node.h:291
u8 * format_ipip_tx_trace(u8 *s, va_list *args)
Definition: ipip.c:40
ipip_tunnel_key_t * key
Definition: ipip.h:77
static void ipip6_fixup(vlib_main_t *vm, ip_adjacency_t *adj, vlib_buffer_t *b, const void *data)
Definition: ipip.c:135
static adj_walk_rc_t ipip_adj_walk_cb(adj_index_t ai, void *ctx)
Definition: ipip.c:201
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
Definition: pool.h:230
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)
Add a &#39;special&#39; entry to the FIB.
Definition: fib_table.c:388
VNET_HW_INTERFACE_CLASS(ipip_hw_interface_class)
ipip_transport_t
IPIP Tunnel key.
Definition: ipip.h:47
ipip_main_t ipip_main
Definition: ipip.c:28
vlib_main_t * vm
Definition: buffer.c:301
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:877
vl_api_address_t dst
Definition: vxlan_gbp.api:33
static u8 * format_ipip_tunnel_name(u8 *s, va_list *args)
Definition: ipip.c:247
void adj_nbr_midchain_update_rewrite(adj_index_t adj_index, adj_midchain_fixup_t fixup, const void *fixup_data, adj_flags_t flags, u8 *rewrite)
adj_nbr_midchain_update_rewrite
Definition: adj_midchain.c:509
fib_node_get_t fnv_get
Definition: fib_node.h:279
static void ipip_fib_add(ipip_tunnel_t *t)
Definition: ipip.c:409
vlib_node_registration_t ipip4_input_node
(constructor) VLIB_REGISTER_NODE (ipip4_input_node)
Definition: node.c:240
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:30
void(* adj_midchain_fixup_t)(vlib_main_t *vm, struct ip_adjacency_t_ *adj, vlib_buffer_t *b0, const void *data)
A function type for post-rewrite fixups on midchain adjacency.
Definition: adj.h:152
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:574
Context passed between object during a back walk.
Definition: fib_node.h:204
fib_node_type_t fib_node_type
Definition: ipip.h:113
u32 fib_index
Definition: ipip.h:80
#define ASSERT(truth)
static ipip_tunnel_t * ipip_tunnel_from_fib_node(fib_node_t *node)
Definition: ipip.c:360
ip6_main_t ip6_main
Definition: ip6_forward.c:2624
ipip_transport_t transport
Definition: ipip.h:76
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
IPv4 main type.
Definition: ip4.h:96
static void ipip_fib_delete(ipip_tunnel_t *t)
Definition: ipip.c:428
static void clib_mem_free(void *p)
Definition: mem.h:205
uword * tunnel_by_key
Definition: ipip.h:111
void adj_nbr_midchain_unstack(adj_index_t adj_index)
adj_nbr_midchain_unstack
Definition: adj_midchain.c:552
ip46_address_t src
Definition: ipip.c:35
static void * clib_mem_alloc(uword size)
Definition: mem.h:132
void ipip_update_adj(vnet_main_t *vnm, u32 sw_if_index, adj_index_t ai)
Definition: ipip.c:223
u32 sw_if_index
Definition: ipip.h:82
void vnet_delete_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
Definition: interface.c:950
enum adj_flags_t_ adj_flags_t
Flags on an IP adjacency.
vlib_node_registration_t ipip6_input_node
(constructor) VLIB_REGISTER_NODE (ipip6_input_node)
Definition: node.c:257
u32 ip_version_traffic_class_and_flow_label
Definition: ip6_packet.h:365
u16 payload_length
Definition: ip6_packet.h:369
vnet_main_t * vnet_main
Definition: ipip.h:117
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_interface_flags_t flags)
Definition: interface.c:504
bool ip6_protocol_registered
Definition: ipip.h:123
u64 uword
Definition: types.h:112
static clib_error_t * ipip_init(vlib_main_t *vm)
Definition: ipip.c:558
a point 2 point interface
Definition: interface.h:382
void vnet_sw_interface_set_mtu(vnet_main_t *vnm, u32 sw_if_index, u32 mtu)
Definition: interface.c:642
int ipip_del_tunnel(u32 sw_if_index)
Definition: ipip.c:535
#define FOR_EACH_FIB_IP_PROTOCOL(_item)
Definition: fib_types.h:70
#define hash_get_mem(h, key)
Definition: hash.h:269
A FIB graph nodes virtual function table.
Definition: fib_node.h:278
u32 dev_instance
Definition: ipip.h:83
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:903
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, vnet_sw_interface_flags_t flags)
Definition: interface.c:513
u8 ip_version_and_header_length
Definition: ip4_packet.h:138
ip46_address_t tunnel_dst
Definition: ipip.h:79
#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:488
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
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:117
vlib_main_t * vlib_main
Definition: ipip.h:116
u32 * fib_index_by_sw_if_index
Definition: ip6.h:193
static fib_node_back_walk_rc_t ipip_tunnel_back_walk(fib_node_t *node, fib_node_back_walk_ctx_t *ctx)
Definition: ipip.c:369
static u16 ip4_header_checksum(ip4_header_t *i)
Definition: ip4_packet.h:247
uword * instance_used
Definition: ipip.h:120
VNET_DEVICE_CLASS(ipip_device_class)
ip6_address_t dst_address
Definition: ip6_packet.h:378