FD.io VPP  v16.09
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/ip/format.h>
22 
24 
25 /**
26  * @brief Tracing function for VXLAN GPE tunnel packets
27  *
28  * @param *s
29  * @param *args
30  *
31  * @return *s
32  *
33  */
34 u8 * format_vxlan_gpe_tunnel (u8 * s, va_list * args)
35 {
36  vxlan_gpe_tunnel_t * t = va_arg (*args, vxlan_gpe_tunnel_t *);
38 
39  s = format (s, "[%d] local: %U remote: %U ",
40  t - gm->tunnels,
43 
44  s = format (s, " vxlan VNI %d ", t->vni);
45 
46  switch (t->protocol)
47  {
48  case VXLAN_GPE_PROTOCOL_IP4:
49  s = format (s, "next-protocol ip4");
50  break;
51  case VXLAN_GPE_PROTOCOL_IP6:
52  s = format (s, "next-protocol ip6");
53  break;
54  case VXLAN_GPE_PROTOCOL_ETHERNET:
55  s = format (s, "next-protocol ethernet");
56  break;
57  case VXLAN_GPE_PROTOCOL_NSH:
58  s = format (s, "next-protocol nsh");
59  break;
60  default:
61  s = format (s, "next-protocol unknown %d", t->protocol);
62  }
63 
64  s = format (s, " fibs: (encap %d, decap %d)",
65  t->encap_fib_index,
66  t->decap_fib_index);
67 
68  return s;
69 }
70 
71 /**
72  * @brief Naming for VXLAN GPE tunnel
73  *
74  * @param *s
75  * @param *args
76  *
77  * @return *s
78  *
79  */
80 static u8 * format_vxlan_gpe_name (u8 * s, va_list * args)
81 {
82  u32 dev_instance = va_arg (*args, u32);
83  return format (s, "vxlan_gpe_tunnel%d", dev_instance);
84 }
85 
87  vlib_node_runtime_t * node,
88  vlib_frame_t * frame)
89 {
90  clib_warning ("you shouldn't be here, leaking buffers...");
91  return frame->n_vectors;
92 }
93 
94 /**
95  * @brief CLI function for VXLAN GPE admin up/down
96  *
97  * @param *vnm
98  * @param hw_if_index
99  * @param flags
100  *
101  * @return *rc
102  *
103  */
104 static clib_error_t *
106 {
109  else
110  vnet_hw_interface_set_flags (vnm, hw_if_index, 0);
111 
112  return 0;
113 }
114 
115 VNET_DEVICE_CLASS (vxlan_gpe_device_class,static) = {
116  .name = "VXLAN_GPE",
117  .format_device_name = format_vxlan_gpe_name,
118  .format_tx_trace = format_vxlan_gpe_encap_trace,
119  .tx_function = dummy_interface_tx,
120  .admin_up_down_function = vxlan_gpe_interface_admin_up_down,
121 };
122 
124  u32 sw_if_index,
125  u32 l3_type,
126  void * dst_address,
127  void * rewrite,
128  uword max_rewrite_bytes)
129 {
130  return 0;
131 }
132 
133 
134 /**
135  * @brief Formatting function for tracing VXLAN GPE with length
136  *
137  * @param *s
138  * @param *args
139  *
140  * @return *s
141  *
142  */
143 static u8 * format_vxlan_gpe_header_with_length (u8 * s, va_list * args)
144 {
145  u32 dev_instance = va_arg (*args, u32);
146  s = format (s, "unimplemented dev %u", dev_instance);
147  return s;
148 }
149 
150 VNET_HW_INTERFACE_CLASS (vxlan_gpe_hw_class) = {
151  .name = "VXLAN_GPE",
152  .format_header = format_vxlan_gpe_header_with_length,
153  .set_rewrite = dummy_set_rewrite,
154 };
155 
156 
157 #define foreach_gpe_copy_field \
158 _(vni) \
159 _(protocol) \
160 _(encap_fib_index) \
161 _(decap_fib_index)
162 
163 #define foreach_copy_ipv4 { \
164  _(local.ip4.as_u32) \
165  _(remote.ip4.as_u32) \
166 }
167 
168 #define foreach_copy_ipv6 { \
169  _(local.ip6.as_u64[0]) \
170  _(local.ip6.as_u64[1]) \
171  _(remote.ip6.as_u64[0]) \
172  _(remote.ip6.as_u64[1]) \
173 }
174 
175 
176 /**
177  * @brief Calculate IPv4 VXLAN GPE rewrite header
178  *
179  * @param *t
180  *
181  * @return rc
182  *
183  */
185 {
186  u8 *rw = 0;
187  ip4_header_t * ip0;
188  ip4_vxlan_gpe_header_t * h0;
189  int len;
190 
191  len = sizeof (*h0);
192 
194 
195  h0 = (ip4_vxlan_gpe_header_t *) rw;
196 
197  /* Fixed portion of the (outer) ip4 header */
198  ip0 = &h0->ip4;
199  ip0->ip_version_and_header_length = 0x45;
200  ip0->ttl = 254;
201  ip0->protocol = IP_PROTOCOL_UDP;
202 
203  /* we fix up the ip4 header length and checksum after-the-fact */
204  ip0->src_address.as_u32 = t->local.ip4.as_u32;
205  ip0->dst_address.as_u32 = t->remote.ip4.as_u32;
206  ip0->checksum = ip4_header_checksum (ip0);
207 
208  /* UDP header, randomize src port on something, maybe? */
209  h0->udp.src_port = clib_host_to_net_u16 (4790);
210  h0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_vxlan_gpe);
211 
212  /* VXLAN header. Are we having fun yet? */
213  h0->vxlan.flags = VXLAN_GPE_FLAGS_I | VXLAN_GPE_FLAGS_P;
214  h0->vxlan.ver_res = VXLAN_GPE_VERSION;
215  h0->vxlan.protocol = VXLAN_GPE_PROTOCOL_IP4;
216  h0->vxlan.vni_res = clib_host_to_net_u32 (t->vni<<8);
217 
218  t->rewrite = rw;
219  return (0);
220 }
221 
222 /**
223  * @brief Calculate IPv6 VXLAN GPE rewrite header
224  *
225  * @param *t
226  *
227  * @return rc
228  *
229  */
231 {
232  u8 *rw = 0;
233  ip6_header_t * ip0;
234  ip6_vxlan_gpe_header_t * h0;
235  int len;
236 
237  len = sizeof (*h0);
238 
240 
241  h0 = (ip6_vxlan_gpe_header_t *) rw;
242 
243  /* Fixed portion of the (outer) ip4 header */
244  ip0 = &h0->ip6;
245  ip0->ip_version_traffic_class_and_flow_label = clib_host_to_net_u32(6 << 28);
246  ip0->hop_limit = 255;
247  ip0->protocol = IP_PROTOCOL_UDP;
248 
249  ip0->src_address.as_u64[0] = t->local.ip6.as_u64[0];
250  ip0->src_address.as_u64[1] = t->local.ip6.as_u64[1];
251  ip0->dst_address.as_u64[0] = t->remote.ip6.as_u64[0];
252  ip0->dst_address.as_u64[1] = t->remote.ip6.as_u64[1];
253 
254  /* UDP header, randomize src port on something, maybe? */
255  h0->udp.src_port = clib_host_to_net_u16 (4790);
256  h0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_vxlan_gpe);
257 
258  /* VXLAN header. Are we having fun yet? */
259  h0->vxlan.flags = VXLAN_GPE_FLAGS_I | VXLAN_GPE_FLAGS_P;
260  h0->vxlan.ver_res = VXLAN_GPE_VERSION;
261  h0->vxlan.protocol = VXLAN_GPE_PROTOCOL_IP4;
262  h0->vxlan.vni_res = clib_host_to_net_u32 (t->vni<<8);
263 
264  t->rewrite = rw;
265  return (0);
266 }
267 
268 /**
269  * @brief Add or Del a VXLAN GPE tunnel
270  *
271  * @param *a
272  * @param *sw_if_index
273  *
274  * @return rc
275  *
276  */
279 {
281  vxlan_gpe_tunnel_t *t = 0;
282  vnet_main_t * vnm = gm->vnet_main;
284  uword * p;
285  u32 hw_if_index = ~0;
286  u32 sw_if_index = ~0;
287  int rv;
288  vxlan4_gpe_tunnel_key_t key4, *key4_copy;
289  vxlan6_gpe_tunnel_key_t key6, *key6_copy;
290  hash_pair_t *hp;
291 
292  if (!a->is_ip6)
293  {
294  key4.local = a->local.ip4.as_u32;
295  key4.remote = a->remote.ip4.as_u32;
296  key4.vni = clib_host_to_net_u32 (a->vni << 8);
297  key4.pad = 0;
298 
299  p = hash_get_mem(gm->vxlan4_gpe_tunnel_by_key, &key4);
300  }
301  else
302  {
303  key6.local.as_u64[0] = a->local.ip6.as_u64[0];
304  key6.local.as_u64[1] = a->local.ip6.as_u64[1];
305  key6.remote.as_u64[0] = a->remote.ip6.as_u64[0];
306  key6.remote.as_u64[1] = a->remote.ip6.as_u64[1];
307  key6.vni = clib_host_to_net_u32 (a->vni << 8);
308 
309  p = hash_get_mem(gm->vxlan6_gpe_tunnel_by_key, &key6);
310  }
311 
312  if (a->is_add)
313  {
314  /* adding a tunnel: tunnel must not already exist */
315  if (p)
316  return VNET_API_ERROR_INVALID_VALUE;
317 
319  memset (t, 0, sizeof (*t));
320 
321  /* copy from arg structure */
322 #define _(x) t->x = a->x;
324  if (!a->is_ip6) foreach_copy_ipv4
325  else foreach_copy_ipv6
326 #undef _
327 
328  if (!a->is_ip6) t->flags |= VXLAN_GPE_TUNNEL_IS_IPV4;
329 
330  if (!a->is_ip6) {
331  rv = vxlan4_gpe_rewrite (t);
332  } else {
333  rv = vxlan6_gpe_rewrite (t);
334  }
335 
336  if (rv)
337  {
338  pool_put (gm->tunnels, t);
339  return rv;
340  }
341 
342  if (!a->is_ip6)
343  {
344  key4_copy = clib_mem_alloc (sizeof (*key4_copy));
345  clib_memcpy (key4_copy, &key4, sizeof (*key4_copy));
346  hash_set_mem (gm->vxlan4_gpe_tunnel_by_key, key4_copy,
347  t - gm->tunnels);
348  }
349  else
350  {
351  key6_copy = clib_mem_alloc (sizeof (*key6_copy));
352  clib_memcpy (key6_copy, &key6, sizeof (*key6_copy));
353  hash_set_mem (gm->vxlan6_gpe_tunnel_by_key, key6_copy,
354  t - gm->tunnels);
355  }
356 
358  {
359  hw_if_index = gm->free_vxlan_gpe_tunnel_hw_if_indices
361  _vec_len (gm->free_vxlan_gpe_tunnel_hw_if_indices) -= 1;
362 
363  hi = vnet_get_hw_interface (vnm, hw_if_index);
364  hi->dev_instance = t - gm->tunnels;
365  hi->hw_instance = hi->dev_instance;
366  }
367  else
368  {
369  hw_if_index = vnet_register_interface
370  (vnm, vxlan_gpe_device_class.index, t - gm->tunnels,
371  vxlan_gpe_hw_class.index, t - gm->tunnels);
372  hi = vnet_get_hw_interface (vnm, hw_if_index);
374  }
375 
376  t->hw_if_index = hw_if_index;
377  t->sw_if_index = sw_if_index = hi->sw_if_index;
379  gm->tunnel_index_by_sw_if_index[sw_if_index] = t - gm->tunnels;
380 
383  }
384  else
385  {
386  /* deleting a tunnel: tunnel must exist */
387  if (!p)
388  return VNET_API_ERROR_NO_SUCH_ENTRY;
389 
390  t = pool_elt_at_index (gm->tunnels, p[0]);
391 
392  vnet_sw_interface_set_flags (vnm, t->sw_if_index, 0 /* down */);
394 
396 
397  if (!a->is_ip6)
398  {
399  hp = hash_get_pair (gm->vxlan4_gpe_tunnel_by_key, &key4);
400  key4_copy = (void *)(hp->key);
402  clib_mem_free (key4_copy);
403  }
404  else
405  {
406  hp = hash_get_pair (gm->vxlan6_gpe_tunnel_by_key, &key6);
407  key6_copy = (void *)(hp->key);
409  clib_mem_free (key6_copy);
410  }
411 
412  vec_free (t->rewrite);
413  pool_put (gm->tunnels, t);
414  }
415 
416  if (sw_if_indexp)
417  *sw_if_indexp = sw_if_index;
418 
419  return 0;
420 }
421 
422 /**
423  * @brief Find the IPv4 FIB index from the FIB ID
424  *
425  * @param fib_id
426  *
427  * @return fib_index
428  *
429  */
431 {
432  ip4_main_t * im = &ip4_main;
433  uword * p;
434 
435  p = hash_get (im->fib_index_by_table_id, fib_id);
436  if (!p)
437  return ~0;
438 
439  return p[0];
440 }
441 
442 /**
443  * @brief Find the IPv4 FIB index from the FIB ID
444  *
445  * @param fib_id
446  *
447  * @return fib_index
448  *
449  */
451 {
452  ip6_main_t * im = &ip6_main;
453  uword * p;
454 
455  p = hash_get (im->fib_index_by_table_id, fib_id);
456  if (!p)
457  return ~0;
458 
459  return p[0];
460 }
461 
462 /**
463  * @brief CLI function for Add/Del of IPv4/IPv6 VXLAN GPE tunnel
464  *
465  * @param *vm
466  * @param *input
467  * @param *cmd
468  *
469  * @return error
470  *
471  */
472 static clib_error_t *
474  unformat_input_t * input,
475  vlib_cli_command_t * cmd)
476 {
477  unformat_input_t _line_input, * line_input = &_line_input;
478  u8 is_add = 1;
479  ip46_address_t local, remote;
480  u8 local_set = 0;
481  u8 remote_set = 0;
482  u8 ipv4_set = 0;
483  u8 ipv6_set = 0;
484  u32 encap_fib_index = 0;
485  u32 decap_fib_index = 0;
486  u8 protocol = VXLAN_GPE_PROTOCOL_IP4;
487  u32 vni;
488  u8 vni_set = 0;
489  int rv;
490  u32 tmp;
492  u32 sw_if_index;
493 
494  /* Get a line of input. */
495  if (! unformat_user (input, unformat_line_input, line_input))
496  return 0;
497 
498  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) {
499  if (unformat (line_input, "del"))
500  is_add = 0;
501  else if (unformat (line_input, "local %U",
502  unformat_ip4_address, &local.ip4))
503  {
504  local_set = 1;
505  ipv4_set = 1;
506  }
507  else if (unformat (line_input, "remote %U",
508  unformat_ip4_address, &remote.ip4))
509  {
510  remote_set = 1;
511  ipv4_set = 1;
512  }
513  else if (unformat (line_input, "local %U",
514  unformat_ip6_address, &local.ip6))
515  {
516  local_set = 1;
517  ipv6_set = 1;
518  }
519  else if (unformat (line_input, "remote %U",
520  unformat_ip6_address, &remote.ip6))
521  {
522  remote_set = 1;
523  ipv6_set = 1;
524  }
525  else if (unformat (line_input, "encap-vrf-id %d", &tmp))
526  {
527  if (ipv6_set)
528  encap_fib_index = fib6_index_from_fib_id (tmp);
529  else
530  encap_fib_index = fib4_index_from_fib_id (tmp);
531 
532  if (encap_fib_index == ~0)
533  return clib_error_return (0, "nonexistent encap fib id %d", tmp);
534  }
535  else if (unformat (line_input, "decap-vrf-id %d", &tmp))
536  {
537 
538  if (ipv6_set)
539  decap_fib_index = fib6_index_from_fib_id (tmp);
540  else
541  decap_fib_index = fib4_index_from_fib_id (tmp);
542 
543  if (decap_fib_index == ~0)
544  return clib_error_return (0, "nonexistent decap fib id %d", tmp);
545  }
546  else if (unformat (line_input, "vni %d", &vni))
547  vni_set = 1;
548  else if (unformat(line_input, "next-ip4"))
549  protocol = VXLAN_GPE_PROTOCOL_IP4;
550  else if (unformat(line_input, "next-ip6"))
551  protocol = VXLAN_GPE_PROTOCOL_IP6;
552  else if (unformat(line_input, "next-ethernet"))
553  protocol = VXLAN_GPE_PROTOCOL_ETHERNET;
554  else if (unformat(line_input, "next-nsh"))
555  protocol = VXLAN_GPE_PROTOCOL_NSH;
556  else
557  return clib_error_return (0, "parse error: '%U'",
558  format_unformat_error, line_input);
559  }
560 
561  unformat_free (line_input);
562 
563  if (local_set == 0)
564  return clib_error_return (0, "tunnel local address not specified");
565 
566  if (remote_set == 0)
567  return clib_error_return (0, "tunnel remote address not specified");
568 
569  if (ipv4_set && ipv6_set)
570  return clib_error_return (0, "both IPv4 and IPv6 addresses specified");
571 
572  if ((ipv4_set && memcmp(&local.ip4, &remote.ip4, sizeof(local.ip4)) == 0) ||
573  (ipv6_set && memcmp(&local.ip6, &remote.ip6, sizeof(local.ip6)) == 0))
574  return clib_error_return (0, "src and dst addresses are identical");
575 
576  if (vni_set == 0)
577  return clib_error_return (0, "vni not specified");
578 
579  memset (a, 0, sizeof (*a));
580 
581  a->is_add = is_add;
582  a->is_ip6 = ipv6_set;
583 
584 #define _(x) a->x = x;
586  if (ipv4_set) foreach_copy_ipv4
587  else foreach_copy_ipv6
588 #undef _
589 
590  rv = vnet_vxlan_gpe_add_del_tunnel (a, &sw_if_index);
591 
592  switch(rv)
593  {
594  case 0:
595  vlib_cli_output(vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main(), sw_if_index);
596  break;
597  case VNET_API_ERROR_INVALID_DECAP_NEXT:
598  return clib_error_return (0, "invalid decap-next...");
599 
600  case VNET_API_ERROR_TUNNEL_EXIST:
601  return clib_error_return (0, "tunnel already exists...");
602 
603  case VNET_API_ERROR_NO_SUCH_ENTRY:
604  return clib_error_return (0, "tunnel does not exist...");
605 
606  default:
607  return clib_error_return
608  (0, "vnet_vxlan_gpe_add_del_tunnel returned %d", rv);
609  }
610 
611  return 0;
612 }
613 
614 VLIB_CLI_COMMAND (create_vxlan_gpe_tunnel_command, static) = {
615  .path = "create vxlan-gpe tunnel",
616  .short_help =
617  "create vxlan-gpe tunnel local <local-addr> remote <remote-addr>"
618  " vni <nn> [next-ip4][next-ip6][next-ethernet][next-nsh]"
619  " [encap-vrf-id <nn>] [decap-vrf-id <nn>]"
620  " [del]\n",
622 };
623 
624 /**
625  * @brief CLI function for showing VXLAN GPE tunnels
626  *
627  * @param *vm
628  * @param *input
629  * @param *cmd
630  *
631  * @return error
632  *
633  */
634 static clib_error_t *
636  unformat_input_t * input,
637  vlib_cli_command_t * cmd)
638 {
640  vxlan_gpe_tunnel_t * t;
641 
642  if (pool_elts (gm->tunnels) == 0)
643  vlib_cli_output (vm, "No vxlan-gpe tunnels configured.");
644 
645  pool_foreach (t, gm->tunnels,
646  ({
647  vlib_cli_output (vm, "%U", format_vxlan_gpe_tunnel, t);
648  }));
649 
650  return 0;
651 }
652 
653 VLIB_CLI_COMMAND (show_vxlan_gpe_tunnel_command, static) = {
654  .path = "show vxlan-gpe",
656 };
657 
658 /**
659  * @brief Feature init function for VXLAN GPE
660  *
661  * @param *vm
662  *
663  * @return error
664  *
665  */
667 {
669 
670  gm->vnet_main = vnet_get_main();
671  gm->vlib_main = vm;
672 
674  = hash_create_mem (0, sizeof(vxlan4_gpe_tunnel_key_t), sizeof (uword));
675 
677  = hash_create_mem (0, sizeof(vxlan6_gpe_tunnel_key_t), sizeof (uword));
678 
679 
680  udp_register_dst_port (vm, UDP_DST_PORT_vxlan_gpe,
681  vxlan4_gpe_input_node.index, 1 /* is_ip4 */);
682  udp_register_dst_port (vm, UDP_DST_PORT_vxlan6_gpe,
683  vxlan6_gpe_input_node.index, 0 /* is_ip4 */);
684  return 0;
685 }
686 
688 
format_function_t format_ip46_address
Definition: format.h:54
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:666
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: interface.c:513
ip4_address_t 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:86
u64 as_u64[2]
Definition: ip6_packet.h:50
#define foreach_copy_ipv4
Definition: vxlan_gpe.c:163
#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)
static uword dummy_set_rewrite(vnet_main_t *vnm, u32 sw_if_index, u32 l3_type, void *dst_address, void *rewrite, uword max_rewrite_bytes)
Definition: vxlan_gpe.c:123
#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:273
#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:278
#define VXLAN_GPE_FLAGS_P
ip6_address_t src_address
Definition: ip6_packet.h:298
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:157
vnet_main_t * vnet_get_main(void)
Definition: misc.c:45
u8 * format_vxlan_gpe_tunnel(u8 *s, va_list *args)
Tracing function for VXLAN GPE tunnel packets.
Definition: vxlan_gpe.c:34
#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:143
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:184
static u32 fib4_index_from_fib_id(u32 fib_id)
Find the IPv4 FIB index from the FIB ID.
Definition: vxlan_gpe.c:430
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:650
u8 * rewrite
Rewrite string.
Definition: vxlan_gpe.h:92
unformat_function_t unformat_ip4_address
Definition: format.h:68
#define hash_create_mem(elts, key_bytes, value_bytes)
Definition: hash.h:626
#define hash_get(h, key)
Definition: hash.h:248
#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
uword * fib_index_by_table_id
Hash table mapping table id to fib index.
Definition: ip4.h:127
Struct for VXLAN GPE tunnel.
Definition: vxlan_gpe.h:90
#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:23
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:86
uword * fib_index_by_table_id
Definition: ip6.h:127
#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:63
static u8 * format_vxlan_gpe_name(u8 *s, va_list *args)
Naming for VXLAN GPE tunnel.
Definition: vxlan_gpe.c:80
static clib_error_t * vxlan_gpe_add_del_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI function for Add/Del of IPv4/IPv6 VXLAN GPE tunnel.
Definition: vxlan_gpe.c:473
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
Definition: interface.h:415
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
ip6_main_t ip6_main
Definition: ip6_forward.c:2955
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:105
Struct for VXLAN GPE node state.
Definition: vxlan_gpe.h:146
u8 * format(u8 *s, char *fmt,...)
Definition: format.c:418
IPv4 main type.
Definition: ip4.h:114
static void clib_mem_free(void *p)
Definition: mem.h:154
static void * clib_mem_alloc(uword size)
Definition: mem.h:107
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:285
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
VLIB_CLI_COMMAND(set_interface_ip_source_and_port_range_check_command, static)
static u32 fib6_index_from_fib_id(u32 fib_id)
Find the IPv4 FIB index from the FIB ID.
Definition: vxlan_gpe.c:450
#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:635
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
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1578
static int vxlan6_gpe_rewrite(vxlan_gpe_tunnel_t *t)
Calculate IPv6 VXLAN GPE rewrite header.
Definition: vxlan_gpe.c:230
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:521
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:461
#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:76
#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:168
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:298
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