FD.io VPP  v19.08.2-294-g37e99c22d
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 
57  mp->tag[ARRAY_LEN (mp->tag) - 1] = '\0';
58  rv =
59  map_create_domain ((ip4_address_t *) & mp->ip4_prefix.address,
60  mp->ip4_prefix.len,
61  (ip6_address_t *) & mp->ip6_prefix.address,
62  mp->ip6_prefix.len,
63  (ip6_address_t *) & mp->ip6_src.address,
64  mp->ip6_src.len, mp->ea_bits_len, mp->psid_offset,
65  mp->psid_length, &index, ntohs (mp->mtu), flags,
66  mp->tag);
67 
68  /* *INDENT-OFF* */
69  REPLY_MACRO2(VL_API_MAP_ADD_DOMAIN_REPLY,
70  ({
71  rmp->index = ntohl(index);
72  }));
73  /* *INDENT-ON* */
74 }
75 
76 static void
78 {
79  map_main_t *mm = &map_main;
80  vl_api_map_del_domain_reply_t *rmp;
81  int rv = 0;
82 
83  rv = map_delete_domain (ntohl (mp->index));
84 
85  REPLY_MACRO (VL_API_MAP_DEL_DOMAIN_REPLY);
86 }
87 
88 static void
90 {
91  map_main_t *mm = &map_main;
92  vl_api_map_del_domain_reply_t *rmp;
93  int rv = 0;
94 
95  rv =
96  map_add_del_psid (ntohl (mp->index), ntohs (mp->psid),
97  (ip6_address_t *) & mp->ip6_dst, mp->is_add);
98 
99  REPLY_MACRO (VL_API_MAP_ADD_DEL_RULE_REPLY);
100 }
101 
102 static void
104 {
106  map_main_t *mm = &map_main;
107  map_domain_t *d;
108  map_domain_extra_t *de;
110  u32 map_domain_index;
111 
112  if (pool_elts (mm->domains) == 0)
113  return;
114 
116  if (!reg)
117  return;
118 
119  /* *INDENT-OFF* */
120  pool_foreach(d, mm->domains,
121  ({
122  map_domain_index = d - mm->domains;
123  de = vec_elt_at_index(mm->domain_extras, map_domain_index);
124  int tag_len = clib_min(ARRAY_LEN(rmp->tag), vec_len(de->tag) + 1);
125 
126  /* Make sure every field is initiated (or don't skip the clib_memset()) */
127  rmp = vl_msg_api_alloc (sizeof (*rmp) + tag_len);
128 
129  rmp->_vl_msg_id = htons(VL_API_MAP_DOMAIN_DETAILS + mm->msg_id_base);
130  rmp->context = mp->context;
131  rmp->domain_index = htonl(map_domain_index);
132  clib_memcpy(&rmp->ip6_prefix.address, &d->ip6_prefix, sizeof(rmp->ip6_prefix.address));
133  clib_memcpy(&rmp->ip4_prefix.address, &d->ip4_prefix, sizeof(rmp->ip4_prefix.address));
134  clib_memcpy(&rmp->ip6_src.address, &d->ip6_src, sizeof(rmp->ip6_src.address));
135  rmp->ip6_prefix.len = d->ip6_prefix_len;
136  rmp->ip4_prefix.len = d->ip4_prefix_len;
137  rmp->ip6_src.len = d->ip6_src_len;
138  rmp->ea_bits_len = d->ea_bits_len;
139  rmp->psid_offset = d->psid_offset;
140  rmp->psid_length = d->psid_length;
141  rmp->flags = d->flags;
142  rmp->mtu = htons(d->mtu);
143  memcpy(rmp->tag, de->tag, tag_len-1);
144  rmp->tag[tag_len-1] = '\0';
145 
146  vl_api_send_msg (reg, (u8 *) rmp);
147  }));
148  /* *INDENT-ON* */
149 }
150 
151 static void
153 {
155  u16 i;
158  map_main_t *mm = &map_main;
159  u32 domain_index = ntohl (mp->domain_index);
160  map_domain_t *d;
161 
162  if (pool_elts (mm->domains) == 0)
163  return;
164 
165  d = pool_elt_at_index (mm->domains, domain_index);
166  if (!d || !d->rules)
167  {
168  return;
169  }
170 
172  if (!reg)
173  return;
174 
175  for (i = 0; i < (0x1 << d->psid_length); i++)
176  {
177  dst = d->rules[i];
178  if (dst.as_u64[0] == 0 && dst.as_u64[1] == 0)
179  {
180  continue;
181  }
182  rmp = vl_msg_api_alloc (sizeof (*rmp));
183  clib_memset (rmp, 0, sizeof (*rmp));
184  rmp->_vl_msg_id = ntohs (VL_API_MAP_RULE_DETAILS + mm->msg_id_base);
185  rmp->psid = htons (i);
186  clib_memcpy (&rmp->ip6_dst, &dst, sizeof (rmp->ip6_dst));
187  rmp->context = mp->context;
188  vl_api_send_msg (reg, (u8 *) rmp);
189  }
190 }
191 
192 static void
194 {
197  vlib_counter_t v;
198  int i, which;
199  u64 total_pkts[VLIB_N_RX_TX];
200  u64 total_bytes[VLIB_N_RX_TX];
201  map_main_t *mm = &map_main;
203 
205  if (!reg)
206  return;
207 
208  rmp = vl_msg_api_alloc (sizeof (*rmp));
209  rmp->_vl_msg_id = htons (VL_API_MAP_SUMMARY_STATS_REPLY + mm->msg_id_base);
210  rmp->context = mp->context;
211  rmp->retval = 0;
212 
213  if (pool_elts (mm->domains) == 0)
214  {
215  rmp->retval = -1;
216  goto out;
217  }
218 
219  clib_memset (total_pkts, 0, sizeof (total_pkts));
220  clib_memset (total_bytes, 0, sizeof (total_bytes));
221 
223  vec_foreach (cm, mm->domain_counters)
224  {
225  which = cm - mm->domain_counters;
226 
227  for (i = 0; i < vlib_combined_counter_n_counters (cm); i++)
228  {
229  vlib_get_combined_counter (cm, i, &v);
230  total_pkts[which] += v.packets;
231  total_bytes[which] += v.bytes;
232  }
233  }
234 
236 
237  /* Note: in network byte order! */
239  clib_host_to_net_u64 (total_pkts[MAP_DOMAIN_COUNTER_RX]);
241  clib_host_to_net_u64 (total_bytes[MAP_DOMAIN_COUNTER_RX]);
243  clib_host_to_net_u64 (total_pkts[MAP_DOMAIN_COUNTER_TX]);
245  clib_host_to_net_u64 (total_bytes[MAP_DOMAIN_COUNTER_TX]);
246  rmp->total_bindings = clib_host_to_net_u64 (pool_elts (mm->domains));
247  rmp->total_ip4_fragments = 0; // Not yet implemented. Should be a simple counter.
249  clib_host_to_net_u64 (map_error_counter_get
250  (ip4_map_node.index, MAP_ERROR_ENCAP_SEC_CHECK));
252  clib_host_to_net_u64 (map_error_counter_get
253  (ip4_map_node.index, MAP_ERROR_DECAP_SEC_CHECK));
254 
255 out:
256  vl_api_send_msg (reg, (u8 *) rmp);
257 }
258 
259 
260 int
261 map_param_set_fragmentation (bool inner, bool ignore_df)
262 {
263  map_main_t *mm = &map_main;
264 
265  mm->frag_inner = ! !inner;
266  mm->frag_ignore_df = ! !ignore_df;
267 
268  return 0;
269 }
270 
271 static void
274 {
275  map_main_t *mm = &map_main;
276  vl_api_map_param_set_fragmentation_reply_t *rmp;
277  int rv = 0;
278 
280 
281  REPLY_MACRO (VL_API_MAP_PARAM_SET_FRAGMENTATION_REPLY);
282 }
283 
284 
285 int
286 map_param_set_icmp (ip4_address_t * icmp_src_address)
287 {
288  map_main_t *mm = &map_main;
289 
290  if (icmp_src_address == 0)
291  return -1;
292 
293  mm->icmp4_src_address = *icmp_src_address;
294 
295  return 0;
296 }
297 
298 
299 static void
301 {
302  map_main_t *mm = &map_main;
303  vl_api_map_param_set_icmp_reply_t *rmp;
304  int rv;
305 
307 
308  REPLY_MACRO (VL_API_MAP_PARAM_SET_ICMP_REPLY);
309 }
310 
311 
312 int
313 map_param_set_icmp6 (u8 enable_unreachable)
314 {
315  map_main_t *mm = &map_main;
316 
317  mm->icmp6_enabled = ! !enable_unreachable;
318 
319  return 0;
320 }
321 
322 static void
324 {
325  map_main_t *mm = &map_main;
326  vl_api_map_param_set_icmp6_reply_t *rmp;
327  int rv;
328 
330 
331  REPLY_MACRO (VL_API_MAP_PARAM_SET_ICMP6_REPLY);
332 }
333 
334 
335 static void
338 {
339  map_main_t *mm = &map_main;
340  vl_api_map_param_add_del_pre_resolve_reply_t *rmp;
341  int rv = 0;
342 
344  (ip6_address_t *) & mp->ip6_nh_address, !mp->is_add);
345 
346  REPLY_MACRO (VL_API_MAP_PARAM_ADD_DEL_PRE_RESOLVE_REPLY);
347 }
348 
349 
350 int
352  u16 lifetime_ms,
353  u16 pool_size,
354  u32 buffers,
355  f64 ht_ratio, u32 * reass, u32 * packets)
356 {
357  u32 ps_reass = 0, ps_packets = 0;
358  u32 ht_reass = 0, ht_packets = 0;
359 
360  if (is_ipv6)
361  {
362  if (pool_size != (u16) ~ 0)
363  {
364  if (pool_size > MAP_IP6_REASS_CONF_POOL_SIZE_MAX)
365  return MAP_ERR_BAD_POOL_SIZE;
367  (pool_size, &ps_reass, &ps_packets))
368  return MAP_ERR_BAD_POOL_SIZE;
369  }
370 
371  if (ht_ratio != (MAP_IP6_REASS_CONF_HT_RATIO_MAX + 1))
372  {
373  if (ht_ratio > MAP_IP6_REASS_CONF_HT_RATIO_MAX)
374  return MAP_ERR_BAD_HT_RATIO;
375  if (map_ip6_reass_conf_ht_ratio (ht_ratio, &ht_reass, &ht_packets))
376  return MAP_ERR_BAD_HT_RATIO;
377  }
378 
379  if (lifetime_ms != (u16) ~ 0)
380  {
381  if (lifetime_ms > MAP_IP6_REASS_CONF_LIFETIME_MAX)
382  return MAP_ERR_BAD_LIFETIME;
383  if (map_ip6_reass_conf_lifetime (lifetime_ms))
384  return MAP_ERR_BAD_LIFETIME;
385  }
386 
387  if (buffers != ~0)
388  {
389  if (buffers > MAP_IP6_REASS_CONF_BUFFERS_MAX)
390  return MAP_ERR_BAD_BUFFERS;
391  if (map_ip6_reass_conf_buffers (buffers))
392  return MAP_ERR_BAD_BUFFERS;
393  }
394 
398  {
400  }
401  }
402  else
403  {
404  if (pool_size != (u16) ~ 0)
405  {
406  if (pool_size > MAP_IP4_REASS_CONF_POOL_SIZE_MAX)
407  return MAP_ERR_BAD_POOL_SIZE;
409  (pool_size, &ps_reass, &ps_packets))
410  return MAP_ERR_BAD_POOL_SIZE;
411  }
412 
413  if (ht_ratio != (MAP_IP4_REASS_CONF_HT_RATIO_MAX + 1))
414  {
415  if (ht_ratio > MAP_IP4_REASS_CONF_HT_RATIO_MAX)
416  return MAP_ERR_BAD_HT_RATIO;
417  if (map_ip4_reass_conf_ht_ratio (ht_ratio, &ht_reass, &ht_packets))
418  return MAP_ERR_BAD_HT_RATIO;
419  }
420 
421  if (lifetime_ms != (u16) ~ 0)
422  {
423  if (lifetime_ms > MAP_IP4_REASS_CONF_LIFETIME_MAX)
424  return MAP_ERR_BAD_LIFETIME;
425  if (map_ip4_reass_conf_lifetime (lifetime_ms))
426  return MAP_ERR_BAD_LIFETIME;
427  }
428 
429  if (buffers != ~0)
430  {
431  if (buffers > MAP_IP4_REASS_CONF_BUFFERS_MAX)
432  return MAP_ERR_BAD_BUFFERS;
433  if (map_ip4_reass_conf_buffers (buffers))
434  return MAP_ERR_BAD_BUFFERS;
435  }
436 
440  {
442  }
443  }
444 
445  if (reass)
446  *reass = ps_reass + ht_reass;
447 
448  if (packets)
449  *packets = ps_packets + ht_packets;
450 
451  return 0;
452 }
453 
454 
455 static void
458 {
459  map_main_t *mm = &map_main;
460  vl_api_map_param_set_reassembly_reply_t *rmp;
461  u32 reass = 0, packets = 0;
462  int rv;
463  f64 ht_ratio;
464 
465  ht_ratio = (f64) clib_net_to_host_f64 (mp->ht_ratio);
466  if (ht_ratio == ~0)
467  ht_ratio = MAP_IP6_REASS_CONF_HT_RATIO_MAX + 1;
468 
470  clib_net_to_host_u16 (mp->lifetime_ms),
471  clib_net_to_host_u16 (mp->pool_size),
472  clib_net_to_host_u32 (mp->buffers),
473  ht_ratio, &reass, &packets);
474 
475  /*
476  * FIXME: Should the lost reass and packet counts be returned in the API?
477  */
478 
479  REPLY_MACRO (VL_API_MAP_PARAM_SET_REASSEMBLY_REPLY);
480 }
481 
482 
483 int
484 map_param_set_security_check (bool enable, bool fragments)
485 {
486  map_main_t *mm = &map_main;
487 
488  mm->sec_check = ! !enable;
489  mm->sec_check_frag = ! !fragments;
490 
491  return 0;
492 }
493 
494 static void
497 {
498  map_main_t *mm = &map_main;
499  vl_api_map_param_set_security_check_reply_t *rmp;
500  int rv;
501 
503 
504  REPLY_MACRO (VL_API_MAP_PARAM_SET_SECURITY_CHECK_REPLY);
505 }
506 
507 
508 int
510 {
511  map_main_t *mm = &map_main;
512 
513  mm->tc_copy = ! !copy;
514  mm->tc = tc;
515 
516  return 0;
517 }
518 
519 static void
522 {
523  map_main_t *mm = &map_main;
524  vl_api_map_param_set_traffic_class_reply_t *rmp;
525  int rv;
526 
527  rv = map_param_set_traffic_class (mp->copy, mp->class);
528 
529  REPLY_MACRO (VL_API_MAP_PARAM_SET_TRAFFIC_CLASS_REPLY);
530 }
531 
532 
533 int
535 {
536  map_main_t *mm = &map_main;
537 
538  mm->tcp_mss = tcp_mss;
539 
540  return 0;
541 }
542 
543 
544 static void
546 {
547  map_main_t *mm = &map_main;
548  vl_api_map_param_set_tcp_reply_t *rmp;
549  int rv = 0;
550 
551  map_param_set_tcp (ntohs (mp->tcp_mss));
552  REPLY_MACRO (VL_API_MAP_PARAM_SET_TCP_REPLY);
553 }
554 
555 
556 static void
558 {
559  map_main_t *mm = &map_main;
562 
564  if (!reg)
565  return;
566 
567  rmp = vl_msg_api_alloc (sizeof (*rmp));
568  rmp->_vl_msg_id = htons (VL_API_MAP_PARAM_GET_REPLY + mm->msg_id_base);
569  rmp->context = mp->context;
570  rmp->retval = 0;
571 
572  rmp->frag_inner = mm->frag_inner;
573  rmp->frag_ignore_df = mm->frag_ignore_df;
574 
576  &mm->icmp4_src_address, sizeof (rmp->icmp_ip4_err_relay_src));
577 
579 
580  /*
581  * FIXME: How are these addresses re-extracted from the FIB?
582  * Or should a local map_main copy be kept?
583  */
584  clib_memset (&rmp->ip4_nh_address, 0, sizeof (rmp->ip4_nh_address));
585  clib_memset (&rmp->ip6_nh_address, 0, sizeof (rmp->ip6_nh_address));
586 
587  rmp->ip4_lifetime_ms =
588  clib_net_to_host_u16 (mm->ip4_reass_conf_lifetime_ms);
589  rmp->ip4_pool_size = clib_net_to_host_u16 (mm->ip4_reass_conf_pool_size);
590  rmp->ip4_buffers = clib_net_to_host_u32 (mm->ip4_reass_conf_buffers);
592 
593  rmp->ip6_lifetime_ms =
594  clib_net_to_host_u16 (mm->ip6_reass_conf_lifetime_ms);
595  rmp->ip6_pool_size = clib_net_to_host_u16 (mm->ip6_reass_conf_pool_size);
596  rmp->ip6_buffers = clib_net_to_host_u32 (mm->ip6_reass_conf_buffers);
598 
599  rmp->sec_check_enable = mm->sec_check;
601 
602  rmp->tc_copy = mm->tc_copy;
603  rmp->tc_class = mm->tc;
604 
605  vl_api_send_msg (reg, (u8 *) rmp);
606 }
607 
608 
609 int
610 map_if_enable_disable (bool is_enable, u32 sw_if_index, bool is_translation)
611 {
612  map_main_t *mm = &map_main;
613 
615  sw_if_index))
616  return VNET_API_ERROR_INVALID_SW_IF_INDEX;
617 
618  is_enable = ! !is_enable;
619 
620  if (is_translation)
621  {
622  if (clib_bitmap_get (mm->bm_trans_enabled_by_sw_if, sw_if_index)
623  == is_enable)
624  return 0;
625  }
626  else
627  {
628  if (clib_bitmap_get (mm->bm_encap_enabled_by_sw_if, sw_if_index)
629  == is_enable)
630  return 0;
631  }
632 
633  if (is_translation == false)
634  {
635  vnet_feature_enable_disable ("ip4-unicast", "ip4-map", sw_if_index,
636  is_enable ? 1 : 0, 0, 0);
637  vnet_feature_enable_disable ("ip6-unicast", "ip6-map", sw_if_index,
638  is_enable ? 1 : 0, 0, 0);
640  clib_bitmap_set (mm->bm_encap_enabled_by_sw_if, sw_if_index,
641  is_enable);
642  }
643  else
644  {
645  vnet_feature_enable_disable ("ip4-unicast", "ip4-map-t", sw_if_index,
646  is_enable ? 1 : 0, 0, 0);
647  vnet_feature_enable_disable ("ip6-unicast", "ip6-map-t", sw_if_index,
648  is_enable ? 1 : 0, 0, 0);
650  clib_bitmap_set (mm->bm_trans_enabled_by_sw_if, sw_if_index,
651  is_enable);
652  }
653 
654  return 0;
655 }
656 
657 
658 static void
660 {
661  map_main_t *mm = &map_main;
662  vl_api_map_if_enable_disable_reply_t *rmp;
663  int rv = 0;
664 
666 
667  rv =
668  map_if_enable_disable (mp->is_enable, htonl (mp->sw_if_index),
669  mp->is_translation);
670 
672  REPLY_MACRO (VL_API_MAP_IF_ENABLE_DISABLE_REPLY);
673 }
674 
675 
676 #define foreach_map_plugin_api_msg \
677 _(MAP_ADD_DOMAIN, map_add_domain) \
678 _(MAP_DEL_DOMAIN, map_del_domain) \
679 _(MAP_ADD_DEL_RULE, map_add_del_rule) \
680 _(MAP_DOMAIN_DUMP, map_domain_dump) \
681 _(MAP_RULE_DUMP, map_rule_dump) \
682 _(MAP_IF_ENABLE_DISABLE, map_if_enable_disable) \
683 _(MAP_SUMMARY_STATS, map_summary_stats) \
684 _(MAP_PARAM_SET_FRAGMENTATION, map_param_set_fragmentation) \
685 _(MAP_PARAM_SET_ICMP, map_param_set_icmp) \
686 _(MAP_PARAM_SET_ICMP6, map_param_set_icmp6) \
687 _(MAP_PARAM_ADD_DEL_PRE_RESOLVE, map_param_add_del_pre_resolve) \
688 _(MAP_PARAM_SET_REASSEMBLY, map_param_set_reassembly) \
689 _(MAP_PARAM_SET_SECURITY_CHECK, map_param_set_security_check) \
690 _(MAP_PARAM_SET_TRAFFIC_CLASS, map_param_set_traffic_class) \
691 _(MAP_PARAM_SET_TCP, map_param_set_tcp) \
692 _(MAP_PARAM_GET, map_param_get)
693 
694 #define vl_msg_name_crc_list
695 #include <map/map_all_api_h.h>
696 #undef vl_msg_name_crc_list
697 
698 static void
700 {
701 #define _(id,n,crc) \
702  vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + mm->msg_id_base);
703  foreach_vl_msg_name_crc_map;
704 #undef _
705 }
706 
707 /* Set up the API message handling tables */
708 clib_error_t *
710 {
711  map_main_t *mm = &map_main;
712  u8 *name = format (0, "map_%08x%c", api_version, 0);
713 
714  /* Ask for a correctly-sized block of API message decode slots */
715  mm->msg_id_base =
717 #define _(N,n) \
718  vl_msg_api_set_handlers((VL_API_##N + mm->msg_id_base), \
719  #n, \
720  vl_api_##n##_t_handler, \
721  vl_noop_handler, \
722  vl_api_##n##_t_endian, \
723  vl_api_##n##_t_print, \
724  sizeof(vl_api_##n##_t), 1);
726 #undef _
727 
728  /*
729  * Set up the (msg_name, crc, message-id) table
730  */
732 
733  vec_free (name);
734  return 0;
735 }
736 
737 /*
738  * fd.io coding-style-patch-verification: ON
739  *
740  * Local Variables:
741  * eval: (c-set-style "gnu")
742  * End:
743  */
static void vl_api_map_param_set_tcp_t_handler(vl_api_map_param_set_tcp_t *mp)
Definition: map_api.c:545
u8 psid_length
Definition: map.h:120
int map_add_del_psid(u32 map_domain_index, u16 psid, ip6_address_t *tep, bool is_add)
Definition: map.c:235
static void vl_api_map_if_enable_disable_t_handler(vl_api_map_if_enable_disable_t *mp)
Definition: map_api.c:659
u32 ip4_reass_conf_buffers
Definition: map.h:301
u32 flags
Definition: vhost_user.h:141
static void vl_api_map_param_set_icmp_t_handler(vl_api_map_param_set_icmp_t *mp)
Definition: map_api.c:300
#define MAP_IP6_REASS_CONF_BUFFERS_MAX
Definition: map.h:559
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:204
map_main_t map_main
Definition: map.c:27
static void vl_api_map_domain_dump_t_handler(vl_api_map_domain_dump_t *mp)
Definition: map_api.c:103
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:274
#define REPLY_MACRO2(t, body)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
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:1088
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:35
u8 tc
Definition: map.h:277
static void vl_api_map_param_set_security_check_t_handler(vl_api_map_param_set_security_check_t *mp)
Definition: map_api.c:496
static void map_domain_counter_unlock(map_main_t *mm)
Definition: map.h:594
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:281
static void vl_api_map_param_set_traffic_class_t_handler(vl_api_map_param_set_traffic_class_t *mp)
Definition: map_api.c:521
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:705
int map_param_set_traffic_class(bool copy, u8 tc)
Definition: map_api.c:509
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, u8 *tag)
Definition: map.c:105
uword * bm_trans_enabled_by_sw_if
Definition: map.h:338
#define MAP_ERR_BAD_HT_RATIO
Definition: map.h:31
void map_pre_resolve(ip4_address_t *ip4, ip6_address_t *ip6, bool is_del)
Definition: map.c:407
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:323
int map_ip6_reass_conf_ht_ratio(f32 ht_ratio, u32 *trashed_reass, u32 *dropped_packets)
Definition: map.c:1898
static void vl_api_map_add_del_rule_t_handler(vl_api_map_add_del_rule_t *mp)
Definition: map_api.c:89
unsigned char u8
Definition: types.h:56
#define MAP_IP6_REASS_CONF_LIFETIME_MAX
Definition: map.h:557
static void vl_api_map_summary_stats_t_handler(vl_api_map_summary_stats_t *mp)
Definition: map_api.c:193
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:484
Set MAP TCP parammeters.
Definition: map.api:301
#define MAP_ERR_BAD_BUFFERS_TOO_LARGE
Definition: map.h:34
string tag[64]
Definition: map.api:43
#define MAP_IP4_REASS_MAX_FRAGMENTS_PER_REASSEMBLY
Definition: map.h:85
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:278
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:493
vl_api_interface_index_t sw_if_index
Definition: gre.api:50
vlib_combined_counter_main_t * domain_counters
Definition: map.h:270
ip4_address_t icmp4_src_address
Definition: map.h:287
Reply for map_param_get request.
Definition: map.api:342
ip6_address_t * rules
Definition: map.h:110
unsigned int u32
Definition: types.h:88
#define MAP_IP4_REASS_CONF_LIFETIME_MAX
Definition: map.h:545
static void vl_api_map_del_domain_t_handler(vl_api_map_del_domain_t *mp)
Definition: map_api.c:77
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:337
#define MAP_IP6_REASS_CONF_POOL_SIZE_MAX
Definition: map.h:555
int map_param_set_icmp6(u8 enable_unreachable)
Definition: map_api.c:313
Delete MAP domain.
Definition: map.api:63
vnet_crypto_main_t * cm
Definition: quic_crypto.c:41
#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:1937
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:610
int map_ip4_reass_conf_lifetime(u16 lifetime_ms)
Definition: map.c:1847
clib_error_t * map_plugin_api_hookup(vlib_main_t *vm)
Definition: map_api.c:709
#define MAP_IP4_REASS_CONF_HT_RATIO_MAX
Definition: map.h:541
bool frag_ignore_df
Definition: map.h:315
static void vl_api_map_rule_dump_t_handler(vl_api_map_rule_dump_t *mp)
Definition: map_api.c:152
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:175
unsigned short u16
Definition: types.h:57
u16 ip4_reass_conf_pool_size
Definition: map.h:299
map_domain_t * domains
Definition: map.h:265
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:557
vl_api_ip4_address_t ip4_nh_address
Definition: map.api:240
int map_ip4_reass_conf_buffers(u32 buffers)
Definition: map.c:1854
int map_ip6_reass_conf_lifetime(u16 lifetime_ms)
Definition: map.c:1930
int map_ip4_reass_conf_pool_size(u16 pool_size, u32 *trashed_reass, u32 *dropped_packets)
Definition: map.c:1832
#define REPLY_MACRO(t)
#define MAP_ERR_BAD_BUFFERS
Definition: map.h:33
vl_api_address_t dst
Definition: gre.api:52
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:699
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:351
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:203
Request for a single block of MAP parameters.
Definition: map.api:313
int map_param_set_tcp(u16 tcp_mss)
Definition: map_api.c:534
Details about a single MAP domain.
Definition: map.api:112
An API client registration, only in vpp/vlib.
Definition: api_common.h:46
#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:273
u16 ip6_reass_conf_pool_size
Definition: map.h:322
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:323
vl_api_ip6_address_t ip6_nh_address
Definition: map.api:351
uword * bm_encap_enabled_by_sw_if
Definition: map.h:339
#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:282
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:283
#define ARRAY_LEN(x)
Definition: clib.h:63
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:57
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:1815
static void map_domain_counter_lock(map_main_t *mm)
Definition: map.h:586
f32 ip4_reass_conf_ht_ratio
Definition: map.h:298
int map_param_set_icmp(ip4_address_t *icmp_src_address)
Definition: map_api.c:286
int map_ip6_reass_conf_pool_size(u16 pool_size, u32 *trashed_reass, u32 *dropped_packets)
Definition: map.c:1915
vl_api_ip6_address_t ip6_nh_address
Definition: map.api:241
bool sec_check
Definition: map.h:280
bool frag_inner
Definition: map.h:314
static f64 clib_net_to_host_f64(f64 x)
Definition: byte_order.h:215
Request for a single block of summary stats.
Definition: map.api:161
Reply for MAP domain add.
Definition: map.api:51
#define MAP_ERR_BAD_POOL_SIZE
Definition: map.h:30
#define foreach_map_plugin_api_msg
Definition: map_api.c:676
f32 ip6_reass_conf_ht_ratio
Definition: map.h:321
counter_t bytes
byte counter
Definition: counter_types.h:29
vnet_main_t * vnet_main
Definition: map.h:292
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:323
#define MAP_IP6_REASS_CONF_HT_RATIO_MAX
Definition: map.h:553
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:837
u16 tcp_mss
Definition: map.h:284
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:543
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:457
#define MAP_IP6_REASS_MAX_FRAGMENTS_PER_REASSEMBLY
Definition: map.h:92
u16 ip4_reass_conf_lifetime_ms
Definition: map.h:300
#define vec_foreach(var, vec)
Vector iterator.
#define MAP_IP4_REASS_CONF_BUFFERS_MAX
Definition: map.h:547
#define MAP_ERR_BAD_LIFETIME
Definition: map.h:32
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:275
#define VALIDATE_SW_IF_INDEX(mp)
int map_param_set_fragmentation(bool inner, bool ignore_df)
Definition: map_api.c:261
Set MAP ICMP parameters.
Definition: map.api:207
u16 vl_msg_api_get_msg_ids(const char *name, int n)
Definition: api_shared.c:957
u32 ip6_reass_conf_buffers
Definition: map.h:324
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:128