FD.io VPP  v19.08.1-401-g8e4ed521a
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  u8 *tag = format (0, "%s", mp->tag);
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, tag);
66  vec_free (tag);
67  /* *INDENT-OFF* */
68  REPLY_MACRO2(VL_API_MAP_ADD_DOMAIN_REPLY,
69  ({
70  rmp->index = ntohl(index);
71  }));
72  /* *INDENT-ON* */
73 }
74 
75 static void
77 {
78  map_main_t *mm = &map_main;
79  vl_api_map_del_domain_reply_t *rmp;
80  int rv = 0;
81 
82  rv = map_delete_domain (ntohl (mp->index));
83 
84  REPLY_MACRO (VL_API_MAP_DEL_DOMAIN_REPLY);
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 =
95  map_add_del_psid (ntohl (mp->index), ntohs (mp->psid),
96  (ip6_address_t *) & mp->ip6_dst, mp->is_add);
97 
98  REPLY_MACRO (VL_API_MAP_ADD_DEL_RULE_REPLY);
99 }
100 
101 static void
103 {
105  map_main_t *mm = &map_main;
106  map_domain_t *d;
107  map_domain_extra_t *de;
109  u32 map_domain_index;
110 
111  if (pool_elts (mm->domains) == 0)
112  return;
113 
115  if (!reg)
116  return;
117 
118  /* *INDENT-OFF* */
119  pool_foreach(d, mm->domains,
120  ({
121  map_domain_index = d - mm->domains;
122  de = vec_elt_at_index(mm->domain_extras, map_domain_index);
123  int tag_len = clib_min(ARRAY_LEN(rmp->tag), vec_len(de->tag) + 1);
124 
125  /* Make sure every field is initiated (or don't skip the clib_memset()) */
126  rmp = vl_msg_api_alloc (sizeof (*rmp) + tag_len);
127 
128  rmp->_vl_msg_id = htons(VL_API_MAP_DOMAIN_DETAILS + mm->msg_id_base);
129  rmp->context = mp->context;
130  rmp->domain_index = htonl(map_domain_index);
131  clib_memcpy(&rmp->ip6_prefix.address, &d->ip6_prefix, sizeof(rmp->ip6_prefix.address));
132  clib_memcpy(&rmp->ip4_prefix.address, &d->ip4_prefix, sizeof(rmp->ip4_prefix.address));
133  clib_memcpy(&rmp->ip6_src.address, &d->ip6_src, sizeof(rmp->ip6_src.address));
134  rmp->ip6_prefix.len = d->ip6_prefix_len;
135  rmp->ip4_prefix.len = d->ip4_prefix_len;
136  rmp->ip6_src.len = d->ip6_src_len;
137  rmp->ea_bits_len = d->ea_bits_len;
138  rmp->psid_offset = d->psid_offset;
139  rmp->psid_length = d->psid_length;
140  rmp->flags = d->flags;
141  rmp->mtu = htons(d->mtu);
142  memcpy(rmp->tag, de->tag, tag_len-1);
143  rmp->tag[tag_len-1] = '\0';
144 
145  vl_api_send_msg (reg, (u8 *) rmp);
146  }));
147  /* *INDENT-ON* */
148 }
149 
150 static void
152 {
154  u16 i;
157  map_main_t *mm = &map_main;
158  u32 domain_index = ntohl (mp->domain_index);
159  map_domain_t *d;
160 
161  if (pool_elts (mm->domains) == 0)
162  return;
163 
164  d = pool_elt_at_index (mm->domains, domain_index);
165  if (!d || !d->rules)
166  {
167  return;
168  }
169 
171  if (!reg)
172  return;
173 
174  for (i = 0; i < (0x1 << d->psid_length); i++)
175  {
176  dst = d->rules[i];
177  if (dst.as_u64[0] == 0 && dst.as_u64[1] == 0)
178  {
179  continue;
180  }
181  rmp = vl_msg_api_alloc (sizeof (*rmp));
182  clib_memset (rmp, 0, sizeof (*rmp));
183  rmp->_vl_msg_id = ntohs (VL_API_MAP_RULE_DETAILS + mm->msg_id_base);
184  rmp->psid = htons (i);
185  clib_memcpy (&rmp->ip6_dst, &dst, sizeof (rmp->ip6_dst));
186  rmp->context = mp->context;
187  vl_api_send_msg (reg, (u8 *) rmp);
188  }
189 }
190 
191 static void
193 {
196  vlib_counter_t v;
197  int i, which;
198  u64 total_pkts[VLIB_N_RX_TX];
199  u64 total_bytes[VLIB_N_RX_TX];
200  map_main_t *mm = &map_main;
202 
204  if (!reg)
205  return;
206 
207  rmp = vl_msg_api_alloc (sizeof (*rmp));
208  rmp->_vl_msg_id = htons (VL_API_MAP_SUMMARY_STATS_REPLY + mm->msg_id_base);
209  rmp->context = mp->context;
210  rmp->retval = 0;
211 
212  if (pool_elts (mm->domains) == 0)
213  {
214  rmp->retval = -1;
215  goto out;
216  }
217 
218  clib_memset (total_pkts, 0, sizeof (total_pkts));
219  clib_memset (total_bytes, 0, sizeof (total_bytes));
220 
222  vec_foreach (cm, mm->domain_counters)
223  {
224  which = cm - mm->domain_counters;
225 
226  for (i = 0; i < vlib_combined_counter_n_counters (cm); i++)
227  {
228  vlib_get_combined_counter (cm, i, &v);
229  total_pkts[which] += v.packets;
230  total_bytes[which] += v.bytes;
231  }
232  }
233 
235 
236  /* Note: in network byte order! */
238  clib_host_to_net_u64 (total_pkts[MAP_DOMAIN_COUNTER_RX]);
240  clib_host_to_net_u64 (total_bytes[MAP_DOMAIN_COUNTER_RX]);
242  clib_host_to_net_u64 (total_pkts[MAP_DOMAIN_COUNTER_TX]);
244  clib_host_to_net_u64 (total_bytes[MAP_DOMAIN_COUNTER_TX]);
245  rmp->total_bindings = clib_host_to_net_u64 (pool_elts (mm->domains));
246  rmp->total_ip4_fragments = 0; // Not yet implemented. Should be a simple counter.
248  clib_host_to_net_u64 (map_error_counter_get
249  (ip4_map_node.index, MAP_ERROR_ENCAP_SEC_CHECK));
251  clib_host_to_net_u64 (map_error_counter_get
252  (ip4_map_node.index, MAP_ERROR_DECAP_SEC_CHECK));
253 
254 out:
255  vl_api_send_msg (reg, (u8 *) rmp);
256 }
257 
258 
259 int
260 map_param_set_fragmentation (bool inner, bool ignore_df)
261 {
262  map_main_t *mm = &map_main;
263 
264  mm->frag_inner = ! !inner;
265  mm->frag_ignore_df = ! !ignore_df;
266 
267  return 0;
268 }
269 
270 static void
273 {
274  map_main_t *mm = &map_main;
275  vl_api_map_param_set_fragmentation_reply_t *rmp;
276  int rv = 0;
277 
279 
280  REPLY_MACRO (VL_API_MAP_PARAM_SET_FRAGMENTATION_REPLY);
281 }
282 
283 
284 int
285 map_param_set_icmp (ip4_address_t * icmp_src_address)
286 {
287  map_main_t *mm = &map_main;
288 
289  if (icmp_src_address == 0)
290  return -1;
291 
292  mm->icmp4_src_address = *icmp_src_address;
293 
294  return 0;
295 }
296 
297 
298 static void
300 {
301  map_main_t *mm = &map_main;
302  vl_api_map_param_set_icmp_reply_t *rmp;
303  int rv;
304 
306 
307  REPLY_MACRO (VL_API_MAP_PARAM_SET_ICMP_REPLY);
308 }
309 
310 
311 int
312 map_param_set_icmp6 (u8 enable_unreachable)
313 {
314  map_main_t *mm = &map_main;
315 
316  mm->icmp6_enabled = ! !enable_unreachable;
317 
318  return 0;
319 }
320 
321 static void
323 {
324  map_main_t *mm = &map_main;
325  vl_api_map_param_set_icmp6_reply_t *rmp;
326  int rv;
327 
329 
330  REPLY_MACRO (VL_API_MAP_PARAM_SET_ICMP6_REPLY);
331 }
332 
333 
334 static void
337 {
338  map_main_t *mm = &map_main;
339  vl_api_map_param_add_del_pre_resolve_reply_t *rmp;
340  int rv = 0;
341 
343  (ip6_address_t *) & mp->ip6_nh_address, !mp->is_add);
344 
345  REPLY_MACRO (VL_API_MAP_PARAM_ADD_DEL_PRE_RESOLVE_REPLY);
346 }
347 
348 
349 int
351  u16 lifetime_ms,
352  u16 pool_size,
353  u32 buffers,
354  f64 ht_ratio, u32 * reass, u32 * packets)
355 {
356  u32 ps_reass = 0, ps_packets = 0;
357  u32 ht_reass = 0, ht_packets = 0;
358 
359  if (is_ipv6)
360  {
361  if (pool_size != (u16) ~ 0)
362  {
363  if (pool_size > MAP_IP6_REASS_CONF_POOL_SIZE_MAX)
364  return MAP_ERR_BAD_POOL_SIZE;
366  (pool_size, &ps_reass, &ps_packets))
367  return MAP_ERR_BAD_POOL_SIZE;
368  }
369 
370  if (ht_ratio != (MAP_IP6_REASS_CONF_HT_RATIO_MAX + 1))
371  {
372  if (ht_ratio > MAP_IP6_REASS_CONF_HT_RATIO_MAX)
373  return MAP_ERR_BAD_HT_RATIO;
374  if (map_ip6_reass_conf_ht_ratio (ht_ratio, &ht_reass, &ht_packets))
375  return MAP_ERR_BAD_HT_RATIO;
376  }
377 
378  if (lifetime_ms != (u16) ~ 0)
379  {
380  if (lifetime_ms > MAP_IP6_REASS_CONF_LIFETIME_MAX)
381  return MAP_ERR_BAD_LIFETIME;
382  if (map_ip6_reass_conf_lifetime (lifetime_ms))
383  return MAP_ERR_BAD_LIFETIME;
384  }
385 
386  if (buffers != ~0)
387  {
388  if (buffers > MAP_IP6_REASS_CONF_BUFFERS_MAX)
389  return MAP_ERR_BAD_BUFFERS;
390  if (map_ip6_reass_conf_buffers (buffers))
391  return MAP_ERR_BAD_BUFFERS;
392  }
393 
397  {
399  }
400  }
401  else
402  {
403  if (pool_size != (u16) ~ 0)
404  {
405  if (pool_size > MAP_IP4_REASS_CONF_POOL_SIZE_MAX)
406  return MAP_ERR_BAD_POOL_SIZE;
408  (pool_size, &ps_reass, &ps_packets))
409  return MAP_ERR_BAD_POOL_SIZE;
410  }
411 
412  if (ht_ratio != (MAP_IP4_REASS_CONF_HT_RATIO_MAX + 1))
413  {
414  if (ht_ratio > MAP_IP4_REASS_CONF_HT_RATIO_MAX)
415  return MAP_ERR_BAD_HT_RATIO;
416  if (map_ip4_reass_conf_ht_ratio (ht_ratio, &ht_reass, &ht_packets))
417  return MAP_ERR_BAD_HT_RATIO;
418  }
419 
420  if (lifetime_ms != (u16) ~ 0)
421  {
422  if (lifetime_ms > MAP_IP4_REASS_CONF_LIFETIME_MAX)
423  return MAP_ERR_BAD_LIFETIME;
424  if (map_ip4_reass_conf_lifetime (lifetime_ms))
425  return MAP_ERR_BAD_LIFETIME;
426  }
427 
428  if (buffers != ~0)
429  {
430  if (buffers > MAP_IP4_REASS_CONF_BUFFERS_MAX)
431  return MAP_ERR_BAD_BUFFERS;
432  if (map_ip4_reass_conf_buffers (buffers))
433  return MAP_ERR_BAD_BUFFERS;
434  }
435 
439  {
441  }
442  }
443 
444  if (reass)
445  *reass = ps_reass + ht_reass;
446 
447  if (packets)
448  *packets = ps_packets + ht_packets;
449 
450  return 0;
451 }
452 
453 
454 static void
457 {
458  map_main_t *mm = &map_main;
459  vl_api_map_param_set_reassembly_reply_t *rmp;
460  u32 reass = 0, packets = 0;
461  int rv;
462  f64 ht_ratio;
463 
464  ht_ratio = (f64) clib_net_to_host_f64 (mp->ht_ratio);
465  if (ht_ratio == ~0)
466  ht_ratio = MAP_IP6_REASS_CONF_HT_RATIO_MAX + 1;
467 
469  clib_net_to_host_u16 (mp->lifetime_ms),
470  clib_net_to_host_u16 (mp->pool_size),
471  clib_net_to_host_u32 (mp->buffers),
472  ht_ratio, &reass, &packets);
473 
474  /*
475  * FIXME: Should the lost reass and packet counts be returned in the API?
476  */
477 
478  REPLY_MACRO (VL_API_MAP_PARAM_SET_REASSEMBLY_REPLY);
479 }
480 
481 
482 int
483 map_param_set_security_check (bool enable, bool fragments)
484 {
485  map_main_t *mm = &map_main;
486 
487  mm->sec_check = ! !enable;
488  mm->sec_check_frag = ! !fragments;
489 
490  return 0;
491 }
492 
493 static void
496 {
497  map_main_t *mm = &map_main;
498  vl_api_map_param_set_security_check_reply_t *rmp;
499  int rv;
500 
502 
503  REPLY_MACRO (VL_API_MAP_PARAM_SET_SECURITY_CHECK_REPLY);
504 }
505 
506 
507 int
509 {
510  map_main_t *mm = &map_main;
511 
512  mm->tc_copy = ! !copy;
513  mm->tc = tc;
514 
515  return 0;
516 }
517 
518 static void
521 {
522  map_main_t *mm = &map_main;
523  vl_api_map_param_set_traffic_class_reply_t *rmp;
524  int rv;
525 
526  rv = map_param_set_traffic_class (mp->copy, mp->class);
527 
528  REPLY_MACRO (VL_API_MAP_PARAM_SET_TRAFFIC_CLASS_REPLY);
529 }
530 
531 
532 int
534 {
535  map_main_t *mm = &map_main;
536 
537  mm->tcp_mss = tcp_mss;
538 
539  return 0;
540 }
541 
542 
543 static void
545 {
546  map_main_t *mm = &map_main;
547  vl_api_map_param_set_tcp_reply_t *rmp;
548  int rv = 0;
549 
550  map_param_set_tcp (ntohs (mp->tcp_mss));
551  REPLY_MACRO (VL_API_MAP_PARAM_SET_TCP_REPLY);
552 }
553 
554 
555 static void
557 {
558  map_main_t *mm = &map_main;
561 
563  if (!reg)
564  return;
565 
566  rmp = vl_msg_api_alloc (sizeof (*rmp));
567  rmp->_vl_msg_id = htons (VL_API_MAP_PARAM_GET_REPLY + mm->msg_id_base);
568  rmp->context = mp->context;
569  rmp->retval = 0;
570 
571  rmp->frag_inner = mm->frag_inner;
572  rmp->frag_ignore_df = mm->frag_ignore_df;
573 
575  &mm->icmp4_src_address, sizeof (rmp->icmp_ip4_err_relay_src));
576 
578 
579  /*
580  * FIXME: How are these addresses re-extracted from the FIB?
581  * Or should a local map_main copy be kept?
582  */
583  clib_memset (&rmp->ip4_nh_address, 0, sizeof (rmp->ip4_nh_address));
584  clib_memset (&rmp->ip6_nh_address, 0, sizeof (rmp->ip6_nh_address));
585 
586  rmp->ip4_lifetime_ms =
587  clib_net_to_host_u16 (mm->ip4_reass_conf_lifetime_ms);
588  rmp->ip4_pool_size = clib_net_to_host_u16 (mm->ip4_reass_conf_pool_size);
589  rmp->ip4_buffers = clib_net_to_host_u32 (mm->ip4_reass_conf_buffers);
591 
592  rmp->ip6_lifetime_ms =
593  clib_net_to_host_u16 (mm->ip6_reass_conf_lifetime_ms);
594  rmp->ip6_pool_size = clib_net_to_host_u16 (mm->ip6_reass_conf_pool_size);
595  rmp->ip6_buffers = clib_net_to_host_u32 (mm->ip6_reass_conf_buffers);
597 
598  rmp->sec_check_enable = mm->sec_check;
600 
601  rmp->tc_copy = mm->tc_copy;
602  rmp->tc_class = mm->tc;
603 
604  vl_api_send_msg (reg, (u8 *) rmp);
605 }
606 
607 
608 int
609 map_if_enable_disable (bool is_enable, u32 sw_if_index, bool is_translation)
610 {
611  map_main_t *mm = &map_main;
612 
614  sw_if_index))
615  return VNET_API_ERROR_INVALID_SW_IF_INDEX;
616 
617  is_enable = ! !is_enable;
618 
619  if (is_translation)
620  {
621  if (clib_bitmap_get (mm->bm_trans_enabled_by_sw_if, sw_if_index)
622  == is_enable)
623  return 0;
624  }
625  else
626  {
627  if (clib_bitmap_get (mm->bm_encap_enabled_by_sw_if, sw_if_index)
628  == is_enable)
629  return 0;
630  }
631 
632  if (is_translation == false)
633  {
634  vnet_feature_enable_disable ("ip4-unicast", "ip4-map", sw_if_index,
635  is_enable ? 1 : 0, 0, 0);
636  vnet_feature_enable_disable ("ip6-unicast", "ip6-map", sw_if_index,
637  is_enable ? 1 : 0, 0, 0);
639  clib_bitmap_set (mm->bm_encap_enabled_by_sw_if, sw_if_index,
640  is_enable);
641  }
642  else
643  {
644  vnet_feature_enable_disable ("ip4-unicast", "ip4-map-t", sw_if_index,
645  is_enable ? 1 : 0, 0, 0);
646  vnet_feature_enable_disable ("ip6-unicast", "ip6-map-t", sw_if_index,
647  is_enable ? 1 : 0, 0, 0);
649  clib_bitmap_set (mm->bm_trans_enabled_by_sw_if, sw_if_index,
650  is_enable);
651  }
652 
653  return 0;
654 }
655 
656 
657 static void
659 {
660  map_main_t *mm = &map_main;
661  vl_api_map_if_enable_disable_reply_t *rmp;
662  int rv = 0;
663 
665 
666  rv =
667  map_if_enable_disable (mp->is_enable, htonl (mp->sw_if_index),
668  mp->is_translation);
669 
671  REPLY_MACRO (VL_API_MAP_IF_ENABLE_DISABLE_REPLY);
672 }
673 
674 
675 #define foreach_map_plugin_api_msg \
676 _(MAP_ADD_DOMAIN, map_add_domain) \
677 _(MAP_DEL_DOMAIN, map_del_domain) \
678 _(MAP_ADD_DEL_RULE, map_add_del_rule) \
679 _(MAP_DOMAIN_DUMP, map_domain_dump) \
680 _(MAP_RULE_DUMP, map_rule_dump) \
681 _(MAP_IF_ENABLE_DISABLE, map_if_enable_disable) \
682 _(MAP_SUMMARY_STATS, map_summary_stats) \
683 _(MAP_PARAM_SET_FRAGMENTATION, map_param_set_fragmentation) \
684 _(MAP_PARAM_SET_ICMP, map_param_set_icmp) \
685 _(MAP_PARAM_SET_ICMP6, map_param_set_icmp6) \
686 _(MAP_PARAM_ADD_DEL_PRE_RESOLVE, map_param_add_del_pre_resolve) \
687 _(MAP_PARAM_SET_REASSEMBLY, map_param_set_reassembly) \
688 _(MAP_PARAM_SET_SECURITY_CHECK, map_param_set_security_check) \
689 _(MAP_PARAM_SET_TRAFFIC_CLASS, map_param_set_traffic_class) \
690 _(MAP_PARAM_SET_TCP, map_param_set_tcp) \
691 _(MAP_PARAM_GET, map_param_get)
692 
693 #define vl_msg_name_crc_list
694 #include <map/map_all_api_h.h>
695 #undef vl_msg_name_crc_list
696 
697 static void
699 {
700 #define _(id,n,crc) \
701  vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + mm->msg_id_base);
702  foreach_vl_msg_name_crc_map;
703 #undef _
704 }
705 
706 /* Set up the API message handling tables */
707 clib_error_t *
709 {
710  map_main_t *mm = &map_main;
711  u8 *name = format (0, "map_%08x%c", api_version, 0);
712 
713  /* Ask for a correctly-sized block of API message decode slots */
714  mm->msg_id_base =
716 #define _(N,n) \
717  vl_msg_api_set_handlers((VL_API_##N + mm->msg_id_base), \
718  #n, \
719  vl_api_##n##_t_handler, \
720  vl_noop_handler, \
721  vl_api_##n##_t_endian, \
722  vl_api_##n##_t_print, \
723  sizeof(vl_api_##n##_t), 1);
725 #undef _
726 
727  /*
728  * Set up the (msg_name, crc, message-id) table
729  */
731 
732  vec_free (name);
733  return 0;
734 }
735 
736 /*
737  * fd.io coding-style-patch-verification: ON
738  *
739  * Local Variables:
740  * eval: (c-set-style "gnu")
741  * End:
742  */
static void vl_api_map_param_set_tcp_t_handler(vl_api_map_param_set_tcp_t *mp)
Definition: map_api.c:544
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:238
static void vl_api_map_if_enable_disable_t_handler(vl_api_map_if_enable_disable_t *mp)
Definition: map_api.c:658
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:299
#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:207
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:102
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:1080
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:495
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:520
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:508
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:108
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:410
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:322
int map_ip6_reass_conf_ht_ratio(f32 ht_ratio, u32 *trashed_reass, u32 *dropped_packets)
Definition: map.c:1890
static void vl_api_map_add_del_rule_t_handler(vl_api_map_add_del_rule_t *mp)
Definition: map_api.c:88
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:192
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:483
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:76
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:336
#define MAP_IP6_REASS_CONF_POOL_SIZE_MAX
Definition: map.h:555
int map_param_set_icmp6(u8 enable_unreachable)
Definition: map_api.c:312
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:1929
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:609
int map_ip4_reass_conf_lifetime(u16 lifetime_ms)
Definition: map.c:1839
clib_error_t * map_plugin_api_hookup(vlib_main_t *vm)
Definition: map_api.c:708
#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:151
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:109
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:556
vl_api_ip4_address_t ip4_nh_address
Definition: map.api:240
int map_ip4_reass_conf_buffers(u32 buffers)
Definition: map.c:1846
int map_ip6_reass_conf_lifetime(u16 lifetime_ms)
Definition: map.c:1922
int map_ip4_reass_conf_pool_size(u16 pool_size, u32 *trashed_reass, u32 *dropped_packets)
Definition: map.c:1824
#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:698
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:350
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:533
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:272
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
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:1807
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:285
int map_ip6_reass_conf_pool_size(u16 pool_size, u32 *trashed_reass, u32 *dropped_packets)
Definition: map.c:1907
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:675
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:456
#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:260
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