FD.io VPP  v21.01.1
Vector Packet Processing
lisp_api.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * lisp_api.c - lisp api
4  *
5  * Copyright (c) 2016 Cisco and/or its affiliates.
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at:
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *------------------------------------------------------------------
18  */
19 
20 #include <vnet/vnet.h>
21 #include <vlibmemory/api.h>
22 
23 #include <vnet/interface.h>
24 #include <vnet/api_errno.h>
25 #include <lisp/lisp-cp/control.h>
26 #include <lisp/lisp-gpe/lisp_gpe.h>
27 #include <vnet/ip/ip_types_api.h>
30 
31 /* define message IDs */
32 #include <vnet/format_fns.h>
33 #include <lisp/lisp-cp/lisp.api_enum.h>
34 #include <lisp/lisp-cp/lisp.api_types.h>
35 
36 /**
37  * Base message ID fot the plugin
38  */
40 #define REPLY_MSG_ID_BASE lisp_base_msg_id
41 
43 
44 static locator_t *
45 unformat_lisp_locs (vl_api_remote_locator_t * rmt_locs, u32 rloc_num)
46 {
47  u32 i;
48  locator_t *locs = 0, loc;
49  vl_api_remote_locator_t *r;
50 
51  for (i = 0; i < rloc_num; i++)
52  {
53  /* remote locators */
54  r = &rmt_locs[i];
55  clib_memset (&loc, 0, sizeof (loc));
56  ip_address_decode2 (&r->ip_address, &loc.address.ippref.addr);
57  loc.address.ippref.len =
58  ip_address_max_len (loc.address.ippref.addr.version);
59 
60  loc.priority = r->priority;
61  loc.weight = r->weight;
62 
63  vec_add1 (locs, loc);
64  }
65  return locs;
66 }
67 
68 static void
70  mp)
71 {
73  int rv = 0;
75  locator_t locator;
76  vl_api_local_locator_t *ls_loc;
77  u32 ls_index = ~0, locator_num;
78  u8 *locator_name = NULL;
79  int i;
80 
81  clib_memset (a, 0, sizeof (a[0]));
82 
83  mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
84  locator_name = format (0, "%s", mp->locator_set_name);
85  vec_terminate_c_string (locator_name);
86 
87  a->name = locator_name;
88  a->is_add = mp->is_add;
89  a->local = 1;
90  locator_num = clib_net_to_host_u32 (mp->locator_num);
91 
92  clib_memset (&locator, 0, sizeof (locator));
93  for (i = 0; i < locator_num; i++)
94  {
95  ls_loc = &mp->locators[i];
96  VALIDATE_SW_IF_INDEX (ls_loc);
97 
98  locator.sw_if_index = htonl (ls_loc->sw_if_index);
99  locator.priority = ls_loc->priority;
100  locator.weight = ls_loc->weight;
101  locator.local = 1;
102  vec_add1 (a->locators, locator);
103  }
104 
105  rv = vnet_lisp_add_del_locator_set (a, &ls_index);
106 
108 
109  vec_free (locator_name);
110  vec_free (a->locators);
111 
112  /* *INDENT-OFF* */
113  REPLY_MACRO2 (VL_API_LISP_ADD_DEL_LOCATOR_SET_REPLY,
114  ({
115  rmp->ls_index = clib_host_to_net_u32 (ls_index);
116  }));
117  /* *INDENT-ON* */
118 }
119 
120 static void
122 {
123  vl_api_lisp_add_del_locator_reply_t *rmp;
124  int rv = 0;
125  locator_t locator, *locators = NULL;
127  u32 ls_index = ~0;
128  u8 *locator_name = NULL;
129 
130  clib_memset (&locator, 0, sizeof (locator));
131  clib_memset (a, 0, sizeof (a[0]));
132 
133  locator.sw_if_index = ntohl (mp->sw_if_index);
134  locator.priority = mp->priority;
135  locator.weight = mp->weight;
136  locator.local = 1;
137  vec_add1 (locators, locator);
138 
139  mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
140  locator_name = format (0, "%s", mp->locator_set_name);
141  vec_terminate_c_string (locator_name);
142 
143  a->name = locator_name;
144  a->locators = locators;
145  a->is_add = mp->is_add;
146  a->local = 1;
147 
148  rv = vnet_lisp_add_del_locator (a, NULL, &ls_index);
149 
150  vec_free (locators);
151  vec_free (locator_name);
152 
153  REPLY_MACRO (VL_API_LISP_ADD_DEL_LOCATOR_REPLY);
154 }
155 
156 static void
158 {
159  vl_api_lisp_add_del_local_eid_reply_t *rmp;
161  int rv = 0;
162  gid_address_t _gid, *gid = &_gid;
163  uword *p = NULL;
164  u32 locator_set_index = ~0, map_index = ~0;
166  u8 *name = NULL, *key = NULL;
167  clib_memset (a, 0, sizeof (a[0]));
168  clib_memset (gid, 0, sizeof (gid[0]));
169 
170  rv = unformat_lisp_eid_api (gid, mp->vni, &mp->eid);
171  if (rv)
172  goto out;
173 
174  mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
175  name = format (0, "%s", mp->locator_set_name);
176  vec_terminate_c_string (name);
177  p = hash_get_mem (lcm->locator_set_index_by_name, name);
178  if (!p)
179  {
180  rv = VNET_API_ERROR_INVALID_VALUE;
181  goto out;
182  }
183  locator_set_index = p[0];
184 
185  if (mp->key.id)
186  key = format (0, "%s", mp->key.key);
187 
188  /* XXX treat batch configuration */
189  a->is_add = mp->is_add;
190  gid_address_copy (&a->eid, gid);
191  a->locator_set_index = locator_set_index;
192  a->local = 1;
193  a->key = key;
194  a->key_id = clib_net_to_host_u16 (mp->key.id);
195 
196  rv = vnet_lisp_add_del_local_mapping (a, &map_index);
197 
198 out:
199  vec_free (name);
200  vec_free (key);
201  gid_address_free (&a->eid);
202 
203  REPLY_MACRO (VL_API_LISP_ADD_DEL_LOCAL_EID_REPLY);
204 }
205 
206 static void
209 {
210  vl_api_lisp_eid_table_add_del_map_reply_t *rmp;
211  int rv = 0;
212  rv = vnet_lisp_eid_table_map (clib_net_to_host_u32 (mp->vni),
213  clib_net_to_host_u32 (mp->dp_table),
214  mp->is_l2, mp->is_add);
215 REPLY_MACRO (VL_API_LISP_EID_TABLE_ADD_DEL_MAP_REPLY)}
216 
217 static void
219  * mp)
220 {
221  vl_api_lisp_add_del_map_server_reply_t *rmp;
222  int rv = 0;
224 
225  clib_memset (&addr, 0, sizeof (addr));
226 
227  ip_address_decode2 (&mp->ip_address, &addr);
228  rv = vnet_lisp_add_del_map_server (&addr, mp->is_add);
229 
230  REPLY_MACRO (VL_API_LISP_ADD_DEL_MAP_SERVER_REPLY);
231 }
232 
233 static void
235  * mp)
236 {
237  vl_api_lisp_add_del_map_resolver_reply_t *rmp;
238  int rv = 0;
240 
241  clib_memset (a, 0, sizeof (a[0]));
242 
243  a->is_add = mp->is_add;
245 
247 
248  REPLY_MACRO (VL_API_LISP_ADD_DEL_MAP_RESOLVER_REPLY);
249 }
250 
251 static void
254 {
255  vl_api_lisp_map_register_enable_disable_reply_t *rmp;
256  int rv = 0;
257 
259  REPLY_MACRO (VL_API_LISP_ENABLE_DISABLE_REPLY);
260 }
261 
262 static void
265 {
266  vl_api_lisp_rloc_probe_enable_disable_reply_t *rmp;
267  int rv = 0;
268 
270  REPLY_MACRO (VL_API_LISP_ENABLE_DISABLE_REPLY);
271 }
272 
273 static void
275 {
276  vl_api_lisp_enable_disable_reply_t *rmp;
277  int rv = 0;
278 
280  REPLY_MACRO (VL_API_LISP_ENABLE_DISABLE_REPLY);
281 }
282 
283 static void
286 {
287  int rv = 0;
289 
290  /* *INDENT-OFF* */
291  REPLY_MACRO2(VL_API_SHOW_LISP_MAP_REQUEST_MODE_REPLY,
292  ({
294  }));
295  /* *INDENT-ON* */
296 }
297 
298 static void
300 {
301  vl_api_lisp_map_request_mode_reply_t *rmp;
302  int rv = 0;
303 
305 
306  REPLY_MACRO (VL_API_LISP_MAP_REQUEST_MODE_REPLY);
307 }
308 
309 static void
311  * mp)
312 {
313  vl_api_lisp_pitr_set_locator_set_reply_t *rmp;
314  int rv = 0;
315  u8 *ls_name = 0;
316 
317  mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
318  ls_name = format (0, "%s", mp->ls_name);
319  vec_terminate_c_string (ls_name);
320  rv = vnet_lisp_pitr_set_locator_set (ls_name, mp->is_add);
321  vec_free (ls_name);
322 
323  REPLY_MACRO (VL_API_LISP_PITR_SET_LOCATOR_SET_REPLY);
324 }
325 
326 static void
328 {
329  vl_api_lisp_use_petr_reply_t *rmp;
330  int rv = 0;
332 
333  ip_address_decode2 (&mp->ip_address, &addr);
334  rv = vnet_lisp_use_petr (&addr, mp->is_add);
335 
336  REPLY_MACRO (VL_API_LISP_USE_PETR_REPLY);
337 }
338 
339 static void
341 {
344  mapping_t *m;
345  locator_set_t *ls = 0;
346  int rv = 0;
347  locator_t *loc = 0;
348  u8 status = 0;
350 
351  clib_memset (&addr, 0, sizeof (addr));
352  status = lcm->flags & LISP_FLAG_USE_PETR;
353  if (status)
354  {
356  if (~0 != m->locator_set_index)
357  {
358  ls =
360  loc = pool_elt_at_index (lcm->locator_pool, ls->locator_indices[0]);
361  gid_address_copy (&addr, &loc->address);
362  }
363  }
364 
365  /* *INDENT-OFF* */
366  REPLY_MACRO2 (VL_API_SHOW_LISP_USE_PETR_REPLY,
367  {
368  rmp->is_petr_enable = status;
369  ip_address_encode2 (&gid_address_ip (&addr), &rmp->ip_address);
370  });
371  /* *INDENT-ON* */
372 }
373 
374 static void
377 {
378  vl_api_lisp_add_del_map_request_itr_rlocs_reply_t *rmp;
379  int rv = 0;
380  u8 *locator_set_name = NULL;
382 
383  mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
384  locator_set_name = format (0, "%s", mp->locator_set_name);
385  vec_terminate_c_string (locator_set_name);
386 
387  a->is_add = mp->is_add;
388  a->locator_set_name = locator_set_name;
389 
391 
392  vec_free (locator_set_name);
393 
394  REPLY_MACRO (VL_API_LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY);
395 }
396 
397 static void
400 {
401  locator_t *rlocs = 0;
402  vl_api_lisp_add_del_remote_mapping_reply_t *rmp;
403  int rv = 0;
404  gid_address_t _eid, *eid = &_eid;
405  u32 rloc_num = clib_net_to_host_u32 (mp->rloc_num);
406 
407  clib_memset (eid, 0, sizeof (eid[0]));
408 
409  rv = unformat_lisp_eid_api (eid, mp->vni, &mp->deid);
410  if (rv)
411  goto send_reply;
412 
413  rlocs = unformat_lisp_locs (mp->rlocs, rloc_num);
414 
415  if (!mp->is_add)
416  {
418  clib_memset (a, 0, sizeof (*a));
419  gid_address_copy (&a->reid, eid);
420  a->is_add = 0;
422  if (rv)
423  {
424  goto out;
425  }
426  }
427 
428  /* NOTE: for now this works as a static remote mapping, i.e.,
429  * not authoritative and ttl infinite. */
430  if (mp->is_add)
431  {
432  vnet_lisp_add_del_mapping_args_t _m_args, *m_args = &_m_args;
433  clib_memset (m_args, 0, sizeof (m_args[0]));
434  gid_address_copy (&m_args->eid, eid);
435  m_args->action = mp->action;
436  m_args->is_static = 1;
437  m_args->ttl = ~0;
438  m_args->authoritative = 0;
439  rv = vnet_lisp_add_mapping (m_args, rlocs, NULL, NULL);
440  }
441  else
442  {
443  rv = vnet_lisp_del_mapping (eid, NULL);
444  }
445 
446  if (mp->del_all)
448 
449 out:
450  vec_free (rlocs);
451 send_reply:
452  REPLY_MACRO (VL_API_LISP_ADD_DEL_REMOTE_MAPPING_REPLY);
453 }
454 
455 static void
457 {
458  vl_api_lisp_add_del_adjacency_reply_t *rmp;
460 
461  int rv = 0;
462  clib_memset (a, 0, sizeof (a[0]));
463 
464  rv = unformat_lisp_eid_api (&a->leid, mp->vni, &mp->leid);
465  rv = unformat_lisp_eid_api (&a->reid, mp->vni, &mp->reid);
466 
467  if (rv)
468  goto send_reply;
469 
470  a->is_add = mp->is_add;
472 
473 send_reply:
474  REPLY_MACRO (VL_API_LISP_ADD_DEL_ADJACENCY_REPLY);
475 }
476 
477 static void
479  locator_t * loc, vl_api_registration_t * reg,
480  u32 context)
481 {
483 
484  rmp = vl_msg_api_alloc (sizeof (*rmp));
485  clib_memset (rmp, 0, sizeof (*rmp));
486  rmp->_vl_msg_id = ntohs (VL_API_LISP_LOCATOR_DETAILS + REPLY_MSG_ID_BASE);
487  rmp->context = context;
488 
489  rmp->local = loc->local;
490  if (loc->local)
491  {
492  rmp->sw_if_index = ntohl (loc->sw_if_index);
493  }
494  else
495  {
497  }
498  rmp->priority = loc->priority;
499  rmp->weight = loc->weight;
500 
501  vl_api_send_msg (reg, (u8 *) rmp);
502 }
503 
504 static void
506 {
507  u8 *ls_name = 0;
508  vl_api_registration_t *reg = 0;
510  locator_set_t *lsit = 0;
511  locator_t *loc = 0;
512  u32 ls_index = ~0, *locit = 0;
513  uword *p = 0;
514 
516  if (!reg)
517  return;
518 
519  if (mp->is_index_set)
520  ls_index = htonl (mp->ls_index);
521  else
522  {
523  /* make sure we get a proper C-string */
524  mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
525  ls_name = format (0, "%s", mp->ls_name);
526  vec_terminate_c_string (ls_name);
527  p = hash_get_mem (lcm->locator_set_index_by_name, ls_name);
528  if (!p)
529  goto out;
530  ls_index = p[0];
531  }
532 
533  if (pool_is_free_index (lcm->locator_set_pool, ls_index))
534  return;
535 
536  lsit = pool_elt_at_index (lcm->locator_set_pool, ls_index);
537 
538  vec_foreach (locit, lsit->locator_indices)
539  {
540  loc = pool_elt_at_index (lcm->locator_pool, locit[0]);
541  send_lisp_locator_details (lcm, loc, reg, mp->context);
542  };
543 out:
544  vec_free (ls_name);
545 }
546 
547 static void
549  locator_set_t * lsit,
550  vl_api_registration_t * reg, u32 context,
551  u32 ls_index)
552 {
554  u8 *str = 0;
555 
556  rmp = vl_msg_api_alloc (sizeof (*rmp));
557  clib_memset (rmp, 0, sizeof (*rmp));
558  rmp->_vl_msg_id =
559  ntohs (VL_API_LISP_LOCATOR_SET_DETAILS + REPLY_MSG_ID_BASE);
560  rmp->context = context;
561 
562  rmp->ls_index = htonl (ls_index);
563  if (lsit->local)
564  {
565  ASSERT (lsit->name != NULL);
566  strncpy ((char *) rmp->ls_name, (char *) lsit->name,
567  vec_len (lsit->name));
568  }
569  else
570  {
571  str = format (0, "<remote-%d>", ls_index);
572  strncpy ((char *) rmp->ls_name, (char *) str, vec_len (str));
573  vec_free (str);
574  }
575 
576  vl_api_send_msg (reg, (u8 *) rmp);
577 }
578 
579 static void
581 {
584  locator_set_t *lsit = NULL;
585  u8 filter;
586 
588  if (!reg)
589  return;
590 
591  filter = mp->filter;
592  /* *INDENT-OFF* */
593  pool_foreach (lsit, lcm->locator_set_pool)
594  {
595  if (filter && !((1 == filter && lsit->local) ||
596  (2 == filter && !lsit->local)))
597  {
598  continue;
599  }
600  send_lisp_locator_set_details (lcm, lsit, reg, mp->context,
601  lsit - lcm->locator_set_pool);
602  }
603  /* *INDENT-ON* */
604 }
605 
606 static void
608  vl_api_registration_t * reg, u32 context,
609  u8 filter)
610 {
612  locator_set_t *ls = 0;
614  gid_address_t *gid = NULL;
615 
616  switch (filter)
617  {
618  case 0: /* all mappings */
619  break;
620 
621  case 1: /* local only */
622  if (!mapit->local)
623  return;
624  break;
625  case 2: /* remote only */
626  if (mapit->local)
627  return;
628  break;
629  default:
630  clib_warning ("Filter error, unknown filter: %d", filter);
631  return;
632  }
633 
634  /* don't send PITR generated mapping */
635  if (mapit->pitr_set)
636  return;
637 
638  gid = &mapit->eid;
639 
640  rmp = vl_msg_api_alloc (sizeof (*rmp));
641  clib_memset (rmp, 0, sizeof (*rmp));
642  rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_DETAILS + REPLY_MSG_ID_BASE);
643 
645  if (vec_len (ls->locator_indices) == 0)
646  rmp->locator_set_index = ~0;
647  else
648  rmp->locator_set_index = clib_host_to_net_u32 (mapit->locator_set_index);
649 
650  rmp->is_local = mapit->local;
651  rmp->ttl = clib_host_to_net_u32 (mapit->ttl);
652  rmp->action = mapit->action;
653  rmp->authoritative = mapit->authoritative;
654  switch (gid_address_type (gid))
655  {
656  case GID_ADDR_SRC_DST:
657  lisp_fid_put_api (&rmp->seid, &gid_address_sd_src (gid));
658  lisp_fid_put_api (&rmp->deid, &gid_address_sd_dst (gid));
659  rmp->is_src_dst = 1;
660  break;
661  case GID_ADDR_IP_PREFIX:
662  lisp_gid_put_api (&rmp->seid, gid);
663  break;
664  case GID_ADDR_MAC:
665  lisp_gid_put_api (&rmp->seid, gid);
666  break;
667  default:
668  ASSERT (0);
669  }
670  rmp->context = context;
671  rmp->vni = clib_host_to_net_u32 (gid_address_vni (gid));
672  rmp->key.id = clib_host_to_net_u16 (mapit->key_id);
673  memcpy (rmp->key.key, mapit->key, vec_len (mapit->key));
674  vl_api_send_msg (reg, (u8 *) rmp);
675 }
676 
677 static void
679 {
680  u32 mi;
683  mapping_t *mapit = NULL;
684  gid_address_t _eid, *eid = &_eid;
685 
687  if (!reg)
688  return;
689 
690  if (mp->eid_set)
691  {
692  clib_memset (eid, 0, sizeof (*eid));
693 
694  unformat_lisp_eid_api (eid, mp->vni, &mp->eid);
695 
697  if ((u32) ~ 0 == mi)
698  return;
699 
700  mapit = pool_elt_at_index (lcm->mapping_pool, mi);
701  send_lisp_eid_table_details (mapit, reg, mp->context,
702  0 /* ignore filter */ );
703  }
704  else
705  {
706  /* *INDENT-OFF* */
707  pool_foreach (mapit, lcm->mapping_pool)
708  {
709  send_lisp_eid_table_details(mapit, reg, mp->context,
710  mp->filter);
711  }
712  /* *INDENT-ON* */
713  }
714 }
715 
716 static void
718  u32 context)
719 {
721 
722  rmp = vl_msg_api_alloc (sizeof (*rmp));
723  clib_memset (rmp, 0, sizeof (*rmp));
724  rmp->_vl_msg_id =
725  ntohs (VL_API_LISP_MAP_SERVER_DETAILS + REPLY_MSG_ID_BASE);
726 
727  ip_address_encode2 (ip, &rmp->ip_address);
728  rmp->context = context;
729 
730  vl_api_send_msg (reg, (u8 *) rmp);
731 }
732 
733 static void
735 {
738  lisp_msmr_t *mr;
739 
741  if (!reg)
742  return;
743 
744  vec_foreach (mr, lcm->map_servers)
745  {
747  }
748 }
749 
750 static void
752  vl_api_registration_t * reg, u32 context)
753 {
755 
756  rmp = vl_msg_api_alloc (sizeof (*rmp));
757  clib_memset (rmp, 0, sizeof (*rmp));
758  rmp->_vl_msg_id =
759  ntohs (VL_API_LISP_MAP_RESOLVER_DETAILS + REPLY_MSG_ID_BASE);
760 
761  ip_address_encode2 (ip, &rmp->ip_address);
762  rmp->context = context;
763 
764  vl_api_send_msg (reg, (u8 *) rmp);
765 }
766 
767 static void
769 {
772  lisp_msmr_t *mr;
773 
775  if (!reg)
776  return;
777 
778  vec_foreach (mr, lcm->map_resolvers)
779  {
781  }
782 }
783 
784 static void
786  u32 context)
787 {
789 
790  rmp = vl_msg_api_alloc (sizeof (*rmp));
791  clib_memset (rmp, 0, sizeof (*rmp));
792  rmp->_vl_msg_id =
793  ntohs (VL_API_LISP_EID_TABLE_MAP_DETAILS + REPLY_MSG_ID_BASE);
794 
795  rmp->vni = clib_host_to_net_u32 (p->key);
796  rmp->dp_table = clib_host_to_net_u32 (p->value[0]);
797  rmp->context = context;
798  vl_api_send_msg (reg, (u8 *) rmp);
799 }
800 
801 static void
803  mp)
804 {
807  hash_pair_t *p;
808  uword *vni_table = 0;
809 
811  if (!reg)
812  return;
813 
814  if (mp->is_l2)
815  {
816  vni_table = lcm->bd_id_by_vni;
817  }
818  else
819  {
820  vni_table = lcm->table_id_by_vni;
821  }
822 
823  /* *INDENT-OFF* */
824  hash_foreach_pair (p, vni_table,
825  ({
826  send_eid_table_map_pair (p, reg, mp->context);
827  }));
828  /* *INDENT-ON* */
829 }
830 
831 static void
833 {
835 
836  rmp = vl_msg_api_alloc (sizeof (*rmp));
837  clib_memset (rmp, 0, sizeof (*rmp));
838  rmp->_vl_msg_id =
839  ntohs (VL_API_LISP_EID_TABLE_VNI_DETAILS + REPLY_MSG_ID_BASE);
840  rmp->context = context;
841  rmp->vni = clib_host_to_net_u32 (vni);
842  vl_api_send_msg (reg, (u8 *) rmp);
843 }
844 
845 static void
846 lisp_adjacency_copy (vl_api_lisp_adjacency_t * dst, lisp_adjacency_t * adjs)
847 {
848  lisp_adjacency_t *adj;
849  vl_api_lisp_adjacency_t a;
850  u32 i, n = vec_len (adjs);
851 
852  for (i = 0; i < n; i++)
853  {
854  adj = vec_elt_at_index (adjs, i);
855  clib_memset (&a, 0, sizeof (a));
856 
857  lisp_gid_put_api (&a.reid, &adj->reid);
858  lisp_gid_put_api (&a.leid, &adj->leid);
859 
860  dst[i] = a;
861  }
862 }
863 
864 static void
867 {
869  int rv = 0;
870 
871  /* *INDENT-OFF* */
872  REPLY_MACRO2 (VL_API_SHOW_LISP_RLOC_PROBE_STATE_REPLY,
873  {
875  });
876  /* *INDENT-ON* */
877 }
878 
879 static void
882 {
884  int rv = 0;
885 
886  /* *INDENT-OFF* */
887  REPLY_MACRO2 (VL_API_SHOW_LISP_MAP_REGISTER_STATE_REPLY,
888  {
890  });
891  /* *INDENT-ON* */
892 }
893 
894 static void
896 {
898  lisp_adjacency_t *adjs = 0;
899  int rv = 0;
900  u32 size = ~0;
901  u32 vni = clib_net_to_host_u32 (mp->vni);
902 
904  size = vec_len (adjs) * sizeof (vl_api_lisp_adjacency_t);
905 
906  /* *INDENT-OFF* */
907  REPLY_MACRO4 (VL_API_LISP_ADJACENCIES_GET_REPLY, size,
908  {
909  rmp->count = clib_host_to_net_u32 (vec_len (adjs));
910  lisp_adjacency_copy (rmp->adjacencies, adjs);
911  });
912  /* *INDENT-ON* */
913 
914  vec_free (adjs);
915 }
916 
917 static void
919  mp)
920 {
921  hash_pair_t *p;
922  u32 *vnis = 0;
923  vl_api_registration_t *reg = 0;
925 
927  if (!reg)
928  return;
929 
930  /* *INDENT-OFF* */
932  ({
933  hash_set (vnis, p->key, 0);
934  }));
935 
937  ({
938  hash_set (vnis, p->key, 0);
939  }));
940 
941  hash_foreach_pair (p, vnis,
942  ({
943  send_eid_table_vni (p->key, reg, mp->context);
944  }));
945  /* *INDENT-ON* */
946 
947  hash_free (vnis);
948 }
949 
950 static void
952 {
954  int rv = 0;
955 
956  /* *INDENT-OFF* */
957  REPLY_MACRO2(VL_API_SHOW_LISP_STATUS_REPLY,
958  ({
961  }));
962  /* *INDENT-ON* */
963 }
964 
965 static void
968 {
971  locator_set_t *loc_set = 0;
972  u8 *tmp_str = 0;
973  int rv = 0;
974 
975  if (~0 == lcm->mreq_itr_rlocs)
976  {
977  tmp_str = format (0, " ");
978  }
979  else
980  {
981  loc_set =
983  tmp_str = format (0, "%s", loc_set->name);
984  }
985 
986  /* *INDENT-OFF* */
987  REPLY_MACRO2(VL_API_LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY,
988  ({
989  strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
990  ARRAY_LEN(rmp->locator_set_name) - 1);
991  }));
992  /* *INDENT-ON* */
993 
994  vec_free (tmp_str);
995 }
996 
997 static void
999 {
1000  vl_api_show_lisp_pitr_reply_t *rmp = NULL;
1002  mapping_t *m;
1003  locator_set_t *ls = 0;
1004  u8 *tmp_str = 0;
1005  int rv = 0;
1006 
1007  u8 is_enabled = (lcm->flags & LISP_FLAG_PITR_MODE)
1008  && lcm->pitr_map_index != ~0;
1009 
1010  if (!is_enabled)
1011  {
1012  tmp_str = format (0, "N/A");
1013  }
1014  else
1015  {
1017  if (~0 != m->locator_set_index)
1018  {
1019  ls =
1021  tmp_str = format (0, "%s", ls->name);
1022  }
1023  else
1024  {
1025  tmp_str = format (0, "N/A");
1026  }
1027  }
1028  vec_add1 (tmp_str, 0);
1029 
1030  /* *INDENT-OFF* */
1031  REPLY_MACRO2(VL_API_SHOW_LISP_PITR_REPLY,
1032  ({
1033  rmp->is_enabled = lcm->flags & LISP_FLAG_PITR_MODE;
1034  strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1035  ARRAY_LEN(rmp->locator_set_name) - 1);
1036  }));
1037  /* *INDENT-ON* */
1038 }
1039 
1040 /*
1041  * lisp_api_hookup
1042  * Add vpe's API message handlers to the table.
1043  * vlib has already mapped shared memory and
1044  * added the client registration handlers.
1045  * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
1046  */
1047 #include <lisp/lisp-cp/lisp.api.c>
1048 
1049 static clib_error_t *
1051 {
1052  /*
1053  * Set up the (msg_name, crc, message-id) table
1054  */
1055  lisp_base_msg_id = setup_message_id_table ();
1056 
1057  return NULL;
1058 }
1059 
1061 
1062 /*
1063  * fd.io coding-style-patch-verification: ON
1064  *
1065  * Local Variables:
1066  * eval: (c-set-style "gnu")
1067  * End:
1068  */
Reply for show_lisp_map_register_state.
Definition: lisp.api:242
static void send_lisp_eid_table_details(mapping_t *mapit, vl_api_registration_t *reg, u32 context, u8 filter)
Definition: lisp_api.c:607
vl_api_local_locator_t locators[locator_num]
Definition: lisp.api:36
static void send_eid_table_map_pair(hash_pair_t *p, vl_api_registration_t *reg, u32 context)
Definition: lisp_api.c:785
u16 vni
Definition: flow_types.api:160
u32 pitr_map_index
Definition: control.h:251
gid_address_t leid
Definition: control.h:74
void lisp_gid_put_api(vl_api_eid_t *eid, const gid_address_t *gid)
LISP locator_set status.
Definition: lisp.api:390
enable/disable LISP RLOC probing
Definition: lisp.api:209
#define gid_address_type(_a)
Definition: lisp_types.h:203
void ip_address_encode2(const ip_address_t *in, vl_api_address_t *out)
Definition: ip_types_api.c:242
a
Definition: bitmap.h:544
u8 vnet_lisp_gpe_enable_disable_status(void)
Check if LISP-GPE is enabled.
Definition: lisp_gpe.c:184
#define ntohs(x)
Definition: af_xdp.bpf.c:29
static void vl_api_lisp_get_map_request_itr_rlocs_t_handler(vl_api_lisp_get_map_request_itr_rlocs_t *mp)
Definition: lisp_api.c:967
lisp_msmr_t * map_resolvers
Definition: control.h:221
VLIB_API_INIT_FUNCTION(lisp_api_hookup)
configure or disable LISP PITR node
Definition: lisp.api:137
Reply for locator_set add/del.
Definition: lisp.api:44
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:527
#define REPLY_MACRO4(t, n, body)
LISP map resolver status.
Definition: lisp.api:570
vl_api_lisp_adjacency_t adjacencies[count]
Definition: lisp.api:509
uword * table_id_by_vni
Definition: control.h:240
#define REPLY_MACRO2(t, body)
vl_api_interface_index_t sw_if_index
Definition: lisp.api:66
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static void lisp_adjacency_copy(vl_api_lisp_adjacency_t *dst, lisp_adjacency_t *adjs)
Definition: lisp_api.c:846
vl_api_address_t ip_address
Definition: lisp.api:573
locator_t * locator_pool
Definition: control.h:178
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:35
static void send_lisp_map_resolver_details(ip_address_t *ip, vl_api_registration_t *reg, u32 context)
Definition: lisp_api.c:751
u8 vnet_lisp_get_map_request_mode(void)
Definition: control.c:55
static u32 lisp_base_msg_id
Base message ID fot the plugin.
Definition: lisp_api.c:39
static void vl_api_lisp_add_del_map_server_t_handler(vl_api_lisp_add_del_map_server_t *mp)
Definition: lisp_api.c:218
#define vec_terminate_c_string(V)
(If necessary) NULL terminate a vector containing a c-string.
Definition: vec.h:1090
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:592
LISP locator_set status.
Definition: lisp.api:405
bool is_add[default=true]
Definition: lisp.api:64
vlib_main_t * vm
Definition: in2out_ed.c:1580
Request for lisp_eid_table_map_details.
Definition: lisp.api:540
configure or disable use of PETR
Definition: lisp.api:151
static void vl_api_lisp_pitr_set_locator_set_t_handler(vl_api_lisp_pitr_set_locator_set_t *mp)
Definition: lisp_api.c:310
Request for LISP PETR status.
Definition: lisp.api:163
static void send_lisp_locator_details(lisp_cp_main_t *lcm, locator_t *loc, vl_api_registration_t *reg, u32 context)
Definition: lisp_api.c:478
static void vl_api_lisp_eid_table_add_del_map_t_handler(vl_api_lisp_eid_table_add_del_map_t *mp)
Definition: lisp_api.c:208
static void vl_api_lisp_add_del_locator_set_t_handler(vl_api_lisp_add_del_locator_set_t *mp)
Definition: lisp_api.c:69
ip_address_t address
Definition: control.h:89
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:1228
static void vl_api_lisp_locator_dump_t_handler(vl_api_lisp_locator_dump_t *mp)
Definition: lisp_api.c:505
bool is_add[default=true]
Definition: lisp.api:324
void * vl_msg_api_alloc(int nbytes)
vhost_vring_addr_t addr
Definition: vhost_user.h:111
unsigned char u8
Definition: types.h:56
u8 vnet_lisp_map_register_state_get(void)
Definition: control.c:374
int vnet_lisp_set_map_request_mode(u8 mode)
Definition: control.c:1508
Reply for show_lisp_map_request_mode.
Definition: lisp.api:277
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:1437
Request for map resolver summary status.
Definition: lisp.api:580
static void vl_api_lisp_map_register_enable_disable_t_handler(vl_api_lisp_map_register_enable_disable_t *mp)
Definition: lisp_api.c:253
uword value[0]
Definition: hash.h:165
lisp_msmr_t * map_servers
Definition: control.h:224
add or delete LISP adjacency adjacency
Definition: lisp.api:320
bool is_add[default=true]
Definition: lisp.api:101
static void vl_api_lisp_rloc_probe_enable_disable_t_handler(vl_api_lisp_rloc_probe_enable_disable_t *mp)
Definition: lisp_api.c:264
static void vl_api_lisp_add_del_remote_mapping_t_handler(vl_api_lisp_add_del_remote_mapping_t *mp)
Definition: lisp_api.c:399
u8 * key
Definition: lisp_types.h:315
description fragment has unexpected format
Definition: map.api:433
#define gid_address_sd_src(_a)
Definition: lisp_types.h:220
static void vl_api_show_lisp_map_register_state_t_handler(vl_api_show_lisp_map_register_state_t *mp)
Definition: lisp_api.c:881
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static void vl_api_lisp_adjacencies_get_t_handler(vl_api_lisp_adjacencies_get_t *mp)
Definition: lisp_api.c:895
bool is_add[default=true]
Definition: lisp.api:360
Get LISP map request itr rlocs status.
Definition: lisp.api:632
Reply for show_lisp_rloc_probe_state.
Definition: lisp.api:197
add or delete map request itr rlocs
Definition: lisp.api:336
typedef eid
Definition: lisp_types.api:59
int vnet_lisp_eid_table_map(u32 vni, u32 dp_id, u8 is_l2, u8 is_add)
Definition: control.c:1034
unsigned int u32
Definition: types.h:88
uword * bd_id_by_vni
Definition: control.h:244
static lisp_cp_main_t * vnet_lisp_cp_get_main()
Definition: control.h:305
u32 petr_map_index
Proxy ETR map index used for &#39;use-petr&#39;.
Definition: control.h:255
static void vl_api_lisp_use_petr_t_handler(vl_api_lisp_use_petr_t *mp)
Definition: lisp_api.c:327
clib_error_t * vnet_lisp_enable_disable(u8 is_enable)
Definition: control.c:2204
static void vl_api_show_lisp_pitr_t_handler(vl_api_show_lisp_pitr_t *mp)
Definition: lisp_api.c:998
vl_api_hmac_key_t key
Definition: lisp.api:88
Get state of LISP map-register.
Definition: lisp.api:232
Get state of LISP RLOC probing.
Definition: lisp.api:186
vl_api_hmac_key_t key
Definition: lisp.api:462
int vnet_lisp_pitr_set_locator_set(u8 *locator_set_name, u8 is_add)
Definition: control.c:1580
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:546
u8 vnet_lisp_rloc_probe_state_get(void)
Definition: control.c:381
set LISP map-request mode.
Definition: lisp.api:255
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:835
Request for LISP adjacencies.
Definition: lisp.api:517
u32 size
Definition: vhost_user.h:106
#define hash_free(h)
Definition: hash.h:310
void gid_address_free(gid_address_t *a)
Definition: lisp_types.c:733
vl_api_lisp_locator_set_filter_t filter
Definition: lisp.api:487
u8 authoritative
Definition: lisp_types.h:305
add or delete lisp eid-table
Definition: lisp.api:80
LISP adjacency reply.
Definition: lisp.api:504
#define REPLY_MACRO(t)
static void vl_api_lisp_map_server_dump_t_handler(vl_api_lisp_map_server_dump_t *mp)
Definition: lisp_api.c:734
static void vl_api_lisp_add_del_adjacency_t_handler(vl_api_lisp_add_del_adjacency_t *mp)
Definition: lisp_api.c:456
vl_api_address_t dst
Definition: gre.api:55
LISP PETR status, enable or disable.
Definition: lisp.api:174
lisp_adjacency_t * vnet_lisp_adjacencies_get_by_vni(u32 vni)
Returns vector of adjacencies.
Definition: control.c:577
string locator_set_name[64]
Definition: lisp.api:65
void ip_address_decode2(const vl_api_address_t *in, ip_address_t *out)
Definition: ip_types_api.c:192
An API client registration, only in vpp/vlib.
Definition: api_common.h:47
static void setup_message_id_table(api_main_t *am)
Definition: bfd_api.c:409
#define BAD_SW_IF_INDEX_LABEL
u32 sw_if_index
Definition: lisp_types.h:266
Request for lisp-gpe protocol status.
Definition: lisp.api:609
vl_api_address_t ip_address
Definition: lisp.api:155
int vnet_lisp_add_del_mreq_itr_rlocs(vnet_lisp_add_del_mreq_itr_rloc_args_t *a)
Definition: control.c:2339
enable or disable LISP feature
Definition: lisp.api:124
bool is_add[default=true]
Definition: lisp.api:115
Shows relationship between vni and vrf/bd.
Definition: lisp.api:528
bool is_add[default=true]
Definition: lisp.api:156
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:317
static void vl_api_show_lisp_status_t_handler(vl_api_show_lisp_status_t *mp)
Definition: lisp_api.c:951
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:380
#define clib_warning(format, args...)
Definition: error.h:59
u32 locator_set_index
Definition: lisp_types.h:298
static void vl_api_lisp_locator_set_dump_t_handler(vl_api_lisp_locator_set_dump_t *mp)
Definition: lisp_api.c:580
int vnet_lisp_map_register_enable_disable(u8 is_enable)
Definition: control.c:2138
add or delete map-resolver
Definition: lisp.api:111
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:298
#define ARRAY_LEN(x)
Definition: clib.h:67
lisp_key_type_t key_id
Definition: lisp_types.h:316
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79
Request for map lisp locator status.
Definition: lisp.api:373
string name[64]
Definition: ip.api:44
u8 vnet_lisp_enable_disable_status(void)
Definition: control.c:2269
vl_api_lisp_locator_set_filter_t filter
Definition: lisp.api:427
struct _gid_address_t gid_address_t
Dump lisp eid-table.
Definition: lisp.api:450
vl_api_address_t ip_address
Definition: lisp.api:592
static clib_error_t * lisp_api_hookup(vlib_main_t *vm)
Definition: lisp_api.c:1050
int vnet_lisp_add_del_map_server(ip_address_t *addr, u8 is_add)
Definition: control.c:631
#define ASSERT(truth)
#define REPLY_MSG_ID_BASE
Definition: lisp_api.c:40
Request for eid table summary status.
Definition: lisp.api:479
enable/disable LISP map-register
Definition: lisp.api:221
int vnet_lisp_clear_all_remote_adjacencies(void)
Definition: control.c:1386
Request for locator_set summary status.
Definition: lisp.api:423
#define gid_address_sd_dst(_a)
Definition: lisp_types.h:221
static void vl_api_show_lisp_use_petr_t_handler(vl_api_show_lisp_use_petr_t *mp)
Definition: lisp_api.c:340
Reply for lisp_add_del_map_request_itr_rlocs.
Definition: lisp.api:356
static void send_lisp_map_server_details(ip_address_t *ip, vl_api_registration_t *reg, u32 context)
Definition: lisp_api.c:717
gid_dictionary_t mapping_index_by_gid
Definition: control.h:169
vl_api_address_t ip_address
Definition: lisp.api:179
locator_set_t * locator_set_pool
Definition: control.h:181
Status of lisp pitr, enable or disable.
Definition: lisp.api:662
static void vl_api_lisp_map_resolver_dump_t_handler(vl_api_lisp_map_resolver_dump_t *mp)
Definition: lisp_api.c:768
int vnet_lisp_rloc_probe_enable_disable(u8 is_enable)
Definition: control.c:2129
add or delete locator_set
Definition: lisp.api:29
vl_api_remote_locator_t rlocs[rloc_num]
Definition: lisp.api:309
static void vl_api_lisp_add_del_map_request_itr_rlocs_t_handler(vl_api_lisp_add_del_map_request_itr_rlocs_t *mp)
Definition: lisp_api.c:376
u64 gid_dictionary_lookup(gid_dictionary_t *db, gid_address_t *key)
bool is_add[default=true]
Definition: lisp.api:141
vl_api_address_t ip_address
Definition: lisp.api:116
void lisp_fid_put_api(vl_api_eid_t *eid, const fid_address_t *fid)
static void vl_api_lisp_add_del_local_eid_t_handler(vl_api_lisp_add_del_local_eid_t *mp)
Definition: lisp_api.c:157
bool is_add[default=true]
Definition: lisp.api:84
typedef key
Definition: ipsec_types.api:86
int vnet_lisp_add_del_locator_set(vnet_lisp_add_del_locator_set_args_t *a, u32 *ls_result)
Definition: control.c:1994
#define gid_address_ip(_a)
Definition: lisp_types.h:206
Status of lisp, enable or disable.
Definition: lisp.api:620
#define gid_address_vni(_a)
Definition: lisp_types.h:213
vl_api_interface_index_t sw_if_index
Definition: lisp.api:394
Request for map server summary status.
Definition: lisp.api:599
static void vl_api_lisp_eid_table_dump_t_handler(vl_api_lisp_eid_table_dump_t *mp)
Definition: lisp_api.c:678
static void vl_api_show_lisp_map_request_mode_t_handler(vl_api_show_lisp_map_request_mode_t *mp)
Definition: lisp_api.c:285
vl_api_address_t ip
Definition: l2.api:501
static locator_t * unformat_lisp_locs(vl_api_remote_locator_t *rmt_locs, u32 rloc_num)
Definition: lisp_api.c:45
static void send_eid_table_vni(u32 vni, vl_api_registration_t *reg, u32 context)
Definition: lisp_api.c:832
#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
static void send_lisp_locator_set_details(lisp_cp_main_t *lcm, locator_set_t *lsit, vl_api_registration_t *reg, u32 context, u32 ls_index)
Definition: lisp_api.c:548
vl_api_address_t ip_address
Definition: lisp.api:395
add or delete locator for locator_set
Definition: lisp.api:60
u64 uword
Definition: types.h:112
int vnet_lisp_del_mapping(gid_address_t *eid, u32 *res_map_index)
Removes a mapping.
Definition: control.c:1337
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:1890
mapping_t * mapping_pool
Definition: control.h:172
u8 ip_address_max_len(u8 version)
Definition: lisp_types.c:432
uword * locator_set_index_by_name
Definition: control.h:187
add or delete remote static mapping
Definition: lisp.api:297
static void vl_api_lisp_map_request_mode_t_handler(vl_api_lisp_map_request_mode_t *mp)
Definition: lisp_api.c:299
void gid_address_copy(gid_address_t *dst, gid_address_t *src)
Definition: lisp_types.c:1203
gid_address_t eid
Definition: lisp_types.h:293
gid_address_t reid
Definition: control.h:75
gid_address_t address
Definition: lisp_types.h:267
#define hash_get_mem(h, key)
Definition: hash.h:269
LISP map server details.
Definition: lisp.api:589
static void vl_api_lisp_enable_disable_t_handler(vl_api_lisp_enable_disable_t *mp)
Definition: lisp_api.c:274
int vnet_lisp_add_del_map_resolver(vnet_lisp_add_del_map_resolver_args_t *a)
Definition: control.c:2276
bool is_enable[default=true]
Definition: lisp.api:128
static void vl_api_lisp_eid_table_vni_dump_t_handler(vl_api_lisp_eid_table_vni_dump_t *mp)
Definition: lisp_api.c:918
#define vec_foreach(var, vec)
Vector iterator.
Dumps all VNIs used in mappings.
Definition: lisp.api:551
vl_api_address_t ip_address
Definition: lisp.api:102
Request for map request itr rlocs summary status.
Definition: lisp.api:640
static void vl_api_lisp_add_del_locator_t_handler(vl_api_lisp_add_del_locator_t *mp)
Definition: lisp_api.c:121
Request for LISP map-request mode.
Definition: lisp.api:266
static void vl_api_show_lisp_rloc_probe_state_t_handler(vl_api_show_lisp_rloc_probe_state_t *mp)
Definition: lisp_api.c:866
int vnet_lisp_use_petr(ip_address_t *ip, u8 is_add)
Configure Proxy-ETR.
Definition: control.c:1647
reply to lisp_eid_table_vni_dump
Definition: lisp.api:561
u32 mreq_itr_rlocs
Definition: control.h:237
bool is_add[default=true]
Definition: lisp.api:33
u32 * locator_indices
Definition: lisp_types.h:287
int unformat_lisp_eid_api(gid_address_t *dst, u32 vni, const vl_api_eid_t *eid)
uword key
Definition: hash.h:162
LISP-GPE definitions.
static void vl_api_lisp_eid_table_map_dump_t_handler(vl_api_lisp_eid_table_map_dump_t *mp)
Definition: lisp_api.c:802
Request for lisp pitr status.
Definition: lisp.api:651
Add/delete map server.
Definition: lisp.api:97
#define VALIDATE_SW_IF_INDEX(mp)
static void vl_api_lisp_add_del_map_resolver_t_handler(vl_api_lisp_add_del_map_resolver_t *mp)
Definition: lisp_api.c:234