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