FD.io VPP  v20.01-48-g3e0dafb74
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/adj/adj_midchain.h>
24 #include <vnet/fib/ip4_fib.h>
25 #include <vnet/fib/ip6_fib.h>
26 #include <vnet/ip/format.h>
27 #include <vnet/ipip/ipip.h>
28 
30 
31 /* Packet trace structure */
32 typedef struct
33 {
36  ip46_address_t src;
37  ip46_address_t dst;
39 
40 u8 *
41 format_ipip_tx_trace (u8 * s, va_list * args)
42 {
43  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
44  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
45  ipip_tx_trace_t *t = va_arg (*args, ipip_tx_trace_t *);
46 
47  s =
48  format (s, "IPIP: tunnel %d len %d src %U dst %U", t->tunnel_id,
51  return s;
52 }
53 
54 static u8 *
56  vnet_link_t link_type, const void *dst_address)
57 {
60  u8 *rewrite = NULL;
62 
63  if (!t)
64  /* not one of ours */
65  return (0);
66 
67  switch (t->transport)
68  {
69  case IPIP_TRANSPORT_IP4:
70  vec_validate (rewrite, sizeof (*ip4) - 1);
71  ip4 = (ip4_header_t *) rewrite;
72  ip4->ip_version_and_header_length = 0x45;
73  ip4->ttl = 64;
74  /* fixup ip4 header length, protocol and checksum after-the-fact */
75  ip4->src_address.as_u32 = t->tunnel_src.ip4.as_u32;
76  ip4->dst_address.as_u32 = t->tunnel_dst.ip4.as_u32;
77  ip4->checksum = ip4_header_checksum (ip4);
78  if (!(t->flags & IPIP_TUNNEL_FLAG_ENCAP_COPY_DSCP))
79  ip4_header_set_dscp (ip4, t->dscp);
80  if (t->flags & IPIP_TUNNEL_FLAG_ENCAP_SET_DF)
81  ip4_header_set_df (ip4);
82  break;
83 
84  case IPIP_TRANSPORT_IP6:
85  vec_validate (rewrite, sizeof (*ip6) - 1);
86  ip6 = (ip6_header_t *) rewrite;
88  clib_host_to_net_u32 (6 << 28);
89  ip6->hop_limit = 64;
90  /* fixup ip6 header length and protocol after-the-fact */
91  ip6->src_address.as_u64[0] = t->tunnel_src.ip6.as_u64[0];
92  ip6->src_address.as_u64[1] = t->tunnel_src.ip6.as_u64[1];
93  ip6->dst_address.as_u64[0] = t->tunnel_dst.ip6.as_u64[0];
94  ip6->dst_address.as_u64[1] = t->tunnel_dst.ip6.as_u64[1];
95  if (!(t->flags & IPIP_TUNNEL_FLAG_ENCAP_COPY_DSCP))
97  break;
98 
99  default:
100  /* pass through */
101  ;
102  }
103  return (rewrite);
104 }
105 
106 static void
108  const void *data)
109 {
110  ip4_header_t *ip4;
111  const ipip_tunnel_t *t = data;
112 
113  ip4 = vlib_buffer_get_current (b);
114  ip4->length = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b));
115  switch (adj->ia_link)
116  {
117  case VNET_LINK_IP6:
118  ip4->protocol = IP_PROTOCOL_IPV6;
119  if (t->flags & IPIP_TUNNEL_FLAG_ENCAP_COPY_DSCP)
120  ip4_header_set_dscp (ip4,
122  1)));
123  if (t->flags & IPIP_TUNNEL_FLAG_ENCAP_COPY_ECN)
124  ip4_header_set_ecn (ip4,
126  1)));
127  break;
128 
129  case VNET_LINK_IP4:
130  ip4->protocol = IP_PROTOCOL_IP_IN_IP;
131  if (t->flags & IPIP_TUNNEL_FLAG_ENCAP_COPY_DSCP)
132  ip4_header_set_dscp (ip4, ip4_header_get_dscp (ip4 + 1));
133  if (t->flags & IPIP_TUNNEL_FLAG_ENCAP_COPY_ECN)
134  ip4_header_set_ecn (ip4, ip4_header_get_ecn (ip4 + 1));
135  if ((t->flags & IPIP_TUNNEL_FLAG_ENCAP_COPY_DF) &&
136  ip4_header_get_df (ip4 + 1))
137  ip4_header_set_df (ip4);
138  break;
139 
140  default:
141  break;
142  }
143 
144  ip4->checksum = ip4_header_checksum (ip4);
145 }
146 
147 static void
149  const void *data)
150 {
151  ip6_header_t *ip6;
152  const ipip_tunnel_t *t = data;
153 
154  /* Must set locally originated otherwise we're not allowed to
155  fragment the packet later */
156  b->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
157 
158  ip6 = vlib_buffer_get_current (b);
159  ip6->payload_length =
160  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b) -
161  sizeof (*ip6));
162  switch (adj->ia_link)
163  {
164  case VNET_LINK_IP6:
165  ip6->protocol = IP_PROTOCOL_IPV6;
166  if (t->flags & IPIP_TUNNEL_FLAG_ENCAP_COPY_DSCP)
168  if (t->flags & IPIP_TUNNEL_FLAG_ENCAP_COPY_ECN)
170  break;
171 
172  case VNET_LINK_IP4:
173  ip6->protocol = IP_PROTOCOL_IP_IN_IP;
174  if (t->flags & IPIP_TUNNEL_FLAG_ENCAP_COPY_DSCP)
176  (ip6, ip4_header_get_dscp ((ip4_header_t *) (ip6 + 1)));
177  if (t->flags & IPIP_TUNNEL_FLAG_ENCAP_COPY_ECN)
179  (ip6, ip4_header_get_ecn ((ip4_header_t *) (ip6 + 1)));
180  break;
181 
182  default:
183  break;
184  }
185 }
186 
187 static void
189 {
190  ip_adjacency_t *adj;
191  ipip_tunnel_t *t;
193 
194  adj = adj_get (ai);
195  sw_if_index = adj->rewrite_header.sw_if_index;
196 
197  t = ipip_tunnel_db_find_by_sw_if_index (sw_if_index);
198  if (!t)
199  return;
200 
203  {
205  }
206  else
207  {
208  /* *INDENT-OFF* */
209  fib_prefix_t dst = {
210  .fp_len = t->transport == IPIP_TRANSPORT_IP6 ? 128 : 32,
211  .fp_proto = (t->transport == IPIP_TRANSPORT_IP6 ?
214  .fp_addr = t->tunnel_dst
215  };
216  /* *INDENT-ON* */
217 
218  adj_midchain_delegate_stack (ai, t->fib_index, &dst);
219  }
220 }
221 
222 static adj_walk_rc_t
224 {
225  ipip_tunnel_stack (ai);
226 
227  return (ADJ_WALK_RC_CONTINUE);
228 }
229 
230 static void
232 {
234 
235  /*
236  * walk all the adjacencies on th IPIP interface and restack them
237  */
239  {
241  }
242 }
243 
244 void
246 {
248  ipip_tunnel_t *t;
249  adj_flags_t af;
250 
251  t = ipip_tunnel_db_find_by_sw_if_index (sw_if_index);
252  if (!t)
253  return;
254 
259 
260  adj_nbr_midchain_update_rewrite (ai, f, t, af,
261  ipip_build_rewrite (vnm,
262  sw_if_index,
264  (ai), NULL));
265  ipip_tunnel_stack (ai);
266 }
267 
268 u8 *
269 format_ipip_tunnel_flags (u8 * s, va_list * args)
270 {
271  ipip_tunnel_flags_t f = va_arg (*args, int);
272 
273  if (f == IPIP_TUNNEL_FLAG_NONE)
274  return (format (s, "none"));
275 
276 #define _(a,b,c) if (f & IPIP_TUNNEL_FLAG_##a) s = format(s, "%s ", b);
278 #undef _
279  return (s);
280 }
281 
282 static u8 *
283 format_ipip_tunnel_name (u8 * s, va_list * args)
284 {
285  u32 dev_instance = va_arg (*args, u32);
287  ipip_tunnel_t *t;
288 
289  if (dev_instance >= vec_len (gm->tunnels))
290  return format (s, "<improperly-referenced>");
291 
292  t = pool_elt_at_index (gm->tunnels, dev_instance);
293  return format (s, "ipip%d", t->user_instance);
294 }
295 
296 static u8 *
297 format_ipip_device (u8 * s, va_list * args)
298 {
299  u32 dev_instance = va_arg (*args, u32);
300  CLIB_UNUSED (int verbose) = va_arg (*args, int);
301 
302  s = format (s, "IPIP tunnel: id %d\n", dev_instance);
303  return s;
304 }
305 
306 static clib_error_t *
308 {
310  ipip_tunnel_t *t;
311 
312  hi = vnet_get_hw_interface (vnm, hw_if_index);
313 
315  if (!t)
316  return 0;
317 
319  vnet_hw_interface_set_flags (vnm, hw_if_index,
321  else
322  vnet_hw_interface_set_flags (vnm, hw_if_index, 0 /* down */ );
323 
325 
326  return /* no error */ 0;
327 }
328 
329 static int
331  ip46_address_t * src, ip46_address_t * dst, u8 * is_l2)
332 {
333  ipip_tunnel_t *t;
334 
335  t = ipip_tunnel_db_find_by_sw_if_index (sw_if_index);
336  if (!t)
337  return -1;
338 
339  *src = t->tunnel_src;
340  *dst = t->tunnel_dst;
341  *is_l2 = 0;
342 
343  return (0);
344 }
345 
346 /* *INDENT-OFF* */
347 VNET_DEVICE_CLASS(ipip_device_class) = {
348  .name = "IPIP tunnel device",
349  .format_device_name = format_ipip_tunnel_name,
350  .format_device = format_ipip_device,
351  .format_tx_trace = format_ipip_tx_trace,
352  .admin_up_down_function = ipip_interface_admin_up_down,
353  .ip_tun_desc = ipip_tunnel_desc,
354 #ifdef SOON
355  .clear counter = 0;
356 #endif
357 };
358 
360  .name = "IPIP",
361  //.format_header = format_ipip_header_with_length,
362  //.unformat_header = unformat_ipip_header,
363  .build_rewrite = ipip_build_rewrite,
364  .update_adjacency = ipip_update_adj,
366 };
367 /* *INDENT-ON* */
368 
371 {
373  uword *p;
374 
375  p = hash_get_mem (gm->tunnel_by_key, key);
376  if (!p)
377  return (NULL);
378  return (pool_elt_at_index (gm->tunnels, p[0]));
379 }
380 
383 {
385  if (vec_len (gm->tunnel_index_by_sw_if_index) <= sw_if_index)
386  return NULL;
388  if (ti == ~0)
389  return NULL;
390  return pool_elt_at_index (gm->tunnels, ti);
391 }
392 
393 void
395 {
397 
398  t->key = clib_mem_alloc (sizeof (*t->key));
399  clib_memcpy (t->key, key, sizeof (*key));
401 }
402 
403 void
405 {
407 
408  hash_unset_mem (gm->tunnel_by_key, t->key);
409  clib_mem_free (t->key);
410  t->key = NULL;
411 }
412 
413 int
415  u32 instance, ip46_address_t * src, ip46_address_t * dst,
416  u32 fib_index, ipip_tunnel_flags_t flags,
417  ip_dscp_t dscp, u32 * sw_if_indexp)
418 {
420  vnet_main_t *vnm = gm->vnet_main;
421  ip4_main_t *im4 = &ip4_main;
422  ip6_main_t *im6 = &ip6_main;
423  ipip_tunnel_t *t;
425  u32 hw_if_index, sw_if_index;
426  ipip_tunnel_key_t key = {.transport = transport,
427  .fib_index = fib_index,
428  .src = *src,
429  .dst = *dst
430  };
431  t = ipip_tunnel_db_find (&key);
432  if (t)
433  {
434  if (sw_if_indexp)
435  sw_if_indexp[0] = t->sw_if_index;
436  return VNET_API_ERROR_IF_ALREADY_EXISTS;
437  }
438 
440  clib_memset (t, 0, sizeof (*t));
441 
442  /* Reconcile the real dev_instance and a possible requested instance */
443  u32 t_idx = t - gm->tunnels; /* tunnel index (or instance) */
444  u32 u_idx = instance; /* user specified instance */
445  if (u_idx == ~0)
446  u_idx = t_idx;
447  if (hash_get (gm->instance_used, u_idx))
448  {
449  pool_put (gm->tunnels, t);
450  return VNET_API_ERROR_INSTANCE_IN_USE;
451  }
452  hash_set (gm->instance_used, u_idx, 1);
453 
454  t->dev_instance = t_idx; /* actual */
455  t->user_instance = u_idx; /* name */
456 
457  hw_if_index = vnet_register_interface (vnm, ipip_device_class.index, t_idx,
459  t_idx);
460 
461  hi = vnet_get_hw_interface (vnm, hw_if_index);
462  sw_if_index = hi->sw_if_index;
463 
464  t->hw_if_index = hw_if_index;
465  t->fib_index = fib_index;
467  t->dscp = dscp;
468  t->flags = flags;
469  t->transport = transport;
470 
473 
474  if (t->transport == IPIP_TRANSPORT_IP4)
475  {
476  vec_validate (im4->fib_index_by_sw_if_index, sw_if_index);
477  hi->min_packet_bytes = 64 + sizeof (ip4_header_t);
478  }
479  else
480  {
481  vec_validate (im6->fib_index_by_sw_if_index, sw_if_index);
482  hi->min_packet_bytes = 64 + sizeof (ip6_header_t);
483  }
484 
485  /* Standard default ipip MTU. */
486  vnet_sw_interface_set_mtu (vnm, sw_if_index, 9000);
487 
488  t->tunnel_src = *src;
489  t->tunnel_dst = *dst;
490 
491  ipip_tunnel_db_add (t, &key);
492 
493  if (sw_if_indexp)
494  *sw_if_indexp = sw_if_index;
495 
497  {
498  ip6_register_protocol (IP_PROTOCOL_IP_IN_IP, ipip6_input_node.index);
499  ip6_register_protocol (IP_PROTOCOL_IPV6, ipip6_input_node.index);
500  gm->ip6_protocol_registered = true;
501  }
503  {
504  ip4_register_protocol (IP_PROTOCOL_IP_IN_IP, ipip4_input_node.index);
505  ip4_register_protocol (IP_PROTOCOL_IPV6, ipip4_input_node.index);
506  gm->ip4_protocol_registered = true;
507  }
508  return 0;
509 }
510 
511 int
513 {
515  vnet_main_t *vnm = gm->vnet_main;
516  ipip_tunnel_t *t;
517 
518 
519  t = ipip_tunnel_db_find_by_sw_if_index (sw_if_index);
520  if (t == NULL)
521  return VNET_API_ERROR_NO_SUCH_ENTRY;
522 
523  vnet_sw_interface_set_flags (vnm, sw_if_index, 0 /* down */ );
528  pool_put (gm->tunnels, t);
529 
530  return 0;
531 }
532 
533 static clib_error_t *
535 {
537 
538  clib_memset (gm, 0, sizeof (gm[0]));
539  gm->vlib_main = vm;
540  gm->vnet_main = vnet_get_main ();
541  gm->tunnel_by_key =
542  hash_create_mem (0, sizeof (ipip_tunnel_key_t), sizeof (uword));
543 
544  return 0;
545 }
546 
548 
549 /*
550  * fd.io coding-style-patch-verification: ON
551  *
552  * Local Variables:
553  * eval: (c-set-style "gnu")
554  * End:
555  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:440
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:124
void ipip_tunnel_db_remove(ipip_tunnel_t *t)
Definition: ipip.c:404
u8 proto
Definition: acl_types.api:47
#define hash_set(h, key, value)
Definition: hash.h:255
static int ipip_tunnel_desc(u32 sw_if_index, ip46_address_t *src, ip46_address_t *dst, u8 *is_l2)
Definition: ipip.c:330
#define CLIB_UNUSED(x)
Definition: clib.h:82
u8 * format_ipip_tunnel_flags(u8 *s, va_list *args)
Definition: ipip.c:269
#define hash_unset(h, key)
Definition: hash.h:261
void ip6_register_protocol(u32 protocol, u32 node_index)
Definition: ip6_forward.c:1590
ip4_address_t src_address
Definition: ip4_packet.h:170
A representation of a IPIP tunnel.
Definition: ipip.h:92
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
static ip_dscp_t ip4_header_get_dscp(const ip4_header_t *ip4)
Definition: ip4_packet.h:299
ip46_address_t tunnel_src
Definition: ipip.h:100
int ipip_add_tunnel(ipip_transport_t transport, u32 instance, ip46_address_t *src, ip46_address_t *dst, u32 fib_index, ipip_tunnel_flags_t flags, ip_dscp_t dscp, u32 *sw_if_indexp)
Definition: ipip.c:414
static clib_error_t * ipip_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: ipip.c:307
u64 as_u64[2]
Definition: ip6_packet.h:51
u32 length
Definition: ipip.c:35
vnet_hw_interface_class_t ipip_hw_interface_class
void adj_midchain_delegate_stack(adj_index_t ai, u32 fib_index, const fib_prefix_t *pfx)
create/attach a midchain delegate and stack it on the prefix passed
vnet_link_t adj_get_link_type(adj_index_t ai)
Return the link type of the adjacency.
Definition: adj.c:475
#define NULL
Definition: clib.h:58
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
IP unicast adjacency.
Definition: adj.h:221
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
ipip_tunnel_flags_t flags
Definition: ipip.h:107
vl_api_address_t src
Definition: gre.api:60
static u8 * format_ipip_device(u8 *s, va_list *args)
Definition: ipip.c:297
#define hash_set_mem(h, key, value)
Definition: hash.h:275
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
Definition: ip4.h:121
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
void(* adj_midchain_fixup_t)(vlib_main_t *vm, const 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
static void ip4_header_set_dscp(ip4_header_t *ip4, ip_dscp_t dscp)
Definition: ip4_packet.h:268
void ip4_register_protocol(u32 protocol, u32 node_index)
Definition: ip4_forward.c:1866
static_always_inline ip_ecn_t ip6_ecn_network_order(const ip6_header_t *ip6)
Definition: ip6_packet.h:331
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:366
u32 hw_if_index
Definition: ipip.h:103
ip6_address_t src_address
Definition: ip6_packet.h:307
bool ip4_protocol_registered
Definition: ipip.h:135
unsigned char u8
Definition: types.h:56
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
static u8 ip4_header_get_df(ip4_header_t *ip4)
Definition: ip4_packet.h:325
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 ip_adjacency_t * adj_get(adj_index_t adj_index)
Get a pointer to an adjacency object from its index.
Definition: adj.h:431
vl_api_interface_index_t sw_if_index
Definition: gre.api:59
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:173
u32 user_instance
Definition: ipip.h:106
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 void ipip_tunnel_restack(ipip_tunnel_t *gt)
Definition: ipip.c:231
Aggregate type for a prefix.
Definition: fib_types.h:203
u32 tunnel_id
Definition: ipip.c:34
u32 * tunnel_index_by_sw_if_index
Definition: ipip.h:126
unsigned int u32
Definition: types.h:88
static void ipip6_fixup(vlib_main_t *vm, const ip_adjacency_t *adj, vlib_buffer_t *b, const void *data)
Definition: ipip.c:148
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:762
ip46_address_t dst
Definition: ipip.c:37
vl_api_ip_dscp_t dscp
Definition: dhcp.api:163
#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:519
#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:394
static void ipip_tunnel_stack(adj_index_t ai)
Definition: ipip.c:188
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:55
static void ip4_header_set_ecn(ip4_header_t *ip4, ip_ecn_t ecn)
Definition: ip4_packet.h:280
static uword vnet_hw_interface_get_flags(vnet_main_t *vnm, u32 hw_if_index)
static void ipip4_fixup(vlib_main_t *vm, const ip_adjacency_t *adj, vlib_buffer_t *b, const void *data)
Definition: ipip.c:107
ipip_tunnel_t * ipip_tunnel_db_find(ipip_tunnel_key_t *key)
Definition: ipip.c:370
#define gm
Definition: dlmalloc.c:1219
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:382
static void ip4_header_set_df(ip4_header_t *ip4)
Definition: ip4_packet.h:311
ipip_tunnel_t * tunnels
Definition: ipip.h:124
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:229
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:287
ip6_main_t ip6_main
Definition: ip6_forward.c:2703
vl_api_address_t dst
Definition: gre.api:61
u8 * format_ipip_tx_trace(u8 *s, va_list *args)
Definition: ipip.c:41
vlib_main_t * vm
Definition: in2out_ed.c:1810
static_always_inline void ip6_set_dscp_network_order(ip6_header_t *ip6, ip_dscp_t dscp)
Definition: ip6_packet.h:348
ipip_tunnel_key_t * key
Definition: ipip.h:99
format_function_t format_ip46_address
Definition: ip46_address.h:50
static adj_walk_rc_t ipip_adj_walk_cb(adj_index_t ai, void *ctx)
Definition: ipip.c:223
ip_dscp_t dscp
Definition: ipip.h:108
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
Definition: pool.h:231
VNET_HW_INTERFACE_CLASS(ipip_hw_interface_class)
u8 ip6[16]
Definition: one.api:477
ipip_transport_t
IPIP Tunnel key.
Definition: ipip.h:47
ipip_main_t ipip_main
Definition: ipip.c:29
u32 flags
Definition: vhost_user.h:141
static_always_inline ip_dscp_t ip6_dscp_network_order(const ip6_header_t *ip6)
Definition: ip6_packet.h:324
static u8 * format_ipip_tunnel_name(u8 *s, va_list *args)
Definition: ipip.c:283
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:532
static_always_inline void ip6_set_ecn_network_order(ip6_header_t *ip6, ip_ecn_t ecn)
Definition: ip6_packet.h:358
vlib_node_registration_t ipip4_input_node
(constructor) VLIB_REGISTER_NODE (ipip4_input_node)
Definition: node.c:262
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:588
vlib_main_t vlib_node_runtime_t * node
Definition: in2out_ed.c:1810
void adj_midchain_delegate_unstack(adj_index_t ai)
unstack a midchain delegate (this stacks it on a drop)
u32 fib_index
Definition: ipip.h:102
ipip_transport_t transport
Definition: ipip.h:98
u8 data[128]
Definition: ipsec_types.api:87
enum ip_dscp_t_ ip_dscp_t
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:105
static void clib_mem_free(void *p)
Definition: mem.h:226
uword * tunnel_by_key
Definition: ipip.h:125
ip46_address_t src
Definition: ipip.c:36
static void * clib_mem_alloc(uword size)
Definition: mem.h:153
enum ipip_tunnel_flags_t_ ipip_tunnel_flags_t
void ipip_update_adj(vnet_main_t *vnm, u32 sw_if_index, adj_index_t ai)
Definition: ipip.c:245
u32 sw_if_index
Definition: ipip.h:104
vl_api_ip4_address_t hi
Definition: arp.api:37
void vnet_delete_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
Definition: interface.c:974
enum adj_flags_t_ adj_flags_t
Flags on an IP adjacency.
typedef key
Definition: ipsec_types.api:83
vlib_node_registration_t ipip6_input_node
(constructor) VLIB_REGISTER_NODE (ipip6_input_node)
Definition: node.c:278
u32 ip_version_traffic_class_and_flow_label
Definition: ip6_packet.h:294
u16 payload_length
Definition: ip6_packet.h:298
vnet_main_t * vnet_main
Definition: ipip.h:130
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u32 instance
Definition: gre.api:57
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:492
VLIB buffer representation.
Definition: buffer.h:102
bool ip6_protocol_registered
Definition: ipip.h:136
u64 uword
Definition: types.h:112
static clib_error_t * ipip_init(vlib_main_t *vm)
Definition: ipip.c:534
a point 2 point interface
Definition: interface.h:375
void vnet_sw_interface_set_mtu(vnet_main_t *vnm, u32 sw_if_index, u32 mtu)
Definition: interface.c:664
static ip_ecn_t ip4_header_get_ecn(const ip4_header_t *ip4)
Definition: ip4_packet.h:305
int ipip_del_tunnel(u32 sw_if_index)
Definition: ipip.c:512
#define FOR_EACH_FIB_IP_PROTOCOL(_item)
Definition: fib_types.h:70
#define hash_get_mem(h, key)
Definition: hash.h:269
u32 dev_instance
Definition: ipip.h:105
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1079
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:501
u8 ip_version_and_header_length
Definition: ip4_packet.h:138
ip46_address_t tunnel_dst
Definition: ipip.h:101
u32 ip4
Definition: one.api:440
#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:487
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
vlib_main_t * vlib_main
Definition: ipip.h:129
u32 * fib_index_by_sw_if_index
Definition: ip6.h:195
static u16 ip4_header_checksum(ip4_header_t *i)
Definition: ip4_packet.h:247
uword * instance_used
Definition: ipip.h:133
VNET_DEVICE_CLASS(ipip_device_class)
ip6_address_t dst_address
Definition: ip6_packet.h:307