FD.io VPP  v18.01.2-1-g9b554f3
Vector Packet Processing
lisp_gpe.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 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, IPv6 and L2 LISP-GPE tunnels.
18  *
19  */
20 
21 #include <vnet/lisp-gpe/lisp_gpe.h>
25 #include <vnet/fib/fib_path_list.h>
26 #include <vnet/fib/fib_table.h>
27 #include <vnet/fib/fib_internal.h>
28 
29 /** LISP-GPE global state */
31 
32 
33 /** CLI command to add/del forwarding entry. */
34 static clib_error_t *
36  unformat_input_t * input,
37  vlib_cli_command_t * cmd)
38 {
39  unformat_input_t _line_input, *line_input = &_line_input;
40  u8 is_add = 1;
41  ip_address_t lloc, rloc;
42  clib_error_t *error = 0;
43  gid_address_t _reid, *reid = &_reid, _leid, *leid = &_leid;
44  u8 reid_set = 0, leid_set = 0, is_negative = 0, dp_table_set = 0,
45  vni_set = 0;
46  u32 vni = 0, dp_table = 0, action = ~0, w;
47  locator_pair_t pair, *pairs = 0;
48  int rv;
49 
50  memset (leid, 0, sizeof (*leid));
51  memset (reid, 0, sizeof (*reid));
52 
53  /* Get a line of input. */
54  if (!unformat_user (input, unformat_line_input, line_input))
55  return 0;
56 
57  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
58  {
59  if (unformat (line_input, "del"))
60  is_add = 0;
61  else if (unformat (line_input, "add"))
62  is_add = 1;
63  else if (unformat (line_input, "leid %U", unformat_gid_address, leid))
64  {
65  leid_set = 1;
66  }
67  else if (unformat (line_input, "reid %U", unformat_gid_address, reid))
68  {
69  reid_set = 1;
70  }
71  else if (unformat (line_input, "vni %u", &vni))
72  {
73  gid_address_vni (leid) = vni;
74  gid_address_vni (reid) = vni;
75  vni_set = 1;
76  }
77  else if (unformat (line_input, "vrf %u", &dp_table))
78  {
79  dp_table_set = 1;
80  }
81  else if (unformat (line_input, "bd %u", &dp_table))
82  {
83  dp_table_set = 1;
84  }
85  else if (unformat (line_input, "negative action %U",
87  {
88  is_negative = 1;
89  }
90  else if (unformat (line_input, "loc-pair %U %U w %d",
91  unformat_ip_address, &lloc,
92  unformat_ip_address, &rloc, &w))
93  {
94  ip_address_copy (&pair.lcl_loc, &lloc);
95  ip_address_copy (&pair.rmt_loc, &rloc);
96  pair.weight = w;
97  pair.priority = 0;
98  vec_add1 (pairs, pair);
99  }
100  else
101  {
102  error = unformat_parse_error (line_input);
103  vlib_cli_output (vm, "parse error: '%U'",
104  format_unformat_error, line_input);
105  goto done;
106  }
107  }
108 
109  if (!reid_set)
110  {
111  vlib_cli_output (vm, "remote eid must be set!");
112  goto done;
113  }
114 
115  if (gid_address_type (reid) != GID_ADDR_NSH && (!vni_set || !dp_table_set))
116  {
117  vlib_cli_output (vm, "vni and vrf/bd must be set!");
118  goto done;
119  }
120 
121  if (is_negative)
122  {
123  if (~0 == action)
124  {
125  vlib_cli_output (vm, "no action set for negative tunnel!");
126  goto done;
127  }
128  }
129  else
130  {
131  if (vec_len (pairs) == 0)
132  {
133  vlib_cli_output (vm, "expected ip4/ip6 locators");
134  goto done;
135  }
136  }
137 
138  if (!leid_set)
139  {
140  /* if leid not set, make sure it's the same AFI like reid */
141  gid_address_type (leid) = gid_address_type (reid);
142  if (GID_ADDR_IP_PREFIX == gid_address_type (reid))
144  }
145 
146  /* add fwd entry */
148  memset (a, 0, sizeof (a[0]));
149 
150  a->is_add = is_add;
151  a->is_negative = is_negative;
152  a->vni = vni;
153  a->table_id = dp_table;
154  gid_address_copy (&a->lcl_eid, leid);
155  gid_address_copy (&a->rmt_eid, reid);
156  a->locator_pairs = pairs;
157  a->action = action;
158 
160  if (0 != rv)
161  {
162  vlib_cli_output (vm, "failed to %s gpe tunnel!",
163  is_add ? "add" : "delete");
164  }
165 
166 done:
167  unformat_free (line_input);
168  vec_free (pairs);
169  return error;
170 }
171 
172 /* *INDENT-OFF* */
173 VLIB_CLI_COMMAND (lisp_gpe_add_del_fwd_entry_command, static) = {
174  .path = "gpe entry",
175  .short_help = "gpe entry add/del vni <vni> vrf/bd <id> [leid <leid>]"
176  "reid <reid> [loc-pair <lloc> <rloc> w <weight>] "
177  "[negative action <action>]",
179 };
180 /* *INDENT-ON* */
181 
182 /** Check if LISP-GPE is enabled. */
183 u8
185 {
187 
188  return lgm->is_en;
189 }
190 
191 /** Enable/disable LISP-GPE. */
192 clib_error_t *
194 {
196 
197  if (a->is_en)
198  {
199  lgm->is_en = 1;
200  }
201  else
202  {
203  /* remove all entries */
205 
206  /* disable all l3 ifaces */
208 
209  lgm->is_en = 0;
210  }
211 
212  return 0;
213 }
214 
215 /** Set GPE encapsulation mode. */
216 int
218 {
220 
221  if (mode >= GPE_ENCAP_COUNT)
222  return VNET_API_ERROR_INVALID_GPE_MODE;
223 
224  if (pool_elts (lgm->lisp_fwd_entry_pool) != 0)
225  return VNET_API_ERROR_LISP_GPE_ENTRIES_PRESENT;
226 
227  lgm->encap_mode = mode;
228  return 0;
229 }
230 
231 /** CLI command to set GPE encap */
232 static clib_error_t *
234  unformat_input_t * input,
235  vlib_cli_command_t * cmd)
236 {
237  unformat_input_t _line_input, *line_input = &_line_input;
239  vnet_api_error_t rv;
240 
241  /* Get a line of input. */
242  if (!unformat_user (input, unformat_line_input, line_input))
243  return 0;
244 
245  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
246  {
247  if (unformat (line_input, "lisp"))
248  mode = GPE_ENCAP_LISP;
249  else if (unformat (line_input, "vxlan"))
250  mode = GPE_ENCAP_VXLAN;
251  else
252  {
253  return clib_error_return (0, "parse error: '%U'",
254  format_unformat_error, line_input);
255  }
256  }
257  rv = vnet_gpe_set_encap_mode (mode);
258  if (rv)
259  {
260  return clib_error_return (0,
261  "Error: invalid mode or GPE entries are present!");
262  }
263 
264  return 0;
265 }
266 
267 /* *INDENT-OFF* */
268 VLIB_CLI_COMMAND (gpe_set_encap_mode_command, static) = {
269  .path = "gpe encap",
270  .short_help = "gpe encap [lisp|vxlan]",
271  .function = gpe_set_encap_mode_command_fn,
272 };
273 /* *INDENT-ON* */
274 
275 /** Format GPE encap mode. */
276 u8 *
277 format_vnet_gpe_encap_mode (u8 * s, va_list * args)
278 {
280 
281  switch (lgm->encap_mode)
282  {
283  case GPE_ENCAP_LISP:
284  return format (s, "lisp");
285  case GPE_ENCAP_VXLAN:
286  return format (s, "vxlan");
287  default:
288  return 0;
289  }
290  return 0;
291 }
292 
293 /** CLI command to show GPE encap */
294 static clib_error_t *
296  unformat_input_t * input,
297  vlib_cli_command_t * cmd)
298 {
299  vlib_cli_output (vm, "encap mode: %U", format_vnet_gpe_encap_mode);
300  return 0;
301 }
302 
303 /* *INDENT-OFF* */
304 VLIB_CLI_COMMAND (gpe_show_encap_mode_command, static) = {
305  .path = "show gpe encap",
306  .short_help = "show GPE encapulation mode",
307  .function = gpe_show_encap_mode_command_fn,
308 };
309 /* *INDENT-ON* */
310 
311 /** CLI command to enable/disable LISP-GPE. */
312 static clib_error_t *
314  unformat_input_t * input,
315  vlib_cli_command_t * cmd)
316 {
317  unformat_input_t _line_input, *line_input = &_line_input;
318  u8 is_en = 1;
320  clib_error_t *error = NULL;
321 
322  /* Get a line of input. */
323  if (!unformat_user (input, unformat_line_input, line_input))
324  return clib_error_return (0, "expected enable | disable");
325 
326  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
327  {
328  if (unformat (line_input, "enable"))
329  is_en = 1;
330  else if (unformat (line_input, "disable"))
331  is_en = 0;
332  else
333  {
334  error = clib_error_return (0, "parse error: '%U'",
335  format_unformat_error, line_input);
336  goto done;
337  }
338  }
339  a->is_en = is_en;
340  error = vnet_lisp_gpe_enable_disable (a);
341 
342 done:
343  unformat_free (line_input);
344 
345  return error;
346 }
347 
348 /* *INDENT-OFF* */
349 VLIB_CLI_COMMAND (enable_disable_lisp_gpe_command, static) = {
350  .path = "gpe",
351  .short_help = "gpe [enable|disable]",
353 };
354 /* *INDENT-ON* */
355 
356 /** CLI command to show LISP-GPE interfaces. */
357 static clib_error_t *
359  unformat_input_t * input,
360  vlib_cli_command_t * cmd)
361 {
363  hash_pair_t *p;
364 
365  vlib_cli_output (vm, "%=10s%=12s", "vrf", "hw_if_index");
366 
367  /* *INDENT-OFF* */
369  vlib_cli_output (vm, "%=10d%=10d", p->key, p->value[0]);
370  }));
371  /* *INDENT-ON* */
372 
373  if (0 != lgm->l2_ifaces.hw_if_index_by_dp_table)
374  {
375  vlib_cli_output (vm, "%=10s%=12s", "bd_id", "hw_if_index");
376  /* *INDENT-OFF* */
378  vlib_cli_output (vm, "%=10d%=10d", p->key, p->value[0]);
379  }));
380  /* *INDENT-ON* */
381  }
382  return 0;
383 }
384 
385 /* *INDENT-OFF* */
386 VLIB_CLI_COMMAND (lisp_show_iface_command) = {
387  .path = "show gpe interface",
388  .short_help = "show gpe interface",
389  .function = lisp_show_iface_command_fn,
390 };
391 /* *INDENT-ON* */
392 
393 /** CLI command to show GPE fwd native route path. */
394 static clib_error_t *
396  unformat_input_t * input,
397  vlib_cli_command_t * cmd)
398 {
400  fib_route_path_t *rpath;
401 
402  if (vec_len (lgm->native_fwd_rpath[IP4]))
403  {
404  vec_foreach (rpath, lgm->native_fwd_rpath[IP4])
405  {
406  vlib_cli_output (vm, "nh: %U fib_index %u sw_if_index %u",
407  format_ip46_address, &rpath->frp_addr,
409  rpath->frp_sw_if_index);
410  }
411  }
412  if (vec_len (lgm->native_fwd_rpath[IP6]))
413  {
414  vec_foreach (rpath, lgm->native_fwd_rpath[IP6])
415  {
416  vlib_cli_output (vm, "nh: %U fib_index %u sw_if_index %u",
418  rpath->frp_fib_index, rpath->frp_sw_if_index);
419  }
420  }
421  return 0;
422 }
423 
424 /* *INDENT-OFF* */
425 VLIB_CLI_COMMAND (gpe_show_native_fwd_rpath_command) = {
426  .path = "show gpe native-forward",
427  .short_help = "show gpe native-forward",
429 };
430 /* *INDENT-ON* */
431 
432 void
434 {
437  fib_prefix_t fib_prefix;
438  u32 *lfei;
439 
440  vec_foreach (lfei, lgm->native_fwd_lfes[ip_version])
441  {
442  lfe = pool_elt_at_index (lgm->lisp_fwd_entry_pool, lfei[0]);
443  ip_prefix_to_fib_prefix (&lfe->key->rmt.ippref, &fib_prefix);
446  lgm->native_fwd_rpath[ip_version]);
447  }
448 }
449 
450 int
452 {
454  fib_route_path_t *rpath;
455  u8 ip_version;
456 
457  ip_version = a->rpath.frp_proto == DPO_PROTO_IP4 ? IP4 : IP6;
458 
459  if (a->is_add)
460  {
461  vec_add1 (lgm->native_fwd_rpath[ip_version], a->rpath);
462  }
463  else
464  {
465  vec_foreach (rpath, lgm->native_fwd_rpath[ip_version])
466  {
467  if (!fib_route_path_cmp (rpath, &a->rpath))
468  {
469  vec_del1 (lgm->native_fwd_rpath[ip_version],
470  rpath - lgm->native_fwd_rpath[ip_version]);
471  break;
472  }
473  }
474  }
475  gpe_update_native_fwd_path (ip_version);
476  return 0;
477 }
478 
479 /**
480  * CLI command to add action for native forward.
481  */
482 static clib_error_t *
484  vlib_cli_command_t * cmd)
485 {
486  vnet_main_t *vnm = vnet_get_main ();
487  unformat_input_t _line_input, *line_input = &_line_input;
488  vnet_api_error_t rv;
489  fib_route_path_t rpath;
490  u32 table_id = ~0;
492  u8 is_add = 1;
493  clib_error_t *error = 0;
494 
495  /* Get a line of input. */
496  if (!unformat_user (input, unformat_line_input, line_input))
497  return 0;
498 
499  memset (&rpath, 0, sizeof (rpath));
500 
501  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
502  {
503  if (unformat (line_input, "table %d", &table_id))
504  ;
505  else if (unformat (line_input, "del"))
506  is_add = 0;
507  else if (unformat (line_input, "via %U %U",
509  &rpath.frp_addr.ip4,
511  &rpath.frp_sw_if_index))
512  {
513  rpath.frp_weight = 1;
514  rpath.frp_proto = DPO_PROTO_IP4;
515  }
516  else if (unformat (line_input, "via %U %U",
518  &rpath.frp_addr.ip6,
520  &rpath.frp_sw_if_index))
521  {
522  rpath.frp_weight = 1;
523  rpath.frp_proto = DPO_PROTO_IP6;
524  }
525  else if (unformat (line_input, "via %U",
526  unformat_ip4_address, &rpath.frp_addr.ip4))
527  {
528  rpath.frp_weight = 1;
529  rpath.frp_sw_if_index = ~0;
530  rpath.frp_proto = DPO_PROTO_IP4;
531  }
532  else if (unformat (line_input, "via %U",
533  unformat_ip6_address, &rpath.frp_addr.ip6))
534  {
535  rpath.frp_weight = 1;
536  rpath.frp_sw_if_index = ~0;
537  rpath.frp_proto = DPO_PROTO_IP6;
538  }
539  else
540  {
541  return clib_error_return (0, "parse error: '%U'",
542  format_unformat_error, line_input);
543  }
544  }
545 
546  if ((u32) ~ 0 == table_id)
547  {
548  rpath.frp_fib_index = 0;
549  }
550  else
551  {
552  rpath.frp_fib_index =
553  fib_table_find (dpo_proto_to_fib (rpath.frp_proto), table_id);
554  if ((u32) ~ 0 == rpath.frp_fib_index)
555  {
556  error = clib_error_return (0, "Nonexistent table id %d", table_id);
557  goto done;
558  }
559  }
560 
561  a->rpath = rpath;
562  a->is_add = is_add;
563 
565  if (rv)
566  {
567  return clib_error_return (0, "Error: couldn't add path!");
568  }
569 
570 done:
571  return error;
572 }
573 
574 /* *INDENT-OFF* */
575 VLIB_CLI_COMMAND (gpe_native_forward_command) = {
576  .path = "gpe native-forward",
577  .short_help = "gpe native-forward [del] via <nh-ip-addr> [iface] "
578  "[table <table>]",
579  .function = gpe_native_forward_command_fn,
580 };
581 /* *INDENT-ON* */
582 
583 /** Format LISP-GPE status. */
584 u8 *
585 format_vnet_lisp_gpe_status (u8 * s, va_list * args)
586 {
588  return format (s, "%s", lgm->is_en ? "enabled" : "disabled");
589 }
590 
591 /** LISP-GPE init function. */
592 clib_error_t *
594 {
596  clib_error_t *error = 0;
597 
598  if ((error = vlib_call_init_function (vm, ip_main_init)))
599  return error;
600 
601  if ((error = vlib_call_init_function (vm, ip4_lookup_init)))
602  return error;
603 
604  lgm->vnet_main = vnet_get_main ();
605  lgm->vlib_main = vm;
606  lgm->im4 = &ip4_main;
607  lgm->im6 = &ip6_main;
608  lgm->lm4 = &ip4_main.lookup_main;
609  lgm->lm6 = &ip6_main.lookup_main;
610  lgm->encap_mode = GPE_ENCAP_LISP;
611 
612  lgm->lisp_gpe_fwd_entries =
613  hash_create_mem (0, sizeof (lisp_gpe_fwd_entry_key_t), sizeof (uword));
614 
615  udp_register_dst_port (vm, UDP_DST_PORT_lisp_gpe,
616  lisp_gpe_ip4_input_node.index, 1 /* is_ip4 */ );
617  udp_register_dst_port (vm, UDP_DST_PORT_lisp_gpe6,
618  lisp_gpe_ip6_input_node.index, 0 /* is_ip4 */ );
619 
621  hash_create_mem (0, sizeof (lisp_stats_key_t), sizeof (uword));
622  memset (&lgm->counters, 0, sizeof (lgm->counters));
623  lgm->counters.name = "LISP counters";
624 
625  return 0;
626 }
627 
630 {
632  return lgm->encap_mode;
633 }
634 
635 static clib_error_t *
637 {
638  vlib_frame_t *f;
639  vlib_buffer_t *b;
641  pcap_main_t pm;
642  clib_error_t *error = 0;
643 
644  if (!file_name)
645  return clib_error_create ("no pcap file specified!");
646 
647  memset (&pm, 0, sizeof (pm));
648  pm.file_name = (char *) file_name;
649  error = pcap_read (&pm);
650  if (error)
651  return error;
652 
653  u32 bi;
654  if (vlib_buffer_alloc (lgm->vlib_main, &bi, 1) != 1)
655  return clib_error_create ("cannot allocate memory!");
656 
657  b = vlib_get_buffer (lgm->vlib_main, bi);
658  tunnel_lookup_t *nsh_ifaces = &lgm->nsh_ifaces;
659  uword *hip;
661 
662  hip = hash_get (nsh_ifaces->hw_if_index_by_dp_table, 0);
663  if (hip == 0)
664  return clib_error_create ("The NSH 0 interface doesn't exist");
665 
666  hi = vnet_get_hw_interface (lgm->vnet_main, hip[0]);
667 
668  vnet_buffer (b)->sw_if_index[VLIB_TX] = hi->sw_if_index;
669  u8 *p = vlib_buffer_put_uninit (b, vec_len (pm.packets_read[0]));
670  clib_memcpy (p, pm.packets_read[0], vec_len (pm.packets_read[0]));
671  vlib_buffer_pull (b, sizeof (ethernet_header_t));
672 
674  (u8 *) "interface-tx");
675  f = vlib_get_frame_to_node (lgm->vlib_main, n->index);
676  u32 *to_next = vlib_frame_vector_args (f);
677  to_next[0] = bi;
678  f->n_vectors = 1;
679  vlib_put_frame_to_node (lgm->vlib_main, n->index, f);
680 
681  return error;
682 }
683 
684 static clib_error_t *
686  vlib_cli_command_t * cmd)
687 {
688  clib_error_t *error = 0;
689  u8 *file_name = 0;
690 
692  {
693  if (unformat (input, "pcap %v", &file_name))
694  {
695  error = lisp_gpe_test_send_nsh_packet (file_name);
696  goto done;
697  }
698  else
699  {
700  error = clib_error_create ("unknown input `%U'",
701  format_unformat_error, input);
702  goto done;
703  }
704  }
705 
706 done:
707  return error;
708 }
709 
710 /* *INDENT-OFF* */
711 VLIB_CLI_COMMAND (lisp_test_nsh_command, static) = {
712  .path = "test one nsh",
713  .short_help = "test gpe nsh pcap <path-to-pcap-file>",
714  .function = lisp_test_nsh_command_fn,
715 };
716 /* *INDENT-ON* */
717 
719 
720 /*
721  * fd.io coding-style-patch-verification: ON
722  *
723  * Local Variables:
724  * eval: (c-set-style "gnu")
725  * End:
726  */
static clib_error_t * lisp_test_nsh_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: lisp_gpe.c:685
vmrglw vmrglh hi
#define gid_address_ip_version(_a)
Definition: lisp_types.h:265
ip46_address_t frp_addr
The next-hop address.
Definition: fib_types.h:393
vnet_api_error_t
Definition: api_errno.h:139
char * file_name
File name of pcap output.
Definition: pcap.h:127
vlib_node_registration_t lisp_gpe_ip4_input_node
(constructor) VLIB_REGISTER_NODE (lisp_gpe_ip4_input_node)
Definition: decap.c:461
#define gid_address_type(_a)
Definition: lisp_types.h:261
static clib_error_t * gpe_native_forward_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI command to add action for native forward.
Definition: lisp_gpe.c:483
a
Definition: bitmap.h:516
u8 vnet_lisp_gpe_enable_disable_status(void)
Check if LISP-GPE is enabled.
Definition: lisp_gpe.c:184
A representation of a path as described by a route producer.
Definition: fib_types.h:377
int fib_route_path_cmp(const fib_route_path_t *rpath1, const fib_route_path_t *rpath2)
Definition: fib_types.c:188
vnet_main_t * vnet_get_main(void)
Definition: misc.c:47
void ip_prefix_to_fib_prefix(const ip_prefix_t *ip_prefix, fib_prefix_t *fib_prefix)
convert from a LISP to a FIB prefix
Definition: control.c:167
void vnet_lisp_gpe_fwd_entry_flush(void)
Flush all the forwrding entries.
fib_node_index_t fib_table_entry_update(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, fib_route_path_t *paths)
Update an entry to have a new set of paths.
Definition: fib_table.c:706
clib_error_t * vnet_lisp_gpe_enable_disable(vnet_lisp_gpe_enable_disable_args_t *a)
Enable/disable LISP-GPE.
Definition: lisp_gpe.c:193
#define NULL
Definition: clib.h:55
u32 index
Definition: node.h:237
LISP-GPE global state.
Definition: lisp_gpe.h:118
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
uword unformat_ip_address(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:164
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:518
LISP-GPE definitions.
lisp_gpe_fwd_entry_key_t * key
The Entry&#39;s key: {lEID,rEID,vni}.
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:983
format_function_t format_ip46_address
Definition: format.h:61
ip_lookup_main_t lookup_main
Definition: ip4.h:97
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
dpo_proto_t frp_proto
The protocol of the address below.
Definition: fib_types.h:382
unformat_function_t unformat_vnet_sw_interface
void ip_address_copy(ip_address_t *dst, const ip_address_t *src)
Definition: lisp_types.c:886
vlib_main_t * vlib_main
convenience
Definition: lisp_gpe.h:171
ip_prefix_t ippref
Definition: lisp_types.h:122
uword unformat_negative_mapping_action(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:391
static lisp_gpe_main_t * vnet_lisp_gpe_get_main()
Definition: lisp_gpe.h:183
PCAP main state data structure.
Definition: pcap.h:124
void gpe_update_native_fwd_path(u8 ip_version)
Definition: lisp_gpe.c:433
unformat_function_t unformat_ip4_address
Definition: format.h:76
u32 frp_sw_if_index
The interface.
Definition: fib_types.h:412
ip6_main_t * im6
Definition: lisp_gpe.h:174
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:111
static clib_error_t * gpe_set_encap_mode_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI command to set GPE encap.
Definition: lisp_gpe.c:233
vlib_combined_counter_main_t counters
Definition: lisp_gpe.h:164
LISP-GPE fwd entry key.
u8 is_add
Definition: lisp_gpe.h:234
Aggregrate type for a prefix.
Definition: fib_types.h:172
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
Definition: main.c:182
#define clib_error_return(e, args...)
Definition: error.h:99
uword * lisp_gpe_fwd_entries
DB of all forwarding entries.
Definition: lisp_gpe.h:124
#define clib_error_create(args...)
Definition: error.h:96
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
Definition: fib_table.c:1028
fib_protocol_t dpo_proto_to_fib(dpo_proto_t dpo_proto)
Definition: fib_types.c:227
#define vlib_call_init_function(vm, x)
Definition: init.h:162
enum gpe_encap_mode_e gpe_encap_mode_t
dp_address_t rmt
Definition: lisp_gpe.h:227
Common utility functions for IPv4, IPv6 and L2 LISP-GPE adjacencys.
Definition: fib_entry.h:238
unformat_function_t unformat_line_input
Definition: format.h:281
vlib_node_registration_t lisp_gpe_ip6_input_node
(constructor) VLIB_REGISTER_NODE (lisp_gpe_ip6_input_node)
Definition: decap.c:483
#define hash_create_mem(elts, key_bytes, value_bytes)
Definition: hash.h:660
#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:459
u32 table_id
table (vrf) id
Definition: lisp_gpe.h:267
static void * vlib_buffer_put_uninit(vlib_buffer_t *b, u8 size)
Append uninitialized data to buffer.
Definition: buffer.h:278
struct _unformat_input_t unformat_input_t
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
Definition: main.c:191
uword unformat_gid_address(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:350
#define vec_del1(v, i)
Delete the element at index I.
Definition: vec.h:801
ip_address_t lcl_loc
Definition: lisp_types.h:386
int vnet_gpe_add_del_native_fwd_rpath(vnet_gpe_native_fwd_rpath_args_t *a)
Definition: lisp_gpe.c:451
clib_error_t * pcap_read(pcap_main_t *pm)
Read PCAP file.
Definition: pcap.c:178
u8 is_negative
type of mapping
Definition: lisp_gpe.h:237
unformat_function_t unformat_ip6_address
Definition: format.h:94
u32 vni
VNI/tenant id in HOST byte order.
Definition: lisp_gpe.h:261
clib_error_t * ip_main_init(vlib_main_t *vm)
Definition: ip_init.c:45
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
u16 n_vectors
Definition: node.h:344
vlib_main_t * vm
Definition: buffer.c:283
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:336
static clib_error_t * lisp_show_iface_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI command to show LISP-GPE interfaces.
Definition: lisp_gpe.c:358
tunnel_lookup_t l2_ifaces
Definition: lisp_gpe.h:146
vnet_main_t * vnet_main
Definition: lisp_gpe.h:172
void lisp_gpe_tenant_flush(void)
Flush/delete ALL the tenants.
#define clib_memcpy(a, b, c)
Definition: string.h:75
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
Definition: node.c:45
lisp_gpe_main_t lisp_gpe_main
LISP-GPE global state.
Definition: lisp_gpe.c:30
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:154
int vnet_lisp_gpe_add_del_fwd_entry(vnet_lisp_gpe_add_del_fwd_entry_args_t *a, u32 *hw_if_indexp)
Forwarding entry create/remove dispatcher.
struct _gid_address_t gid_address_t
u8 * format_vnet_lisp_gpe_status(u8 *s, va_list *args)
Format LISP-GPE status.
Definition: lisp_gpe.c:585
gpe_encap_mode_t vnet_gpe_get_encap_mode(void)
Definition: lisp_gpe.c:629
unsigned int u32
Definition: types.h:88
ip6_main_t ip6_main
Definition: ip6_forward.c:3009
ip_lookup_main_t lookup_main
Definition: ip6.h:158
clib_error_t * lisp_gpe_init(vlib_main_t *vm)
LISP-GPE init function.
Definition: lisp_gpe.c:593
gpe_encap_mode_t encap_mode
Definition: lisp_gpe.h:160
uword * hw_if_index_by_dp_table
Lookup lisp-gpe interfaces by dp table (eg.
Definition: lisp_gpe.h:84
static clib_error_t * lisp_gpe_test_send_nsh_packet(u8 *file_name)
Definition: lisp_gpe.c:636
static clib_error_t * gpe_show_native_fwd_rpath_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI command to show GPE fwd native route path.
Definition: lisp_gpe.c:395
int vnet_gpe_set_encap_mode(gpe_encap_mode_t mode)
Set GPE encapsulation mode.
Definition: lisp_gpe.c:217
gid_address_t rmt_eid
remote eid
Definition: lisp_gpe.h:246
clib_error_t * ip4_lookup_init(vlib_main_t *vm)
Definition: ip4_forward.c:1184
u64 uword
Definition: types.h:112
#define unformat_parse_error(input)
Definition: format.h:267
static clib_error_t * gpe_show_encap_mode_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI command to show GPE encap.
Definition: lisp_gpe.c:295
Definition: defs.h:47
negative_fwd_actions_e action
action for negative mappings
Definition: lisp_gpe.h:240
#define gid_address_vni(_a)
Definition: lisp_types.h:271
u32 eid_fib_index
The FIB index for the overlay, i.e.
struct lisp_gpe_fwd_entry_t_ * lisp_fwd_entry_pool
A Pool of all LISP forwarding entries.
Definition: lisp_gpe.h:129
static clib_error_t * lisp_gpe_enable_disable_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI command to enable/disable LISP-GPE.
Definition: lisp_gpe.c:313
ip_lookup_main_t * lm4
Definition: lisp_gpe.h:175
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
tunnel_lookup_t l3_ifaces
Definition: lisp_gpe.h:138
ip4_main_t * im4
Definition: lisp_gpe.h:173
#define hash_foreach_pair(p, v, body)
Iterate over hash pairs.
Definition: hash.h:372
static void unformat_free(unformat_input_t *i)
Definition: format.h:161
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:267
locator_pair_t * locator_pairs
vector of locator pairs
Definition: lisp_gpe.h:249
char * name
The counter collection&#39;s name.
Definition: counter.h:185
void gid_address_copy(gid_address_t *dst, gid_address_t *src)
Definition: lisp_types.c:1495
Definition: lisp_types.h:37
#define vnet_buffer(b)
Definition: buffer.h:326
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
fib_route_path_t * native_fwd_rpath[2]
Native fwd data structures.
Definition: lisp_gpe.h:167
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1181
LISP.
Definition: fib_entry.h:78
ip_address_t rmt_loc
Definition: lisp_types.h:387
#define vec_foreach(var, vec)
Vector iterator.
static void * vlib_buffer_pull(vlib_buffer_t *b, u8 size)
Retrieve bytes from buffer head.
Definition: buffer.h:320
u8 ** packets_read
Packets read from file.
Definition: pcap.h:152
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:492
uword * lisp_stats_index_by_key
Definition: lisp_gpe.h:163
ip_lookup_main_t * lm6
Definition: lisp_gpe.h:176
Definition: lisp_types.h:38
u8 * format_vnet_gpe_encap_mode(u8 *s, va_list *args)
Format GPE encap mode.
Definition: lisp_gpe.c:277
u8 frp_weight
[un]equal cost path weight
Definition: fib_types.h:459
static u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
Definition: buffer_funcs.h:341
gid_address_t lcl_eid
local eid
Definition: lisp_gpe.h:243
tunnel_lookup_t nsh_ifaces
Definition: lisp_gpe.h:156
u32 * native_fwd_lfes[2]
Definition: lisp_gpe.h:168
u32 frp_fib_index
The FIB index to lookup the nexthop Only valid for recursive paths.
Definition: fib_types.h:423
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:680
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:57
LISP-GPE definitions.
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:169
static clib_error_t * lisp_gpe_add_del_fwd_entry_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI command to add/del forwarding entry.
Definition: lisp_gpe.c:35
A LISP Forwarding Entry.
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:128