FD.io VPP  v20.01-48-g3e0dafb74
Vector Packet Processing
one_cli.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 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 #include <vnet/lisp-cp/control.h>
17 #include <vnet/lisp-gpe/lisp_gpe.h>
18 
19 static clib_error_t *
21  unformat_input_t * input,
22  vlib_cli_command_t * cmd)
23 {
24  lisp_adjacency_t *adjs, *adj;
25  vlib_cli_output (vm, "%s %40s\n", "leid", "reid");
26  unformat_input_t _line_input, *line_input = &_line_input;
27  u32 vni = ~0;
28 
29  /* Get a line of input. */
30  if (!unformat_user (input, unformat_line_input, line_input))
31  return 0;
32 
33  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
34  {
35  if (unformat (line_input, "vni %d", &vni))
36  ;
37  else
38  {
39  vlib_cli_output (vm, "parse error: '%U'",
40  format_unformat_error, line_input);
41  unformat_free (line_input);
42  return 0;
43  }
44  }
45  unformat_free (line_input);
46 
47  if (~0 == vni)
48  {
49  vlib_cli_output (vm, "error: no vni specified!");
50  return 0;
51  }
52 
54 
55  vec_foreach (adj, adjs)
56  {
57  vlib_cli_output (vm, "%U %40U\n", format_gid_address, &adj->leid,
58  format_gid_address, &adj->reid);
59  }
60  vec_free (adjs);
61 
62  return 0;
63 }
64 
65 /* *INDENT-OFF* */
66 VLIB_CLI_COMMAND (one_show_adjacencies_command) = {
67  .path = "show one adjacencies",
68  .short_help = "show one adjacencies",
70 };
71 /* *INDENT-ON* */
72 
73 static clib_error_t *
75  unformat_input_t * input,
76  vlib_cli_command_t * cmd)
77 {
78  int rv = 0;
79  u8 is_add = 1, ip_set = 0;
81  unformat_input_t _line_input, *line_input = &_line_input;
82 
83  /* Get a line of input. */
84  if (!unformat_user (input, unformat_line_input, line_input))
85  return 0;
86 
87  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
88  {
89  if (unformat (line_input, "add"))
90  is_add = 1;
91  else if (unformat (line_input, "del"))
92  is_add = 0;
93  else if (unformat (line_input, "%U", unformat_ip_address, &ip))
94  ip_set = 1;
95  else
96  {
97  vlib_cli_output (vm, "parse error: '%U'",
98  format_unformat_error, line_input);
99  unformat_free (line_input);
100  return 0;
101  }
102  }
103  unformat_free (line_input);
104 
105  if (!ip_set)
106  {
107  vlib_cli_output (vm, "map-server ip address not set!");
108  return 0;
109  }
110 
111  rv = vnet_lisp_add_del_map_server (&ip, is_add);
112  if (!rv)
113  vlib_cli_output (vm, "failed to %s map-server!",
114  is_add ? "add" : "delete");
115 
116  return 0;
117 }
118 
119 /* *INDENT-OFF* */
120 VLIB_CLI_COMMAND (one_add_del_map_server_command) = {
121  .path = "one map-server",
122  .short_help = "one map-server add|del <ip>",
124 };
125 /* *INDENT-ON* */
126 
127 
128 static clib_error_t *
130  vlib_cli_command_t * cmd)
131 {
133  unformat_input_t _line_input, *line_input = &_line_input;
134  u8 is_add = 1;
135  gid_address_t eid;
136  gid_address_t *eids = 0;
137  clib_error_t *error = 0;
138  u8 *locator_set_name = 0;
139  u32 locator_set_index = 0, map_index = 0;
140  uword *p;
142  int rv = 0;
143  u32 vni = 0;
144  u8 *key = 0;
145  u32 key_id = 0;
146 
147  clib_memset (&eid, 0, sizeof (eid));
148  clib_memset (a, 0, sizeof (*a));
149 
150  /* Get a line of input. */
151  if (!unformat_user (input, unformat_line_input, line_input))
152  return 0;
153 
154  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
155  {
156  if (unformat (line_input, "add"))
157  is_add = 1;
158  else if (unformat (line_input, "del"))
159  is_add = 0;
160  else if (unformat (line_input, "eid %U", unformat_gid_address, &eid))
161  ;
162  else if (unformat (line_input, "vni %d", &vni))
163  gid_address_vni (&eid) = vni;
164  else if (unformat (line_input, "secret-key %_%v%_", &key))
165  ;
166  else if (unformat (line_input, "key-id %U", unformat_hmac_key_id,
167  &key_id))
168  ;
169  else if (unformat (line_input, "locator-set %_%v%_", &locator_set_name))
170  {
171  vec_terminate_c_string (locator_set_name);
172  p = hash_get_mem (lcm->locator_set_index_by_name, locator_set_name);
173  if (!p)
174  {
175  error = clib_error_return (0, "locator-set %s doesn't exist",
176  locator_set_name);
177  goto done;
178  }
179  locator_set_index = p[0];
180  }
181  else if (unformat (line_input, "authoritative"))
182  a->authoritative = 1;
183  else
184  {
185  error = unformat_parse_error (line_input);
186  goto done;
187  }
188  }
189  /* XXX treat batch configuration */
190 
191  if (GID_ADDR_SRC_DST == gid_address_type (&eid))
192  {
193  error =
194  clib_error_return (0, "src/dst is not supported for local EIDs!");
195  goto done;
196  }
197 
198  if (key && (0 == key_id))
199  {
200  vlib_cli_output (vm, "invalid key_id!");
201  goto done;
202  }
203 
204  gid_address_copy (&a->eid, &eid);
205  a->is_add = is_add;
206  a->locator_set_index = locator_set_index;
207  a->local = 1;
208  a->key = key;
209  a->key_id = key_id;
210 
211  rv = vnet_lisp_add_del_local_mapping (a, &map_index);
212  if (0 != rv)
213  {
214  error = clib_error_return (0, "failed to %s local mapping!",
215  is_add ? "add" : "delete");
216  }
217 done:
218  vec_free (eids);
219  if (locator_set_name)
220  vec_free (locator_set_name);
221  gid_address_free (&a->eid);
222  vec_free (a->key);
223  unformat_free (line_input);
224  return error;
225 }
226 
227 /* *INDENT-OFF* */
228 VLIB_CLI_COMMAND (one_add_del_local_eid_command) = {
229  .path = "one eid-table",
230  .short_help = "one eid-table add/del [vni <vni>] eid <eid> "
231  "locator-set <locator-set> [key <secret-key> key-id sha1|sha256 ]",
233 };
234 /* *INDENT-ON* */
235 
236 static clib_error_t *
238  unformat_input_t * input,
239  vlib_cli_command_t * cmd)
240 {
241  u8 is_add = 1, is_l2 = 0;
242  u32 vni = 0, dp_id = 0;
243  unformat_input_t _line_input, *line_input = &_line_input;
244  clib_error_t *error = NULL;
245 
246  /* Get a line of input. */
247  if (!unformat_user (input, unformat_line_input, line_input))
248  return 0;
249 
250  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
251  {
252  if (unformat (line_input, "del"))
253  is_add = 0;
254  else if (unformat (line_input, "vni %d", &vni))
255  ;
256  else if (unformat (line_input, "vrf %d", &dp_id))
257  ;
258  else if (unformat (line_input, "bd %d", &dp_id))
259  is_l2 = 1;
260  else
261  {
262  error = unformat_parse_error (line_input);
263  goto done;
264  }
265  }
266  vnet_lisp_eid_table_map (vni, dp_id, is_l2, is_add);
267 
268 done:
269  unformat_free (line_input);
270 
271  return error;
272 }
273 
274 /* *INDENT-OFF* */
275 VLIB_CLI_COMMAND (one_eid_table_map_command) = {
276  .path = "one eid-table map",
277  .short_help = "one eid-table map [del] vni <vni> vrf <vrf> | bd <bdi>",
278  .function = lisp_eid_table_map_command_fn,
279 };
280 /* *INDENT-ON* */
281 
282 static clib_error_t *
284  unformat_input_t * input,
285  vlib_cli_command_t * cmd)
286 {
287  unformat_input_t _line_input, *line_input = &_line_input;
288  clib_error_t *error = NULL;
289  int rc = 0;
290  u8 hw_addr[6], bd = 0;
292  u32 hw_addr_set = 0, ip_set = 0, is_add = 1;
293  gid_address_t _g, *g = &_g;
294 
295  clib_memset (&ip6, 0, sizeof (ip6));
296  clib_memset (hw_addr, 0, sizeof (hw_addr));
297  clib_memset (g, 0, sizeof (*g));
298 
299  if (!unformat_user (input, unformat_line_input, line_input))
300  return 0;
301 
302  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
303  {
304  if (unformat (line_input, "mac %U", unformat_mac_address, hw_addr))
305  hw_addr_set = 1;
306  else if (unformat (line_input, "ip %U", unformat_ip6_address, &ip6))
307  ip_set = 1;
308  else if (unformat (line_input, "del"))
309  is_add = 0;
310  else if (unformat (line_input, "bd %d", &bd))
311  ;
312  else
313  {
314  error = clib_error_return (0, "parse error");
315  goto done;
316  }
317  }
318 
319  if (!ip_set || (!hw_addr_set && is_add))
320  {
321  vlib_cli_output (vm, "expected IP and MAC addresses!");
322  return 0;
323  }
324 
325  /* build GID address */
327  gid_address_ndp_bd (g) = bd;
329  rc = vnet_lisp_add_del_l2_arp_ndp_entry (g, hw_addr, is_add);
330  if (rc)
331  clib_warning ("Failed to %s ndp entry!", is_add ? "add" : "delete");
332 
333 done:
334  unformat_free (line_input);
335  return error;
336 }
337 
338 /* *INDENT-OFF* */
339 VLIB_CLI_COMMAND (one_add_del_ndp_entry_command) = {
340  .path = "one ndp",
341  .short_help = "one ndp [del] bd <bd> mac <mac> ip <ipv6>",
343 };
344 /* *INDENT-ON* */
345 
346 static clib_error_t *
348  unformat_input_t * input,
349  vlib_cli_command_t * cmd)
350 {
351  unformat_input_t _line_input, *line_input = &_line_input;
352  clib_error_t *error = NULL;
353  int rc = 0;
354  u8 hw_addr[6], bd = 0;
356  u32 hw_addr_set = 0, ip_set = 0, is_add = 1;
357  gid_address_t _arp, *arp = &_arp;
358 
359  clib_memset (&ip4, 0, sizeof (ip4));
360  clib_memset (hw_addr, 0, sizeof (hw_addr));
361  clib_memset (arp, 0, sizeof (*arp));
362 
363  if (!unformat_user (input, unformat_line_input, line_input))
364  return 0;
365 
366  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
367  {
368  if (unformat (line_input, "mac %U", unformat_mac_address, hw_addr))
369  hw_addr_set = 1;
370  else if (unformat (line_input, "ip %U", unformat_ip4_address, &ip4))
371  ip_set = 1;
372  else if (unformat (line_input, "del"))
373  is_add = 0;
374  else if (unformat (line_input, "bd %d", &bd))
375  ;
376  else
377  {
378  error = clib_error_return (0, "parse error");
379  goto done;
380  }
381  }
382 
383  if (!ip_set || (!hw_addr_set && is_add))
384  {
385  vlib_cli_output (vm, "expected IP and MAC addresses!");
386  return 0;
387  }
388 
389  /* build GID address */
390  gid_address_arp_ip4 (arp) = ip4;
391  gid_address_arp_bd (arp) = bd;
393  rc = vnet_lisp_add_del_l2_arp_ndp_entry (arp, hw_addr, is_add);
394  if (rc)
395  clib_warning ("Failed to %s l2 arp entry!", is_add ? "add" : "delete");
396 
397 done:
398  unformat_free (line_input);
399  return error;
400 }
401 
402 /* *INDENT-OFF* */
403 VLIB_CLI_COMMAND (one_add_del_l2_arp_entry_command) = {
404  .path = "one l2 arp",
405  .short_help = "one l2 arp [del] bd <bd> mac <mac> ip <ipv4>",
407 };
408 /* *INDENT-ON* */
409 
410 static clib_error_t *
412  unformat_input_t * input,
413  vlib_cli_command_t * cmd)
414 {
415  u32 *ht = vnet_lisp_l2_arp_bds_get ();
417  hash_pair_t *p;
418 
419  /* *INDENT-OFF* */
420  hash_foreach_pair (p, ht,
421  ({
423  vlib_cli_output (vm, "Table: %d", p->key);
424 
425  vec_foreach (e, entries)
426  {
427  vlib_cli_output (vm, "\t%U -> %U", format_ip4_address, &e->ip4,
428  format_mac_address, e->mac);
429  }
430  vec_free (entries);
431  }));
432  /* *INDENT-ON* */
433 
434  hash_free (ht);
435  return 0;
436 }
437 
438 /* *INDENT-OFF* */
439 VLIB_CLI_COMMAND (one_show_l2_arp_entries_command) = {
440  .path = "show one l2 arp entries",
441  .short_help = "Show ONE L2 ARP entries",
443 };
444 /* *INDENT-ON* */
445 
446 static clib_error_t *
448  unformat_input_t * input,
449  vlib_cli_command_t * cmd)
450 {
451  u32 *ht = vnet_lisp_ndp_bds_get ();
453  hash_pair_t *p;
454 
455  /* *INDENT-OFF* */
456  hash_foreach_pair (p, ht,
457  ({
458  entries = vnet_lisp_ndp_entries_get_by_bd (p->key);
459  vlib_cli_output (vm, "Table: %d", p->key);
460 
461  vec_foreach (e, entries)
462  {
463  vlib_cli_output (vm, "\t%U -> %U", format_ip6_address, &e->ip6,
464  format_mac_address, e->mac);
465  }
466  vec_free (entries);
467  }));
468  /* *INDENT-ON* */
469 
470  hash_free (ht);
471  return 0;
472 }
473 
474 /* *INDENT-OFF* */
475 VLIB_CLI_COMMAND (one_show_ndp_entries_command) = {
476  .path = "show one ndp entries",
477  .short_help = "Show ONE NDP entries",
479 };
480 /* *INDENT-ON* */
481 
482 /**
483  * Handler for add/del remote mapping CLI.
484  *
485  * @param vm vlib context
486  * @param input input from user
487  * @param cmd cmd
488  * @return pointer to clib error structure
489  */
490 static clib_error_t *
492  unformat_input_t * input,
493  vlib_cli_command_t * cmd)
494 {
495  clib_error_t *error = 0;
496  unformat_input_t _line_input, *line_input = &_line_input;
497  u8 is_add = 1, del_all = 0;
498  locator_t rloc, *rlocs = 0, *curr_rloc = 0;
499  gid_address_t eid;
500  u8 eid_set = 0;
501  u32 vni, action = ~0, p, w;
502  int rv;
503 
504  /* Get a line of input. */
505  if (!unformat_user (input, unformat_line_input, line_input))
506  return 0;
507 
508  clib_memset (&eid, 0, sizeof (eid));
509  clib_memset (&rloc, 0, sizeof (rloc));
510 
511  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
512  {
513  if (unformat (line_input, "del-all"))
514  del_all = 1;
515  else if (unformat (line_input, "del"))
516  is_add = 0;
517  else if (unformat (line_input, "add"))
518  ;
519  else if (unformat (line_input, "eid %U", unformat_gid_address, &eid))
520  eid_set = 1;
521  else if (unformat (line_input, "vni %u", &vni))
522  {
523  gid_address_vni (&eid) = vni;
524  }
525  else if (unformat (line_input, "p %d w %d", &p, &w))
526  {
527  if (!curr_rloc)
528  {
530  ("No RLOC configured for setting priority/weight!");
531  goto done;
532  }
533  curr_rloc->priority = p;
534  curr_rloc->weight = w;
535  }
536  else if (unformat (line_input, "rloc %U", unformat_ip_address,
537  &gid_address_ip (&rloc.address)))
538  {
539  /* since rloc is stored in ip prefix we need to set prefix length */
540  ip_prefix_t *pref = &gid_address_ippref (&rloc.address);
541 
543  ip_prefix_len (pref) = ip_address_max_len (version);
544 
545  vec_add1 (rlocs, rloc);
546  curr_rloc = &rlocs[vec_len (rlocs) - 1];
547  }
548  else if (unformat (line_input, "action %U",
550  ;
551  else
552  {
553  clib_warning ("parse error");
554  goto done;
555  }
556  }
557 
558  if (!del_all && !eid_set)
559  {
560  clib_warning ("missing eid!");
561  goto done;
562  }
563 
564  if (!del_all)
565  {
566  if (is_add && (~0 == action) && 0 == vec_len (rlocs))
567  {
568  clib_warning ("no action set for negative map-reply!");
569  goto done;
570  }
571  }
572  else
573  {
575  goto done;
576  }
577 
578  /* if it's a delete, clean forwarding */
579  if (!is_add)
580  {
582  clib_memset (a, 0, sizeof (a[0]));
583  gid_address_copy (&a->reid, &eid);
585  {
586  clib_warning ("failed to delete adjacency!");
587  goto done;
588  }
589  }
590 
591  /* add as static remote mapping, i.e., not authoritative and infinite
592  * ttl */
593  if (is_add)
594  {
595  vnet_lisp_add_del_mapping_args_t _map_args, *map_args = &_map_args;
596  clib_memset (map_args, 0, sizeof (map_args[0]));
597  gid_address_copy (&map_args->eid, &eid);
598  map_args->action = action;
599  map_args->is_static = 1;
600  map_args->authoritative = 0;
601  map_args->ttl = ~0;
602  rv = vnet_lisp_add_mapping (map_args, rlocs, NULL, NULL);
603  }
604  else
605  rv = vnet_lisp_del_mapping (&eid, NULL);
606 
607  if (rv)
608  clib_warning ("failed to %s remote mapping!", is_add ? "add" : "delete");
609 
610 done:
611  vec_free (rlocs);
612  unformat_free (line_input);
613  return error;
614 }
615 
616 /* *INDENT-OFF* */
617 VLIB_CLI_COMMAND (one_add_del_remote_mapping_command) = {
618  .path = "one remote-mapping",
619  .short_help =
620  "one remote-mapping add|del [del-all] vni <vni> "
621  "eid <est-eid> [action <no-action|natively-forward|"
622  "send-map-request|drop>] rloc <dst-locator> p <prio> w <weight> "
623  "[rloc <dst-locator> ... ]",
625 };
626 /* *INDENT-ON* */
627 
628 /**
629  * Handler for add/del adjacency CLI.
630  */
631 static clib_error_t *
633  vlib_cli_command_t * cmd)
634 {
635  clib_error_t *error = 0;
636  unformat_input_t _line_input, *line_input = &_line_input;
638  u8 is_add = 1;
639  ip_prefix_t *reid_ippref, *leid_ippref;
641  u8 *dmac = gid_address_mac (&reid);
642  u8 *smac = gid_address_mac (&leid);
643  u8 reid_set = 0, leid_set = 0;
644  u32 vni;
645 
646  /* Get a line of input. */
647  if (!unformat_user (input, unformat_line_input, line_input))
648  return 0;
649 
650  clib_memset (&reid, 0, sizeof (reid));
651  clib_memset (&leid, 0, sizeof (leid));
652 
653  leid_ippref = &gid_address_ippref (&leid);
654  reid_ippref = &gid_address_ippref (&reid);
655 
656  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
657  {
658  if (unformat (line_input, "del"))
659  is_add = 0;
660  else if (unformat (line_input, "add"))
661  ;
662  else if (unformat (line_input, "reid %U",
663  unformat_ip_prefix, reid_ippref))
664  {
666  reid_set = 1;
667  }
668  else if (unformat (line_input, "reid %U", unformat_mac_address, dmac))
669  {
670  gid_address_type (&reid) = GID_ADDR_MAC;
671  reid_set = 1;
672  }
673  else if (unformat (line_input, "vni %u", &vni))
674  {
675  gid_address_vni (&leid) = vni;
676  gid_address_vni (&reid) = vni;
677  }
678  else if (unformat (line_input, "leid %U",
679  unformat_ip_prefix, leid_ippref))
680  {
682  leid_set = 1;
683  }
684  else if (unformat (line_input, "leid %U", unformat_mac_address, smac))
685  {
686  gid_address_type (&leid) = GID_ADDR_MAC;
687  leid_set = 1;
688  }
689  else
690  {
691  clib_warning ("parse error");
692  goto done;
693  }
694  }
695 
696  if (!reid_set || !leid_set)
697  {
698  clib_warning ("missing remote or local eid!");
699  goto done;
700  }
701 
702  if ((gid_address_type (&leid) != gid_address_type (&reid))
703  || (gid_address_type (&reid) == GID_ADDR_IP_PREFIX
704  && ip_prefix_version (reid_ippref)
705  != ip_prefix_version (leid_ippref)))
706  {
707  clib_warning ("remote and local EIDs are of different types!");
708  goto done;
709  }
710 
711  clib_memset (a, 0, sizeof (a[0]));
712  gid_address_copy (&a->leid, &leid);
713  gid_address_copy (&a->reid, &reid);
714  a->is_add = is_add;
715 
717  clib_warning ("failed to %s adjacency!", is_add ? "add" : "delete");
718 
719 done:
720  unformat_free (line_input);
721  return error;
722 }
723 
724 /* *INDENT-OFF* */
725 VLIB_CLI_COMMAND (one_add_del_adjacency_command) = {
726  .path = "one adjacency",
727  .short_help = "one adjacency add|del vni <vni> reid <remote-eid> "
728  "leid <local-eid>",
730 };
731 /* *INDENT-ON* */
732 
733 
734 static clib_error_t *
736  unformat_input_t * input,
737  vlib_cli_command_t * cmd)
738 {
739  unformat_input_t _i, *i = &_i;
740  map_request_mode_t mr_mode = _MR_MODE_MAX;
741 
742  /* Get a line of input. */
743  if (!unformat_user (input, unformat_line_input, i))
744  return 0;
745 
747  {
748  if (unformat (i, "dst-only"))
749  mr_mode = MR_MODE_DST_ONLY;
750  else if (unformat (i, "src-dst"))
751  mr_mode = MR_MODE_SRC_DST;
752  else
753  {
754  clib_warning ("parse error '%U'", format_unformat_error, i);
755  goto done;
756  }
757  }
758 
759  if (_MR_MODE_MAX == mr_mode)
760  {
761  clib_warning ("No map request mode entered!");
762  goto done;
763  }
764 
766 
767 done:
768  unformat_free (i);
769 
770  return 0;
771 }
772 
773 /* *INDENT-OFF* */
774 VLIB_CLI_COMMAND (one_map_request_mode_command) = {
775  .path = "one map-request mode",
776  .short_help = "one map-request mode dst-only|src-dst",
778 };
779 /* *INDENT-ON* */
780 
781 
782 static u8 *
783 format_lisp_map_request_mode (u8 * s, va_list * args)
784 {
785  u32 mode = va_arg (*args, u32);
786 
787  switch (mode)
788  {
789  case 0:
790  return format (0, "dst-only");
791  case 1:
792  return format (0, "src-dst");
793  }
794  return 0;
795 }
796 
797 static clib_error_t *
799  unformat_input_t * input,
800  vlib_cli_command_t * cmd)
801 {
802  vlib_cli_output (vm, "map-request mode: %U", format_lisp_map_request_mode,
804  return 0;
805 }
806 
807 /* *INDENT-OFF* */
808 VLIB_CLI_COMMAND (one_show_map_request_mode_command) = {
809  .path = "show one map-request mode",
810  .short_help = "show one map-request mode",
812 };
813 /* *INDENT-ON* */
814 
815 static clib_error_t *
817  unformat_input_t * input,
818  vlib_cli_command_t * cmd)
819 {
820  lisp_msmr_t *mr;
822 
823  vec_foreach (mr, lcm->map_resolvers)
824  {
825  vlib_cli_output (vm, "%U", format_ip_address, &mr->address);
826  }
827  return 0;
828 }
829 
830 /* *INDENT-OFF* */
831 VLIB_CLI_COMMAND (one_show_map_resolvers_command) = {
832  .path = "show one map-resolvers",
833  .short_help = "show one map-resolvers",
835 };
836 /* *INDENT-ON* */
837 
838 static clib_error_t *
840  unformat_input_t * input,
841  vlib_cli_command_t * cmd)
842 {
843  u8 locator_name_set = 0;
844  u8 *locator_set_name = 0;
845  u8 is_add = 1;
846  unformat_input_t _line_input, *line_input = &_line_input;
847  clib_error_t *error = 0;
848  int rv = 0;
849 
850  /* Get a line of input. */
851  if (!unformat_user (input, unformat_line_input, line_input))
852  return 0;
853 
854  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
855  {
856  if (unformat (line_input, "ls %_%v%_", &locator_set_name))
857  locator_name_set = 1;
858  else if (unformat (line_input, "disable"))
859  is_add = 0;
860  else
861  {
862  error = clib_error_return (0, "parse error");
863  goto done;
864  }
865  }
866 
867  if (!locator_name_set)
868  {
869  clib_warning ("No locator set specified!");
870  goto done;
871  }
872 
873  vec_terminate_c_string (locator_set_name);
874  rv = vnet_lisp_nsh_set_locator_set (locator_set_name, is_add);
875  if (0 != rv)
876  {
877  error = clib_error_return (0, "failed to %s NSH mapping!",
878  is_add ? "add" : "delete");
879  }
880 
881 done:
882  vec_free (locator_set_name);
883  unformat_free (line_input);
884  return error;
885 }
886 
887 /* *INDENT-OFF* */
888 VLIB_CLI_COMMAND (one_nsh_set_locator_set_command) = {
889  .path = "one nsh-mapping",
890  .short_help = "one nsh-mapping [del] ls <locator-set-name>",
892 };
893 /* *INDENT-ON* */
894 
895 static clib_error_t *
898  input,
900  cmd)
901 {
903  vlib_cli_output (vm, "map register fallback threshold value: %d", val);
904  return 0;
905 }
906 
907 /* *INDENT-OFF* */
908 VLIB_CLI_COMMAND (one_map_register_fallback_threshold_show_command) = {
909  .path = "show one map-register fallback-threshold",
910  .short_help = "show one map-register fallback-threshold",
912 };
913 
914 /* *INDENT-ON* */
915 
916 static clib_error_t *
918  unformat_input_t * input,
919  vlib_cli_command_t * cmd)
920 {
921  unformat_input_t _line_input, *line_input = &_line_input;
922  clib_error_t *error = 0;
923  u32 val = 0;
924  int rv = 0;
925 
926  /* Get a line of input. */
927  if (!unformat_user (input, unformat_line_input, line_input))
928  return 0;
929 
930  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
931  {
932  if (unformat (line_input, "%d", &val))
933  ;
934  else
935  {
936  error = clib_error_return (0, "parse error");
937  goto done;
938  }
939  }
940 
942  if (rv)
943  {
944  error = clib_error_return (0, "setting fallback threshold failed!");
945  }
946 
947 done:
948  unformat_free (line_input);
949  return error;
950 }
951 
952 /* *INDENT-OFF* */
953 VLIB_CLI_COMMAND (one_map_register_fallback_threshold_command) = {
954  .path = "one map-register fallback-threshold",
955  .short_help = "one map-register fallback-threshold <count>",
957 };
958 /* *INDENT-ON* */
959 
960 static clib_error_t *
962  unformat_input_t * input,
963  vlib_cli_command_t * cmd)
964 {
965  u8 locator_name_set = 0;
966  u8 *locator_set_name = 0;
967  u8 is_add = 1;
968  unformat_input_t _line_input, *line_input = &_line_input;
969  clib_error_t *error = 0;
970  int rv = 0;
971 
972  /* Get a line of input. */
973  if (!unformat_user (input, unformat_line_input, line_input))
974  return 0;
975 
976  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
977  {
978  if (unformat (line_input, "ls %_%v%_", &locator_set_name))
979  locator_name_set = 1;
980  else if (unformat (line_input, "disable"))
981  is_add = 0;
982  else
983  {
984  error = clib_error_return (0, "parse error");
985  goto done;
986  }
987  }
988 
989  if (!locator_name_set)
990  {
991  clib_warning ("No locator set specified!");
992  goto done;
993  }
994  vec_terminate_c_string (locator_set_name);
995  rv = vnet_lisp_pitr_set_locator_set (locator_set_name, is_add);
996  if (0 != rv)
997  {
998  error = clib_error_return (0, "failed to %s pitr!",
999  is_add ? "add" : "delete");
1000  }
1001 
1002 done:
1003  if (locator_set_name)
1004  vec_free (locator_set_name);
1005  unformat_free (line_input);
1006  return error;
1007 }
1008 
1009 /* *INDENT-OFF* */
1010 VLIB_CLI_COMMAND (one_pitr_set_locator_set_command) = {
1011  .path = "one pitr",
1012  .short_help = "one pitr [disable] ls <locator-set-name>",
1014 };
1015 /* *INDENT-ON* */
1016 
1017 static clib_error_t *
1019  unformat_input_t * input, vlib_cli_command_t * cmd)
1020 {
1022  mapping_t *m;
1023  locator_set_t *ls;
1024  u8 *tmp_str = 0;
1025  u8 status = lcm->flags & LISP_FLAG_PITR_MODE;
1026 
1027  vlib_cli_output (vm, "%=20s%=16s", "pitr", status ? "locator-set" : "");
1028 
1029  if (!status)
1030  {
1031  vlib_cli_output (vm, "%=20s", "disable");
1032  return 0;
1033  }
1034 
1035  if (~0 == lcm->pitr_map_index)
1036  {
1037  tmp_str = format (0, "N/A");
1038  }
1039  else
1040  {
1042  if (~0 != m->locator_set_index)
1043  {
1044  ls =
1046  tmp_str = format (0, "%s", ls->name);
1047  }
1048  else
1049  {
1050  tmp_str = format (0, "N/A");
1051  }
1052  }
1053  vec_add1 (tmp_str, 0);
1054 
1055  vlib_cli_output (vm, "%=20s%=16s", "enable", tmp_str);
1056 
1057  vec_free (tmp_str);
1058 
1059  return 0;
1060 }
1061 
1062 /* *INDENT-OFF* */
1063 VLIB_CLI_COMMAND (one_show_pitr_command) = {
1064  .path = "show one pitr",
1065  .short_help = "Show pitr",
1066  .function = lisp_show_pitr_command_fn,
1067 };
1068 /* *INDENT-ON* */
1069 
1070 static u8 *
1071 format_eid_entry (u8 * s, va_list * args)
1072 {
1073  vnet_main_t *vnm = va_arg (*args, vnet_main_t *);
1074  lisp_cp_main_t *lcm = va_arg (*args, lisp_cp_main_t *);
1075  mapping_t *mapit = va_arg (*args, mapping_t *);
1076  locator_set_t *ls = va_arg (*args, locator_set_t *);
1077  gid_address_t *gid = &mapit->eid;
1078  u32 ttl = mapit->ttl;
1079  u8 aut = mapit->authoritative;
1080  u32 *loc_index;
1081  u8 first_line = 1;
1082  u8 *loc;
1083 
1084  u8 *type = ls->local ? format (0, "local(%s)", ls->name)
1085  : format (0, "remote");
1086 
1087  if (vec_len (ls->locator_indices) == 0)
1088  {
1089  s = format (s, "%-35U%-20saction:%-30U%-20u%-u", format_gid_address,
1090  gid, type, format_negative_mapping_action, mapit->action,
1091  ttl, aut);
1092  }
1093  else
1094  {
1095  vec_foreach (loc_index, ls->locator_indices)
1096  {
1097  locator_t *l = pool_elt_at_index (lcm->locator_pool, loc_index[0]);
1098  if (l->local)
1099  loc = format (0, "%U", format_vnet_sw_if_index_name, vnm,
1100  l->sw_if_index);
1101  else
1102  loc = format (0, "%U", format_ip_address,
1103  &gid_address_ip (&l->address));
1104 
1105  if (first_line)
1106  {
1107  s = format (s, "%-35U%-20s%-30v%-20u%-u\n", format_gid_address,
1108  gid, type, loc, ttl, aut);
1109  first_line = 0;
1110  }
1111  else
1112  s = format (s, "%55s%v\n", "", loc);
1113  }
1114  }
1115  return s;
1116 }
1117 
1118 static clib_error_t *
1120  unformat_input_t * input,
1121  vlib_cli_command_t * cmd)
1122 {
1124  mapping_t *mapit;
1125  unformat_input_t _line_input, *line_input = &_line_input;
1126  u32 mi;
1127  gid_address_t eid;
1128  u8 print_all = 1;
1129  u8 filter = 0;
1130  clib_error_t *error = NULL;
1131 
1132  clib_memset (&eid, 0, sizeof (eid));
1133 
1134  /* Get a line of input. */
1135  if (!unformat_user (input, unformat_line_input, line_input))
1136  return 0;
1137 
1138  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1139  {
1140  if (unformat (line_input, "eid %U", unformat_gid_address, &eid))
1141  print_all = 0;
1142  else if (unformat (line_input, "local"))
1143  filter = 1;
1144  else if (unformat (line_input, "remote"))
1145  filter = 2;
1146  else
1147  {
1148  error = clib_error_return (0, "parse error: '%U'",
1149  format_unformat_error, line_input);
1150  goto done;
1151  }
1152  }
1153 
1154  vlib_cli_output (vm, "%-35s%-20s%-30s%-20s%-s",
1155  "EID", "type", "locators", "ttl", "authoritative");
1156 
1157  if (print_all)
1158  {
1159  /* *INDENT-OFF* */
1160  pool_foreach (mapit, lcm->mapping_pool,
1161  ({
1162  if (mapit->pitr_set || mapit->nsh_set)
1163  continue;
1164 
1165  locator_set_t * ls = pool_elt_at_index (lcm->locator_set_pool,
1166  mapit->locator_set_index);
1167  if (filter && !((1 == filter && ls->local) ||
1168  (2 == filter && !ls->local)))
1169  {
1170  continue;
1171  }
1172  vlib_cli_output (vm, "%U", format_eid_entry, lcm->vnet_main,
1173  lcm, mapit, ls);
1174  }));
1175  /* *INDENT-ON* */
1176  }
1177  else
1178  {
1179  mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, &eid);
1180  if ((u32) ~ 0 == mi)
1181  goto done;
1182 
1183  mapit = pool_elt_at_index (lcm->mapping_pool, mi);
1184  locator_set_t *ls = pool_elt_at_index (lcm->locator_set_pool,
1185  mapit->locator_set_index);
1186 
1187  if (filter && !((1 == filter && ls->local) ||
1188  (2 == filter && !ls->local)))
1189  {
1190  goto done;
1191  }
1192 
1193  vlib_cli_output (vm, "%U,", format_eid_entry, lcm->vnet_main,
1194  lcm, mapit, ls);
1195  }
1196 
1197 done:
1198  unformat_free (line_input);
1199 
1200  return error;
1201 }
1202 
1203 /* *INDENT-OFF* */
1204 VLIB_CLI_COMMAND (one_cp_show_eid_table_command) = {
1205  .path = "show one eid-table",
1206  .short_help = "Shows EID table",
1207  .function = lisp_show_eid_table_command_fn,
1208 };
1209 /* *INDENT-ON* */
1210 
1211 static clib_error_t *
1213  unformat_input_t * input,
1214  vlib_cli_command_t * cmd)
1215 {
1216  unformat_input_t _line_input, *line_input = &_line_input;
1217  u8 is_enabled = 0;
1218  u8 is_set = 0;
1219  clib_error_t *error = NULL;
1220 
1221  /* Get a line of input. */
1222  if (!unformat_user (input, unformat_line_input, line_input))
1223  return clib_error_return (0, "expected enable | disable");
1224 
1225  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1226  {
1227  if (unformat (line_input, "enable"))
1228  {
1229  is_set = 1;
1230  is_enabled = 1;
1231  }
1232  else if (unformat (line_input, "disable"))
1233  is_set = 1;
1234  else
1235  {
1236  error = clib_error_return (0, "parse error: '%U'",
1237  format_unformat_error, line_input);
1238  goto done;
1239  }
1240  }
1241 
1242  if (!is_set)
1243  {
1244  error = clib_error_return (0, "state not set");
1245  goto done;
1246  }
1247 
1249 
1250 done:
1251  unformat_free (line_input);
1252 
1253  return error;
1254 }
1255 
1256 /* *INDENT-OFF* */
1257 VLIB_CLI_COMMAND (one_cp_enable_disable_pitr_mode_command) = {
1258  .path = "one pitr mode",
1259  .short_help = "one pitr mode [enable|disable]",
1261 };
1262 /* *INDENT-ON* */
1263 
1264 
1265 static clib_error_t *
1267  unformat_input_t * input,
1268  vlib_cli_command_t * cmd)
1269 {
1270  unformat_input_t _line_input, *line_input = &_line_input;
1271  u8 is_enabled = 0;
1272  u8 is_set = 0;
1273  clib_error_t *error = NULL;
1274 
1275  /* Get a line of input. */
1276  if (!unformat_user (input, unformat_line_input, line_input))
1277  return clib_error_return (0, "expected enable | disable");
1278 
1279  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1280  {
1281  if (unformat (line_input, "enable"))
1282  {
1283  is_set = 1;
1284  is_enabled = 1;
1285  }
1286  else if (unformat (line_input, "disable"))
1287  is_set = 1;
1288  else
1289  {
1290  error = clib_error_return (0, "parse error: '%U'",
1291  format_unformat_error, line_input);
1292  goto done;
1293  }
1294  }
1295 
1296  if (!is_set)
1297  {
1298  error = clib_error_return (0, "state not set");
1299  goto done;
1300  }
1301 
1303 
1304 done:
1305  unformat_free (line_input);
1306 
1307  return error;
1308 }
1309 
1310 /* *INDENT-OFF* */
1311 VLIB_CLI_COMMAND (one_cp_enable_disable_petr_mode_command) = {
1312  .path = "one petr mode",
1313  .short_help = "one petr mode [enable|disable]",
1315 };
1316 /* *INDENT-ON* */
1317 
1318 static clib_error_t *
1320  unformat_input_t * input,
1321  vlib_cli_command_t * cmd)
1322 {
1323  unformat_input_t _line_input, *line_input = &_line_input;
1324  u8 is_enabled = 0;
1325  u8 is_set = 0;
1326  clib_error_t *error = NULL;
1327 
1328  /* Get a line of input. */
1329  if (!unformat_user (input, unformat_line_input, line_input))
1330  return clib_error_return (0, "expected enable | disable");
1331 
1332  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1333  {
1334  if (unformat (line_input, "enable"))
1335  {
1336  is_set = 1;
1337  is_enabled = 1;
1338  }
1339  else if (unformat (line_input, "disable"))
1340  is_set = 1;
1341  else
1342  {
1343  error = clib_error_return (0, "parse error: '%U'",
1344  format_unformat_error, line_input);
1345  goto done;
1346  }
1347  }
1348 
1349  if (!is_set)
1350  {
1351  error = clib_error_return (0, "state not set");
1352  goto done;
1353  }
1354 
1355  vnet_lisp_enable_disable_xtr_mode (is_enabled);
1356 
1357 done:
1358  unformat_free (line_input);
1359 
1360  return error;
1361 }
1362 
1363 /* *INDENT-OFF* */
1364 VLIB_CLI_COMMAND (one_cp_enable_disable_xtr_mode_command) = {
1365  .path = "one xtr mode",
1366  .short_help = "one xtr mode [enable|disable]",
1368 };
1369 /* *INDENT-ON* */
1370 
1371 static clib_error_t *
1373  vlib_cli_command_t * cmd)
1374 {
1375  unformat_input_t _line_input, *line_input = &_line_input;
1376  u8 is_enabled = 0;
1377  u8 is_set = 0;
1378  clib_error_t *error = NULL;
1379 
1380  /* Get a line of input. */
1381  if (!unformat_user (input, unformat_line_input, line_input))
1382  return clib_error_return (0, "expected enable | disable");
1383 
1384  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1385  {
1386  if (unformat (line_input, "enable"))
1387  {
1388  is_set = 1;
1389  is_enabled = 1;
1390  }
1391  else if (unformat (line_input, "disable"))
1392  is_set = 1;
1393  else
1394  {
1395  error = clib_error_return (0, "parse error: '%U'",
1396  format_unformat_error, line_input);
1397  goto done;
1398  }
1399  }
1400 
1401  if (!is_set)
1402  {
1403  error = clib_error_return (0, "state not set");
1404  goto done;
1405  }
1406 
1407  vnet_lisp_enable_disable (is_enabled);
1408 
1409 done:
1410  unformat_free (line_input);
1411 
1412  return error;
1413 }
1414 
1415 /* *INDENT-OFF* */
1416 VLIB_CLI_COMMAND (one_cp_enable_disable_command) = {
1417  .path = "one",
1418  .short_help = "one [enable|disable]",
1419  .function = lisp_enable_disable_command_fn,
1420 };
1421 /* *INDENT-ON* */
1422 
1423 static clib_error_t *
1425  unformat_input_t * input,
1426  vlib_cli_command_t * cmd)
1427 {
1428  unformat_input_t _line_input, *line_input = &_line_input;
1429  u32 ttl = 0;
1430  u8 is_set = 0;
1431  clib_error_t *error = NULL;
1432 
1433  /* Get a line of input. */
1434  if (!unformat_user (input, unformat_line_input, line_input))
1435  return clib_error_return (0, "expected enable | disable");
1436 
1437  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1438  {
1439  if (unformat (line_input, "%u", &ttl))
1440  is_set = 1;
1441  else
1442  {
1443  vlib_cli_output (vm, "parse error: '%U'", format_unformat_error,
1444  line_input);
1445  goto done;
1446  }
1447  }
1448 
1449  if (!is_set)
1450  {
1451  vlib_cli_output (vm, "expected integer value for TTL!");
1452  goto done;
1453  }
1454 
1456 
1457 done:
1458  unformat_free (line_input);
1459  return error;
1460 }
1461 
1462 /* *INDENT-OFF* */
1463 VLIB_CLI_COMMAND (one_map_register_set_ttl_command) = {
1464  .path = "one map-register ttl",
1465  .short_help = "one map-register ttl",
1467 };
1468 /* *INDENT-ON* */
1469 
1470 static clib_error_t *
1472  unformat_input_t * input,
1473  vlib_cli_command_t * cmd)
1474 {
1476 
1477  vlib_cli_output (vm, "map-register TTL: %u", ttl);
1478  return 0;
1479 }
1480 
1481 /* *INDENT-OFF* */
1482 VLIB_CLI_COMMAND (one_map_register_show_ttl_command) = {
1483  .path = "show one map-register ttl",
1484  .short_help = "show one map-register ttl",
1486 };
1487 
1488 /* *INDENT-ON* */
1489 
1490 static clib_error_t *
1492  unformat_input_t * input,
1493  vlib_cli_command_t * cmd)
1494 {
1495  unformat_input_t _line_input, *line_input = &_line_input;
1496  u8 is_enabled = 0;
1497  u8 is_set = 0;
1498  clib_error_t *error = NULL;
1499 
1500  /* Get a line of input. */
1501  if (!unformat_user (input, unformat_line_input, line_input))
1502  return clib_error_return (0, "expected enable | disable");
1503 
1504  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1505  {
1506  if (unformat (line_input, "enable"))
1507  {
1508  is_set = 1;
1509  is_enabled = 1;
1510  }
1511  else if (unformat (line_input, "disable"))
1512  is_set = 1;
1513  else
1514  {
1515  vlib_cli_output (vm, "parse error: '%U'", format_unformat_error,
1516  line_input);
1517  goto done;
1518  }
1519  }
1520 
1521  if (!is_set)
1522  {
1523  vlib_cli_output (vm, "state not set!");
1524  goto done;
1525  }
1526 
1528 
1529 done:
1530  unformat_free (line_input);
1531 
1532  return error;
1533 }
1534 
1535 /* *INDENT-OFF* */
1536 VLIB_CLI_COMMAND (one_map_register_enable_disable_command) = {
1537  .path = "one map-register",
1538  .short_help = "one map-register [enable|disable]",
1540 };
1541 /* *INDENT-ON* */
1542 
1543 static clib_error_t *
1545  unformat_input_t * input,
1546  vlib_cli_command_t * cmd)
1547 {
1548  unformat_input_t _line_input, *line_input = &_line_input;
1549  u8 is_enabled = 0;
1550  u8 is_set = 0;
1551  clib_error_t *error = NULL;
1552 
1553  /* Get a line of input. */
1554  if (!unformat_user (input, unformat_line_input, line_input))
1555  return clib_error_return (0, "expected enable | disable");
1556 
1557  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1558  {
1559  if (unformat (line_input, "enable"))
1560  {
1561  is_set = 1;
1562  is_enabled = 1;
1563  }
1564  else if (unformat (line_input, "disable"))
1565  is_set = 1;
1566  else
1567  {
1568  vlib_cli_output (vm, "parse error: '%U'", format_unformat_error,
1569  line_input);
1570  goto done;
1571  }
1572  }
1573 
1574  if (!is_set)
1575  {
1576  vlib_cli_output (vm, "state not set!");
1577  goto done;
1578  }
1579 
1581 
1582 done:
1583  unformat_free (line_input);
1584 
1585  return error;
1586 }
1587 
1588 /* *INDENT-OFF* */
1589 VLIB_CLI_COMMAND (one_rloc_probe_enable_disable_command) = {
1590  .path = "one rloc-probe",
1591  .short_help = "one rloc-probe [enable|disable]",
1593 };
1594 /* *INDENT-ON* */
1595 
1596 static u8 *
1597 format_lisp_status (u8 * s, va_list * args)
1598 {
1600  return format (s, "%s", lcm->is_enabled ? "enabled" : "disabled");
1601 }
1602 
1603 static clib_error_t *
1605  vlib_cli_command_t * cmd)
1606 {
1607  u8 *msg = 0;
1608  msg = format (msg, "feature: %U\ngpe: %U\n",
1610  vlib_cli_output (vm, "%v", msg);
1611  vec_free (msg);
1612  return 0;
1613 }
1614 
1615 /* *INDENT-OFF* */
1616 VLIB_CLI_COMMAND (one_show_status_command) = {
1617  .path = "show one status",
1618  .short_help = "show one status",
1619  .function = lisp_show_status_command_fn,
1620 };
1621 /* *INDENT-ON* */
1622 
1623 static clib_error_t *
1625  unformat_input_t * input,
1626  vlib_cli_command_t * cmd)
1627 {
1628  hash_pair_t *p;
1629  unformat_input_t _line_input, *line_input = &_line_input;
1631  uword *vni_table = 0;
1632  u8 is_l2 = 0;
1633  clib_error_t *error = NULL;
1634 
1635  /* Get a line of input. */
1636  if (!unformat_user (input, unformat_line_input, line_input))
1637  return 0;
1638 
1639  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1640  {
1641  if (unformat (line_input, "l2"))
1642  {
1643  vni_table = lcm->bd_id_by_vni;
1644  is_l2 = 1;
1645  }
1646  else if (unformat (line_input, "l3"))
1647  {
1648  vni_table = lcm->table_id_by_vni;
1649  is_l2 = 0;
1650  }
1651  else
1652  {
1653  error = clib_error_return (0, "parse error: '%U'",
1654  format_unformat_error, line_input);
1655  goto done;
1656  }
1657  }
1658 
1659  if (!vni_table)
1660  {
1661  vlib_cli_output (vm, "Error: expected l2|l3 param!\n");
1662  goto done;
1663  }
1664 
1665  vlib_cli_output (vm, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
1666 
1667  /* *INDENT-OFF* */
1668  hash_foreach_pair (p, vni_table,
1669  ({
1670  vlib_cli_output (vm, "%=10d%=10d", p->key, p->value[0]);
1671  }));
1672  /* *INDENT-ON* */
1673 
1674 done:
1675  unformat_free (line_input);
1676 
1677  return error;
1678 }
1679 
1680 /* *INDENT-OFF* */
1681 VLIB_CLI_COMMAND (one_show_eid_table_map_command) = {
1682  .path = "show one eid-table map",
1683  .short_help = "show one eid-table l2|l3",
1685 };
1686 /* *INDENT-ON* */
1687 
1688 
1689 static clib_error_t *
1691  unformat_input_t * input,
1692  vlib_cli_command_t * cmd)
1693 {
1695  vnet_main_t *vnm = lgm->vnet_main;
1696  unformat_input_t _line_input, *line_input = &_line_input;
1697  u8 is_add = 1;
1698  clib_error_t *error = 0;
1699  u8 *locator_set_name = 0;
1700  locator_t locator, *locators = 0;
1702  u32 ls_index = 0;
1703  int rv = 0;
1704 
1705  clib_memset (&locator, 0, sizeof (locator));
1706  clib_memset (a, 0, sizeof (a[0]));
1707 
1708  /* Get a line of input. */
1709  if (!unformat_user (input, unformat_line_input, line_input))
1710  return 0;
1711 
1712  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1713  {
1714  if (unformat (line_input, "add %_%v%_", &locator_set_name))
1715  is_add = 1;
1716  else if (unformat (line_input, "del %_%v%_", &locator_set_name))
1717  is_add = 0;
1718  else if (unformat (line_input, "iface %U p %d w %d",
1720  &locator.sw_if_index, &locator.priority,
1721  &locator.weight))
1722  {
1723  locator.local = 1;
1724  locator.state = 1;
1725  vec_add1 (locators, locator);
1726  }
1727  else
1728  {
1729  error = unformat_parse_error (line_input);
1730  goto done;
1731  }
1732  }
1733 
1734  vec_terminate_c_string (locator_set_name);
1735  a->name = locator_set_name;
1736  a->locators = locators;
1737  a->is_add = is_add;
1738  a->local = 1;
1739 
1740  rv = vnet_lisp_add_del_locator_set (a, &ls_index);
1741  if (0 != rv)
1742  {
1743  error = clib_error_return (0, "failed to %s locator-set!",
1744  is_add ? "add" : "delete");
1745  }
1746 
1747 done:
1748  vec_free (locators);
1749  if (locator_set_name)
1750  vec_free (locator_set_name);
1751  unformat_free (line_input);
1752  return error;
1753 }
1754 
1755 /* *INDENT-OFF* */
1756 VLIB_CLI_COMMAND (one_cp_add_del_locator_set_command) = {
1757  .path = "one locator-set",
1758  .short_help = "one locator-set add/del <name> [iface <iface-name> "
1759  "p <priority> w <weight>]",
1761 };
1762 /* *INDENT-ON* */
1763 
1764 static clib_error_t *
1766  unformat_input_t * input,
1767  vlib_cli_command_t * cmd)
1768 {
1770  vnet_main_t *vnm = lgm->vnet_main;
1771  unformat_input_t _line_input, *line_input = &_line_input;
1772  u8 is_add = 1;
1773  clib_error_t *error = 0;
1774  u8 *locator_set_name = 0;
1775  u8 locator_set_name_set = 0;
1776  locator_t locator, *locators = 0;
1778  u32 ls_index = 0;
1779 
1780  clib_memset (&locator, 0, sizeof (locator));
1781  clib_memset (a, 0, sizeof (a[0]));
1782 
1783  /* Get a line of input. */
1784  if (!unformat_user (input, unformat_line_input, line_input))
1785  return 0;
1786 
1787  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1788  {
1789  if (unformat (line_input, "add"))
1790  is_add = 1;
1791  else if (unformat (line_input, "del"))
1792  is_add = 0;
1793  else if (unformat (line_input, "locator-set %_%v%_", &locator_set_name))
1794  locator_set_name_set = 1;
1795  else if (unformat (line_input, "iface %U p %d w %d",
1797  &locator.sw_if_index, &locator.priority,
1798  &locator.weight))
1799  {
1800  locator.local = 1;
1801  vec_add1 (locators, locator);
1802  }
1803  else
1804  {
1805  error = unformat_parse_error (line_input);
1806  goto done;
1807  }
1808  }
1809 
1810  if (!locator_set_name_set)
1811  {
1812  error = clib_error_return (0, "locator_set name not set!");
1813  goto done;
1814  }
1815 
1816  vec_terminate_c_string (locator_set_name);
1817  a->name = locator_set_name;
1818  a->locators = locators;
1819  a->is_add = is_add;
1820  a->local = 1;
1821 
1822  vnet_lisp_add_del_locator (a, 0, &ls_index);
1823 
1824 done:
1825  vec_free (locators);
1826  vec_free (locator_set_name);
1827  unformat_free (line_input);
1828  return error;
1829 }
1830 
1831 /* *INDENT-OFF* */
1832 VLIB_CLI_COMMAND (one_cp_add_del_locator_in_set_command) = {
1833  .path = "one locator",
1834  .short_help = "one locator add/del locator-set <name> iface <iface-name> "
1835  "p <priority> w <weight>",
1837 };
1838 /* *INDENT-ON* */
1839 
1840 static clib_error_t *
1842  unformat_input_t * input,
1843  vlib_cli_command_t * cmd)
1844 {
1845  locator_set_t *lsit;
1846  locator_t *loc;
1847  u32 *locit;
1849 
1850  vlib_cli_output (vm, "%s%=16s%=16s%=16s", "Locator-set", "Locator",
1851  "Priority", "Weight");
1852 
1853  /* *INDENT-OFF* */
1854  pool_foreach (lsit, lcm->locator_set_pool,
1855  ({
1856  u8 * msg = 0;
1857  int next_line = 0;
1858  if (lsit->local)
1859  {
1860  msg = format (msg, "%s", lsit->name);
1861  }
1862  else
1863  {
1864  msg = format (msg, "<%s-%d>", "remote", lsit - lcm->locator_set_pool);
1865  }
1866  vec_foreach (locit, lsit->locator_indices)
1867  {
1868  if (next_line)
1869  {
1870  msg = format (msg, "%16s", " ");
1871  }
1872  loc = pool_elt_at_index (lcm->locator_pool, locit[0]);
1873  if (loc->local)
1874  msg = format (msg, "%16d%16d%16d\n", loc->sw_if_index, loc->priority,
1875  loc->weight);
1876  else
1877  msg = format (msg, "%16U%16d%16d\n", format_ip_address,
1878  &gid_address_ip(&loc->address), loc->priority,
1879  loc->weight);
1880  next_line = 1;
1881  }
1882  vlib_cli_output (vm, "%v", msg);
1883  vec_free (msg);
1884  }));
1885  /* *INDENT-ON* */
1886  return 0;
1887 }
1888 
1889 /* *INDENT-OFF* */
1890 VLIB_CLI_COMMAND (one_cp_show_locator_sets_command) = {
1891  .path = "show one locator-set",
1892  .short_help = "Shows locator-sets",
1894 };
1895 /* *INDENT-ON* */
1896 
1897 
1898 static clib_error_t *
1900  unformat_input_t * input,
1901  vlib_cli_command_t * cmd)
1902 {
1903  unformat_input_t _line_input, *line_input = &_line_input;
1904  u8 is_add = 1, addr_set = 0;
1905  ip_address_t ip_addr;
1906  clib_error_t *error = 0;
1907  int rv = 0;
1909 
1910  /* Get a line of input. */
1911  if (!unformat_user (input, unformat_line_input, line_input))
1912  return 0;
1913 
1914  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1915  {
1916  if (unformat (line_input, "add"))
1917  is_add = 1;
1918  else if (unformat (line_input, "del"))
1919  is_add = 0;
1920  else if (unformat (line_input, "%U", unformat_ip_address, &ip_addr))
1921  addr_set = 1;
1922  else
1923  {
1924  error = unformat_parse_error (line_input);
1925  goto done;
1926  }
1927  }
1928 
1929  if (!addr_set)
1930  {
1931  error = clib_error_return (0, "Map-resolver address must be set!");
1932  goto done;
1933  }
1934 
1935  a->is_add = is_add;
1936  a->address = ip_addr;
1938  if (0 != rv)
1939  {
1940  error = clib_error_return (0, "failed to %s map-resolver!",
1941  is_add ? "add" : "delete");
1942  }
1943 
1944 done:
1945  unformat_free (line_input);
1946  return error;
1947 }
1948 
1949 /* *INDENT-OFF* */
1950 VLIB_CLI_COMMAND (one_add_del_map_resolver_command) = {
1951  .path = "one map-resolver",
1952  .short_help = "one map-resolver add/del <ip_address>",
1954 };
1955 /* *INDENT-ON* */
1956 
1957 
1958 static clib_error_t *
1960  unformat_input_t * input,
1961  vlib_cli_command_t * cmd)
1962 {
1963  unformat_input_t _line_input, *line_input = &_line_input;
1964  u8 is_add = 1;
1965  u8 *locator_set_name = 0;
1966  clib_error_t *error = 0;
1967  int rv = 0;
1969 
1970  /* Get a line of input. */
1971  if (!unformat_user (input, unformat_line_input, line_input))
1972  return 0;
1973 
1974  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1975  {
1976  if (unformat (line_input, "del"))
1977  is_add = 0;
1978  else if (unformat (line_input, "add %_%v%_", &locator_set_name))
1979  is_add = 1;
1980  else
1981  {
1982  error = unformat_parse_error (line_input);
1983  goto done;
1984  }
1985  }
1986 
1987  vec_terminate_c_string (locator_set_name);
1988  a->is_add = is_add;
1989  a->locator_set_name = locator_set_name;
1991  if (0 != rv)
1992  {
1993  error = clib_error_return (0, "failed to %s map-request itr-rlocs!",
1994  is_add ? "add" : "delete");
1995  }
1996 
1997 done:
1998  vec_free (locator_set_name);
1999  unformat_free (line_input);
2000  return error;
2001 
2002 }
2003 
2004 /* *INDENT-OFF* */
2005 VLIB_CLI_COMMAND (one_add_del_map_request_command) = {
2006  .path = "one map-request itr-rlocs",
2007  .short_help = "one map-request itr-rlocs add/del <locator_set_name>",
2009 };
2010 /* *INDENT-ON* */
2011 
2012 static clib_error_t *
2014  unformat_input_t * input,
2015  vlib_cli_command_t * cmd)
2016 {
2018  locator_set_t *loc_set;
2019 
2020  vlib_cli_output (vm, "%=20s", "itr-rlocs");
2021 
2022  if (~0 == lcm->mreq_itr_rlocs)
2023  {
2024  return 0;
2025  }
2026 
2027  loc_set = pool_elt_at_index (lcm->locator_set_pool, lcm->mreq_itr_rlocs);
2028 
2029  vlib_cli_output (vm, "%=20s", loc_set->name);
2030 
2031  return 0;
2032 }
2033 
2034 /* *INDENT-OFF* */
2035 VLIB_CLI_COMMAND (one_show_map_request_command) = {
2036  .path = "show one map-request itr-rlocs",
2037  .short_help = "Shows map-request itr-rlocs",
2039 };
2040 /* *INDENT-ON* */
2041 
2042 static clib_error_t *
2044  unformat_input_t * input,
2045  vlib_cli_command_t * cmd)
2046 {
2047  u8 is_add = 1, ip_set = 0;
2048  unformat_input_t _line_input, *line_input = &_line_input;
2049  clib_error_t *error = 0;
2050  ip_address_t ip;
2051 
2052  /* Get a line of input. */
2053  if (!unformat_user (input, unformat_line_input, line_input))
2054  return 0;
2055 
2056  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
2057  {
2058  if (unformat (line_input, "%U", unformat_ip_address, &ip))
2059  ip_set = 1;
2060  else if (unformat (line_input, "disable"))
2061  is_add = 0;
2062  else
2063  {
2064  error = clib_error_return (0, "parse error");
2065  goto done;
2066  }
2067  }
2068 
2069  if (!ip_set)
2070  {
2071  clib_warning ("No petr IP specified!");
2072  goto done;
2073  }
2074 
2075  if (vnet_lisp_use_petr (&ip, is_add))
2076  {
2077  error = clib_error_return (0, "failed to %s petr!",
2078  is_add ? "add" : "delete");
2079  }
2080 
2081 done:
2082  unformat_free (line_input);
2083  return error;
2084 }
2085 
2086 /* *INDENT-OFF* */
2087 VLIB_CLI_COMMAND (one_use_petr_set_locator_set_command) = {
2088  .path = "one use-petr",
2089  .short_help = "one use-petr [disable] <petr-ip>",
2091 };
2092 
2093 static clib_error_t *
2095  unformat_input_t * input, vlib_cli_command_t * cmd)
2096 {
2098  mapping_t *m;
2099  locator_set_t *ls;
2100  locator_t *loc;
2101  u8 *tmp_str = 0;
2102  u8 use_petr = lcm->flags & LISP_FLAG_USE_PETR;
2103  vlib_cli_output (vm, "%=20s%=16s", "petr", use_petr ? "ip" : "");
2104 
2105  if (!use_petr)
2106  {
2107  vlib_cli_output (vm, "%=20s", "disable");
2108  return 0;
2109  }
2110 
2111  if (~0 == lcm->petr_map_index)
2112  {
2113  tmp_str = format (0, "N/A");
2114  }
2115  else
2116  {
2118  if (~0 != m->locator_set_index)
2119  {
2121  loc = pool_elt_at_index (lcm->locator_pool, ls->locator_indices[0]);
2122  tmp_str = format (0, "%U", format_ip_address, &loc->address);
2123  }
2124  else
2125  {
2126  tmp_str = format (0, "N/A");
2127  }
2128  }
2129  vec_add1 (tmp_str, 0);
2130 
2131  vlib_cli_output (vm, "%=20s%=16s", "enable", tmp_str);
2132 
2133  vec_free (tmp_str);
2134 
2135  return 0;
2136 }
2137 
2138 /* *INDENT-OFF* */
2139 VLIB_CLI_COMMAND (one_show_petr_command) = {
2140  .path = "show one petr",
2141  .short_help = "Show petr",
2142  .function = lisp_show_petr_command_fn,
2143 };
2144 /* *INDENT-ON* */
2145 
2146 static clib_error_t *
2148  unformat_input_t * input,
2149  vlib_cli_command_t * cmd)
2150 {
2151  lisp_msmr_t *ms;
2153 
2154  vec_foreach (ms, lcm->map_servers)
2155  {
2156  vlib_cli_output (vm, "%U", format_ip_address, &ms->address);
2157  }
2158  return 0;
2159 }
2160 
2161 /* *INDENT-OFF* */
2162 VLIB_CLI_COMMAND (one_show_map_servers_command) = {
2163  .path = "show one map-servers",
2164  .short_help = "show one map servers",
2166 };
2167 /* *INDENT-ON* */
2168 
2169 static clib_error_t *
2171  unformat_input_t * input,
2172  vlib_cli_command_t * cmd)
2173 {
2174  u8 *msg = 0;
2175  u8 is_enabled = vnet_lisp_map_register_state_get ();
2176 
2177  msg = format (msg, "%s\n", is_enabled ? "enabled" : "disabled");
2178  vlib_cli_output (vm, "%v", msg);
2179  vec_free (msg);
2180  return 0;
2181 }
2182 
2183 /* *INDENT-OFF* */
2184 VLIB_CLI_COMMAND (one_show_map_register_state_command) = {
2185  .path = "show one map-register state",
2186  .short_help = "show one map-register state",
2188 };
2189 /* *INDENT-ON* */
2190 
2191 static clib_error_t *
2193  unformat_input_t * input,
2194  vlib_cli_command_t * cmd)
2195 {
2196  u8 *msg = 0;
2197  u8 is_enabled = vnet_lisp_rloc_probe_state_get ();
2198 
2199  msg = format (msg, "%s\n", is_enabled ? "enabled" : "disabled");
2200  vlib_cli_output (vm, "%v", msg);
2201  vec_free (msg);
2202  return 0;
2203 }
2204 
2205 /* *INDENT-OFF* */
2206 VLIB_CLI_COMMAND (one_show_rloc_probe_state_command) = {
2207  .path = "show one rloc state",
2208  .short_help = "show one RLOC state",
2210 };
2211 /* *INDENT-ON* */
2212 
2213 static clib_error_t *
2215  unformat_input_t * input,
2216  vlib_cli_command_t * cmd)
2217 {
2218  u8 is_enabled = vnet_lisp_stats_enable_disable_state ();
2219  vlib_cli_output (vm, "%s\n", is_enabled ? "enabled" : "disabled");
2220  return 0;
2221 }
2222 
2223 /* *INDENT-OFF* */
2224 VLIB_CLI_COMMAND (one_show_stats_command) = {
2225  .path = "show one statistics status",
2226  .short_help = "show ONE statistics enable/disable status",
2227  .function = lisp_show_stats_command_fn,
2228 };
2229 /* *INDENT-ON* */
2230 
2231 static clib_error_t *
2233  unformat_input_t * input,
2234  vlib_cli_command_t * cmd)
2235 {
2236  lisp_api_stats_t *stat, *stats = vnet_lisp_get_stats ();
2237 
2238  if (vec_len (stats) > 0)
2239  vlib_cli_output (vm,
2240  "[src-EID, dst-EID] [loc-rloc, rmt-rloc] count bytes\n");
2241  else
2242  vlib_cli_output (vm, "No statistics found.\n");
2243 
2244  vec_foreach (stat, stats)
2245  {
2246  vlib_cli_output (vm, "[%U, %U] [%U, %U] %7u %7u\n",
2247  format_fid_address, &stat->seid,
2248  format_fid_address, &stat->deid,
2249  format_ip_address, &stat->loc_rloc,
2250  format_ip_address, &stat->rmt_rloc,
2251  stat->counters.packets, stat->counters.bytes);
2252  }
2253  vec_free (stats);
2254  return 0;
2255 }
2256 
2257 /* *INDENT-OFF* */
2258 VLIB_CLI_COMMAND (one_show_stats_details_command) = {
2259  .path = "show one statistics details",
2260  .short_help = "show ONE statistics",
2262 };
2263 /* *INDENT-ON* */
2264 
2265 static clib_error_t *
2267  unformat_input_t * input,
2268  vlib_cli_command_t * cmd)
2269 {
2270  unformat_input_t _line_input, *line_input = &_line_input;
2271  u8 enable = 0;
2272 
2273  /* Get a line of input. */
2274  if (!unformat_user (input, unformat_line_input, line_input))
2275  return clib_error_return (0, "expected enable | disable");
2276 
2277  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
2278  {
2279  if (unformat (line_input, "enable"))
2280  enable = 1;
2281  else if (unformat (line_input, "disable"))
2282  enable = 0;
2283  else
2284  {
2285  clib_warning ("Error: expected enable/disable!");
2286  goto done;
2287  }
2288  }
2290 done:
2291  unformat_free (line_input);
2292  return 0;
2293 }
2294 
2295 /* *INDENT-OFF* */
2296 VLIB_CLI_COMMAND (one_stats_enable_disable_command) = {
2297  .path = "one statistics",
2298  .short_help = "enable/disable ONE statistics collecting",
2300 };
2301 /* *INDENT-ON* */
2302 
2303 static clib_error_t *
2305  unformat_input_t * input,
2306  vlib_cli_command_t * cmd)
2307 {
2309  return 0;
2310 }
2311 
2312 /* *INDENT-OFF* */
2313 VLIB_CLI_COMMAND (one_stats_flush_command) = {
2314  .path = "one statistics flush",
2315  .short_help = "Flush ONE statistics",
2316  .function = lisp_stats_flush_command_fn,
2317 };
2318 /* *INDENT-ON* */
2319 
2320 static clib_error_t *
2322  unformat_input_t * input,
2323  vlib_cli_command_t * cmd)
2324 {
2325  u8 pitr_mode = vnet_lisp_get_pitr_mode ();
2326  u8 petr_mode = vnet_lisp_get_petr_mode ();
2327  u8 xtr_mode = vnet_lisp_get_xtr_mode ();
2328 
2329  vlib_cli_output (vm, "xTR: %s\n", xtr_mode ? "enabled" : "disabled");
2330  vlib_cli_output (vm, "P-ITR: %s\n", pitr_mode ? "enabled" : "disabled");
2331  vlib_cli_output (vm, "P-ETR: %s\n", petr_mode ? "enabled" : "disabled");
2332 
2333  return 0;
2334 }
2335 
2336 /* *INDENT-OFF* */
2337 VLIB_CLI_COMMAND (one_cp_show_one_modes_modes_command) = {
2338  .path = "show one modes",
2339  .short_help = "show one modes",
2340  .function = lisp_show_one_modes_command_fn,
2341 };
2342 /* *INDENT-ON* */
2343 
2344 /*
2345  * fd.io coding-style-patch-verification: ON
2346  *
2347  * Local Variables:
2348  * eval: (c-set-style "gnu")
2349  * End:
2350  */
static clib_error_t * lisp_stats_flush_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:2304
#define gid_address_ip_version(_a)
Definition: lisp_types.h:207
u32 pitr_map_index
Definition: control.h:250
gid_address_t leid
Definition: control.h:73
u8 vnet_lisp_get_pitr_mode(void)
Definition: control.c:5051
#define gid_address_type(_a)
Definition: lisp_types.h:203
static clib_error_t * lisp_show_pitr_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:1018
a
Definition: bitmap.h:538
void ip_address_set(ip_address_t *dst, const void *src, u8 version)
Definition: ip_types.c:152
lisp_api_l2_arp_entry_t * vnet_lisp_l2_arp_entries_get_by_bd(u32 bd)
Definition: control.c:978
lisp_msmr_t * map_resolvers
Definition: control.h:220
static clib_error_t * lisp_enable_disable_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:1372
uword * table_id_by_vni
Definition: control.h:239
option version
Definition: sample.api:19
void ip_set(ip46_address_t *dst, void *src, u8 is_ip4)
Definition: ip.c:90
#define NULL
Definition: clib.h:58
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static u8 * format_eid_entry(u8 *s, va_list *args)
Definition: one_cli.c:1071
locator_t * locator_pool
Definition: control.h:177
dp_address_t seid
Definition: lisp_gpe.h:103
LISP-GPE global state.
Definition: lisp_gpe.h:118
u8 vnet_lisp_get_map_request_mode(void)
Definition: control.c:57
ip_address_t loc_rloc
Definition: lisp_gpe.h:104
#define vec_terminate_c_string(V)
(If necessary) NULL terminate a vector containing a c-string.
Definition: vec.h:1017
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:523
static clib_error_t * lisp_add_del_locator_set_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:1690
static clib_error_t * lisp_add_del_adjacency_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Handler for add/del adjacency CLI.
Definition: one_cli.c:632
static clib_error_t * lisp_show_map_request_mode_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:798
int i
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:989
static clib_error_t * lisp_add_del_local_eid_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:129
u32 ip4
Definition: control.h:103
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
unformat_function_t unformat_vnet_sw_interface
static clib_error_t * lisp_add_del_l2_arp_entry_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:347
ip_address_t address
Definition: control.h:88
vnet_api_error_t vnet_lisp_stats_enable_disable(u8 enable)
Definition: control.c:4888
int vnet_lisp_add_mapping(vnet_lisp_add_del_mapping_args_t *a, locator_t *rlocs, u32 *res_map_index, u8 *is_updated)
Adds/updates mapping.
Definition: control.c:1268
uword unformat_hmac_key_id(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:247
u8 vnet_lisp_stats_enable_disable_state(void)
Definition: control.c:4904
format_function_t format_vnet_sw_if_index_name
unsigned char u8
Definition: types.h:56
u8 vnet_lisp_map_register_state_get(void)
Definition: control.c:408
u8 vnet_lisp_get_petr_mode(void)
Definition: control.c:5058
int vnet_lisp_set_map_request_mode(u8 mode)
Definition: control.c:1548
int vnet_lisp_add_del_adjacency(vnet_lisp_add_del_adjacency_args_t *a)
Adds adjacency or removes forwarding entry associated to remote mapping.
Definition: control.c:1477
uword value[0]
Definition: hash.h:165
uword unformat_negative_mapping_action(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:313
lisp_msmr_t * map_servers
Definition: control.h:223
int vnet_lisp_enable_disable_petr_mode(u8 is_enabled)
Definition: control.c:5013
format_function_t format_ip4_address
Definition: format.h:73
int vnet_lisp_enable_disable_pitr_mode(u8 is_enabled)
Definition: control.c:4984
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:498
static clib_error_t * lisp_show_one_modes_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:2321
unformat_function_t unformat_ip4_address
Definition: format.h:68
static clib_error_t * lisp_show_map_servers_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:2147
static clib_error_t * lisp_map_register_fallback_threshold_show_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:896
static clib_error_t * lisp_show_rloc_probe_state_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:2192
ip_address_t rmt_rloc
Definition: lisp_gpe.h:105
int vnet_lisp_flush_stats(void)
static clib_error_t * lisp_show_ndp_entries_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:447
static clib_error_t * lisp_show_eid_table_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:1119
u8 ip6[16]
Definition: control.h:109
#define clib_error_return(e, args...)
Definition: error.h:99
int vnet_lisp_eid_table_map(u32 vni, u32 dp_id, u8 is_l2, u8 is_add)
Definition: control.c:1068
lisp_api_ndp_entry_t * vnet_lisp_ndp_entries_get_by_bd(u32 bd)
Definition: control.c:1014
unsigned int u32
Definition: types.h:88
static clib_error_t * lisp_enable_disable_petr_mode_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:1266
uword * bd_id_by_vni
Definition: control.h:243
static lisp_cp_main_t * vnet_lisp_cp_get_main()
Definition: control.h:304
static clib_error_t * lisp_nsh_set_locator_set_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:839
static clib_error_t * lisp_cp_show_locator_sets_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:1841
vl_api_gre_tunnel_mode_t mode
Definition: gre.api:55
static clib_error_t * lisp_enable_disable_pitr_mode_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:1212
u32 petr_map_index
Proxy ETR map index used for &#39;use-petr&#39;.
Definition: control.h:254
unformat_function_t unformat_line_input
Definition: format.h:283
vl_api_fib_path_type_t type
Definition: fib_types.api:123
clib_error_t * vnet_lisp_enable_disable(u8 is_enable)
Definition: control.c:2249
int vnet_lisp_pitr_set_locator_set(u8 *locator_set_name, u8 is_add)
Definition: control.c:1620
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:519
u8 vnet_lisp_rloc_probe_state_get(void)
Definition: control.c:415
counter_t packets
packet counter
Definition: counter_types.h:28
static clib_error_t * lisp_add_del_map_server_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:74
#define gid_address_arp_ndp_ip(_a)
Definition: lisp_types.h:226
u8 * format_negative_mapping_action(u8 *s, va_list *args)
Definition: lisp_types.c:360
static clib_error_t * lisp_map_request_mode_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:735
#define gid_address_mac(_a)
Definition: lisp_types.h:209
u8 mac[6]
Definition: control.h:102
struct _unformat_input_t unformat_input_t
int vnet_lisp_add_del_local_mapping(vnet_lisp_add_del_mapping_args_t *a, u32 *map_index_result)
Add/update/delete mapping to/in/from map-cache.
Definition: control.c:869
u32 vni
Definition: lisp_gpe.api:129
#define hash_free(h)
Definition: hash.h:310
void gid_address_free(gid_address_t *a)
Definition: lisp_types.c:733
u8 authoritative
Definition: lisp_types.h:305
lisp_api_stats_t * vnet_lisp_get_stats(void)
Definition: control.c:4588
uword unformat_gid_address(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:272
u8 * format_gid_address(u8 *s, va_list *args)
Definition: lisp_types.c:187
uword unformat_ip_address(unformat_input_t *input, va_list *args)
Definition: ip_types.c:40
static clib_error_t * lisp_map_register_enable_disable_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:1491
u8 vnet_lisp_get_xtr_mode(void)
Definition: control.c:5044
vlib_main_t * vm
Definition: in2out_ed.c:1810
static clib_error_t * lisp_add_del_ndp_entry_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:283
u8 mac[6]
Definition: control.h:108
#define gid_address_ippref(_a)
Definition: lisp_types.h:204
dp_address_t deid
Definition: lisp_gpe.h:102
lisp_adjacency_t * vnet_lisp_adjacencies_get_by_vni(u32 vni)
Returns vector of adjacencies.
Definition: control.c:611
unformat_function_t unformat_ip6_address
Definition: format.h:89
u32 sw_if_index
Definition: lisp_types.h:266
u8 ip6[16]
Definition: one.api:477
u32 * vnet_lisp_ndp_bds_get(void)
Definition: control.c:940
static clib_error_t * lisp_stats_enable_disable_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:2266
#define UNFORMAT_END_OF_INPUT
Definition: format.h:145
int vnet_lisp_add_del_mreq_itr_rlocs(vnet_lisp_add_del_mreq_itr_rloc_args_t *a)
Definition: control.c:2384
vlib_counter_t counters
Definition: lisp_gpe.h:107
format_function_t format_ip6_address
Definition: format.h:91
static clib_error_t * lisp_add_del_mreq_itr_rlocs_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:1959
#define gid_address_arp_bd
Definition: lisp_types.h:230
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:342
vnet_main_t * vnet_main
Definition: lisp_gpe.h:172
u8 ttl
Definition: fib_types.api:26
#define clib_warning(format, args...)
Definition: error.h:59
u32 locator_set_index
Definition: lisp_types.h:298
u8 * format_ip_address(u8 *s, va_list *args)
Definition: ip_types.c:20
int vnet_lisp_map_register_enable_disable(u8 is_enable)
Definition: control.c:2183
u32 vnet_lisp_map_register_fallback_threshold_get(void)
Definition: control.c:1672
static clib_error_t * lisp_add_del_map_resolver_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:1899
uword unformat_mac_address(unformat_input_t *input, va_list *args)
Definition: format.c:241
static clib_error_t * lisp_show_map_resolvers_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:816
u8 leid[16]
Definition: lisp.api:566
static clib_error_t * lisp_eid_table_map_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:237
lisp_gpe_main_t lisp_gpe_main
LISP-GPE global state.
Definition: lisp_gpe.c:30
static clib_error_t * lisp_show_adjacencies_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:20
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:152
int vnet_lisp_enable_disable_xtr_mode(u8 is_enabled)
Definition: control.c:4947
Definition: control.h:106
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:592
int vnet_lisp_add_del_map_server(ip_address_t *addr, u8 is_add)
Definition: control.c:665
int vnet_lisp_clear_all_remote_adjacencies(void)
Definition: control.c:1426
static u8 * format_lisp_status(u8 *s, va_list *args)
Definition: one_cli.c:1597
locator_set_t * locator_set_pool
Definition: control.h:180
static clib_error_t * lisp_show_stats_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:2214
#define gid_address_ndp_bd
Definition: lisp_types.h:229
int vnet_lisp_rloc_probe_enable_disable(u8 is_enable)
Definition: control.c:2174
static clib_error_t * lisp_add_del_remote_mapping_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Handler for add/del remote mapping CLI.
Definition: one_cli.c:491
static clib_error_t * lisp_pitr_set_locator_set_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:961
static clib_error_t * lisp_show_eid_table_map_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:1624
static clib_error_t * lisp_map_register_fallback_threshold_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:917
u64 gid_dictionary_lookup(gid_dictionary_t *db, gid_address_t *key)
Definition: control.h:100
static clib_error_t * lisp_rloc_probe_enable_disable_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:1544
u32 entries
int vnet_lisp_map_register_fallback_threshold_set(u32 value)
Definition: control.c:1659
#define unformat_parse_error(input)
Definition: format.h:269
typedef key
Definition: ipsec_types.api:83
counter_t bytes
byte counter
Definition: counter_types.h:29
int vnet_lisp_add_del_locator_set(vnet_lisp_add_del_locator_set_args_t *a, u32 *ls_result)
Definition: control.c:2034
static clib_error_t * lisp_show_l2_arp_entries_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:411
#define gid_address_ip(_a)
Definition: lisp_types.h:206
static clib_error_t * lisp_show_mreq_itr_rlocs_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:2013
static clib_error_t * lisp_show_status_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:1604
#define gid_address_vni(_a)
Definition: lisp_types.h:213
u8 action
Definition: l2.api:173
vl_api_address_t ip
Definition: l2.api:490
map_request_mode_t
Definition: control.h:112
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define hash_foreach_pair(p, v, body)
Iterate over hash pairs.
Definition: hash.h:373
u64 uword
Definition: types.h:112
static void unformat_free(unformat_input_t *i)
Definition: format.h:163
static clib_error_t * lisp_map_register_show_ttl_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:1471
int vnet_lisp_del_mapping(gid_address_t *eid, u32 *res_map_index)
Removes a mapping.
Definition: control.c:1377
u32 * vnet_lisp_l2_arp_bds_get(void)
Definition: control.c:916
int vnet_lisp_add_del_locator(vnet_lisp_add_del_locator_set_args_t *a, locator_set_t *ls, u32 *ls_result)
Definition: control.c:1930
mapping_t * mapping_pool
Definition: control.h:171
#define ip_prefix_len(_a)
Definition: ip_types.h:76
u8 ip_address_max_len(u8 version)
Definition: lisp_types.c:432
uword * locator_set_index_by_name
Definition: control.h:186
int vnet_lisp_nsh_set_locator_set(u8 *locator_set_name, u8 is_add)
Definition: control.c:1569
void gid_address_copy(gid_address_t *dst, gid_address_t *src)
Definition: lisp_types.c:1203
#define ip_prefix_version(_a)
Definition: ip_types.h:75
gid_address_t eid
Definition: lisp_types.h:293
gid_address_t reid
Definition: control.h:74
static clib_error_t * lisp_show_map_register_state_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:2170
gid_address_t address
Definition: lisp_types.h:267
u8 * format_mac_address(u8 *s, va_list *args)
Definition: format.c:58
#define hash_get_mem(h, key)
Definition: hash.h:269
static clib_error_t * lisp_enable_disable_xtr_mode_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:1319
static clib_error_t * lisp_show_petr_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:2094
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
int vnet_lisp_add_del_map_resolver(vnet_lisp_add_del_map_resolver_args_t *a)
Definition: control.c:2321
static u8 * format_lisp_map_request_mode(u8 *s, va_list *args)
Definition: one_cli.c:783
int vnet_lisp_add_del_l2_arp_ndp_entry(gid_address_t *key, u8 *mac, u8 is_add)
Definition: control.c:1029
static clib_error_t * lisp_use_petr_set_locator_set_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:2043
#define vec_foreach(var, vec)
Vector iterator.
static clib_error_t * lisp_map_register_set_ttl_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:1424
#define gid_address_arp_ip4(_a)
Definition: lisp_types.h:227
uword unformat_ip_prefix(unformat_input_t *input, va_list *args)
Definition: ip_types.c:63
u32 ip4
Definition: one.api:440
static clib_error_t * lisp_add_del_locator_in_set_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:1765
static clib_error_t * lisp_show_stats_details_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: one_cli.c:2232
int vnet_lisp_map_register_set_ttl(u32 ttl)
Definition: control.c:2369
u8 * format_fid_address(u8 *s, va_list *args)
Definition: lisp_types.c:166
u32 vnet_lisp_map_register_get_ttl(void)
Definition: control.c:2377
int vnet_lisp_use_petr(ip_address_t *ip, u8 is_add)
Configure Proxy-ETR.
Definition: control.c:1687
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:689
u32 mreq_itr_rlocs
Definition: control.h:236
u32 * locator_indices
Definition: lisp_types.h:287
vnet_main_t * vnet_main
Definition: control.h:291
uword key
Definition: hash.h:162
LISP-GPE definitions.
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
u8 reid[16]
Definition: lisp.api:565
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:171