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