FD.io VPP  v17.04-9-g99c0734
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;
80  ip_address_t ip;
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  memset (&eid, 0, sizeof (eid));
148  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  p = hash_get_mem (lcm->locator_set_index_by_name, locator_set_name);
172  if (!p)
173  {
174  error = clib_error_return (0, "locator-set %s doesn't exist",
175  locator_set_name);
176  goto done;
177  }
178  locator_set_index = p[0];
179  }
180  else
181  {
182  error = unformat_parse_error (line_input);
183  goto done;
184  }
185  }
186  /* XXX treat batch configuration */
187 
188  if (GID_ADDR_SRC_DST == gid_address_type (&eid))
189  {
190  error =
191  clib_error_return (0, "src/dst is not supported for local EIDs!");
192  goto done;
193  }
194 
195  if (key && (0 == key_id))
196  {
197  vlib_cli_output (vm, "invalid key_id!");
198  goto done;
199  }
200 
201  gid_address_copy (&a->eid, &eid);
202  a->is_add = is_add;
203  a->locator_set_index = locator_set_index;
204  a->local = 1;
205  a->key = key;
206  a->key_id = key_id;
207 
208  rv = vnet_lisp_add_del_local_mapping (a, &map_index);
209  if (0 != rv)
210  {
211  error = clib_error_return (0, "failed to %s local mapping!",
212  is_add ? "add" : "delete");
213  }
214 done:
215  vec_free (eids);
216  if (locator_set_name)
217  vec_free (locator_set_name);
218  gid_address_free (&a->eid);
219  vec_free (a->key);
220  unformat_free (line_input);
221  return error;
222 }
223 
224 /* *INDENT-OFF* */
225 VLIB_CLI_COMMAND (one_add_del_local_eid_command) = {
226  .path = "one eid-table",
227  .short_help = "one eid-table add/del [vni <vni>] eid <eid> "
228  "locator-set <locator-set> [key <secret-key> key-id sha1|sha256 ]",
230 };
231 /* *INDENT-ON* */
232 
233 static clib_error_t *
235  unformat_input_t * input,
236  vlib_cli_command_t * cmd)
237 {
238  u8 is_add = 1, is_l2 = 0;
239  u32 vni = 0, dp_id = 0;
240  unformat_input_t _line_input, *line_input = &_line_input;
241  clib_error_t *error = NULL;
242 
243  /* Get a line of input. */
244  if (!unformat_user (input, unformat_line_input, line_input))
245  return 0;
246 
247  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
248  {
249  if (unformat (line_input, "del"))
250  is_add = 0;
251  else if (unformat (line_input, "vni %d", &vni))
252  ;
253  else if (unformat (line_input, "vrf %d", &dp_id))
254  ;
255  else if (unformat (line_input, "bd %d", &dp_id))
256  is_l2 = 1;
257  else
258  {
259  error = unformat_parse_error (line_input);
260  goto done;
261  }
262  }
263  vnet_lisp_eid_table_map (vni, dp_id, is_l2, is_add);
264 
265 done:
266  unformat_free (line_input);
267 
268  return error;
269 }
270 
271 /* *INDENT-OFF* */
272 VLIB_CLI_COMMAND (one_eid_table_map_command) = {
273  .path = "one eid-table map",
274  .short_help = "one eid-table map [del] vni <vni> vrf <vrf> | bd <bdi>",
275  .function = lisp_eid_table_map_command_fn,
276 };
277 /* *INDENT-ON* */
278 
279 /**
280  * Handler for add/del remote mapping CLI.
281  *
282  * @param vm vlib context
283  * @param input input from user
284  * @param cmd cmd
285  * @return pointer to clib error structure
286  */
287 static clib_error_t *
289  unformat_input_t * input,
290  vlib_cli_command_t * cmd)
291 {
292  clib_error_t *error = 0;
293  unformat_input_t _line_input, *line_input = &_line_input;
294  u8 is_add = 1, del_all = 0;
295  locator_t rloc, *rlocs = 0, *curr_rloc = 0;
296  gid_address_t eid;
297  u8 eid_set = 0;
298  u32 vni, action = ~0, p, w;
299  int rv;
300 
301  /* Get a line of input. */
302  if (!unformat_user (input, unformat_line_input, line_input))
303  return 0;
304 
305  memset (&eid, 0, sizeof (eid));
306  memset (&rloc, 0, sizeof (rloc));
307 
308  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
309  {
310  if (unformat (line_input, "del-all"))
311  del_all = 1;
312  else if (unformat (line_input, "del"))
313  is_add = 0;
314  else if (unformat (line_input, "add"))
315  ;
316  else if (unformat (line_input, "eid %U", unformat_gid_address, &eid))
317  eid_set = 1;
318  else if (unformat (line_input, "vni %u", &vni))
319  {
320  gid_address_vni (&eid) = vni;
321  }
322  else if (unformat (line_input, "p %d w %d", &p, &w))
323  {
324  if (!curr_rloc)
325  {
327  ("No RLOC configured for setting priority/weight!");
328  goto done;
329  }
330  curr_rloc->priority = p;
331  curr_rloc->weight = w;
332  }
333  else if (unformat (line_input, "rloc %U", unformat_ip_address,
334  &gid_address_ip (&rloc.address)))
335  {
336  /* since rloc is stored in ip prefix we need to set prefix length */
337  ip_prefix_t *pref = &gid_address_ippref (&rloc.address);
338 
339  u8 version = gid_address_ip_version (&rloc.address);
340  ip_prefix_len (pref) = ip_address_max_len (version);
341 
342  vec_add1 (rlocs, rloc);
343  curr_rloc = &rlocs[vec_len (rlocs) - 1];
344  }
345  else if (unformat (line_input, "action %U",
347  ;
348  else
349  {
350  clib_warning ("parse error");
351  goto done;
352  }
353  }
354 
355  if (!del_all && !eid_set)
356  {
357  clib_warning ("missing eid!");
358  goto done;
359  }
360 
361  if (!del_all)
362  {
363  if (is_add && (~0 == action) && 0 == vec_len (rlocs))
364  {
365  clib_warning ("no action set for negative map-reply!");
366  goto done;
367  }
368  }
369  else
370  {
372  goto done;
373  }
374 
375  /* if it's a delete, clean forwarding */
376  if (!is_add)
377  {
379  memset (a, 0, sizeof (a[0]));
380  gid_address_copy (&a->reid, &eid);
382  {
383  clib_warning ("failed to delete adjacency!");
384  goto done;
385  }
386  }
387 
388  /* add as static remote mapping, i.e., not authoritative and infinite
389  * ttl */
390  rv = vnet_lisp_add_del_mapping (&eid, rlocs, action, 0, ~0, is_add,
391  1 /* is_static */ , 0);
392 
393  if (rv)
394  clib_warning ("failed to %s remote mapping!", is_add ? "add" : "delete");
395 
396 done:
397  vec_free (rlocs);
398  unformat_free (line_input);
399  return error;
400 }
401 
402 /* *INDENT-OFF* */
403 VLIB_CLI_COMMAND (one_add_del_remote_mapping_command) = {
404  .path = "one remote-mapping",
405  .short_help =
406  "one remote-mapping add|del [del-all] vni <vni> "
407  "eid <est-eid> [action <no-action|natively-forward|"
408  "send-map-request|drop>] rloc <dst-locator> p <prio> w <weight> "
409  "[rloc <dst-locator> ... ]",
411 };
412 /* *INDENT-ON* */
413 
414 /**
415  * Handler for add/del adjacency CLI.
416  */
417 static clib_error_t *
419  vlib_cli_command_t * cmd)
420 {
421  clib_error_t *error = 0;
422  unformat_input_t _line_input, *line_input = &_line_input;
424  u8 is_add = 1;
425  ip_prefix_t *reid_ippref, *leid_ippref;
426  gid_address_t leid, reid;
427  u8 *dmac = gid_address_mac (&reid);
428  u8 *smac = gid_address_mac (&leid);
429  u8 reid_set = 0, leid_set = 0;
430  u32 vni;
431 
432  /* Get a line of input. */
433  if (!unformat_user (input, unformat_line_input, line_input))
434  return 0;
435 
436  memset (&reid, 0, sizeof (reid));
437  memset (&leid, 0, sizeof (leid));
438 
439  leid_ippref = &gid_address_ippref (&leid);
440  reid_ippref = &gid_address_ippref (&reid);
441 
442  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
443  {
444  if (unformat (line_input, "del"))
445  is_add = 0;
446  else if (unformat (line_input, "add"))
447  ;
448  else if (unformat (line_input, "reid %U",
449  unformat_ip_prefix, reid_ippref))
450  {
452  reid_set = 1;
453  }
454  else if (unformat (line_input, "reid %U", unformat_mac_address, dmac))
455  {
456  gid_address_type (&reid) = GID_ADDR_MAC;
457  reid_set = 1;
458  }
459  else if (unformat (line_input, "vni %u", &vni))
460  {
461  gid_address_vni (&leid) = vni;
462  gid_address_vni (&reid) = vni;
463  }
464  else if (unformat (line_input, "leid %U",
465  unformat_ip_prefix, leid_ippref))
466  {
468  leid_set = 1;
469  }
470  else if (unformat (line_input, "leid %U", unformat_mac_address, smac))
471  {
472  gid_address_type (&leid) = GID_ADDR_MAC;
473  leid_set = 1;
474  }
475  else
476  {
477  clib_warning ("parse error");
478  goto done;
479  }
480  }
481 
482  if (!reid_set || !leid_set)
483  {
484  clib_warning ("missing remote or local eid!");
485  goto done;
486  }
487 
488  if ((gid_address_type (&leid) != gid_address_type (&reid))
489  || (gid_address_type (&reid) == GID_ADDR_IP_PREFIX
490  && ip_prefix_version (reid_ippref)
491  != ip_prefix_version (leid_ippref)))
492  {
493  clib_warning ("remote and local EIDs are of different types!");
494  goto done;
495  }
496 
497  memset (a, 0, sizeof (a[0]));
498  gid_address_copy (&a->leid, &leid);
499  gid_address_copy (&a->reid, &reid);
500  a->is_add = is_add;
501 
503  clib_warning ("failed to %s adjacency!", is_add ? "add" : "delete");
504 
505 done:
506  unformat_free (line_input);
507  return error;
508 }
509 
510 /* *INDENT-OFF* */
511 VLIB_CLI_COMMAND (one_add_del_adjacency_command) = {
512  .path = "one adjacency",
513  .short_help = "one adjacency add|del vni <vni> reid <remote-eid> "
514  "leid <local-eid>",
516 };
517 /* *INDENT-ON* */
518 
519 
520 static clib_error_t *
522  unformat_input_t * input,
523  vlib_cli_command_t * cmd)
524 {
525  unformat_input_t _i, *i = &_i;
526  map_request_mode_t mr_mode = _MR_MODE_MAX;
527 
528  /* Get a line of input. */
529  if (!unformat_user (input, unformat_line_input, i))
530  return 0;
531 
533  {
534  if (unformat (i, "dst-only"))
535  mr_mode = MR_MODE_DST_ONLY;
536  else if (unformat (i, "src-dst"))
537  mr_mode = MR_MODE_SRC_DST;
538  else
539  {
540  clib_warning ("parse error '%U'", format_unformat_error, i);
541  goto done;
542  }
543  }
544 
545  if (_MR_MODE_MAX == mr_mode)
546  {
547  clib_warning ("No map request mode entered!");
548  goto done;
549  }
550 
552 
553 done:
554  unformat_free (i);
555 
556  return 0;
557 }
558 
559 /* *INDENT-OFF* */
560 VLIB_CLI_COMMAND (one_map_request_mode_command) = {
561  .path = "one map-request mode",
562  .short_help = "one map-request mode dst-only|src-dst",
564 };
565 /* *INDENT-ON* */
566 
567 
568 static u8 *
569 format_lisp_map_request_mode (u8 * s, va_list * args)
570 {
571  u32 mode = va_arg (*args, u32);
572 
573  switch (mode)
574  {
575  case 0:
576  return format (0, "dst-only");
577  case 1:
578  return format (0, "src-dst");
579  }
580  return 0;
581 }
582 
583 static clib_error_t *
585  unformat_input_t * input,
586  vlib_cli_command_t * cmd)
587 {
588  vlib_cli_output (vm, "map-request mode: %U", format_lisp_map_request_mode,
590  return 0;
591 }
592 
593 /* *INDENT-OFF* */
594 VLIB_CLI_COMMAND (one_show_map_request_mode_command) = {
595  .path = "show one map-request mode",
596  .short_help = "show one map-request mode",
598 };
599 /* *INDENT-ON* */
600 
601 static clib_error_t *
603  unformat_input_t * input,
604  vlib_cli_command_t * cmd)
605 {
606  lisp_msmr_t *mr;
608 
609  vec_foreach (mr, lcm->map_resolvers)
610  {
611  vlib_cli_output (vm, "%U", format_ip_address, &mr->address);
612  }
613  return 0;
614 }
615 
616 /* *INDENT-OFF* */
617 VLIB_CLI_COMMAND (one_show_map_resolvers_command) = {
618  .path = "show one map-resolvers",
619  .short_help = "show one map-resolvers",
621 };
622 /* *INDENT-ON* */
623 
624 
625 static clib_error_t *
627  unformat_input_t * input,
628  vlib_cli_command_t * cmd)
629 {
630  u8 locator_name_set = 0;
631  u8 *locator_set_name = 0;
632  u8 is_add = 1;
633  unformat_input_t _line_input, *line_input = &_line_input;
634  clib_error_t *error = 0;
635  int rv = 0;
636 
637  /* Get a line of input. */
638  if (!unformat_user (input, unformat_line_input, line_input))
639  return 0;
640 
641  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
642  {
643  if (unformat (line_input, "ls %_%v%_", &locator_set_name))
644  locator_name_set = 1;
645  else if (unformat (line_input, "disable"))
646  is_add = 0;
647  else
648  {
649  error = clib_error_return (0, "parse error");
650  goto done;
651  }
652  }
653 
654  if (!locator_name_set)
655  {
656  clib_warning ("No locator set specified!");
657  goto done;
658  }
659  rv = vnet_lisp_pitr_set_locator_set (locator_set_name, is_add);
660  if (0 != rv)
661  {
662  error = clib_error_return (0, "failed to %s pitr!",
663  is_add ? "add" : "delete");
664  }
665 
666 done:
667  if (locator_set_name)
668  vec_free (locator_set_name);
669  unformat_free (line_input);
670  return error;
671 }
672 
673 /* *INDENT-OFF* */
674 VLIB_CLI_COMMAND (one_pitr_set_locator_set_command) = {
675  .path = "one pitr",
676  .short_help = "one pitr [disable] ls <locator-set-name>",
678 };
679 /* *INDENT-ON* */
680 
681 static clib_error_t *
683  unformat_input_t * input, vlib_cli_command_t * cmd)
684 {
686  mapping_t *m;
687  locator_set_t *ls;
688  u8 *tmp_str = 0;
689 
690  vlib_cli_output (vm, "%=20s%=16s",
691  "pitr", lcm->lisp_pitr ? "locator-set" : "");
692 
693  if (!lcm->lisp_pitr)
694  {
695  vlib_cli_output (vm, "%=20s", "disable");
696  return 0;
697  }
698 
699  if (~0 == lcm->pitr_map_index)
700  {
701  tmp_str = format (0, "N/A");
702  }
703  else
704  {
706  if (~0 != m->locator_set_index)
707  {
708  ls =
710  tmp_str = format (0, "%s", ls->name);
711  }
712  else
713  {
714  tmp_str = format (0, "N/A");
715  }
716  }
717  vec_add1 (tmp_str, 0);
718 
719  vlib_cli_output (vm, "%=20s%=16s", "enable", tmp_str);
720 
721  vec_free (tmp_str);
722 
723  return 0;
724 }
725 
726 /* *INDENT-OFF* */
727 VLIB_CLI_COMMAND (one_show_pitr_command) = {
728  .path = "show one pitr",
729  .short_help = "Show pitr",
730  .function = lisp_show_pitr_command_fn,
731 };
732 /* *INDENT-ON* */
733 
734 static u8 *
735 format_eid_entry (u8 * s, va_list * args)
736 {
737  vnet_main_t *vnm = va_arg (*args, vnet_main_t *);
738  lisp_cp_main_t *lcm = va_arg (*args, lisp_cp_main_t *);
739  mapping_t *mapit = va_arg (*args, mapping_t *);
740  locator_set_t *ls = va_arg (*args, locator_set_t *);
741  gid_address_t *gid = &mapit->eid;
742  u32 ttl = mapit->ttl;
743  u8 aut = mapit->authoritative;
744  u32 *loc_index;
745  u8 first_line = 1;
746  u8 *loc;
747 
748  u8 *type = ls->local ? format (0, "local(%s)", ls->name)
749  : format (0, "remote");
750 
751  if (vec_len (ls->locator_indices) == 0)
752  {
753  s = format (s, "%-35U%-30s%-20u%-u", format_gid_address, gid,
754  type, ttl, aut);
755  }
756  else
757  {
758  vec_foreach (loc_index, ls->locator_indices)
759  {
760  locator_t *l = pool_elt_at_index (lcm->locator_pool, loc_index[0]);
761  if (l->local)
762  loc = format (0, "%U", format_vnet_sw_if_index_name, vnm,
763  l->sw_if_index);
764  else
765  loc = format (0, "%U", format_ip_address,
766  &gid_address_ip (&l->address));
767 
768  if (first_line)
769  {
770  s = format (s, "%-35U%-20s%-30v%-20u%-u\n", format_gid_address,
771  gid, type, loc, ttl, aut);
772  first_line = 0;
773  }
774  else
775  s = format (s, "%55s%v\n", "", loc);
776  }
777  }
778  return s;
779 }
780 
781 static clib_error_t *
783  unformat_input_t * input,
784  vlib_cli_command_t * cmd)
785 {
787  mapping_t *mapit;
788  unformat_input_t _line_input, *line_input = &_line_input;
789  u32 mi;
790  gid_address_t eid;
791  u8 print_all = 1;
792  u8 filter = 0;
793  clib_error_t *error = NULL;
794 
795  memset (&eid, 0, sizeof (eid));
796 
797  /* Get a line of input. */
798  if (!unformat_user (input, unformat_line_input, line_input))
799  return 0;
800 
801  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
802  {
803  if (unformat (line_input, "eid %U", unformat_gid_address, &eid))
804  print_all = 0;
805  else if (unformat (line_input, "local"))
806  filter = 1;
807  else if (unformat (line_input, "remote"))
808  filter = 2;
809  else
810  {
811  error = clib_error_return (0, "parse error: '%U'",
812  format_unformat_error, line_input);
813  goto done;
814  }
815  }
816 
817  vlib_cli_output (vm, "%-35s%-20s%-30s%-20s%-s",
818  "EID", "type", "locators", "ttl", "autoritative");
819 
820  if (print_all)
821  {
822  /* *INDENT-OFF* */
823  pool_foreach (mapit, lcm->mapping_pool,
824  ({
825  locator_set_t * ls = pool_elt_at_index (lcm->locator_set_pool,
826  mapit->locator_set_index);
827  if (filter && !((1 == filter && ls->local) ||
828  (2 == filter && !ls->local)))
829  {
830  continue;
831  }
832  vlib_cli_output (vm, "%U", format_eid_entry, lcm->vnet_main,
833  lcm, mapit, ls);
834  }));
835  /* *INDENT-ON* */
836  }
837  else
838  {
839  mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, &eid);
840  if ((u32) ~ 0 == mi)
841  goto done;
842 
843  mapit = pool_elt_at_index (lcm->mapping_pool, mi);
844  locator_set_t *ls = pool_elt_at_index (lcm->locator_set_pool,
845  mapit->locator_set_index);
846 
847  if (filter && !((1 == filter && ls->local) ||
848  (2 == filter && !ls->local)))
849  {
850  goto done;
851  }
852 
853  vlib_cli_output (vm, "%U,", format_eid_entry, lcm->vnet_main,
854  lcm, mapit, ls);
855  }
856 
857 done:
858  unformat_free (line_input);
859 
860  return error;
861 }
862 
863 /* *INDENT-OFF* */
864 VLIB_CLI_COMMAND (one_cp_show_eid_table_command) = {
865  .path = "show one eid-table",
866  .short_help = "Shows EID table",
867  .function = lisp_show_eid_table_command_fn,
868 };
869 /* *INDENT-ON* */
870 
871 
872 static clib_error_t *
874  vlib_cli_command_t * cmd)
875 {
876  unformat_input_t _line_input, *line_input = &_line_input;
877  u8 is_enabled = 0;
878  u8 is_set = 0;
879  clib_error_t *error = NULL;
880 
881  /* Get a line of input. */
882  if (!unformat_user (input, unformat_line_input, line_input))
883  return 0;
884 
885  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
886  {
887  if (unformat (line_input, "enable"))
888  {
889  is_set = 1;
890  is_enabled = 1;
891  }
892  else if (unformat (line_input, "disable"))
893  is_set = 1;
894  else
895  {
896  error = clib_error_return (0, "parse error: '%U'",
897  format_unformat_error, line_input);
898  goto done;
899  }
900  }
901 
902  if (!is_set)
903  {
904  error = clib_error_return (0, "state not set");
905  goto done;
906  }
907 
908  vnet_lisp_enable_disable (is_enabled);
909 
910 done:
911  unformat_free (line_input);
912 
913  return error;
914 }
915 
916 /* *INDENT-OFF* */
917 VLIB_CLI_COMMAND (one_cp_enable_disable_command) = {
918  .path = "one",
919  .short_help = "one [enable|disable]",
920  .function = lisp_enable_disable_command_fn,
921 };
922 /* *INDENT-ON* */
923 
924 static clib_error_t *
926  unformat_input_t * input,
927  vlib_cli_command_t * cmd)
928 {
929  unformat_input_t _line_input, *line_input = &_line_input;
930  u8 is_enabled = 0;
931  u8 is_set = 0;
932  clib_error_t *error = NULL;
933 
934  /* Get a line of input. */
935  if (!unformat_user (input, unformat_line_input, line_input))
936  return 0;
937 
938  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
939  {
940  if (unformat (line_input, "enable"))
941  {
942  is_set = 1;
943  is_enabled = 1;
944  }
945  else if (unformat (line_input, "disable"))
946  is_set = 1;
947  else
948  {
949  vlib_cli_output (vm, "parse error: '%U'", format_unformat_error,
950  line_input);
951  goto done;
952  }
953  }
954 
955  if (!is_set)
956  {
957  vlib_cli_output (vm, "state not set!");
958  goto done;
959  }
960 
962 
963 done:
964  unformat_free (line_input);
965 
966  return error;
967 }
968 
969 /* *INDENT-OFF* */
970 VLIB_CLI_COMMAND (one_map_register_enable_disable_command) = {
971  .path = "one map-register",
972  .short_help = "one map-register [enable|disable]",
974 };
975 /* *INDENT-ON* */
976 
977 static clib_error_t *
979  unformat_input_t * input,
980  vlib_cli_command_t * cmd)
981 {
982  unformat_input_t _line_input, *line_input = &_line_input;
983  u8 is_enabled = 0;
984  u8 is_set = 0;
985  clib_error_t *error = NULL;
986 
987  /* Get a line of input. */
988  if (!unformat_user (input, unformat_line_input, line_input))
989  return 0;
990 
991  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
992  {
993  if (unformat (line_input, "enable"))
994  {
995  is_set = 1;
996  is_enabled = 1;
997  }
998  else if (unformat (line_input, "disable"))
999  is_set = 1;
1000  else
1001  {
1002  vlib_cli_output (vm, "parse error: '%U'", format_unformat_error,
1003  line_input);
1004  goto done;
1005  }
1006  }
1007 
1008  if (!is_set)
1009  {
1010  vlib_cli_output (vm, "state not set!");
1011  goto done;
1012  }
1013 
1015 
1016 done:
1017  unformat_free (line_input);
1018 
1019  return error;
1020 }
1021 
1022 /* *INDENT-OFF* */
1023 VLIB_CLI_COMMAND (one_rloc_probe_enable_disable_command) = {
1024  .path = "one rloc-probe",
1025  .short_help = "one rloc-probe [enable|disable]",
1027 };
1028 /* *INDENT-ON* */
1029 
1030 static u8 *
1031 format_lisp_status (u8 * s, va_list * args)
1032 {
1034  return format (s, "%s", lcm->is_enabled ? "enabled" : "disabled");
1035 }
1036 
1037 static clib_error_t *
1039  vlib_cli_command_t * cmd)
1040 {
1041  u8 *msg = 0;
1042  msg = format (msg, "feature: %U\ngpe: %U\n",
1044  vlib_cli_output (vm, "%v", msg);
1045  vec_free (msg);
1046  return 0;
1047 }
1048 
1049 /* *INDENT-OFF* */
1050 VLIB_CLI_COMMAND (one_show_status_command) = {
1051  .path = "show one status",
1052  .short_help = "show one status",
1053  .function = lisp_show_status_command_fn,
1054 };
1055 /* *INDENT-ON* */
1056 
1057 static clib_error_t *
1059  unformat_input_t * input,
1060  vlib_cli_command_t * cmd)
1061 {
1062  hash_pair_t *p;
1063  unformat_input_t _line_input, *line_input = &_line_input;
1065  uword *vni_table = 0;
1066  u8 is_l2 = 0;
1067  clib_error_t *error = NULL;
1068 
1069  /* Get a line of input. */
1070  if (!unformat_user (input, unformat_line_input, line_input))
1071  return 0;
1072 
1073  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1074  {
1075  if (unformat (line_input, "l2"))
1076  {
1077  vni_table = lcm->bd_id_by_vni;
1078  is_l2 = 1;
1079  }
1080  else if (unformat (line_input, "l3"))
1081  {
1082  vni_table = lcm->table_id_by_vni;
1083  is_l2 = 0;
1084  }
1085  else
1086  {
1087  error = clib_error_return (0, "parse error: '%U'",
1088  format_unformat_error, line_input);
1089  goto done;
1090  }
1091  }
1092 
1093  if (!vni_table)
1094  {
1095  vlib_cli_output (vm, "Error: expected l2|l3 param!\n");
1096  goto done;
1097  }
1098 
1099  vlib_cli_output (vm, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
1100 
1101  /* *INDENT-OFF* */
1102  hash_foreach_pair (p, vni_table,
1103  ({
1104  vlib_cli_output (vm, "%=10d%=10d", p->key, p->value[0]);
1105  }));
1106  /* *INDENT-ON* */
1107 
1108 done:
1109  unformat_free (line_input);
1110 
1111  return error;
1112 }
1113 
1114 /* *INDENT-OFF* */
1115 VLIB_CLI_COMMAND (one_show_eid_table_map_command) = {
1116  .path = "show one eid-table map",
1117  .short_help = "show one eid-table l2|l3",
1119 };
1120 /* *INDENT-ON* */
1121 
1122 
1123 static clib_error_t *
1125  unformat_input_t * input,
1126  vlib_cli_command_t * cmd)
1127 {
1129  vnet_main_t *vnm = lgm->vnet_main;
1130  unformat_input_t _line_input, *line_input = &_line_input;
1131  u8 is_add = 1;
1132  clib_error_t *error = 0;
1133  u8 *locator_set_name = 0;
1134  locator_t locator, *locators = 0;
1136  u32 ls_index = 0;
1137  int rv = 0;
1138 
1139  memset (&locator, 0, sizeof (locator));
1140  memset (a, 0, sizeof (a[0]));
1141 
1142  /* Get a line of input. */
1143  if (!unformat_user (input, unformat_line_input, line_input))
1144  return 0;
1145 
1146  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1147  {
1148  if (unformat (line_input, "add %_%v%_", &locator_set_name))
1149  is_add = 1;
1150  else if (unformat (line_input, "del %_%v%_", &locator_set_name))
1151  is_add = 0;
1152  else if (unformat (line_input, "iface %U p %d w %d",
1154  &locator.sw_if_index, &locator.priority,
1155  &locator.weight))
1156  {
1157  locator.local = 1;
1158  vec_add1 (locators, locator);
1159  }
1160  else
1161  {
1162  error = unformat_parse_error (line_input);
1163  goto done;
1164  }
1165  }
1166 
1167  a->name = locator_set_name;
1168  a->locators = locators;
1169  a->is_add = is_add;
1170  a->local = 1;
1171 
1172  rv = vnet_lisp_add_del_locator_set (a, &ls_index);
1173  if (0 != rv)
1174  {
1175  error = clib_error_return (0, "failed to %s locator-set!",
1176  is_add ? "add" : "delete");
1177  }
1178 
1179 done:
1180  vec_free (locators);
1181  if (locator_set_name)
1182  vec_free (locator_set_name);
1183  unformat_free (line_input);
1184  return error;
1185 }
1186 
1187 /* *INDENT-OFF* */
1188 VLIB_CLI_COMMAND (one_cp_add_del_locator_set_command) = {
1189  .path = "one locator-set",
1190  .short_help = "one locator-set add/del <name> [iface <iface-name> "
1191  "p <priority> w <weight>]",
1193 };
1194 /* *INDENT-ON* */
1195 
1196 static clib_error_t *
1198  unformat_input_t * input,
1199  vlib_cli_command_t * cmd)
1200 {
1202  vnet_main_t *vnm = lgm->vnet_main;
1203  unformat_input_t _line_input, *line_input = &_line_input;
1204  u8 is_add = 1;
1205  clib_error_t *error = 0;
1206  u8 *locator_set_name = 0;
1207  u8 locator_set_name_set = 0;
1208  locator_t locator, *locators = 0;
1210  u32 ls_index = 0;
1211 
1212  memset (&locator, 0, sizeof (locator));
1213  memset (a, 0, sizeof (a[0]));
1214 
1215  /* Get a line of input. */
1216  if (!unformat_user (input, unformat_line_input, line_input))
1217  return 0;
1218 
1219  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1220  {
1221  if (unformat (line_input, "add"))
1222  is_add = 1;
1223  else if (unformat (line_input, "del"))
1224  is_add = 0;
1225  else if (unformat (line_input, "locator-set %_%v%_", &locator_set_name))
1226  locator_set_name_set = 1;
1227  else if (unformat (line_input, "iface %U p %d w %d",
1229  &locator.sw_if_index, &locator.priority,
1230  &locator.weight))
1231  {
1232  locator.local = 1;
1233  vec_add1 (locators, locator);
1234  }
1235  else
1236  {
1237  error = unformat_parse_error (line_input);
1238  goto done;
1239  }
1240  }
1241 
1242  if (!locator_set_name_set)
1243  {
1244  error = clib_error_return (0, "locator_set name not set!");
1245  goto done;
1246  }
1247 
1248  a->name = locator_set_name;
1249  a->locators = locators;
1250  a->is_add = is_add;
1251  a->local = 1;
1252 
1253  vnet_lisp_add_del_locator (a, 0, &ls_index);
1254 
1255 done:
1256  vec_free (locators);
1257  vec_free (locator_set_name);
1258  unformat_free (line_input);
1259  return error;
1260 }
1261 
1262 /* *INDENT-OFF* */
1263 VLIB_CLI_COMMAND (one_cp_add_del_locator_in_set_command) = {
1264  .path = "one locator",
1265  .short_help = "one locator add/del locator-set <name> iface <iface-name> "
1266  "p <priority> w <weight>",
1268 };
1269 /* *INDENT-ON* */
1270 
1271 static clib_error_t *
1273  unformat_input_t * input,
1274  vlib_cli_command_t * cmd)
1275 {
1276  locator_set_t *lsit;
1277  locator_t *loc;
1278  u32 *locit;
1280 
1281  vlib_cli_output (vm, "%s%=16s%=16s%=16s", "Locator-set", "Locator",
1282  "Priority", "Weight");
1283 
1284  /* *INDENT-OFF* */
1285  pool_foreach (lsit, lcm->locator_set_pool,
1286  ({
1287  u8 * msg = 0;
1288  int next_line = 0;
1289  if (lsit->local)
1290  {
1291  msg = format (msg, "%v", lsit->name);
1292  }
1293  else
1294  {
1295  msg = format (msg, "<%s-%d>", "remote", lsit - lcm->locator_set_pool);
1296  }
1297  vec_foreach (locit, lsit->locator_indices)
1298  {
1299  if (next_line)
1300  {
1301  msg = format (msg, "%16s", " ");
1302  }
1303  loc = pool_elt_at_index (lcm->locator_pool, locit[0]);
1304  if (loc->local)
1305  msg = format (msg, "%16d%16d%16d\n", loc->sw_if_index, loc->priority,
1306  loc->weight);
1307  else
1308  msg = format (msg, "%16U%16d%16d\n", format_ip_address,
1309  &gid_address_ip(&loc->address), loc->priority,
1310  loc->weight);
1311  next_line = 1;
1312  }
1313  vlib_cli_output (vm, "%v", msg);
1314  vec_free (msg);
1315  }));
1316  /* *INDENT-ON* */
1317  return 0;
1318 }
1319 
1320 /* *INDENT-OFF* */
1321 VLIB_CLI_COMMAND (one_cp_show_locator_sets_command) = {
1322  .path = "show one locator-set",
1323  .short_help = "Shows locator-sets",
1325 };
1326 /* *INDENT-ON* */
1327 
1328 
1329 static clib_error_t *
1331  unformat_input_t * input,
1332  vlib_cli_command_t * cmd)
1333 {
1334  unformat_input_t _line_input, *line_input = &_line_input;
1335  u8 is_add = 1, addr_set = 0;
1336  ip_address_t ip_addr;
1337  clib_error_t *error = 0;
1338  int rv = 0;
1340 
1341  /* Get a line of input. */
1342  if (!unformat_user (input, unformat_line_input, line_input))
1343  return 0;
1344 
1345  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1346  {
1347  if (unformat (line_input, "add"))
1348  is_add = 1;
1349  else if (unformat (line_input, "del"))
1350  is_add = 0;
1351  else if (unformat (line_input, "%U", unformat_ip_address, &ip_addr))
1352  addr_set = 1;
1353  else
1354  {
1355  error = unformat_parse_error (line_input);
1356  goto done;
1357  }
1358  }
1359 
1360  if (!addr_set)
1361  {
1362  error = clib_error_return (0, "Map-resolver address must be set!");
1363  goto done;
1364  }
1365 
1366  a->is_add = is_add;
1367  a->address = ip_addr;
1369  if (0 != rv)
1370  {
1371  error = clib_error_return (0, "failed to %s map-resolver!",
1372  is_add ? "add" : "delete");
1373  }
1374 
1375 done:
1376  unformat_free (line_input);
1377  return error;
1378 }
1379 
1380 /* *INDENT-OFF* */
1381 VLIB_CLI_COMMAND (one_add_del_map_resolver_command) = {
1382  .path = "one map-resolver",
1383  .short_help = "one map-resolver add/del <ip_address>",
1385 };
1386 /* *INDENT-ON* */
1387 
1388 
1389 static clib_error_t *
1391  unformat_input_t * input,
1392  vlib_cli_command_t * cmd)
1393 {
1394  unformat_input_t _line_input, *line_input = &_line_input;
1395  u8 is_add = 1;
1396  u8 *locator_set_name = 0;
1397  clib_error_t *error = 0;
1398  int rv = 0;
1400 
1401  /* Get a line of input. */
1402  if (!unformat_user (input, unformat_line_input, line_input))
1403  return 0;
1404 
1405  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1406  {
1407  if (unformat (line_input, "del"))
1408  is_add = 0;
1409  else if (unformat (line_input, "add %_%v%_", &locator_set_name))
1410  is_add = 1;
1411  else
1412  {
1413  error = unformat_parse_error (line_input);
1414  goto done;
1415  }
1416  }
1417 
1418  a->is_add = is_add;
1419  a->locator_set_name = locator_set_name;
1421  if (0 != rv)
1422  {
1423  error = clib_error_return (0, "failed to %s map-request itr-rlocs!",
1424  is_add ? "add" : "delete");
1425  }
1426 
1427 done:
1428  vec_free (locator_set_name);
1429  unformat_free (line_input);
1430  return error;
1431 
1432 }
1433 
1434 /* *INDENT-OFF* */
1435 VLIB_CLI_COMMAND (one_add_del_map_request_command) = {
1436  .path = "one map-request itr-rlocs",
1437  .short_help = "one map-request itr-rlocs add/del <locator_set_name>",
1439 };
1440 /* *INDENT-ON* */
1441 
1442 static clib_error_t *
1444  unformat_input_t * input,
1445  vlib_cli_command_t * cmd)
1446 {
1448  locator_set_t *loc_set;
1449 
1450  vlib_cli_output (vm, "%=20s", "itr-rlocs");
1451 
1452  if (~0 == lcm->mreq_itr_rlocs)
1453  {
1454  return 0;
1455  }
1456 
1457  loc_set = pool_elt_at_index (lcm->locator_set_pool, lcm->mreq_itr_rlocs);
1458 
1459  vlib_cli_output (vm, "%=20s", loc_set->name);
1460 
1461  return 0;
1462 }
1463 
1464 /* *INDENT-OFF* */
1465 VLIB_CLI_COMMAND (one_show_map_request_command) = {
1466  .path = "show one map-request itr-rlocs",
1467  .short_help = "Shows map-request itr-rlocs",
1469 };
1470 /* *INDENT-ON* */
1471 
1472 static clib_error_t *
1474  unformat_input_t * input,
1475  vlib_cli_command_t * cmd)
1476 {
1477  u8 is_add = 1, ip_set = 0;
1478  unformat_input_t _line_input, *line_input = &_line_input;
1479  clib_error_t *error = 0;
1480  ip_address_t ip;
1481 
1482  /* Get a line of input. */
1483  if (!unformat_user (input, unformat_line_input, line_input))
1484  return 0;
1485 
1486  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1487  {
1488  if (unformat (line_input, "%U", unformat_ip_address, &ip))
1489  ip_set = 1;
1490  else if (unformat (line_input, "disable"))
1491  is_add = 0;
1492  else
1493  {
1494  error = clib_error_return (0, "parse error");
1495  goto done;
1496  }
1497  }
1498 
1499  if (!ip_set)
1500  {
1501  clib_warning ("No petr IP specified!");
1502  goto done;
1503  }
1504 
1505  if (vnet_lisp_use_petr (&ip, is_add))
1506  {
1507  error = clib_error_return (0, "failed to %s petr!",
1508  is_add ? "add" : "delete");
1509  }
1510 
1511 done:
1512  unformat_free (line_input);
1513  return error;
1514 }
1515 
1516 /* *INDENT-OFF* */
1517 VLIB_CLI_COMMAND (one_use_petr_set_locator_set_command) = {
1518  .path = "one use-petr",
1519  .short_help = "one use-petr [disable] <petr-ip>",
1521 };
1522 
1523 static clib_error_t *
1525  unformat_input_t * input, vlib_cli_command_t * cmd)
1526 {
1528  mapping_t *m;
1529  locator_set_t *ls;
1530  locator_t *loc;
1531  u8 *tmp_str = 0;
1532  u8 use_petr = lcm->flags & LISP_FLAG_USE_PETR;
1533  vlib_cli_output (vm, "%=20s%=16s", "petr", use_petr ? "ip" : "");
1534 
1535  if (!use_petr)
1536  {
1537  vlib_cli_output (vm, "%=20s", "disable");
1538  return 0;
1539  }
1540 
1541  if (~0 == lcm->petr_map_index)
1542  {
1543  tmp_str = format (0, "N/A");
1544  }
1545  else
1546  {
1548  if (~0 != m->locator_set_index)
1549  {
1551  loc = pool_elt_at_index (lcm->locator_pool, ls->locator_indices[0]);
1552  tmp_str = format (0, "%U", format_ip_address, &loc->address);
1553  }
1554  else
1555  {
1556  tmp_str = format (0, "N/A");
1557  }
1558  }
1559  vec_add1 (tmp_str, 0);
1560 
1561  vlib_cli_output (vm, "%=20s%=16s", "enable", tmp_str);
1562 
1563  vec_free (tmp_str);
1564 
1565  return 0;
1566 }
1567 
1568 /* *INDENT-OFF* */
1569 VLIB_CLI_COMMAND (one_show_petr_command) = {
1570  .path = "show one petr",
1571  .short_help = "Show petr",
1572  .function = lisp_show_petr_command_fn,
1573 };
1574 /* *INDENT-ON* */
1575 
1576 static clib_error_t *
1578  unformat_input_t * input,
1579  vlib_cli_command_t * cmd)
1580 {
1581  lisp_msmr_t *ms;
1583 
1584  vec_foreach (ms, lcm->map_servers)
1585  {
1586  vlib_cli_output (vm, "%U", format_ip_address, &ms->address);
1587  }
1588  return 0;
1589 }
1590 
1591 /* *INDENT-OFF* */
1592 VLIB_CLI_COMMAND (one_show_map_servers_command) = {
1593  .path = "show one map-servers",
1594  .short_help = "show one map servers",
1596 };
1597 /* *INDENT-ON* */
1598 
1599 static clib_error_t *
1601  unformat_input_t * input,
1602  vlib_cli_command_t * cmd)
1603 {
1604  u8 *msg = 0;
1605  u8 is_enabled = vnet_lisp_map_register_state_get ();
1606 
1607  msg = format (msg, "%s\n", is_enabled ? "enabled" : "disabled");
1608  vlib_cli_output (vm, "%v", msg);
1609  vec_free (msg);
1610  return 0;
1611 }
1612 
1613 /* *INDENT-OFF* */
1614 VLIB_CLI_COMMAND (one_show_map_register_state_command) = {
1615  .path = "show one map-register state",
1616  .short_help = "show one map-register state",
1618 };
1619 /* *INDENT-ON* */
1620 
1621 static clib_error_t *
1623  unformat_input_t * input,
1624  vlib_cli_command_t * cmd)
1625 {
1626  u8 *msg = 0;
1627  u8 is_enabled = vnet_lisp_rloc_probe_state_get ();
1628 
1629  msg = format (msg, "%s\n", is_enabled ? "enabled" : "disabled");
1630  vlib_cli_output (vm, "%v", msg);
1631  vec_free (msg);
1632  return 0;
1633 }
1634 
1635 /* *INDENT-OFF* */
1636 VLIB_CLI_COMMAND (one_show_rloc_probe_state_command) = {
1637  .path = "show one rloc state",
1638  .short_help = "show one RLOC state",
1640 };
1641 /* *INDENT-ON* */
1642 
1643 static clib_error_t *
1645  unformat_input_t * input,
1646  vlib_cli_command_t * cmd)
1647 {
1648  u8 is_enabled = vnet_lisp_stats_enable_disable_state ();
1649  vlib_cli_output (vm, "%s\n", is_enabled ? "enabled" : "disabled");
1650  return 0;
1651 }
1652 
1653 /* *INDENT-OFF* */
1654 VLIB_CLI_COMMAND (one_show_stats_command) = {
1655  .path = "show one statistics status",
1656  .short_help = "show ONE statistics enable/disable status",
1657  .function = lisp_show_stats_command_fn,
1658 };
1659 /* *INDENT-ON* */
1660 
1661 static clib_error_t *
1663  unformat_input_t * input,
1664  vlib_cli_command_t * cmd)
1665 {
1666  lisp_api_stats_t *stat, *stats = vnet_lisp_get_stats ();
1667 
1668  if (vec_len (stats) > 0)
1669  vlib_cli_output (vm,
1670  "[src-EID, dst-EID] [loc-rloc, rmt-rloc] count bytes\n");
1671  else
1672  vlib_cli_output (vm, "No statistics found.\n");
1673 
1674  vec_foreach (stat, stats)
1675  {
1676  vlib_cli_output (vm, "[%U, %U] [%U, %U] %7u %7u\n",
1677  format_fid_address, &stat->seid,
1678  format_fid_address, &stat->deid,
1679  format_ip_address, &stat->loc_rloc,
1680  format_ip_address, &stat->rmt_rloc,
1681  stat->counters.packets, stat->counters.bytes);
1682  }
1683  vec_free (stats);
1684  return 0;
1685 }
1686 
1687 /* *INDENT-OFF* */
1688 VLIB_CLI_COMMAND (one_show_stats_details_command) = {
1689  .path = "show one statistics details",
1690  .short_help = "show ONE statistics",
1692 };
1693 /* *INDENT-ON* */
1694 
1695 static clib_error_t *
1697  unformat_input_t * input,
1698  vlib_cli_command_t * cmd)
1699 {
1700  unformat_input_t _line_input, *line_input = &_line_input;
1701  u8 enable = 0;
1702 
1703  /* Get a line of input. */
1704  if (!unformat_user (input, unformat_line_input, line_input))
1705  return 0;
1706 
1707  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1708  {
1709  if (unformat (line_input, "enable"))
1710  enable = 1;
1711  else if (unformat (line_input, "disable"))
1712  enable = 0;
1713  else
1714  {
1715  clib_warning ("Error: expected enable/disable!");
1716  goto done;
1717  }
1718  }
1720 done:
1721  unformat_free (line_input);
1722  return 0;
1723 }
1724 
1725 /* *INDENT-OFF* */
1726 VLIB_CLI_COMMAND (one_stats_enable_disable_command) = {
1727  .path = "one statistics",
1728  .short_help = "enable/disable ONE statistics collecting",
1730 };
1731 /* *INDENT-ON* */
1732 
1733 static clib_error_t *
1735  unformat_input_t * input,
1736  vlib_cli_command_t * cmd)
1737 {
1739  return 0;
1740 }
1741 
1742 /* *INDENT-OFF* */
1743 VLIB_CLI_COMMAND (one_stats_flush_command) = {
1744  .path = "one statistics flush",
1745  .short_help = "Flush ONE statistics",
1746  .function = lisp_stats_flush_command_fn,
1747 };
1748 /* *INDENT-ON* */
1749 
1750 /*
1751  * fd.io coding-style-patch-verification: ON
1752  *
1753  * Local Variables:
1754  * eval: (c-set-style "gnu")
1755  * End:
1756  */
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:1734
#define gid_address_ip_version(_a)
Definition: lisp_types.h:245
u32 pitr_map_index
Definition: control.h:194
gid_address_t leid
Definition: control.h:63
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
#define gid_address_type(_a)
Definition: lisp_types.h:241
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:682
a
Definition: bitmap.h:516
lisp_msmr_t * map_resolvers
Definition: control.h:166
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:873
uword * table_id_by_vni
Definition: control.h:183
#define NULL
Definition: clib.h:55
static u8 * format_eid_entry(u8 *s, va_list *args)
Definition: one_cli.c:735
locator_t * locator_pool
Definition: control.h:132
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:55
#define ip_prefix_len(_a)
Definition: lisp_types.h:73
ip_address_t loc_rloc
Definition: lisp_gpe.h:104
uword unformat_ip_address(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:147
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:522
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:1124
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:418
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:584
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:982
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
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:418
unformat_function_t unformat_vnet_sw_interface
ip_address_t address
Definition: control.h:78
vnet_api_error_t vnet_lisp_stats_enable_disable(u8 enable)
Definition: control.c:3862
uword unformat_hmac_key_id(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:296
#define ip_prefix_version(_a)
Definition: lisp_types.h:72
u8 vnet_lisp_stats_enable_disable_state(void)
Definition: control.c:3878
format_function_t format_vnet_sw_if_index_name
u8 vnet_lisp_map_register_state_get(void)
Definition: control.c:420
int vnet_lisp_set_map_request_mode(u8 mode)
Definition: control.c:1265
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:1219
uword value[0]
Definition: hash.h:164
uword unformat_negative_mapping_action(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:362
lisp_msmr_t * map_servers
Definition: control.h:169
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:376
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:1577
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:1622
ip_address_t rmt_rloc
Definition: lisp_gpe.h:105
int vnet_lisp_flush_stats(void)
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:782
#define clib_error_return(e, args...)
Definition: error.h:111
int vnet_lisp_eid_table_map(u32 vni, u32 dp_id, u8 is_l2, u8 is_add)
Definition: control.c:832
uword * bd_id_by_vni
Definition: control.h:187
static lisp_cp_main_t * vnet_lisp_cp_get_main()
Definition: control.h:231
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:1272
u32 petr_map_index
Proxy ETR map index.
Definition: control.h:197
unformat_function_t unformat_line_input
Definition: format.h:281
clib_error_t * vnet_lisp_enable_disable(u8 is_enable)
Definition: control.c:1745
u32 gid_dictionary_lookup(gid_dictionary_t *db, gid_address_t *key)
int vnet_lisp_pitr_set_locator_set(u8 *locator_set_name, u8 is_add)
Definition: control.c:1286
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:397
u8 vnet_lisp_rloc_probe_state_get(void)
Definition: control.c:427
counter_t packets
packet counter
Definition: counter.h:141
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
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:521
#define gid_address_mac(_a)
Definition: lisp_types.h:247
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:798
void gid_address_free(gid_address_t *a)
Definition: lisp_types.c:785
u8 authoritative
Definition: lisp_types.h:333
lisp_api_stats_t * vnet_lisp_get_stats(void)
Definition: control.c:3645
uword unformat_gid_address(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:321
u8 * format_gid_address(u8 *s, va_list *args)
Definition: lisp_types.c:241
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:925
int vnet_lisp_add_del_mapping(gid_address_t *eid, locator_t *rlocs, u8 action, u8 authoritative, u32 ttl, u8 is_add, u8 is_static, u32 *res_map_index)
Adds/removes/updates mapping.
Definition: control.c:1035
#define gid_address_ippref(_a)
Definition: lisp_types.h:242
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:598
u32 sw_if_index
Definition: lisp_types.h:294
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:1696
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
int vnet_lisp_add_del_mreq_itr_rlocs(vnet_lisp_add_del_mreq_itr_rloc_args_t *a)
Definition: control.c:1842
vlib_counter_t counters
Definition: lisp_gpe.h:107
vlib_main_t * vm
Definition: buffer.c:276
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:1390
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:340
vnet_main_t * vnet_main
Definition: lisp_gpe.h:168
#define clib_warning(format, args...)
Definition: error.h:59
u32 locator_set_index
Definition: lisp_types.h:326
int vnet_lisp_map_register_enable_disable(u8 is_enable)
Definition: control.c:1736
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:1330
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:602
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:234
lisp_gpe_main_t lisp_gpe_main
LISP-GPE global state.
Definition: lisp_gpe.c:27
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:154
struct _gid_address_t gid_address_t
uword unformat_mac_address(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:190
u8 * format_vnet_lisp_gpe_status(u8 *s, va_list *args)
Format LISP-GPE status.
Definition: lisp_gpe.c:392
int vnet_lisp_add_del_map_server(ip_address_t *addr, u8 is_add)
Definition: control.c:652
unsigned int u32
Definition: types.h:88
u8 * format_ip_address(u8 *s, va_list *args)
Definition: lisp_types.c:127
int vnet_lisp_clear_all_remote_adjacencies(void)
Definition: control.c:1168
static u8 * format_lisp_status(u8 *s, va_list *args)
Definition: one_cli.c:1031
locator_set_t * locator_set_pool
Definition: control.h:135
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:1644
int vnet_lisp_rloc_probe_enable_disable(u8 is_enable)
Definition: control.c:1727
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:288
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:626
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:1058
uword unformat_ip_prefix(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:170
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:978
u64 uword
Definition: types.h:112
#define unformat_parse_error(input)
Definition: format.h:267
counter_t bytes
byte counter
Definition: counter.h:142
int vnet_lisp_add_del_locator_set(vnet_lisp_add_del_locator_set_args_t *a, u32 *ls_result)
Definition: control.c:1587
#define gid_address_ip(_a)
Definition: lisp_types.h:244
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:1443
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:1038
#define gid_address_vni(_a)
Definition: lisp_types.h:249
map_request_mode_t
Definition: control.h:90
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
#define hash_foreach_pair(p, v, body)
Iterate over hash pairs.
Definition: hash.h:349
static void unformat_free(unformat_input_t *i)
Definition: format.h:161
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:1497
mapping_t * mapping_pool
Definition: control.h:126
u8 ip_address_max_len(u8 version)
Definition: lisp_types.c:520
uword * locator_set_index_by_name
Definition: control.h:141
void gid_address_copy(gid_address_t *dst, gid_address_t *src)
Definition: lisp_types.c:1399
gid_address_t eid
Definition: lisp_types.h:321
gid_address_t reid
Definition: control.h:64
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:1600
gid_address_t address
Definition: lisp_types.h:295
#define hash_get_mem(h, key)
Definition: hash.h:268
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:1524
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:1794
static u8 * format_lisp_map_request_mode(u8 *s, va_list *args)
Definition: one_cli.c:569
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:1473
#define vec_foreach(var, vec)
Vector iterator.
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:1197
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:1662
u8 * format_fid_address(u8 *s, va_list *args)
Definition: lisp_types.c:220
int vnet_lisp_use_petr(ip_address_t *ip, u8 is_add)
Configure Proxy-ETR.
Definition: control.c:1338
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:577
u32 mreq_itr_rlocs
Definition: control.h:180
u32 * locator_indices
Definition: lisp_types.h:315
vnet_main_t * vnet_main
Definition: control.h:218
uword key
Definition: hash.h:161
LISP-GPE definitions.
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:971
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:169