FD.io VPP  v19.04.1-1-ge4a0f9f
Vector Packet Processing
map_api.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * map_api.c - vnet map 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 <map/map.h>
21 #include <map/map_msg_enum.h>
22 #include <vnet/ip/ip.h>
23 #include <vnet/fib/fib_table.h>
24 #include <vlibmemory/api.h>
25 
26 #define vl_typedefs /* define message structures */
27 #include <map/map_all_api_h.h>
28 #undef vl_typedefs
29 
30 #define vl_endianfun /* define message structures */
31 #include <map/map_all_api_h.h>
32 #undef vl_endianfun
33 
34 /* instantiate all the print functions we know about */
35 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
36 #define vl_printfun
37 #include <map/map_all_api_h.h>
38 #undef vl_printfun
39 
40 /* Get the API version number */
41 #define vl_api_version(n,v) static u32 api_version=(v);
42 #include <map/map_all_api_h.h>
43 #undef vl_api_version
44 
45 #define REPLY_MSG_ID_BASE mm->msg_id_base
47 
48 static void
50 {
51  map_main_t *mm = &map_main;
53  int rv = 0;
54  u32 index;
55  u8 flags = 0;
56  char *tag = 0;
57  u32 len;
58 
59  len = ntohl (mp->tag.length);
60  if (len > 0)
61  {
62  tag = clib_mem_alloc (len + 1);
63  clib_memset (tag, 0, len + 1);
64  clib_memcpy (tag, (char *) mp->tag.buf, len);
65  }
66 
67  rv =
68  map_create_domain ((ip4_address_t *) & mp->ip4_prefix.prefix,
69  mp->ip4_prefix.len,
70  (ip6_address_t *) & mp->ip6_prefix.prefix,
71  mp->ip6_prefix.len,
72  (ip6_address_t *) & mp->ip6_src.prefix,
73  mp->ip6_src.len, mp->ea_bits_len, mp->psid_offset,
74  mp->psid_length, &index, ntohs (mp->mtu), flags, tag);
75 
76  if (tag)
77  clib_mem_free (tag);
78 
79  /* *INDENT-OFF* */
80  REPLY_MACRO2(VL_API_MAP_ADD_DOMAIN_REPLY,
81  ({
82  rmp->index = ntohl(index);
83  }));
84  /* *INDENT-ON* */
85 }
86 
87 static void
89 {
90  map_main_t *mm = &map_main;
91  vl_api_map_del_domain_reply_t *rmp;
92  int rv = 0;
93 
94  rv = map_delete_domain (ntohl (mp->index));
95 
96  REPLY_MACRO (VL_API_MAP_DEL_DOMAIN_REPLY);
97 }
98 
99 static void
101 {
102  map_main_t *mm = &map_main;
103  vl_api_map_del_domain_reply_t *rmp;
104  int rv = 0;
105 
106  rv =
107  map_add_del_psid (ntohl (mp->index), ntohs (mp->psid),
108  (ip6_address_t *) & mp->ip6_dst, mp->is_add);
109 
110  REPLY_MACRO (VL_API_MAP_ADD_DEL_RULE_REPLY);
111 }
112 
113 static void
115 {
117  map_main_t *mm = &map_main;
118  map_domain_t *d;
119  map_domain_extra_t *de;
121  u32 map_domain_index;
122 
123  if (pool_elts (mm->domains) == 0)
124  return;
125 
127  if (!reg)
128  return;
129 
130  /* *INDENT-OFF* */
131  pool_foreach(d, mm->domains,
132  ({
133  u32 len;
134 
135  map_domain_index = d - mm->domains;
136  de = vec_elt_at_index(mm->domain_extras, map_domain_index);
137 
138  len = 0;
139  if (de->tag)
140  len = strlen(de->tag);
141 
142  /* Make sure every field is initiated (or don't skip the clib_memset()) */
143  rmp = vl_msg_api_alloc (sizeof (*rmp) + sizeof(rmp->tag.length) + len);
144 
145  rmp->_vl_msg_id = htons(VL_API_MAP_DOMAIN_DETAILS + mm->msg_id_base);
146  rmp->context = mp->context;
147  rmp->domain_index = htonl(map_domain_index);
148  clib_memcpy(&rmp->ip6_prefix.prefix, &d->ip6_prefix, sizeof(rmp->ip6_prefix.prefix));
149  clib_memcpy(&rmp->ip4_prefix.prefix, &d->ip4_prefix, sizeof(rmp->ip4_prefix.prefix));
150  clib_memcpy(&rmp->ip6_src.prefix, &d->ip6_src, sizeof(rmp->ip6_src.prefix));
151  rmp->ip6_prefix.len = d->ip6_prefix_len;
152  rmp->ip4_prefix.len = d->ip4_prefix_len;
153  rmp->ip6_src.len = d->ip6_src_len;
154  rmp->ea_bits_len = d->ea_bits_len;
155  rmp->psid_offset = d->psid_offset;
156  rmp->psid_length = d->psid_length;
157  rmp->flags = d->flags;
158  rmp->mtu = htons(d->mtu);
159 
160  if (de->tag)
161  {
162  rmp->tag.length = htonl (len);
163  clib_memcpy ((char *)rmp->tag.buf, de->tag, len);
164  }
165 
166  vl_api_send_msg (reg, (u8 *) rmp);
167  }));
168  /* *INDENT-ON* */
169 }
170 
171 static void
173 {
175  u16 i;
178  map_main_t *mm = &map_main;
179  u32 domain_index = ntohl (mp->domain_index);
180  map_domain_t *d;
181 
182  if (pool_elts (mm->domains) == 0)
183  return;
184 
185  d = pool_elt_at_index (mm->domains, domain_index);
186  if (!d || !d->rules)
187  {
188  return;
189  }
190 
192  if (!reg)
193  return;
194 
195  for (i = 0; i < (0x1 << d->psid_length); i++)
196  {
197  dst = d->rules[i];
198  if (dst.as_u64[0] == 0 && dst.as_u64[1] == 0)
199  {
200  continue;
201  }
202  rmp = vl_msg_api_alloc (sizeof (*rmp));
203  clib_memset (rmp, 0, sizeof (*rmp));
204  rmp->_vl_msg_id = ntohs (VL_API_MAP_RULE_DETAILS + mm->msg_id_base);
205  rmp->psid = htons (i);
206  clib_memcpy (&rmp->ip6_dst, &dst, sizeof (rmp->ip6_dst));
207  rmp->context = mp->context;
208  vl_api_send_msg (reg, (u8 *) rmp);
209  }
210 }
211 
212 static void
214 {
217  vlib_counter_t v;
218  int i, which;
219  u64 total_pkts[VLIB_N_RX_TX];
220  u64 total_bytes[VLIB_N_RX_TX];
221  map_main_t *mm = &map_main;
223 
225  if (!reg)
226  return;
227 
228  rmp = vl_msg_api_alloc (sizeof (*rmp));
229  rmp->_vl_msg_id = htons (VL_API_MAP_SUMMARY_STATS_REPLY + mm->msg_id_base);
230  rmp->context = mp->context;
231  rmp->retval = 0;
232 
233  if (pool_elts (mm->domains) == 0)
234  {
235  rmp->retval = -1;
236  goto out;
237  }
238 
239  clib_memset (total_pkts, 0, sizeof (total_pkts));
240  clib_memset (total_bytes, 0, sizeof (total_bytes));
241 
243  vec_foreach (cm, mm->domain_counters)
244  {
245  which = cm - mm->domain_counters;
246 
247  for (i = 0; i < vlib_combined_counter_n_counters (cm); i++)
248  {
249  vlib_get_combined_counter (cm, i, &v);
250  total_pkts[which] += v.packets;
251  total_bytes[which] += v.bytes;
252  }
253  }
254 
256 
257  /* Note: in network byte order! */
259  clib_host_to_net_u64 (total_pkts[MAP_DOMAIN_COUNTER_RX]);
261  clib_host_to_net_u64 (total_bytes[MAP_DOMAIN_COUNTER_RX]);
263  clib_host_to_net_u64 (total_pkts[MAP_DOMAIN_COUNTER_TX]);
265  clib_host_to_net_u64 (total_bytes[MAP_DOMAIN_COUNTER_TX]);
266  rmp->total_bindings = clib_host_to_net_u64 (pool_elts (mm->domains));
267  rmp->total_ip4_fragments = 0; // Not yet implemented. Should be a simple counter.
269  clib_host_to_net_u64 (map_error_counter_get
270  (ip4_map_node.index, MAP_ERROR_ENCAP_SEC_CHECK));
272  clib_host_to_net_u64 (map_error_counter_get
273  (ip4_map_node.index, MAP_ERROR_DECAP_SEC_CHECK));
274 
275 out:
276  vl_api_send_msg (reg, (u8 *) rmp);
277 }
278 
279 
280 int
281 map_param_set_fragmentation (bool inner, bool ignore_df)
282 {
283  map_main_t *mm = &map_main;
284 
285  mm->frag_inner = ! !inner;
286  mm->frag_ignore_df = ! !ignore_df;
287 
288  return 0;
289 }
290 
291 static void
294 {
295  map_main_t *mm = &map_main;
296  vl_api_map_param_set_fragmentation_reply_t *rmp;
297  int rv = 0;
298 
300 
301  REPLY_MACRO (VL_API_MAP_PARAM_SET_FRAGMENTATION_REPLY);
302 }
303 
304 
305 int
306 map_param_set_icmp (ip4_address_t * icmp_src_address)
307 {
308  map_main_t *mm = &map_main;
309 
310  if (icmp_src_address == 0)
311  return -1;
312 
313  mm->icmp4_src_address = *icmp_src_address;
314 
315  return 0;
316 }
317 
318 
319 static void
321 {
322  map_main_t *mm = &map_main;
323  vl_api_map_param_set_icmp_reply_t *rmp;
324  int rv;
325 
327 
328  REPLY_MACRO (VL_API_MAP_PARAM_SET_ICMP_REPLY);
329 }
330 
331 
332 int
333 map_param_set_icmp6 (u8 enable_unreachable)
334 {
335  map_main_t *mm = &map_main;
336 
337  mm->icmp6_enabled = ! !enable_unreachable;
338 
339  return 0;
340 }
341 
342 static void
344 {
345  map_main_t *mm = &map_main;
346  vl_api_map_param_set_icmp6_reply_t *rmp;
347  int rv;
348 
350 
351  REPLY_MACRO (VL_API_MAP_PARAM_SET_ICMP6_REPLY);
352 }
353 
354 
355 static void
358 {
359  map_main_t *mm = &map_main;
360  vl_api_map_param_add_del_pre_resolve_reply_t *rmp;
361  int rv = 0;
362 
364  (ip6_address_t *) & mp->ip6_nh_address, !mp->is_add);
365 
366  REPLY_MACRO (VL_API_MAP_PARAM_ADD_DEL_PRE_RESOLVE_REPLY);
367 }
368 
369 
370 int
372  u16 lifetime_ms,
373  u16 pool_size,
374  u32 buffers,
375  f64 ht_ratio, u32 * reass, u32 * packets)
376 {
377  u32 ps_reass = 0, ps_packets = 0;
378  u32 ht_reass = 0, ht_packets = 0;
379 
380  if (is_ipv6)
381  {
382  if (pool_size != (u16) ~ 0)
383  {
384  if (pool_size > MAP_IP6_REASS_CONF_POOL_SIZE_MAX)
385  return MAP_ERR_BAD_POOL_SIZE;
387  (pool_size, &ps_reass, &ps_packets))
388  return MAP_ERR_BAD_POOL_SIZE;
389  }
390 
391  if (ht_ratio != (MAP_IP6_REASS_CONF_HT_RATIO_MAX + 1))
392  {
393  if (ht_ratio > MAP_IP6_REASS_CONF_HT_RATIO_MAX)
394  return MAP_ERR_BAD_HT_RATIO;
395  if (map_ip6_reass_conf_ht_ratio (ht_ratio, &ht_reass, &ht_packets))
396  return MAP_ERR_BAD_HT_RATIO;
397  }
398 
399  if (lifetime_ms != (u16) ~ 0)
400  {
401  if (lifetime_ms > MAP_IP6_REASS_CONF_LIFETIME_MAX)
402  return MAP_ERR_BAD_LIFETIME;
403  if (map_ip6_reass_conf_lifetime (lifetime_ms))
404  return MAP_ERR_BAD_LIFETIME;
405  }
406 
407  if (buffers != ~0)
408  {
409  if (buffers > MAP_IP6_REASS_CONF_BUFFERS_MAX)
410  return MAP_ERR_BAD_BUFFERS;
411  if (map_ip6_reass_conf_buffers (buffers))
412  return MAP_ERR_BAD_BUFFERS;
413  }
414 
418  {
420  }
421  }
422  else
423  {
424  if (pool_size != (u16) ~ 0)
425  {
426  if (pool_size > MAP_IP4_REASS_CONF_POOL_SIZE_MAX)
427  return MAP_ERR_BAD_POOL_SIZE;
429  (pool_size, &ps_reass, &ps_packets))
430  return MAP_ERR_BAD_POOL_SIZE;
431  }
432 
433  if (ht_ratio != (MAP_IP4_REASS_CONF_HT_RATIO_MAX + 1))
434  {
435  if (ht_ratio > MAP_IP4_REASS_CONF_HT_RATIO_MAX)
436  return MAP_ERR_BAD_HT_RATIO;
437  if (map_ip4_reass_conf_ht_ratio (ht_ratio, &ht_reass, &ht_packets))
438  return MAP_ERR_BAD_HT_RATIO;
439  }
440 
441  if (lifetime_ms != (u16) ~ 0)
442  {
443  if (lifetime_ms > MAP_IP4_REASS_CONF_LIFETIME_MAX)
444  return MAP_ERR_BAD_LIFETIME;
445  if (map_ip4_reass_conf_lifetime (lifetime_ms))
446  return MAP_ERR_BAD_LIFETIME;
447  }
448 
449  if (buffers != ~0)
450  {
451  if (buffers > MAP_IP4_REASS_CONF_BUFFERS_MAX)
452  return MAP_ERR_BAD_BUFFERS;
453  if (map_ip4_reass_conf_buffers (buffers))
454  return MAP_ERR_BAD_BUFFERS;
455  }
456 
460  {
462  }
463  }
464 
465  if (reass)
466  *reass = ps_reass + ht_reass;
467 
468  if (packets)
469  *packets = ps_packets + ht_packets;
470 
471  return 0;
472 }
473 
474 
475 static void
478 {
479  map_main_t *mm = &map_main;
480  vl_api_map_param_set_reassembly_reply_t *rmp;
481  u32 reass = 0, packets = 0;
482  int rv;
483  f64 ht_ratio;
484 
485  ht_ratio = (f64) clib_net_to_host_u64 (mp->ht_ratio);
486  if (ht_ratio == ~0)
487  ht_ratio = MAP_IP6_REASS_CONF_HT_RATIO_MAX + 1;
488 
490  clib_net_to_host_u16 (mp->lifetime_ms),
491  clib_net_to_host_u16 (mp->pool_size),
492  clib_net_to_host_u32 (mp->buffers),
493  ht_ratio, &reass, &packets);
494 
495  /*
496  * FIXME: Should the lost reass and packet counts be returned in the API?
497  */
498 
499  REPLY_MACRO (VL_API_MAP_PARAM_SET_REASSEMBLY_REPLY);
500 }
501 
502 
503 int
504 map_param_set_security_check (bool enable, bool fragments)
505 {
506  map_main_t *mm = &map_main;
507 
508  mm->sec_check = ! !enable;
509  mm->sec_check_frag = ! !fragments;
510 
511  return 0;
512 }
513 
514 static void
517 {
518  map_main_t *mm = &map_main;
519  vl_api_map_param_set_security_check_reply_t *rmp;
520  int rv;
521 
523 
524  REPLY_MACRO (VL_API_MAP_PARAM_SET_SECURITY_CHECK_REPLY);
525 }
526 
527 
528 int
530 {
531  map_main_t *mm = &map_main;
532 
533  mm->tc_copy = ! !copy;
534  mm->tc = tc;
535 
536  return 0;
537 }
538 
539 static void
542 {
543  map_main_t *mm = &map_main;
544  vl_api_map_param_set_traffic_class_reply_t *rmp;
545  int rv;
546 
547  rv = map_param_set_traffic_class (mp->copy, mp->class);
548 
549  REPLY_MACRO (VL_API_MAP_PARAM_SET_TRAFFIC_CLASS_REPLY);
550 }
551 
552 
553 int
555 {
556  map_main_t *mm = &map_main;
557 
558  mm->tcp_mss = tcp_mss;
559 
560  return 0;
561 }
562 
563 
564 static void
566 {
567  map_main_t *mm = &map_main;
568  vl_api_map_param_set_tcp_reply_t *rmp;
569  int rv = 0;
570 
571  map_param_set_tcp (ntohs (mp->tcp_mss));
572  REPLY_MACRO (VL_API_MAP_PARAM_SET_TCP_REPLY);
573 }
574 
575 
576 static void
578 {
579  map_main_t *mm = &map_main;
582 
584  if (!reg)
585  return;
586 
587  rmp = vl_msg_api_alloc (sizeof (*rmp));
588  rmp->_vl_msg_id = htons (VL_API_MAP_PARAM_GET_REPLY + mm->msg_id_base);
589  rmp->context = mp->context;
590  rmp->retval = 0;
591 
592  rmp->frag_inner = mm->frag_inner;
593  rmp->frag_ignore_df = mm->frag_ignore_df;
594 
596  &mm->icmp4_src_address, sizeof (rmp->icmp_ip4_err_relay_src));
597 
599 
600  /*
601  * FIXME: How are these addresses re-extracted from the FIB?
602  * Or should a local map_main copy be kept?
603  */
604  clib_memset (&rmp->ip4_nh_address, 0, sizeof (rmp->ip4_nh_address));
605  clib_memset (&rmp->ip6_nh_address, 0, sizeof (rmp->ip6_nh_address));
606 
607  rmp->ip4_lifetime_ms =
608  clib_net_to_host_u16 (mm->ip4_reass_conf_lifetime_ms);
609  rmp->ip4_pool_size = clib_net_to_host_u16 (mm->ip4_reass_conf_pool_size);
610  rmp->ip4_buffers = clib_net_to_host_u32 (mm->ip4_reass_conf_buffers);
611  rmp->ip4_ht_ratio =
612  clib_net_to_host_u64 ((u64) mm->ip4_reass_conf_ht_ratio);
613 
614  rmp->ip6_lifetime_ms =
615  clib_net_to_host_u16 (mm->ip6_reass_conf_lifetime_ms);
616  rmp->ip6_pool_size = clib_net_to_host_u16 (mm->ip6_reass_conf_pool_size);
617  rmp->ip6_buffers = clib_net_to_host_u32 (mm->ip6_reass_conf_buffers);
618  rmp->ip6_ht_ratio =
619  clib_net_to_host_u64 ((u64) mm->ip6_reass_conf_ht_ratio);
620 
621  rmp->sec_check_enable = mm->sec_check;
623 
624  rmp->tc_copy = mm->tc_copy;
625  rmp->tc_class = mm->tc;
626 
627  vl_api_send_msg (reg, (u8 *) rmp);
628 }
629 
630 
631 int
632 map_if_enable_disable (bool is_enable, u32 sw_if_index, bool is_translation)
633 {
634  map_main_t *mm = &map_main;
635 
637  sw_if_index))
638  return VNET_API_ERROR_INVALID_SW_IF_INDEX;
639 
640  is_enable = ! !is_enable;
641 
642  if (is_translation)
643  {
644  if (clib_bitmap_get (mm->bm_trans_enabled_by_sw_if, sw_if_index)
645  == is_enable)
646  return 0;
647  }
648  else
649  {
650  if (clib_bitmap_get (mm->bm_encap_enabled_by_sw_if, sw_if_index)
651  == is_enable)
652  return 0;
653  }
654 
655  if (is_translation == false)
656  {
657  vnet_feature_enable_disable ("ip4-unicast", "ip4-map", sw_if_index,
658  is_enable ? 1 : 0, 0, 0);
659  vnet_feature_enable_disable ("ip6-unicast", "ip6-map", sw_if_index,
660  is_enable ? 1 : 0, 0, 0);
662  clib_bitmap_set (mm->bm_encap_enabled_by_sw_if, sw_if_index,
663  is_enable);
664  }
665  else
666  {
667  vnet_feature_enable_disable ("ip4-unicast", "ip4-map-t", sw_if_index,
668  is_enable ? 1 : 0, 0, 0);
669  vnet_feature_enable_disable ("ip6-unicast", "ip6-map-t", sw_if_index,
670  is_enable ? 1 : 0, 0, 0);
672  clib_bitmap_set (mm->bm_trans_enabled_by_sw_if, sw_if_index,
673  is_enable);
674  }
675 
676  return 0;
677 }
678 
679 
680 static void
682 {
683  map_main_t *mm = &map_main;
684  vl_api_map_if_enable_disable_reply_t *rmp;
685  int rv = 0;
686 
688 
689  rv =
690  map_if_enable_disable (mp->is_enable, htonl (mp->sw_if_index),
691  mp->is_translation);
692 
694  REPLY_MACRO (VL_API_MAP_IF_ENABLE_DISABLE_REPLY);
695 }
696 
697 
698 #define foreach_map_plugin_api_msg \
699 _(MAP_ADD_DOMAIN, map_add_domain) \
700 _(MAP_DEL_DOMAIN, map_del_domain) \
701 _(MAP_ADD_DEL_RULE, map_add_del_rule) \
702 _(MAP_DOMAIN_DUMP, map_domain_dump) \
703 _(MAP_RULE_DUMP, map_rule_dump) \
704 _(MAP_IF_ENABLE_DISABLE, map_if_enable_disable) \
705 _(MAP_SUMMARY_STATS, map_summary_stats) \
706 _(MAP_PARAM_SET_FRAGMENTATION, map_param_set_fragmentation) \
707 _(MAP_PARAM_SET_ICMP, map_param_set_icmp) \
708 _(MAP_PARAM_SET_ICMP6, map_param_set_icmp6) \
709 _(MAP_PARAM_ADD_DEL_PRE_RESOLVE, map_param_add_del_pre_resolve) \
710 _(MAP_PARAM_SET_REASSEMBLY, map_param_set_reassembly) \
711 _(MAP_PARAM_SET_SECURITY_CHECK, map_param_set_security_check) \
712 _(MAP_PARAM_SET_TRAFFIC_CLASS, map_param_set_traffic_class) \
713 _(MAP_PARAM_SET_TCP, map_param_set_tcp) \
714 _(MAP_PARAM_GET, map_param_get)
715 
716 #define vl_msg_name_crc_list
717 #include <map/map_all_api_h.h>
718 #undef vl_msg_name_crc_list
719 
720 static void
722 {
723 #define _(id,n,crc) \
724  vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + mm->msg_id_base);
725  foreach_vl_msg_name_crc_map;
726 #undef _
727 }
728 
729 /* Set up the API message handling tables */
730 clib_error_t *
732 {
733  map_main_t *mm = &map_main;
734  u8 *name = format (0, "map_%08x%c", api_version, 0);
735 
736  /* Ask for a correctly-sized block of API message decode slots */
737  mm->msg_id_base =
739 #define _(N,n) \
740  vl_msg_api_set_handlers((VL_API_##N + mm->msg_id_base), \
741  #n, \
742  vl_api_##n##_t_handler, \
743  vl_noop_handler, \
744  vl_api_##n##_t_endian, \
745  vl_api_##n##_t_print, \
746  sizeof(vl_api_##n##_t), 1);
748 #undef _
749 
750  /*
751  * Set up the (msg_name, crc, message-id) table
752  */
754 
755  vec_free (name);
756  return 0;
757 }
758 
759 /*
760  * fd.io coding-style-patch-verification: ON
761  *
762  * Local Variables:
763  * eval: (c-set-style "gnu")
764  * End:
765  */
u32 sw_if_index
Definition: ipsec_gre.api:37
static void vl_api_map_param_set_tcp_t_handler(vl_api_map_param_set_tcp_t *mp)
Definition: map_api.c:565
int map_create_domain(ip4_address_t *ip4_prefix, u8 ip4_prefix_len, ip6_address_t *ip6_prefix, u8 ip6_prefix_len, ip6_address_t *ip6_src, u8 ip6_src_len, u8 ea_bits_len, u8 psid_offset, u8 psid_length, u32 *map_domain_index, u16 mtu, u8 flags, char *tag)
Definition: map.c:110
u8 psid_length
Definition: map.h:119
int map_add_del_psid(u32 map_domain_index, u16 psid, ip6_address_t *tep, bool is_add)
Definition: map.c:240
static void vl_api_map_if_enable_disable_t_handler(vl_api_map_if_enable_disable_t *mp)
Definition: map_api.c:681
u32 ip4_reass_conf_buffers
Definition: map.h:300
u32 flags
Definition: vhost_user.h:115
static void vl_api_map_param_set_icmp_t_handler(vl_api_map_param_set_icmp_t *mp)
Definition: map_api.c:320
#define MAP_IP6_REASS_CONF_BUFFERS_MAX
Definition: map.h:558
Set MAP traffic class parameters.
Definition: map.api:287
Add or Delete MAP rule from a domain (Only used for shared IPv4 per subscriber)
Definition: map.api:79
int map_delete_domain(u32 map_domain_index)
Definition: map.c:209
map_main_t map_main
Definition: map.c:26
static void vl_api_map_domain_dump_t_handler(vl_api_map_domain_dump_t *mp)
Definition: map_api.c:114
vnet_interface_main_t interface_main
Definition: vnet.h:56
vl_api_ip6_prefix_t ip6_src
Definition: map.api:38
u64 as_u64[2]
Definition: ip6_packet.h:51
unsigned long u64
Definition: types.h:89
u16 msg_id_base
Definition: map.h:273
#define REPLY_MACRO2(t, body)
Add/delete MAP pre-resolve IP addresses parameters.
Definition: map.api:235
u64 map_error_counter_get(u32 node_index, map_error_t map_error)
Definition: map.c:1092
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:34
u8 tc
Definition: map.h:276
static void vl_api_map_param_set_security_check_t_handler(vl_api_map_param_set_security_check_t *mp)
Definition: map_api.c:516
static void map_domain_counter_unlock(map_main_t *mm)
Definition: map.h:592
Combined counter to hold both packets and byte differences.
Definition: counter_types.h:26
int i
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap. ...
Definition: bitmap.h:167
bool sec_check_frag
Definition: map.h:280
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
static void vl_api_map_param_set_traffic_class_t_handler(vl_api_map_param_set_traffic_class_t *mp)
Definition: map_api.c:541
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
vlib_node_registration_t ip4_map_node
(constructor) VLIB_REGISTER_NODE (ip4_map_node)
Definition: ip4_map.c:719
int map_param_set_traffic_class(bool copy, u8 tc)
Definition: map_api.c:529
vl_api_ip4_address_t dst
Definition: ipsec_gre.api:39
uword * bm_trans_enabled_by_sw_if
Definition: map.h:337
#define MAP_ERR_BAD_HT_RATIO
Definition: map.h:30
void map_pre_resolve(ip4_address_t *ip4, ip6_address_t *ip6, bool is_del)
Definition: map.c:422
void * vl_msg_api_alloc(int nbytes)
static void vl_api_map_param_set_icmp6_t_handler(vl_api_map_param_set_icmp6_t *mp)
Definition: map_api.c:343
int map_ip6_reass_conf_ht_ratio(f32 ht_ratio, u32 *trashed_reass, u32 *dropped_packets)
Definition: map.c:1902
static void vl_api_map_add_del_rule_t_handler(vl_api_map_add_del_rule_t *mp)
Definition: map_api.c:100
unsigned char u8
Definition: types.h:56
#define MAP_IP6_REASS_CONF_LIFETIME_MAX
Definition: map.h:556
static void vl_api_map_summary_stats_t_handler(vl_api_map_summary_stats_t *mp)
Definition: map_api.c:213
vl_api_ip6_address_t ip6_dst
Definition: map.api:85
double f64
Definition: types.h:142
Get list of map domains.
Definition: map.api:93
#define clib_memcpy(d, s, n)
Definition: string.h:180
int map_param_set_security_check(bool enable, bool fragments)
Definition: map_api.c:504
Set MAP TCP parammeters.
Definition: map.api:301
#define MAP_ERR_BAD_BUFFERS_TOO_LARGE
Definition: map.h:33
#define MAP_IP4_REASS_MAX_FRAGMENTS_PER_REASSEMBLY
Definition: map.h:84
static void vl_api_map_add_domain_t_handler(vl_api_map_add_domain_t *mp)
Definition: map_api.c:49
vl_api_ip4_prefix_t ip4_prefix
Definition: map.api:37
bool tc_copy
Definition: map.h:277
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:493
vlib_combined_counter_main_t * domain_counters
Definition: map.h:269
ip4_address_t icmp4_src_address
Definition: map.h:286
Reply for map_param_get request.
Definition: map.api:342
ip6_address_t * rules
Definition: map.h:109
unsigned int u32
Definition: types.h:88
#define MAP_IP4_REASS_CONF_LIFETIME_MAX
Definition: map.h:544
static void vl_api_map_del_domain_t_handler(vl_api_map_del_domain_t *mp)
Definition: map_api.c:88
Set MAP fragmentation parameters.
Definition: map.api:193
static void vl_api_map_param_add_del_pre_resolve_t_handler(vl_api_map_param_add_del_pre_resolve_t *mp)
Definition: map_api.c:357
#define MAP_IP6_REASS_CONF_POOL_SIZE_MAX
Definition: map.h:554
int map_param_set_icmp6(u8 enable_unreachable)
Definition: map_api.c:333
Delete MAP domain.
Definition: map.api:63
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:514
int map_ip6_reass_conf_buffers(u32 buffers)
Definition: map.c:1941
counter_t packets
packet counter
Definition: counter_types.h:28
int map_if_enable_disable(bool is_enable, u32 sw_if_index, bool is_translation)
Definition: map_api.c:632
int map_ip4_reass_conf_lifetime(u16 lifetime_ms)
Definition: map.c:1851
clib_error_t * map_plugin_api_hookup(vlib_main_t *vm)
Definition: map_api.c:731
#define MAP_IP4_REASS_CONF_HT_RATIO_MAX
Definition: map.h:540
bool frag_ignore_df
Definition: map.h:314
static void vl_api_map_rule_dump_t_handler(vl_api_map_rule_dump_t *mp)
Definition: map_api.c:172
u32 vlib_combined_counter_n_counters(const vlib_combined_counter_main_t *cm)
The number of counters (not the number of per-thread counters)
Definition: counter.c:121
unsigned short u16
Definition: types.h:57
u16 ip4_reass_conf_pool_size
Definition: map.h:298
map_domain_t * domains
Definition: map.h:264
vl_api_ip4_address_t ip4_nh_address
Definition: map.api:350
static void vl_api_map_param_get_t_handler(vl_api_map_param_get_t *mp)
Definition: map_api.c:577
vl_api_ip4_address_t ip4_nh_address
Definition: map.api:240
int map_ip4_reass_conf_buffers(u32 buffers)
Definition: map.c:1858
int map_ip6_reass_conf_lifetime(u16 lifetime_ms)
Definition: map.c:1934
int map_ip4_reass_conf_pool_size(u16 pool_size, u32 *trashed_reass, u32 *dropped_packets)
Definition: map.c:1836
#define REPLY_MACRO(t)
#define MAP_ERR_BAD_BUFFERS
Definition: map.h:32
u8 name[64]
Definition: memclnt.api:152
static void setup_message_id_table(map_main_t *mm, api_main_t *am)
Definition: map_api.c:721
int map_param_set_reassembly(bool is_ipv6, u16 lifetime_ms, u16 pool_size, u32 buffers, f64 ht_ratio, u32 *reass, u32 *packets)
Definition: map_api.c:371
u8 len
Definition: ip_types.api:49
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:202
Request for a single block of MAP parameters.
Definition: map.api:313
int map_param_set_tcp(u16 tcp_mss)
Definition: map_api.c:554
Details about a single MAP domain.
Definition: map.api:112
An API client registration, only in vpp/vlib.
Definition: api_common.h:45
#define BAD_SW_IF_INDEX_LABEL
static void vl_api_map_param_set_fragmentation_t_handler(vl_api_map_param_set_fragmentation_t *mp)
Definition: map_api.c:293
u16 ip6_reass_conf_pool_size
Definition: map.h:321
Enable or disable a MAP interface.
Definition: map.api:148
static void vlib_get_combined_counter(const vlib_combined_counter_main_t *cm, u32 index, vlib_counter_t *result)
Get the value of a combined counter, never called in the speed path Scrapes the entire set of per-thr...
Definition: counter.h:259
vlib_main_t * vm
Definition: buffer.c:312
vl_api_ip6_address_t ip6_nh_address
Definition: map.api:351
uword * bm_encap_enabled_by_sw_if
Definition: map.h:338
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:341
Set MAP ICMP6 parameters.
Definition: map.api:220
Reply for map_summary_stats request.
Definition: map.api:175
bool icmp6_enabled
Definition: map.h:281
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:283
static uword clib_bitmap_get(uword *ai, uword i)
Gets the ith bit value from a bitmap.
Definition: bitmap.h:197
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:56
vl_api_ip6_address_t ip6_dst
Definition: map.api:137
int map_ip4_reass_conf_ht_ratio(f32 ht_ratio, u32 *trashed_reass, u32 *dropped_packets)
Definition: map.c:1819
static void map_domain_counter_lock(map_main_t *mm)
Definition: map.h:585
f32 ip4_reass_conf_ht_ratio
Definition: map.h:297
int map_param_set_icmp(ip4_address_t *icmp_src_address)
Definition: map_api.c:306
int map_ip6_reass_conf_pool_size(u16 pool_size, u32 *trashed_reass, u32 *dropped_packets)
Definition: map.c:1919
vl_api_ip6_address_t ip6_nh_address
Definition: map.api:241
bool sec_check
Definition: map.h:279
bool frag_inner
Definition: map.h:313
static void clib_mem_free(void *p)
Definition: mem.h:205
Request for a single block of summary stats.
Definition: map.api:161
Reply for MAP domain add.
Definition: map.api:51
static void * clib_mem_alloc(uword size)
Definition: mem.h:132
#define MAP_ERR_BAD_POOL_SIZE
Definition: map.h:29
#define foreach_map_plugin_api_msg
Definition: map_api.c:698
f32 ip6_reass_conf_ht_ratio
Definition: map.h:320
counter_t bytes
byte counter
Definition: counter_types.h:29
vnet_main_t * vnet_main
Definition: map.h:291
Set MAP security-check parameters.
Definition: map.api:272
vl_api_ip4_address_t ip4_err_relay_src
Definition: map.api:211
u16 ip6_reass_conf_lifetime_ms
Definition: map.h:322
#define MAP_IP6_REASS_CONF_HT_RATIO_MAX
Definition: map.h:552
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:815
u16 tcp_mss
Definition: map.h:283
A collection of combined counters.
Definition: counter.h:188
Add MAP domains.
Definition: map.api:32
#define MAP_IP4_REASS_CONF_POOL_SIZE_MAX
Definition: map.h:542
vl_api_ip4_address_t icmp_ip4_err_relay_src
Definition: map.api:348
vl_api_ip6_prefix_t ip6_prefix
Definition: map.api:36
static void vl_api_map_param_set_reassembly_t_handler(vl_api_map_param_set_reassembly_t *mp)
Definition: map_api.c:477
#define MAP_IP6_REASS_MAX_FRAGMENTS_PER_REASSEMBLY
Definition: map.h:91
u16 ip4_reass_conf_lifetime_ms
Definition: map.h:299
#define vec_foreach(var, vec)
Vector iterator.
#define MAP_IP4_REASS_CONF_BUFFERS_MAX
Definition: map.h:546
#define MAP_ERR_BAD_LIFETIME
Definition: map.h:31
Set MAP reassembly parameters.
Definition: map.api:254
api_main_t api_main
Definition: api_shared.c:35
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
Definition: feature.c:274
#define VALIDATE_SW_IF_INDEX(mp)
int map_param_set_fragmentation(bool inner, bool ignore_df)
Definition: map_api.c:281
Set MAP ICMP parameters.
Definition: map.api:207
u16 vl_msg_api_get_msg_ids(const char *name, int n)
Definition: api_shared.c:880
u32 ip6_reass_conf_buffers
Definition: map.h:323
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:128