FD.io VPP  v16.12-rc0-308-g931be3a
Vector Packet Processing
vxlan_gpe.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 /**
16  * @file
17  * @brief Common utility functions for IPv4 and IPv6 VXLAN GPE tunnels
18  *
19 */
21 #include <vnet/fib/fib.h>
22 #include <vnet/ip/format.h>
23 
25 
26 /**
27  * @brief Tracing function for VXLAN GPE tunnel packets
28  *
29  * @param *s formatting string
30  * @param *args
31  *
32  * @return *s formatted string
33  *
34  */
35 u8 * format_vxlan_gpe_tunnel (u8 * s, va_list * args)
36 {
37  vxlan_gpe_tunnel_t * t = va_arg (*args, vxlan_gpe_tunnel_t *);
39 
40  s = format (s, "[%d] local: %U remote: %U ",
41  t - gm->tunnels,
44 
45  s = format (s, " vxlan VNI %d ", t->vni);
46 
47  switch (t->protocol)
48  {
49  case VXLAN_GPE_PROTOCOL_IP4:
50  s = format (s, "next-protocol ip4");
51  break;
52  case VXLAN_GPE_PROTOCOL_IP6:
53  s = format (s, "next-protocol ip6");
54  break;
55  case VXLAN_GPE_PROTOCOL_ETHERNET:
56  s = format (s, "next-protocol ethernet");
57  break;
58  case VXLAN_GPE_PROTOCOL_NSH:
59  s = format (s, "next-protocol nsh");
60  break;
61  default:
62  s = format (s, "next-protocol unknown %d", t->protocol);
63  }
64 
65  s = format (s, " fibs: (encap %d, decap %d)",
66  t->encap_fib_index,
67  t->decap_fib_index);
68 
69  return s;
70 }
71 
72 /**
73  * @brief Naming for VXLAN GPE tunnel
74  *
75  * @param *s formatting string
76  * @param *args
77  *
78  * @return *s formatted string
79  *
80  */
81 static u8 * format_vxlan_gpe_name (u8 * s, va_list * args)
82 {
83  u32 dev_instance = va_arg (*args, u32);
84  return format (s, "vxlan_gpe_tunnel%d", dev_instance);
85 }
86 
88  vlib_node_runtime_t * node,
89  vlib_frame_t * frame)
90 {
91  clib_warning ("you shouldn't be here, leaking buffers...");
92  return frame->n_vectors;
93 }
94 
95 /**
96  * @brief CLI function for VXLAN GPE admin up/down
97  *
98  * @param *vnm
99  * @param hw_if_index
100  * @param flag
101  *
102  * @return *rc
103  *
104  */
105 static clib_error_t *
107 {
110  else
111  vnet_hw_interface_set_flags (vnm, hw_if_index, 0);
112 
113  return 0;
114 }
115 
116 VNET_DEVICE_CLASS (vxlan_gpe_device_class,static) = {
117  .name = "VXLAN_GPE",
118  .format_device_name = format_vxlan_gpe_name,
119  .format_tx_trace = format_vxlan_gpe_encap_trace,
120  .tx_function = dummy_interface_tx,
121  .admin_up_down_function = vxlan_gpe_interface_admin_up_down,
122 };
123 
124 /**
125  * @brief Formatting function for tracing VXLAN GPE with length
126  *
127  * @param *s
128  * @param *args
129  *
130  * @return *s
131  *
132  */
133 static u8 * format_vxlan_gpe_header_with_length (u8 * s, va_list * args)
134 {
135  u32 dev_instance = va_arg (*args, u32);
136  s = format (s, "unimplemented dev %u", dev_instance);
137  return s;
138 }
139 
140 VNET_HW_INTERFACE_CLASS (vxlan_gpe_hw_class) = {
141  .name = "VXLAN_GPE",
142  .format_header = format_vxlan_gpe_header_with_length,
143  .build_rewrite = default_build_rewrite,
145 };
146 
147 
148 #define foreach_gpe_copy_field \
149 _(vni) \
150 _(protocol) \
151 _(encap_fib_index) \
152 _(decap_fib_index)
153 
154 #define foreach_copy_ipv4 { \
155  _(local.ip4.as_u32) \
156  _(remote.ip4.as_u32) \
157 }
158 
159 #define foreach_copy_ipv6 { \
160  _(local.ip6.as_u64[0]) \
161  _(local.ip6.as_u64[1]) \
162  _(remote.ip6.as_u64[0]) \
163  _(remote.ip6.as_u64[1]) \
164 }
165 
166 
167 /**
168  * @brief Calculate IPv4 VXLAN GPE rewrite header
169  *
170  * @param *t
171  *
172  * @return rc
173  *
174  */
176 {
177  u8 *rw = 0;
178  ip4_header_t * ip0;
179  ip4_vxlan_gpe_header_t * h0;
180  int len;
181 
182  len = sizeof (*h0);
183 
185 
186  h0 = (ip4_vxlan_gpe_header_t *) rw;
187 
188  /* Fixed portion of the (outer) ip4 header */
189  ip0 = &h0->ip4;
190  ip0->ip_version_and_header_length = 0x45;
191  ip0->ttl = 254;
192  ip0->protocol = IP_PROTOCOL_UDP;
193 
194  /* we fix up the ip4 header length and checksum after-the-fact */
195  ip0->src_address.as_u32 = t->local.ip4.as_u32;
196  ip0->dst_address.as_u32 = t->remote.ip4.as_u32;
197  ip0->checksum = ip4_header_checksum (ip0);
198 
199  /* UDP header, randomize src port on something, maybe? */
200  h0->udp.src_port = clib_host_to_net_u16 (4790);
201  h0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_vxlan_gpe);
202 
203  /* VXLAN header. Are we having fun yet? */
204  h0->vxlan.flags = VXLAN_GPE_FLAGS_I | VXLAN_GPE_FLAGS_P;
205  h0->vxlan.ver_res = VXLAN_GPE_VERSION;
206  h0->vxlan.protocol = t->protocol;
207  h0->vxlan.vni_res = clib_host_to_net_u32 (t->vni<<8);
208 
209  t->rewrite = rw;
210  return (0);
211 }
212 
213 /**
214  * @brief Calculate IPv6 VXLAN GPE rewrite header
215  *
216  * @param *t
217  *
218  * @return rc
219  *
220  */
222 {
223  u8 *rw = 0;
224  ip6_header_t * ip0;
225  ip6_vxlan_gpe_header_t * h0;
226  int len;
227 
228  len = sizeof (*h0);
229 
231 
232  h0 = (ip6_vxlan_gpe_header_t *) rw;
233 
234  /* Fixed portion of the (outer) ip4 header */
235  ip0 = &h0->ip6;
236  ip0->ip_version_traffic_class_and_flow_label = clib_host_to_net_u32(6 << 28);
237  ip0->hop_limit = 255;
238  ip0->protocol = IP_PROTOCOL_UDP;
239 
240  ip0->src_address.as_u64[0] = t->local.ip6.as_u64[0];
241  ip0->src_address.as_u64[1] = t->local.ip6.as_u64[1];
242  ip0->dst_address.as_u64[0] = t->remote.ip6.as_u64[0];
243  ip0->dst_address.as_u64[1] = t->remote.ip6.as_u64[1];
244 
245  /* UDP header, randomize src port on something, maybe? */
246  h0->udp.src_port = clib_host_to_net_u16 (4790);
247  h0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_vxlan_gpe);
248 
249  /* VXLAN header. Are we having fun yet? */
250  h0->vxlan.flags = VXLAN_GPE_FLAGS_I | VXLAN_GPE_FLAGS_P;
251  h0->vxlan.ver_res = VXLAN_GPE_VERSION;
252  h0->vxlan.protocol = t->protocol;
253  h0->vxlan.vni_res = clib_host_to_net_u32 (t->vni<<8);
254 
255  t->rewrite = rw;
256  return (0);
257 }
258 
259 /**
260  * @brief Add or Del a VXLAN GPE tunnel
261  *
262  * @param *a
263  * @param *sw_if_index
264  *
265  * @return rc
266  *
267  */
270 {
272  vxlan_gpe_tunnel_t *t = 0;
273  vnet_main_t * vnm = gm->vnet_main;
275  uword * p;
276  u32 hw_if_index = ~0;
277  u32 sw_if_index = ~0;
278  int rv;
279  vxlan4_gpe_tunnel_key_t key4, *key4_copy;
280  vxlan6_gpe_tunnel_key_t key6, *key6_copy;
281  hash_pair_t *hp;
282 
283  if (!a->is_ip6)
284  {
285  key4.local = a->local.ip4.as_u32;
286  key4.remote = a->remote.ip4.as_u32;
287  key4.vni = clib_host_to_net_u32 (a->vni << 8);
288  key4.pad = 0;
289 
290  p = hash_get_mem(gm->vxlan4_gpe_tunnel_by_key, &key4);
291  }
292  else
293  {
294  key6.local.as_u64[0] = a->local.ip6.as_u64[0];
295  key6.local.as_u64[1] = a->local.ip6.as_u64[1];
296  key6.remote.as_u64[0] = a->remote.ip6.as_u64[0];
297  key6.remote.as_u64[1] = a->remote.ip6.as_u64[1];
298  key6.vni = clib_host_to_net_u32 (a->vni << 8);
299 
300  p = hash_get_mem(gm->vxlan6_gpe_tunnel_by_key, &key6);
301  }
302 
303  if (a->is_add)
304  {
305  /* adding a tunnel: tunnel must not already exist */
306  if (p)
307  return VNET_API_ERROR_INVALID_VALUE;
308 
310  memset (t, 0, sizeof (*t));
311 
312  /* copy from arg structure */
313 #define _(x) t->x = a->x;
315  if (!a->is_ip6) foreach_copy_ipv4
316  else foreach_copy_ipv6
317 #undef _
318 
319  if (!a->is_ip6) t->flags |= VXLAN_GPE_TUNNEL_IS_IPV4;
320 
321  if (!a->is_ip6) {
322  rv = vxlan4_gpe_rewrite (t);
323  } else {
324  rv = vxlan6_gpe_rewrite (t);
325  }
326 
327  if (rv)
328  {
329  pool_put (gm->tunnels, t);
330  return rv;
331  }
332 
333  if (!a->is_ip6)
334  {
335  key4_copy = clib_mem_alloc (sizeof (*key4_copy));
336  clib_memcpy (key4_copy, &key4, sizeof (*key4_copy));
337  hash_set_mem (gm->vxlan4_gpe_tunnel_by_key, key4_copy,
338  t - gm->tunnels);
339  }
340  else
341  {
342  key6_copy = clib_mem_alloc (sizeof (*key6_copy));
343  clib_memcpy (key6_copy, &key6, sizeof (*key6_copy));
344  hash_set_mem (gm->vxlan6_gpe_tunnel_by_key, key6_copy,
345  t - gm->tunnels);
346  }
347 
349  {
350  hw_if_index = gm->free_vxlan_gpe_tunnel_hw_if_indices
352  _vec_len (gm->free_vxlan_gpe_tunnel_hw_if_indices) -= 1;
353 
354  hi = vnet_get_hw_interface (vnm, hw_if_index);
355  hi->dev_instance = t - gm->tunnels;
356  hi->hw_instance = hi->dev_instance;
357  }
358  else
359  {
360  hw_if_index = vnet_register_interface
361  (vnm, vxlan_gpe_device_class.index, t - gm->tunnels,
362  vxlan_gpe_hw_class.index, t - gm->tunnels);
363  hi = vnet_get_hw_interface (vnm, hw_if_index);
365  }
366 
367  t->hw_if_index = hw_if_index;
368  t->sw_if_index = sw_if_index = hi->sw_if_index;
370  gm->tunnel_index_by_sw_if_index[sw_if_index] = t - gm->tunnels;
371 
374  }
375  else
376  {
377  /* deleting a tunnel: tunnel must exist */
378  if (!p)
379  return VNET_API_ERROR_NO_SUCH_ENTRY;
380 
381  t = pool_elt_at_index (gm->tunnels, p[0]);
382 
383  vnet_sw_interface_set_flags (vnm, t->sw_if_index, 0 /* down */);
385 
387 
388  if (!a->is_ip6)
389  {
390  hp = hash_get_pair (gm->vxlan4_gpe_tunnel_by_key, &key4);
391  key4_copy = (void *)(hp->key);
393  clib_mem_free (key4_copy);
394  }
395  else
396  {
397  hp = hash_get_pair (gm->vxlan6_gpe_tunnel_by_key, &key6);
398  key6_copy = (void *)(hp->key);
400  clib_mem_free (key6_copy);
401  }
402 
403  vec_free (t->rewrite);
404  pool_put (gm->tunnels, t);
405  }
406 
407  if (sw_if_indexp)
408  *sw_if_indexp = sw_if_index;
409 
410  return 0;
411 }
412 
413 static clib_error_t *
415  unformat_input_t * input,
416  vlib_cli_command_t * cmd)
417 {
418  unformat_input_t _line_input, * line_input = &_line_input;
419  u8 is_add = 1;
420  ip46_address_t local, remote;
421  u8 local_set = 0;
422  u8 remote_set = 0;
423  u8 ipv4_set = 0;
424  u8 ipv6_set = 0;
425  u32 encap_fib_index = 0;
426  u32 decap_fib_index = 0;
427  u8 protocol = VXLAN_GPE_PROTOCOL_IP4;
428  u32 vni;
429  u8 vni_set = 0;
430  int rv;
431  u32 tmp;
433  u32 sw_if_index;
434 
435  /* Get a line of input. */
436  if (! unformat_user (input, unformat_line_input, line_input))
437  return 0;
438 
439  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) {
440  if (unformat (line_input, "del"))
441  is_add = 0;
442  else if (unformat (line_input, "local %U",
443  unformat_ip4_address, &local.ip4))
444  {
445  local_set = 1;
446  ipv4_set = 1;
447  }
448  else if (unformat (line_input, "remote %U",
449  unformat_ip4_address, &remote.ip4))
450  {
451  remote_set = 1;
452  ipv4_set = 1;
453  }
454  else if (unformat (line_input, "local %U",
455  unformat_ip6_address, &local.ip6))
456  {
457  local_set = 1;
458  ipv6_set = 1;
459  }
460  else if (unformat (line_input, "remote %U",
461  unformat_ip6_address, &remote.ip6))
462  {
463  remote_set = 1;
464  ipv6_set = 1;
465  }
466  else if (unformat (line_input, "encap-vrf-id %d", &tmp))
467  {
468  if (ipv6_set)
469  encap_fib_index = ip6_fib_index_from_table_id (tmp);
470  else
471  encap_fib_index = ip4_fib_index_from_table_id (tmp);
472 
473  if (encap_fib_index == ~0)
474  return clib_error_return (0, "nonexistent encap fib id %d", tmp);
475  }
476  else if (unformat (line_input, "decap-vrf-id %d", &tmp))
477  {
478  if (ipv6_set)
479  decap_fib_index = ip6_fib_index_from_table_id (tmp);
480  else
481  decap_fib_index = ip4_fib_index_from_table_id (tmp);
482 
483  if (decap_fib_index == ~0)
484  return clib_error_return (0, "nonexistent decap fib id %d", tmp);
485  }
486  else if (unformat (line_input, "vni %d", &vni))
487  vni_set = 1;
488  else if (unformat(line_input, "next-ip4"))
489  protocol = VXLAN_GPE_PROTOCOL_IP4;
490  else if (unformat(line_input, "next-ip6"))
491  protocol = VXLAN_GPE_PROTOCOL_IP6;
492  else if (unformat(line_input, "next-ethernet"))
493  protocol = VXLAN_GPE_PROTOCOL_ETHERNET;
494  else if (unformat(line_input, "next-nsh"))
495  protocol = VXLAN_GPE_PROTOCOL_NSH;
496  else
497  return clib_error_return (0, "parse error: '%U'",
498  format_unformat_error, line_input);
499  }
500 
501  unformat_free (line_input);
502 
503  if (local_set == 0)
504  return clib_error_return (0, "tunnel local address not specified");
505 
506  if (remote_set == 0)
507  return clib_error_return (0, "tunnel remote address not specified");
508 
509  if (ipv4_set && ipv6_set)
510  return clib_error_return (0, "both IPv4 and IPv6 addresses specified");
511 
512  if ((ipv4_set && memcmp(&local.ip4, &remote.ip4, sizeof(local.ip4)) == 0) ||
513  (ipv6_set && memcmp(&local.ip6, &remote.ip6, sizeof(local.ip6)) == 0))
514  return clib_error_return (0, "src and dst addresses are identical");
515 
516  if (vni_set == 0)
517  return clib_error_return (0, "vni not specified");
518 
519  memset (a, 0, sizeof (*a));
520 
521  a->is_add = is_add;
522  a->is_ip6 = ipv6_set;
523 
524 #define _(x) a->x = x;
526  if (ipv4_set) foreach_copy_ipv4
527  else foreach_copy_ipv6
528 #undef _
529 
530  rv = vnet_vxlan_gpe_add_del_tunnel (a, &sw_if_index);
531 
532  switch(rv)
533  {
534  case 0:
535  vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), sw_if_index);
536  break;
537  case VNET_API_ERROR_INVALID_DECAP_NEXT:
538  return clib_error_return (0, "invalid decap-next...");
539 
540  case VNET_API_ERROR_TUNNEL_EXIST:
541  return clib_error_return (0, "tunnel already exists...");
542 
543  case VNET_API_ERROR_NO_SUCH_ENTRY:
544  return clib_error_return (0, "tunnel does not exist...");
545 
546  default:
547  return clib_error_return
548  (0, "vnet_vxlan_gpe_add_del_tunnel returned %d", rv);
549  }
550 
551  return 0;
552 }
553 
554 VLIB_CLI_COMMAND (create_vxlan_gpe_tunnel_command, static) = {
555  .path = "create vxlan-gpe tunnel",
556  .short_help =
557  "create vxlan-gpe tunnel local <local-addr> remote <remote-addr>"
558  " vni <nn> [next-ip4][next-ip6][next-ethernet][next-nsh]"
559  " [encap-vrf-id <nn>] [decap-vrf-id <nn>]"
560  " [del]\n",
562 };
563 
564 /**
565  * @brief CLI function for showing VXLAN GPE tunnels
566  *
567  * @param *vm
568  * @param *input
569  * @param *cmd
570  *
571  * @return error
572  *
573  */
574 static clib_error_t *
576  unformat_input_t * input,
577  vlib_cli_command_t * cmd)
578 {
580  vxlan_gpe_tunnel_t * t;
581 
582  if (pool_elts (gm->tunnels) == 0)
583  vlib_cli_output (vm, "No vxlan-gpe tunnels configured.");
584 
585  pool_foreach (t, gm->tunnels,
586  ({
587  vlib_cli_output (vm, "%U", format_vxlan_gpe_tunnel, t);
588  }));
589 
590  return 0;
591 }
592 
593 VLIB_CLI_COMMAND (show_vxlan_gpe_tunnel_command, static) = {
594  .path = "show vxlan-gpe",
596 };
597 
598 /**
599  * @brief Feature init function for VXLAN GPE
600  *
601  * @param *vm
602  *
603  * @return error
604  *
605  */
607 {
609 
610  gm->vnet_main = vnet_get_main();
611  gm->vlib_main = vm;
612 
614  = hash_create_mem (0, sizeof(vxlan4_gpe_tunnel_key_t), sizeof (uword));
615 
617  = hash_create_mem (0, sizeof(vxlan6_gpe_tunnel_key_t), sizeof (uword));
618 
619 
620  udp_register_dst_port (vm, UDP_DST_PORT_vxlan_gpe,
621  vxlan4_gpe_input_node.index, 1 /* is_ip4 */);
622  udp_register_dst_port (vm, UDP_DST_PORT_vxlan6_gpe,
623  vxlan6_gpe_input_node.index, 0 /* is_ip4 */);
624  return 0;
625 }
626 
628 
format_function_t format_ip46_address
Definition: format.h:61
uword * vxlan6_gpe_tunnel_by_key
lookup IPv6 VXLAN GPE tunnel by key
Definition: vxlan_gpe.h:153
vmrglw vmrglh hi
u32 flags
flags
Definition: vxlan_gpe.h:116
uword unformat(unformat_input_t *i, char *fmt,...)
Definition: unformat.c:966
clib_error_t * vxlan_gpe_init(vlib_main_t *vm)
Feature init function for VXLAN GPE.
Definition: vxlan_gpe.c:606
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: interface.c:522
ip4_address_t src_address
Definition: ip4_packet.h:138
vlib_node_registration_t vxlan4_gpe_input_node
(constructor) VLIB_REGISTER_NODE (vxlan4_gpe_input_node)
Definition: decap.c:639
static uword dummy_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: vxlan_gpe.c:87
u64 as_u64[2]
Definition: ip6_packet.h:50
#define foreach_copy_ipv4
Definition: vxlan_gpe.c:154
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
u32 * tunnel_index_by_sw_if_index
Mapping from sw_if_index to tunnel index.
Definition: vxlan_gpe.h:159
VXLAN GPE definitions.
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:482
vlib_node_registration_t vxlan6_gpe_input_node
(constructor) VLIB_REGISTER_NODE (vxlan6_gpe_input_node)
Definition: decap.c:662
#define hash_set_mem(h, key, value)
Definition: hash.h:274
#define VNET_HW_INTERFACE_FLAG_LINK_UP
Definition: interface.h:348
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:407
int vnet_vxlan_gpe_add_del_tunnel(vnet_vxlan_gpe_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
Add or Del a VXLAN GPE tunnel.
Definition: vxlan_gpe.c:269
#define VXLAN_GPE_FLAGS_P
ip6_address_t src_address
Definition: ip6_packet.h:300
format_function_t format_vnet_sw_if_index_name
vnet_main_t * vnet_main
State convenience vnet_main_t.
Definition: vxlan_gpe.h:164
#define VXLAN_GPE_VERSION
#define VXLAN_GPE_FLAGS_I
#define foreach_gpe_copy_field
Definition: vxlan_gpe.c:148
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
u8 * format_vxlan_gpe_tunnel(u8 *s, va_list *args)
Tracing function for VXLAN GPE tunnel packets.
Definition: vxlan_gpe.c:35
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:348
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:111
ip46_address_t local
tunnel local address
Definition: vxlan_gpe.h:98
static u8 * format_vxlan_gpe_header_with_length(u8 *s, va_list *args)
Formatting function for tracing VXLAN GPE with length.
Definition: vxlan_gpe.c:133
ip4_address_t dst_address
Definition: ip4_packet.h:138
u8 * format_vxlan_gpe_encap_trace(u8 *s, va_list *args)
Trace of packets encapsulated in VXLAN GPE.
Definition: encap.c:76
static int vxlan4_gpe_rewrite(vxlan_gpe_tunnel_t *t)
Calculate IPv4 VXLAN GPE rewrite header.
Definition: vxlan_gpe.c:175
static void unformat_free(unformat_input_t *i)
Definition: format.h:161
#define clib_warning(format, args...)
Definition: error.h:59
#define hash_get_pair(h, key)
Definition: hash.h:251
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:977
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
u8 * rewrite
Rewrite string.
Definition: vxlan_gpe.h:92
unformat_function_t unformat_ip4_address
Definition: format.h:75
#define hash_create_mem(elts, key_bytes, value_bytes)
Definition: hash.h:637
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:369
#define hash_unset_mem(h, key)
Definition: hash.h:280
Struct for VXLAN GPE tunnel.
Definition: vxlan_gpe.h:90
static u32 ip6_fib_index_from_table_id(u32 table_id)
Definition: ip6_fib.h:115
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:214
vxlan_gpe_main_t vxlan_gpe_main
Definition: vxlan_gpe.c:24
vlib_main_t * vlib_main
State convenience vlib_main_t.
Definition: vxlan_gpe.h:162
u8 protocol
encapsulated protocol
Definition: vxlan_gpe.h:95
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:575
ip46_address_t remote
tunnel remote address
Definition: vxlan_gpe.h:100
u32 vni
VXLAN GPE VNI in HOST byte order, shifted left 8 bits.
Definition: vxlan_gpe.h:108
unformat_function_t unformat_ip6_address
Definition: format.h:93
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P (general version).
Definition: pool.h:169
Struct for VXLAN GPE add/del args.
Definition: vxlan_gpe.h:176
u16 n_vectors
Definition: node.h:344
VNET_DEVICE_CLASS(vxlan_gpe_device_class, static)
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:300
#define clib_memcpy(a, b, c)
Definition: string.h:64
static u32 ip4_fib_index_from_table_id(u32 table_id)
Definition: ip4_fib.h:101
static u8 * format_vxlan_gpe_name(u8 *s, va_list *args)
Naming for VXLAN GPE tunnel.
Definition: vxlan_gpe.c:81
u8 * default_build_rewrite(vnet_main_t *vnm, u32 sw_if_index, vnet_link_t link_type, const void *dst_address)
Return a complete, zero-length (aka dummy) rewrite.
Definition: interface.c:1350
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:154
static clib_error_t * vxlan_gpe_add_del_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: vxlan_gpe.c:414
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
Definition: interface.h:490
unsigned int u32
Definition: types.h:88
VNET_HW_INTERFACE_CLASS(vxlan_gpe_hw_class)
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
static clib_error_t * vxlan_gpe_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
CLI function for VXLAN GPE admin up/down.
Definition: vxlan_gpe.c:106
Struct for VXLAN GPE node state.
Definition: vxlan_gpe.h:146
static void clib_mem_free(void *p)
Definition: mem.h:176
static void * clib_mem_alloc(uword size)
Definition: mem.h:109
vxlan_gpe_tunnel_t * tunnels
vector of encap tunnel instances
Definition: vxlan_gpe.h:148
u64 uword
Definition: types.h:112
u32 ip_version_traffic_class_and_flow_label
Definition: ip6_packet.h:287
uword * vxlan4_gpe_tunnel_by_key
lookup IPv4 VXLAN GPE tunnel by key
Definition: vxlan_gpe.h:151
u32 decap_fib_index
FIB indices - inner IP packet lookup here.
Definition: vxlan_gpe.h:105
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
static clib_error_t * show_vxlan_gpe_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI function for showing VXLAN GPE tunnels.
Definition: vxlan_gpe.c:575
a point 2 point interface
Definition: interface.h:246
u32 hw_if_index
vnet intfc hw_if_index
Definition: vxlan_gpe.h:111
#define hash_get_mem(h, key)
Definition: hash.h:268
u32 encap_fib_index
FIB indices - tunnel partner lookup here.
Definition: vxlan_gpe.h:103
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:169
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:418
static int vxlan6_gpe_rewrite(vxlan_gpe_tunnel_t *t)
Calculate IPv6 VXLAN GPE rewrite header.
Definition: vxlan_gpe.c:221
u32 sw_if_index
vnet intfc sw_if_index
Definition: vxlan_gpe.h:113
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
Definition: interface.c:530
void udp_register_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u32 node_index, u8 is_ip4)
Definition: udp_local.c:458
#define clib_error_return(e, args...)
Definition: error.h:111
u8 ip_version_and_header_length
Definition: ip4_packet.h:108
struct _unformat_input_t unformat_input_t
vlib_node_registration_t vxlan_gpe_encap_node
(constructor) VLIB_REGISTER_NODE (vxlan_gpe_encap_node)
Definition: encap.c:396
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
#define VXLAN_GPE_TUNNEL_IS_IPV4
Flags for vxlan_gpe_tunnel_t.
Definition: vxlan_gpe.h:120
unformat_function_t unformat_line_input
Definition: format.h:281
#define foreach_copy_ipv6
Definition: vxlan_gpe.c:159
static u16 ip4_header_checksum(ip4_header_t *i)
Definition: ip4_packet.h:194
uword key
Definition: hash.h:161
ip6_address_t dst_address
Definition: ip6_packet.h:300
u32 * free_vxlan_gpe_tunnel_hw_if_indices
Free vlib hw_if_indices.
Definition: vxlan_gpe.h:156
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:109