FD.io VPP  v20.01-48-g3e0dafb74
Vector Packet Processing
ip_api.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * ip_api.c - vnet ip api
4  *
5  * Copyright (c) 2016 Cisco and/or its affiliates.
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at:
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *------------------------------------------------------------------
18  */
19 
20 #include <vnet/vnet.h>
21 #include <vlibmemory/api.h>
22 
23 #include <vnet/interface.h>
24 #include <vnet/api_errno.h>
25 #include <vnet/ethernet/ethernet.h>
27 #include <vnet/ip/ip.h>
28 #include <vnet/ip/ip_types_api.h>
29 #include <vnet/ip/ip_punt_drop.h>
30 #include <vnet/ip/ip_types_api.h>
31 #include <vnet/fib/fib_table.h>
32 #include <vnet/fib/fib_api.h>
34 #include <vnet/mfib/ip6_mfib.h>
35 #include <vnet/mfib/ip4_mfib.h>
36 #include <vnet/mfib/mfib_signal.h>
37 #include <vnet/mfib/mfib_entry.h>
38 #include <vnet/mfib/mfib_api.h>
40 #include <vnet/fib/ip4_fib.h>
41 #include <vnet/fib/ip6_fib.h>
42 #include <vnet/fib/fib_path_list.h>
43 #include <vnet/ip/ip6_hop_by_hop.h>
44 #include <vnet/ip/ip6_link.h>
49 
50 #include <vnet/vnet_msg_enum.h>
51 
52 #define vl_typedefs /* define message structures */
53 #include <vnet/vnet_all_api_h.h>
54 #undef vl_typedefs
55 
56 #define vl_endianfun /* define message structures */
57 #include <vnet/vnet_all_api_h.h>
58 #undef vl_endianfun
59 
60 /* instantiate all the print functions we know about */
61 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
62 #define vl_printfun
63 #include <vnet/vnet_all_api_h.h>
64 #undef vl_printfun
65 
67 
68 #include <vnet/format_fns.h>
69 
70 #define foreach_ip_api_msg \
71 _(SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable) \
72 _(IP_TABLE_DUMP, ip_table_dump) \
73 _(IP_ROUTE_DUMP, ip_route_dump) \
74 _(IP_MTABLE_DUMP, ip_mtable_dump) \
75 _(IP_MROUTE_DUMP, ip_mroute_dump) \
76 _(IP_MROUTE_ADD_DEL, ip_mroute_add_del) \
77 _(MFIB_SIGNAL_DUMP, mfib_signal_dump) \
78 _(IP_ADDRESS_DUMP, ip_address_dump) \
79 _(IP_UNNUMBERED_DUMP, ip_unnumbered_dump) \
80 _(IP_DUMP, ip_dump) \
81 _(IP_TABLE_REPLACE_BEGIN, ip_table_replace_begin) \
82 _(IP_TABLE_REPLACE_END, ip_table_replace_end) \
83 _(IP_TABLE_FLUSH, ip_table_flush) \
84 _(IP_ROUTE_ADD_DEL, ip_route_add_del) \
85 _(IP_TABLE_ADD_DEL, ip_table_add_del) \
86 _(IP_PUNT_POLICE, ip_punt_police) \
87 _(IP_PUNT_REDIRECT, ip_punt_redirect) \
88 _(SET_IP_FLOW_HASH,set_ip_flow_hash) \
89 _(IP_CONTAINER_PROXY_ADD_DEL, ip_container_proxy_add_del) \
90 _(IP_CONTAINER_PROXY_DUMP, ip_container_proxy_dump) \
91 _(IOAM_ENABLE, ioam_enable) \
92 _(IOAM_DISABLE, ioam_disable) \
93 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, \
94  ip_source_and_port_range_check_add_del) \
95 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, \
96  ip_source_and_port_range_check_interface_add_del) \
97 _(IP_SOURCE_CHECK_INTERFACE_ADD_DEL, \
98  ip_source_check_interface_add_del) \
99  _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, \
100  sw_interface_ip6_set_link_local_address) \
101 _(IP_REASSEMBLY_SET, ip_reassembly_set) \
102 _(IP_REASSEMBLY_GET, ip_reassembly_get) \
103 _(IP_REASSEMBLY_ENABLE_DISABLE, ip_reassembly_enable_disable) \
104 _(IP_PUNT_REDIRECT_DUMP, ip_punt_redirect_dump)
105 
106 static void
109 {
110  vl_api_sw_interface_ip6_enable_disable_reply_t *rmp;
111  int rv = 0;
112 
114 
115  rv = ((mp->enable == 1) ?
116  ip6_link_enable (ntohl (mp->sw_if_index)) :
117  ip6_link_disable (ntohl (mp->sw_if_index)));
118 
120 
121  REPLY_MACRO (VL_API_SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY);
122 }
123 
124 static void
126  vl_api_registration_t * reg,
127  u32 context, const fib_table_t * table)
128 {
130 
131  mp = vl_msg_api_alloc (sizeof (*mp));
132  if (!mp)
133  return;
134  clib_memset (mp, 0, sizeof (*mp));
135  mp->_vl_msg_id = ntohs (VL_API_IP_TABLE_DETAILS);
136  mp->context = context;
137 
138  mp->table.is_ip6 = (table->ft_proto == FIB_PROTOCOL_IP6);
139  mp->table.table_id = htonl (table->ft_table_id);
140  memcpy (mp->table.name, table->ft_desc,
141  clib_min (vec_len (table->ft_desc), sizeof (mp->table.name)));
142 
143  vl_api_send_msg (reg, (u8 *) mp);
144 }
145 
146 static void
148 {
151  fib_table_t *fib_table;
152 
154  if (!reg)
155  return;
156 
157  /* *INDENT-OFF* */
158  pool_foreach (fib_table, ip4_main.fibs,
159  ({
160  send_ip_table_details(am, reg, mp->context, fib_table);
161  }));
162  pool_foreach (fib_table, ip6_main.fibs,
163  ({
164  /* don't send link locals */
165  if (fib_table->ft_flags & FIB_TABLE_FLAG_IP6_LL)
166  continue;
167  send_ip_table_details(am, reg, mp->context, fib_table);
168  }));
169  /* *INDENT-ON* */
170 }
171 
173 {
176 
177 static fib_table_walk_rc_t
179 {
181 
182  vec_add1 (ctx->feis, fei);
183 
184  return (FIB_TABLE_WALK_CONTINUE);
185 }
186 
187 static void
189  vl_api_registration_t * reg,
190  u32 context, fib_node_index_t fib_entry_index)
191 {
192  fib_route_path_t *rpaths, *rpath;
194  const fib_prefix_t *pfx;
195  vl_api_fib_path_t *fp;
196  int path_count;
197 
198  rpaths = NULL;
199  pfx = fib_entry_get_prefix (fib_entry_index);
200  rpaths = fib_entry_encode (fib_entry_index);
201 
202  path_count = vec_len (rpaths);
203  mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
204  if (!mp)
205  return;
206  clib_memset (mp, 0, sizeof (*mp));
207  mp->_vl_msg_id = ntohs (VL_API_IP_ROUTE_DETAILS);
208  mp->context = context;
209 
210  ip_prefix_encode (pfx, &mp->route.prefix);
211  mp->route.table_id =
213  (fib_entry_get_fib_index (fib_entry_index), pfx->fp_proto));
214  mp->route.n_paths = path_count;
215  mp->route.stats_index =
217  (fib_entry_get_fib_index (fib_entry_index), pfx));
218 
219  fp = mp->route.paths;
220  vec_foreach (rpath, rpaths)
221  {
222  fib_api_path_encode (rpath, fp);
223  fp++;
224  }
225 
226  vl_api_send_msg (reg, (u8 *) mp);
227  vec_free (rpaths);
228 }
229 
231 {
234 
235 static void
237 {
239  fib_node_index_t *fib_entry_index;
241  fib_protocol_t fproto;
242  u32 fib_index;
243 
245  if (!reg)
246  return;
247 
249  .feis = NULL,
250  };
251 
252  fproto = (mp->table.is_ip6 ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4);
253  fib_index = fib_table_find (fproto, ntohl (mp->table.table_id));
254 
255  if (INDEX_INVALID == fib_index)
256  return;
257 
258  fib_table_walk (fib_index, fproto, vl_api_ip_fib_dump_walk, &ctx);
259 
260  vec_foreach (fib_entry_index, ctx.feis)
261  {
262  send_ip_route_details (am, reg, mp->context, *fib_entry_index);
263  }
264 
265  vec_free (ctx.feis);
266 }
267 
268 static void
270  u32 context, const mfib_table_t * mfib_table)
271 {
273 
274  mp = vl_msg_api_alloc (sizeof (*mp));
275  if (!mp)
276  return;
277  memset (mp, 0, sizeof (*mp));
278  mp->_vl_msg_id = ntohs (VL_API_IP_MTABLE_DETAILS);
279  mp->context = context;
280 
281  mp->table.table_id = htonl (mfib_table->mft_table_id);
282  mp->table.is_ip6 = (FIB_PROTOCOL_IP6 == mfib_table->mft_proto);
283 
284  vl_api_send_msg (reg, (u8 *) mp);
285 }
286 
287 static void
289 {
291  mfib_table_t *mfib_table;
292 
294  if (!reg)
295  return;
296 
297  /* *INDENT-OFF* */
298  pool_foreach (mfib_table, ip4_main.mfibs,
299  ({
300  send_ip_mtable_details (reg, mp->context, mfib_table);
301  }));
302  pool_foreach (mfib_table, ip6_main.mfibs,
303  ({
304  send_ip_mtable_details (reg, mp->context, mfib_table);
305  }));
306  /* *INDENT-ON* */
307 }
308 
310 {
313 
314 static walk_rc_t
316 {
318 
319  vec_add1 (ctx->entries, fei);
320 
321  return (WALK_CONTINUE);
322 }
323 
324 static void
326  vl_api_registration_t * reg,
327  u32 context, fib_node_index_t mfib_entry_index)
328 {
329  fib_route_path_t *rpaths, *rpath;
331  const mfib_prefix_t *pfx;
332  vl_api_mfib_path_t *fp;
333  int path_count;
334 
335  rpaths = NULL;
336  pfx = mfib_entry_get_prefix (mfib_entry_index);
337  rpaths = mfib_entry_encode (mfib_entry_index);
338 
339  path_count = vec_len (rpaths);
340  mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
341  if (!mp)
342  return;
343  clib_memset (mp, 0, sizeof (*mp));
344  mp->_vl_msg_id = ntohs (VL_API_IP_MROUTE_DETAILS);
345  mp->context = context;
346 
347  ip_mprefix_encode (pfx, &mp->route.prefix);
348  mp->route.table_id =
350  (mfib_entry_get_fib_index (mfib_entry_index), pfx->fp_proto));
351  mp->route.n_paths = htonl (path_count);
352  fp = mp->route.paths;
353  vec_foreach (rpath, rpaths)
354  {
355  mfib_api_path_encode (rpath, fp);
356  fp++;
357  }
358 
359  vl_api_send_msg (reg, (u8 *) mp);
360  vec_free (rpaths);
361 }
362 
363 static void
365 {
368  fib_node_index_t *mfeip;
369  fib_protocol_t fproto;
370  u32 fib_index;
371 
373  .entries = NULL,
374  };
375 
377  if (!reg)
378  return;
379 
380  fproto = fib_ip_proto (mp->table.is_ip6);
381  fib_index = mfib_table_find (fproto, ntohl (mp->table.table_id));
382 
383  if (INDEX_INVALID == fib_index)
384  return;
385 
386  mfib_table_walk (fib_index, fproto, mfib_route_dump_walk, &ctx);
387 
389 
390  vec_foreach (mfeip, ctx.entries)
391  {
392  send_ip_mroute_details (am, reg, mp->context, *mfeip);
393  }
394 
395  vec_free (ctx.entries);
396 }
397 
398 static void
400  vlib_main_t * vm)
401 {
402  vl_api_ip_punt_police_reply_t *rmp;
403  int rv = 0;
404 
405  if (mp->is_ip6)
406  ip6_punt_policer_add_del (mp->is_add, ntohl (mp->policer_index));
407  else
408  ip4_punt_policer_add_del (mp->is_add, ntohl (mp->policer_index));
409 
410  REPLY_MACRO (VL_API_IP_PUNT_POLICE_REPLY);
411 }
412 
413 static void
415  vlib_main_t * vm)
416 {
417  vl_api_ip_punt_redirect_reply_t *rmp;
418  int rv = 0;
419  ip46_type_t ipv;
420  ip46_address_t nh;
421 
422  if (!vnet_sw_if_index_is_api_valid (ntohl (mp->punt.tx_sw_if_index)))
423  goto bad_sw_if_index;
424 
425  ipv = ip_address_decode (&mp->punt.nh, &nh);
426  if (mp->is_add)
427  {
428  if (ipv == IP46_TYPE_IP6)
429  {
430  ip6_punt_redirect_add (ntohl (mp->punt.rx_sw_if_index),
431  ntohl (mp->punt.tx_sw_if_index), &nh);
432  }
433  else if (ipv == IP46_TYPE_IP4)
434  {
435  ip4_punt_redirect_add (ntohl (mp->punt.rx_sw_if_index),
436  ntohl (mp->punt.tx_sw_if_index), &nh);
437  }
438  }
439  else
440  {
441  if (ipv == IP46_TYPE_IP6)
442  {
443  ip6_punt_redirect_del (ntohl (mp->punt.rx_sw_if_index));
444  }
445  else if (ipv == IP46_TYPE_IP4)
446  {
447  ip4_punt_redirect_del (ntohl (mp->punt.rx_sw_if_index));
448  }
449  }
450 
452 
453  REPLY_MACRO (VL_API_IP_PUNT_REDIRECT_REPLY);
454 }
455 
456 void
458 {
459  u32 fib_index, mfib_index;
460 
461  /*
462  * ignore action on the default table - this is always present
463  * and cannot be added nor deleted from the API
464  */
465  if (0 != table_id)
466  {
467  /*
468  * The API holds only one lock on the table.
469  * i.e. it can be added many times via the API but needs to be
470  * deleted only once.
471  * The FIB index for unicast and multicast is not necessarily the
472  * same, since internal VPP systesm (like LISP and SR) create
473  * their own unicast tables.
474  */
475  fib_index = fib_table_find (fproto, table_id);
476  mfib_index = mfib_table_find (fproto, table_id);
477 
478  if (~0 != fib_index)
479  {
480  fib_table_unlock (fib_index, fproto,
481  (is_api ? FIB_SOURCE_API : FIB_SOURCE_CLI));
482  }
483  if (~0 != mfib_index)
484  {
485  mfib_table_unlock (mfib_index, fproto,
486  (is_api ? MFIB_SOURCE_API : MFIB_SOURCE_CLI));
487  }
488  }
489 }
490 
491 void
493 {
494  vl_api_ip_table_add_del_reply_t *rmp;
495  fib_protocol_t fproto = (mp->table.is_ip6 ?
497  u32 table_id = ntohl (mp->table.table_id);
498  int rv = 0;
499 
500  if (mp->is_add)
501  {
502  ip_table_create (fproto, table_id, 1, mp->table.name);
503  }
504  else
505  {
506  ip_table_delete (fproto, table_id, 1);
507  }
508 
509  REPLY_MACRO (VL_API_IP_TABLE_ADD_DEL_REPLY);
510 }
511 
512 static int
514 {
515  fib_route_path_t *rpaths = NULL, *rpath;
517  vl_api_fib_path_t *apath;
518  fib_prefix_t pfx;
519  u32 fib_index;
520  int rv, ii;
521 
522  entry_flags = FIB_ENTRY_FLAG_NONE;
523  ip_prefix_decode (&mp->route.prefix, &pfx);
524 
526  ntohl (mp->route.table_id), &fib_index);
527  if (0 != rv)
528  goto out;
529 
530  if (0 != mp->route.n_paths)
531  vec_validate (rpaths, mp->route.n_paths - 1);
532 
533  for (ii = 0; ii < mp->route.n_paths; ii++)
534  {
535  apath = &mp->route.paths[ii];
536  rpath = &rpaths[ii];
537 
538  rv = fib_api_path_decode (apath, rpath);
539 
540  if ((rpath->frp_flags & FIB_ROUTE_PATH_LOCAL) &&
541  (~0 == rpath->frp_sw_if_index))
543 
544  if (0 != rv)
545  goto out;
546  }
547 
548  rv = fib_api_route_add_del (mp->is_add,
549  mp->is_multipath,
550  fib_index, &pfx, entry_flags, rpaths);
551 
552  if (mp->is_add && 0 == rv)
553  *stats_index = fib_table_entry_get_stats_index (fib_index, &pfx);
554 
555 out:
556  vec_free (rpaths);
557 
558  return (rv);
559 }
560 
561 void
563 {
565  u32 stats_index = ~0;
566  int rv;
567 
568  rv = ip_route_add_del_t_handler (mp, &stats_index);
569 
570  /* *INDENT-OFF* */
571  REPLY_MACRO2 (VL_API_IP_ROUTE_ADD_DEL_REPLY,
572  ({
573  rmp->stats_index = htonl (stats_index);
574  }))
575  /* *INDENT-ON* */
576 }
577 
578 void
580  u32 table_id, u8 is_api, const u8 * name)
581 {
582  u32 fib_index, mfib_index;
583 
584  /*
585  * ignore action on the default table - this is always present
586  * and cannot be added nor deleted from the API
587  */
588  if (0 != table_id)
589  {
590  /*
591  * The API holds only one lock on the table.
592  * i.e. it can be added many times via the API but needs to be
593  * deleted only once.
594  * The FIB index for unicast and multicast is not necessarily the
595  * same, since internal VPP systesm (like LISP and SR) create
596  * their own unicast tables.
597  */
598  fib_index = fib_table_find (fproto, table_id);
599  mfib_index = mfib_table_find (fproto, table_id);
600 
601  if (~0 == fib_index)
602  {
604  (is_api ?
606  FIB_SOURCE_CLI), name);
607  }
608  if (~0 == mfib_index)
609  {
611  (is_api ?
613  MFIB_SOURCE_CLI), name);
614  }
615  }
616 }
617 
618 static u32
620  u8 is_multipath,
621  u32 fib_index,
622  const mfib_prefix_t * prefix,
624  u32 rpf_id, fib_route_path_t * rpaths)
625 {
626  u32 mfib_entry_index = ~0;
627 
628  if (0 == vec_len (rpaths))
629  {
630  mfib_entry_index = mfib_table_entry_update (fib_index, prefix,
632  rpf_id, entry_flags);
633  }
634  else
635  {
636  if (is_add)
637  {
638  mfib_entry_index =
639  mfib_table_entry_paths_update (fib_index, prefix,
640  MFIB_SOURCE_API, rpaths);
641  }
642  else
643  {
644  mfib_table_entry_paths_remove (fib_index, prefix,
645  MFIB_SOURCE_API, rpaths);
646  }
647  }
648 
649  return (mfib_entry_index);
650 }
651 
652 static int
654  u32 * stats_index)
655 {
656  fib_route_path_t *rpath, *rpaths = NULL;
657  fib_node_index_t mfib_entry_index;
658  mfib_prefix_t pfx;
659  u32 fib_index;
660  int rv;
661  u16 ii;
662 
663  ip_mprefix_decode (&mp->route.prefix, &pfx);
664 
666  ntohl (mp->route.table_id), &fib_index);
667  if (0 != rv)
668  goto out;
669 
670  vec_validate (rpaths, mp->route.n_paths - 1);
671 
672  for (ii = 0; ii < mp->route.n_paths; ii++)
673  {
674  rpath = &rpaths[ii];
675 
676  rv = mfib_api_path_decode (&mp->route.paths[ii], rpath);
677 
678  if (0 != rv)
679  goto out;
680  }
681 
682  mfib_entry_index = mroute_add_del_handler (mp->is_add,
683  mp->is_add,
684  fib_index, &pfx,
685  ntohl (mp->route.entry_flags),
686  ntohl (mp->route.rpf_id),
687  rpaths);
688 
689  if (~0 != mfib_entry_index)
690  *stats_index = mfib_entry_get_stats_index (mfib_entry_index);
691 
692 out:
693  return (rv);
694 }
695 
696 void
698 {
700  u32 stats_index = ~0;
701  int rv;
702 
703  rv = api_mroute_add_del_t_handler (mp, &stats_index);
704 
705  /* *INDENT-OFF* */
706  REPLY_MACRO2 (VL_API_IP_MROUTE_ADD_DEL_REPLY,
707  ({
708  rmp->stats_index = htonl (stats_index);
709  }));
710  /* *INDENT-ON* */
711 }
712 
713 static void
716  u32 context)
717 {
719 
720  mp = vl_msg_api_alloc (sizeof (*mp));
721  clib_memset (mp, 0, sizeof (*mp));
722  mp->_vl_msg_id = ntohs (VL_API_IP_DETAILS);
723 
724  mp->sw_if_index = ntohl (sw_if_index);
725  mp->is_ipv6 = is_ipv6;
726  mp->context = context;
727 
728  vl_api_send_msg (reg, (u8 *) mp);
729 }
730 
731 static void
733  vl_api_registration_t * reg,
734  const fib_prefix_t * pfx,
735  u32 sw_if_index, u32 context)
736 {
738 
739  mp = vl_msg_api_alloc (sizeof (*mp));
740  clib_memset (mp, 0, sizeof (*mp));
741  mp->_vl_msg_id = ntohs (VL_API_IP_ADDRESS_DETAILS);
742 
743  ip_prefix_encode (pfx, &mp->prefix);
744  mp->context = context;
745  mp->sw_if_index = htonl (sw_if_index);
746 
747  vl_api_send_msg (reg, (u8 *) mp);
748 }
749 
750 static void
752 {
755  ip6_main_t *im6 = &ip6_main;
756  ip4_main_t *im4 = &ip4_main;
757  ip_lookup_main_t *lm6 = &im6->lookup_main;
758  ip_lookup_main_t *lm4 = &im4->lookup_main;
759  ip_interface_address_t *ia = 0;
760  u32 sw_if_index = ~0;
761  int rv __attribute__ ((unused)) = 0;
762 
764 
765  sw_if_index = ntohl (mp->sw_if_index);
766 
768  if (!reg)
769  return;
770 
771  if (mp->is_ipv6)
772  {
773  /* *INDENT-OFF* */
774  /* Do not send subnet details of the IP-interface for
775  * unnumbered interfaces. otherwise listening clients
776  * will be confused that the subnet is applied on more
777  * than one interface */
778  foreach_ip_interface_address (lm6, ia, sw_if_index, 0,
779  ({
780  fib_prefix_t pfx = {
782  .fp_len = ia->address_length,
783  .fp_proto = FIB_PROTOCOL_IP6,
784  };
785  send_ip_address_details(am, reg, &pfx, sw_if_index, mp->context);
786  }));
787  /* *INDENT-ON* */
788  }
789  else
790  {
791  /* *INDENT-OFF* */
792  foreach_ip_interface_address (lm4, ia, sw_if_index, 0,
793  ({
794  fib_prefix_t pfx = {
796  .fp_len = ia->address_length,
797  .fp_proto = FIB_PROTOCOL_IP4,
798  };
799 
800  send_ip_address_details(am, reg, &pfx, sw_if_index, mp->context);
801  }));
802  /* *INDENT-ON* */
803  }
804 
806 }
807 
808 static void
810  vl_api_registration_t * reg,
811  u32 sw_if_index, u32 ip_sw_if_index, u32 context)
812 {
814 
815  mp = vl_msg_api_alloc (sizeof (*mp));
816  clib_memset (mp, 0, sizeof (*mp));
817  mp->_vl_msg_id = ntohs (VL_API_IP_UNNUMBERED_DETAILS);
818 
819  mp->context = context;
820  mp->sw_if_index = htonl (sw_if_index);
821  mp->ip_sw_if_index = htonl (ip_sw_if_index);
822 
823  vl_api_send_msg (reg, (u8 *) mp);
824 }
825 
826 static void
828 {
829  vnet_main_t *vnm = vnet_get_main ();
831  int rv __attribute__ ((unused)) = 0;
836 
837  sw_if_index = ntohl (mp->sw_if_index);
838 
840  if (!reg)
841  return;
842 
843  if (~0 != sw_if_index)
844  {
846 
847  si = vnet_get_sw_interface (vnm, ntohl (mp->sw_if_index));
848 
850  {
852  sw_if_index,
854  mp->context);
855  }
856  }
857  else
858  {
859  /* *INDENT-OFF* */
860  pool_foreach (si, im->sw_interfaces,
861  ({
862  if ((si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED))
863  {
864  send_ip_unnumbered_details(am, reg,
865  si->sw_if_index,
866  si->unnumbered_sw_if_index,
867  mp->context);
868  }
869  }));
870  /* *INDENT-ON* */
871  }
872 
874 }
875 
876 static void
878 {
880  vnet_main_t *vnm = vnet_get_main ();
881  //vlib_main_t *vm = vlib_get_main ();
884  vnet_sw_interface_t *si, *sorted_sis;
885  u32 sw_if_index = ~0;
886 
888  if (!reg)
889  return;
890 
891  /* Gather interfaces. */
892  sorted_sis = vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
893  _vec_len (sorted_sis) = 0;
894  /* *INDENT-OFF* */
895  pool_foreach (si, im->sw_interfaces,
896  ({
897  vec_add1 (sorted_sis, si[0]);
898  }));
899  /* *INDENT-ON* */
900 
901  vec_foreach (si, sorted_sis)
902  {
904  {
905  /* if (mp->is_ipv6 && !ip6_interface_enabled (vm, si->sw_if_index)) */
906  /* { */
907  /* continue; */
908  /* } */
909  sw_if_index = si->sw_if_index;
910  send_ip_details (am, reg, sw_if_index, mp->is_ipv6, mp->context);
911  }
912  }
913 
914  vec_free (sorted_sis);
915 }
916 
917 static void
919 {
920  vl_api_set_ip_flow_hash_reply_t *rmp;
921  int rv;
922  u32 table_id;
923  flow_hash_config_t flow_hash_config = 0;
924 
925  table_id = ntohl (mp->vrf_id);
926 
927 #define _(a,b) if (mp->a) flow_hash_config |= b;
929 #undef _
930 
931  rv = vnet_set_ip6_flow_hash (table_id, flow_hash_config);
932 
933  REPLY_MACRO (VL_API_SET_IP_FLOW_HASH_REPLY);
934 }
935 
936 static void
938 {
939  vl_api_set_ip_flow_hash_reply_t *rmp;
940  int rv;
941  u32 table_id;
942  flow_hash_config_t flow_hash_config = 0;
943 
944  table_id = ntohl (mp->vrf_id);
945 
946 #define _(a,b) if (mp->a) flow_hash_config |= b;
948 #undef _
949 
950  rv = vnet_set_ip4_flow_hash (table_id, flow_hash_config);
951 
952  REPLY_MACRO (VL_API_SET_IP_FLOW_HASH_REPLY);
953 }
954 
955 
956 static void
958 {
959  if (mp->is_ipv6 == 0)
960  set_ip4_flow_hash (mp);
961  else
962  set_ip6_flow_hash (mp);
963 }
964 
965 void
967  u32 context, const mfib_signal_t * mfs)
968 {
970  const mfib_prefix_t *prefix;
971  mfib_table_t *mfib;
972  mfib_itf_t *mfi;
973 
974  mp = vl_msg_api_alloc (sizeof (*mp));
975 
976  clib_memset (mp, 0, sizeof (*mp));
977  mp->_vl_msg_id = ntohs (VL_API_MFIB_SIGNAL_DETAILS);
978  mp->context = context;
979 
980  mfi = mfib_itf_get (mfs->mfs_itf);
981  prefix = mfib_entry_get_prefix (mfs->mfs_entry);
983  prefix->fp_proto);
984  mp->table_id = ntohl (mfib->mft_table_id);
985  mp->sw_if_index = ntohl (mfi->mfi_sw_if_index);
986 
987  ip_mprefix_encode (prefix, &mp->prefix);
988 
989  if (0 != mfs->mfs_buffer_len)
990  {
991  mp->ip_packet_len = ntohs (mfs->mfs_buffer_len);
992 
993  memcpy (mp->ip_packet_data, mfs->mfs_buffer, mfs->mfs_buffer_len);
994  }
995  else
996  {
997  mp->ip_packet_len = 0;
998  }
999 
1000  vl_api_send_msg (reg, (u8 *) mp);
1001 }
1002 
1003 static void
1005 {
1006  vl_api_registration_t *reg;
1007 
1009  if (!reg)
1010  return;
1011 
1012  while (vl_api_can_send_msg (reg) && mfib_signal_send_one (reg, mp->context))
1013  ;
1014 }
1015 
1016 static void
1019 {
1020  vl_api_ip_container_proxy_add_del_reply_t *rmp;
1022  int rv = 0;
1023  clib_error_t *error;
1024 
1025  clib_memset (&args, 0, sizeof (args));
1026 
1027  ip_prefix_decode (&mp->pfx, &args.prefix);
1028 
1029  args.sw_if_index = clib_net_to_host_u32 (mp->sw_if_index);
1030  args.is_add = mp->is_add;
1031  if ((error = vnet_ip_container_proxy_add_del (&args)))
1032  {
1033  rv = clib_error_get_code (error);
1034  clib_error_report (error);
1035  }
1036 
1037  REPLY_MACRO (VL_API_IP_CONTAINER_PROXY_ADD_DEL_REPLY);
1038 }
1039 
1041 {
1045 
1046 static int
1048  void *args)
1049 {
1052 
1053  mp = vl_msg_api_alloc (sizeof (*mp));
1054  if (!mp)
1055  return 1;
1056 
1057  clib_memset (mp, 0, sizeof (*mp));
1058  mp->_vl_msg_id = ntohs (VL_API_IP_CONTAINER_PROXY_DETAILS);
1059  mp->context = ctx->context;
1060 
1061  mp->sw_if_index = ntohl (sw_if_index);
1062  ip_prefix_encode (pfx, &mp->prefix);
1063 
1064  vl_api_send_msg (ctx->reg, (u8 *) mp);
1065 
1066  return 1;
1067 }
1068 
1069 static void
1071  mp)
1072 {
1073  vl_api_registration_t *reg;
1074 
1076  if (!reg)
1077  return;
1078 
1080  .context = mp->context,
1081  .reg = reg,
1082  };
1083 
1085 }
1086 
1087 static void
1089 {
1090  int rv = 0;
1091  vl_api_ioam_enable_reply_t *rmp;
1092  clib_error_t *error;
1093 
1094  /* Ignoring the profile id as currently a single profile
1095  * is supported */
1096  error = ip6_ioam_enable (mp->trace_enable, mp->pot_enable,
1097  mp->seqno, mp->analyse);
1098  if (error)
1099  {
1100  clib_error_report (error);
1101  rv = clib_error_get_code (error);
1102  }
1103 
1104  REPLY_MACRO (VL_API_IOAM_ENABLE_REPLY);
1105 }
1106 
1107 static void
1109 {
1110  int rv = 0;
1111  vl_api_ioam_disable_reply_t *rmp;
1112  clib_error_t *error;
1113 
1114  error = clear_ioam_rewrite_fn ();
1115  if (error)
1116  {
1117  clib_error_report (error);
1118  rv = clib_error_get_code (error);
1119  }
1120 
1121  REPLY_MACRO (VL_API_IOAM_DISABLE_REPLY);
1122 }
1123 
1124 static void
1127 {
1128  vl_api_ip_source_and_port_range_check_add_del_reply_t *rmp;
1129  int rv = 0;
1130 
1131  u8 is_add = mp->is_add;
1132  fib_prefix_t pfx;
1133  u16 *low_ports = 0;
1134  u16 *high_ports = 0;
1135  u32 vrf_id;
1136  u16 tmp_low, tmp_high;
1137  u8 num_ranges;
1138  int i;
1139 
1140  ip_prefix_decode (&mp->prefix, &pfx);
1141 
1142  // Validate port range
1143  num_ranges = mp->number_of_ranges;
1144  if (num_ranges > 32)
1145  { // This is size of array in VPE.API
1146  rv = VNET_API_ERROR_EXCEEDED_NUMBER_OF_RANGES_CAPACITY;
1147  goto reply;
1148  }
1149 
1150  vec_reset_length (low_ports);
1151  vec_reset_length (high_ports);
1152 
1153  for (i = 0; i < num_ranges; i++)
1154  {
1155  tmp_low = mp->low_ports[i];
1156  tmp_high = mp->high_ports[i];
1157  // If tmp_low <= tmp_high then only need to check tmp_low = 0
1158  // If tmp_low <= tmp_high then only need to check tmp_high > 65535
1159  if (tmp_low > tmp_high || tmp_low == 0 || tmp_high > 65535)
1160  {
1161  rv = VNET_API_ERROR_INVALID_VALUE;
1162  goto reply;
1163  }
1164  vec_add1 (low_ports, tmp_low);
1165  vec_add1 (high_ports, tmp_high + 1);
1166  }
1167 
1168  vrf_id = ntohl (mp->vrf_id);
1169 
1170  if (vrf_id < 1)
1171  {
1172  rv = VNET_API_ERROR_INVALID_VALUE;
1173  goto reply;
1174  }
1175 
1176 
1177  if (FIB_PROTOCOL_IP6 == pfx.fp_proto)
1178  {
1180  pfx.fp_len,
1181  vrf_id,
1182  low_ports,
1183  high_ports, is_add);
1184  }
1185  else
1186  {
1188  pfx.fp_len,
1189  vrf_id,
1190  low_ports,
1191  high_ports, is_add);
1192  }
1193 
1194 reply:
1195  vec_free (low_ports);
1196  vec_free (high_ports);
1197  REPLY_MACRO (VL_API_IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY);
1198 }
1199 
1200 static void
1203 {
1205  vl_api_ip_source_and_port_range_check_interface_add_del_reply_t *rmp;
1206  ip4_main_t *im = &ip4_main;
1207  int rv;
1208  u32 sw_if_index;
1211  uword *p = 0;
1212  int i;
1213 
1215  ntohl (mp->tcp_out_vrf_id);
1217  ntohl (mp->udp_out_vrf_id);
1219  ntohl (mp->tcp_in_vrf_id);
1221  ntohl (mp->udp_in_vrf_id);
1222 
1223 
1224  for (i = 0; i < IP_SOURCE_AND_PORT_RANGE_CHECK_N_PROTOCOLS; i++)
1225  {
1226  if (vrf_id[i] != 0 && vrf_id[i] != ~0)
1227  {
1228  p = hash_get (im->fib_index_by_table_id, vrf_id[i]);
1229 
1230  if (p == 0)
1231  {
1232  rv = VNET_API_ERROR_INVALID_VALUE;
1233  goto reply;
1234  }
1235 
1236  fib_index[i] = p[0];
1237  }
1238  else
1239  fib_index[i] = ~0;
1240  }
1241  sw_if_index = ntohl (mp->sw_if_index);
1242 
1243  VALIDATE_SW_IF_INDEX (mp);
1244 
1245  rv =
1246  set_ip_source_and_port_range_check (vm, fib_index, sw_if_index,
1247  mp->is_add);
1248 
1250 reply:
1251 
1252  REPLY_MACRO (VL_API_IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY);
1253 }
1254 
1255 static void
1258 {
1259  vl_api_sw_interface_ip6_set_link_local_address_reply_t *rmp;
1260  ip6_address_t ip;
1261  int rv;
1262 
1263  VALIDATE_SW_IF_INDEX (mp);
1264 
1265  ip6_address_decode (mp->ip, &ip);
1266 
1267  rv = ip6_set_link_local_address (ntohl (mp->sw_if_index), &ip);
1268 
1270  REPLY_MACRO (VL_API_SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY);
1271 }
1272 
1273 typedef union
1274 {
1275  u32 fib_index;
1277 
1278 static void
1281 {
1282  vl_api_ip_source_check_interface_add_del_reply_t *rmp;
1283  int rv;
1284  u32 sw_if_index = ntohl (mp->sw_if_index);
1285  u8 is_add = mp->is_add;
1286  char *feature_name =
1287  mp->loose ? "ip4-source-check-via-any" : "ip4-source-check-via-rx";
1288 
1290 
1291  VALIDATE_SW_IF_INDEX (mp);
1292 
1293  config.fib_index =
1295  rv =
1296  vnet_feature_enable_disable ("ip4-unicast", feature_name, sw_if_index,
1297  is_add, &config, sizeof (config));
1299 
1300  REPLY_MACRO (VL_API_IP_SOURCE_CHECK_INTERFACE_ADD_DEL_REPLY);
1301 }
1302 
1303 
1304 static void
1306 {
1307  vl_api_ip_table_replace_begin_reply_t *rmp;
1308  fib_protocol_t fproto;
1309  u32 fib_index;
1310  int rv = 0;
1311 
1312  fproto = (mp->table.is_ip6 ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4);
1313  fib_index = fib_table_find (fproto, ntohl (mp->table.table_id));
1314 
1315  if (INDEX_INVALID == fib_index)
1316  rv = VNET_API_ERROR_NO_SUCH_FIB;
1317  else
1318  {
1319  fib_table_mark (fib_index, fproto, FIB_SOURCE_API);
1320  mfib_table_mark (mfib_table_find (fproto, ntohl (mp->table.table_id)),
1321  fproto, MFIB_SOURCE_API);
1322  }
1323  REPLY_MACRO (VL_API_IP_TABLE_REPLACE_BEGIN_REPLY);
1324 }
1325 
1326 static void
1328 {
1329  vl_api_ip_table_replace_end_reply_t *rmp;
1330  fib_protocol_t fproto;
1331  u32 fib_index;
1332  int rv = 0;
1333 
1334  fproto = (mp->table.is_ip6 ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4);
1335  fib_index = fib_table_find (fproto, ntohl (mp->table.table_id));
1336 
1337  if (INDEX_INVALID == fib_index)
1338  rv = VNET_API_ERROR_NO_SUCH_FIB;
1339  else
1340  {
1341  fib_table_sweep (fib_index, fproto, FIB_SOURCE_API);
1343  (fproto, ntohl (mp->table.table_id)), fproto,
1344  MFIB_SOURCE_API);
1345  }
1346  REPLY_MACRO (VL_API_IP_TABLE_REPLACE_END_REPLY);
1347 }
1348 
1349 static void
1351 {
1352  vl_api_ip_table_flush_reply_t *rmp;
1353  fib_protocol_t fproto;
1354  u32 fib_index;
1355  int rv = 0;
1356 
1357  fproto = (mp->table.is_ip6 ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4);
1358  fib_index = fib_table_find (fproto, ntohl (mp->table.table_id));
1359 
1360  if (INDEX_INVALID == fib_index)
1361  rv = VNET_API_ERROR_NO_SUCH_FIB;
1362  else
1363  {
1364  vnet_main_t *vnm = vnet_get_main ();
1366  vnet_sw_interface_t *si;
1367 
1368  /* Shut down interfaces in this FIB / clean out intfc routes */
1369  /* *INDENT-OFF* */
1370  pool_foreach (si, im->sw_interfaces,
1371  ({
1372  if (fib_index == fib_table_get_index_for_sw_if_index (fproto,
1373  si->sw_if_index))
1374  {
1375  u32 flags = si->flags;
1376  flags &= ~VNET_SW_INTERFACE_FLAG_ADMIN_UP;
1377  vnet_sw_interface_set_flags (vnm, si->sw_if_index, flags);
1378  }
1379  }));
1380  /* *INDENT-ON* */
1381 
1382  fib_table_flush (fib_index, fproto, FIB_SOURCE_API);
1383  mfib_table_flush (mfib_table_find (fproto, ntohl (mp->table.table_id)),
1384  fproto, MFIB_SOURCE_API);
1385  }
1386 
1387  REPLY_MACRO (VL_API_IP_TABLE_FLUSH_REPLY);
1388 }
1389 
1390 void
1392 {
1393  vl_api_ip_reassembly_set_reply_t *rmp;
1394  int rv = 0;
1395  switch ((vl_api_ip_reass_type_t) clib_net_to_host_u32 (mp->type))
1396  {
1397  case IP_REASS_TYPE_FULL:
1398  if (mp->is_ip6)
1399  {
1400  rv = ip6_full_reass_set (clib_net_to_host_u32 (mp->timeout_ms),
1401  clib_net_to_host_u32
1402  (mp->max_reassemblies),
1403  clib_net_to_host_u32
1404  (mp->max_reassembly_length),
1405  clib_net_to_host_u32
1406  (mp->expire_walk_interval_ms));
1407  }
1408  else
1409  {
1410  rv = ip4_full_reass_set (clib_net_to_host_u32 (mp->timeout_ms),
1411  clib_net_to_host_u32
1412  (mp->max_reassemblies),
1413  clib_net_to_host_u32
1414  (mp->max_reassembly_length),
1415  clib_net_to_host_u32
1416  (mp->expire_walk_interval_ms));
1417  }
1418  break;
1420  if (mp->is_ip6)
1421  {
1422  rv =
1423  ip6_sv_reass_set (clib_net_to_host_u32 (mp->timeout_ms),
1424  clib_net_to_host_u32 (mp->max_reassemblies),
1425  clib_net_to_host_u32
1426  (mp->max_reassembly_length),
1427  clib_net_to_host_u32
1428  (mp->expire_walk_interval_ms));
1429  }
1430  else
1431  {
1432  rv = ip4_sv_reass_set (clib_net_to_host_u32 (mp->timeout_ms),
1433  clib_net_to_host_u32 (mp->max_reassemblies),
1434  clib_net_to_host_u32
1435  (mp->max_reassembly_length),
1436  clib_net_to_host_u32
1437  (mp->expire_walk_interval_ms));
1438  }
1439  break;
1440  }
1441 
1442  REPLY_MACRO (VL_API_IP_REASSEMBLY_SET_REPLY);
1443 }
1444 
1445 void
1447 {
1449 
1451  if (rp == 0)
1452  return;
1453 
1454  vl_api_ip_reassembly_get_reply_t *rmp = vl_msg_api_alloc (sizeof (*rmp));
1455  clib_memset (rmp, 0, sizeof (*rmp));
1456  rmp->_vl_msg_id = ntohs (VL_API_IP_REASSEMBLY_GET_REPLY);
1457  rmp->context = mp->context;
1458  rmp->retval = 0;
1459  u32 timeout_ms;
1460  u32 max_reassemblies;
1461  u32 max_reassembly_length;
1462  u32 expire_walk_interval_ms;
1463  switch ((vl_api_ip_reass_type_t) clib_net_to_host_u32 (mp->type))
1464  {
1465  case IP_REASS_TYPE_FULL:
1466  if (mp->is_ip6)
1467  {
1468  rmp->is_ip6 = 1;
1469  ip6_full_reass_get (&timeout_ms, &max_reassemblies,
1470  &max_reassembly_length,
1471  &expire_walk_interval_ms);
1472  }
1473  else
1474  {
1475  rmp->is_ip6 = 0;
1476  ip4_full_reass_get (&timeout_ms, &max_reassemblies,
1477  &max_reassembly_length,
1478  &expire_walk_interval_ms);
1479  }
1480  break;
1482  if (mp->is_ip6)
1483  {
1484  rmp->is_ip6 = 1;
1485  ip6_sv_reass_get (&timeout_ms, &max_reassemblies,
1486  &max_reassembly_length, &expire_walk_interval_ms);
1487  }
1488  else
1489  {
1490  rmp->is_ip6 = 0;
1491  ip4_sv_reass_get (&timeout_ms, &max_reassemblies,
1492  &max_reassembly_length, &expire_walk_interval_ms);
1493  }
1494  break;
1495  }
1496  rmp->timeout_ms = clib_host_to_net_u32 (timeout_ms);
1497  rmp->max_reassemblies = clib_host_to_net_u32 (max_reassemblies);
1498  rmp->max_reassembly_length = clib_host_to_net_u32 (max_reassembly_length);
1500  clib_host_to_net_u32 (expire_walk_interval_ms);
1501  vl_api_send_msg (rp, (u8 *) rmp);
1502 }
1503 
1504 void
1507 {
1508  vl_api_ip_reassembly_enable_disable_reply_t *rmp;
1509  int rv = 0;
1510  switch ((vl_api_ip_reass_type_t) clib_net_to_host_u32 (mp->type))
1511  {
1512  case IP_REASS_TYPE_FULL:
1513  rv =
1514  ip4_full_reass_enable_disable (clib_net_to_host_u32 (mp->sw_if_index),
1515  mp->enable_ip4);
1516  if (0 == rv)
1517  rv =
1518  ip6_full_reass_enable_disable (clib_net_to_host_u32
1519  (mp->sw_if_index), mp->enable_ip6);
1520  break;
1522  rv =
1523  ip4_sv_reass_enable_disable (clib_net_to_host_u32 (mp->sw_if_index),
1524  mp->enable_ip4);
1525  if (0 == rv)
1526  {
1527  rv =
1528  ip6_sv_reass_enable_disable (clib_net_to_host_u32
1529  (mp->sw_if_index), mp->enable_ip6);
1530  }
1531  break;
1532  }
1533 
1534  REPLY_MACRO (VL_API_IP_REASSEMBLY_ENABLE_DISABLE_REPLY);
1535 }
1536 
1538 {
1542 
1543 static walk_rc_t
1545  const ip_punt_redirect_rx_t * ipr, void *arg)
1546 {
1549  fib_path_encode_ctx_t path_ctx = {
1550  .rpaths = NULL,
1551  };
1552 
1553  mp = vl_msg_api_alloc (sizeof (*mp));
1554  if (!mp)
1555  return (WALK_STOP);;
1556 
1557  clib_memset (mp, 0, sizeof (*mp));
1558  mp->_vl_msg_id = ntohs (VL_API_IP_PUNT_REDIRECT_DETAILS);
1559  mp->context = ctx->context;
1560 
1561  fib_path_list_walk_w_ext (ipr->pl, NULL, fib_path_encode, &path_ctx);
1562 
1563  mp->punt.rx_sw_if_index = htonl (rx_sw_if_index);
1564  mp->punt.tx_sw_if_index = htonl (path_ctx.rpaths[0].frp_sw_if_index);
1565 
1566  ip_address_encode (&path_ctx.rpaths[0].frp_addr,
1567  fib_proto_to_ip46 (ipr->fproto), &mp->punt.nh);
1568 
1569  vl_api_send_msg (ctx->reg, (u8 *) mp);
1570 
1571  vec_free (path_ctx.rpaths);
1572 
1573  return (WALK_CONTINUE);
1574 }
1575 
1576 static void
1578 {
1579  vl_api_registration_t *reg;
1580  fib_protocol_t fproto;
1581 
1583  if (!reg)
1584  return;
1585 
1586  fproto = mp->is_ipv6 ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4;
1587 
1589  .reg = reg,
1590  .context = mp->context,
1591  };
1592 
1593  if (~0 != mp->sw_if_index)
1594  {
1595  u32 rx_sw_if_index;
1596  index_t pri;
1597 
1598  rx_sw_if_index = ntohl (mp->sw_if_index);
1599  pri = ip_punt_redirect_find (fproto, rx_sw_if_index);
1600 
1601  if (INDEX_INVALID == pri)
1602  return;
1603 
1604  send_ip_punt_redirect_details (rx_sw_if_index,
1605  ip_punt_redirect_get (pri), &ctx);
1606  }
1607  else
1609 }
1610 
1611 #define vl_msg_name_crc_list
1612 #include <vnet/ip/ip.api.h>
1613 #undef vl_msg_name_crc_list
1614 
1615 static void
1617 {
1618 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
1619  foreach_vl_msg_name_crc_ip;
1620 #undef _
1621 }
1622 
1623 static clib_error_t *
1625 {
1626  api_main_t *am = vlibapi_get_main ();
1627 
1628 #define _(N,n) \
1629  vl_msg_api_set_handlers(VL_API_##N, #n, \
1630  vl_api_##n##_t_handler, \
1631  vl_noop_handler, \
1632  vl_api_##n##_t_endian, \
1633  vl_api_##n##_t_print, \
1634  sizeof(vl_api_##n##_t), 1);
1636 #undef _
1637 
1638  /*
1639  * Mark the route add/del API as MP safe
1640  */
1641  am->is_mp_safe[VL_API_IP_ROUTE_ADD_DEL] = 1;
1642  am->is_mp_safe[VL_API_IP_ROUTE_ADD_DEL_REPLY] = 1;
1643 
1644  /*
1645  * Set up the (msg_name, crc, message-id) table
1646  */
1648 
1649  return 0;
1650 }
1651 
1653 
1654 /*
1655  * fd.io coding-style-patch-verification: ON
1656  *
1657  * Local Variables:
1658  * eval: (c-set-style "gnu")
1659  * End:
1660  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:440
#define foreach_ip_interface_address(lm, a, sw_if_index, loop, body)
Definition: lookup.h:213
vnet_api_error_t ip6_full_reass_get(u32 *timeout_ms, u32 *max_reassemblies, u32 *max_reassembly_length, u32 *expire_walk_interval_ms)
get ip6 reassembly configuration
fib_protocol_t fp_proto
protocol type
Definition: fib_types.h:212
vl_api_ip_reass_type_t type
Definition: ip.api:596
bool is_add[default=true]
Definition: ip.api:162
bool is_add[default=true]
Definition: ip.api:292
u32 fib_entry_get_fib_index(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:1701
vl_api_ip_table_t table
Definition: ip.api:181
void fib_table_sweep(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Signal that the table has converged, i.e.
Definition: fib_table.c:1467
ip46_address_t frp_addr
The next-hop address.
Definition: fib_types.h:501
static void send_ip_address_details(vpe_api_main_t *am, vl_api_registration_t *reg, const fib_prefix_t *pfx, u32 sw_if_index, u32 context)
Definition: ip_api.c:732
Dump IP unnumbered configurations.
Definition: ip.api:351
void ip4_punt_redirect_add(u32 rx_sw_if_index, u32 tx_sw_if_index, ip46_address_t *nh)
Continue on to the next entry.
Definition: fib_table.h:916
#define clib_min(x, y)
Definition: clib.h:295
static void vl_api_ip_route_dump_t_handler(vl_api_ip_route_dump_t *mp)
Definition: ip_api.c:236
fib_protocol_t ft_proto
Which protocol this table serves.
Definition: fib_table.h:76
vnet_api_error_t ip4_full_reass_enable_disable(u32 sw_if_index, u8 enable_disable)
static void vl_api_ip_container_proxy_add_del_t_handler(vl_api_ip_container_proxy_add_del_t *mp)
Definition: ip_api.c:1018
int vnet_set_ip4_flow_hash(u32 table_id, flow_hash_config_t flow_hash_config)
Definition: ip4_forward.c:2725
IP punt redirect.
Definition: ip.api:425
bool is_add[default=true]
Definition: ip.api:430
static walk_rc_t send_ip_punt_redirect_details(u32 rx_sw_if_index, const ip_punt_redirect_rx_t *ipr, void *arg)
Definition: ip_api.c:1544
void ip_prefix_decode(const vl_api_prefix_t *in, fib_prefix_t *out)
Definition: ip_types_api.c:200
A representation of a path as described by a route producer.
Definition: fib_types.h:485
int fib_api_route_add_del(u8 is_add, u8 is_multipath, u32 fib_index, const fib_prefix_t *prefix, fib_entry_flag_t entry_flags, fib_route_path_t *rpaths)
Adding routes from the API.
Definition: fib_api.c:456
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
fib_protocol_t fproto
Definition: ip_punt_drop.h:201
vnet_interface_main_t interface_main
Definition: vnet.h:56
vl_api_fib_path_nh_t nh
Definition: fib_types.api:126
ip46_type_t fib_proto_to_ip46(fib_protocol_t fproto)
Convert from fib_protocol to ip46_type.
Definition: fib_types.c:310
void ip4_punt_redirect_del(u32 rx_sw_if_index)
vl_api_ip_table_t table
Definition: ip.api:310
A pair of indicies, for the entry and interface resp.
Definition: mfib_signal.h:29
u32 fib_table_find_or_create_and_lock_w_name(fib_protocol_t proto, u32 table_id, fib_source_t src, const u8 *name)
Get the index of the FIB for a Table-ID.
Definition: fib_table.c:1165
static void vl_api_ip_mtable_dump_t_handler(vl_api_ip_mtable_dump_t *mp)
Definition: ip_api.c:288
static void vl_api_ip_table_replace_end_t_handler(vl_api_ip_table_replace_end_t *mp)
Definition: ip_api.c:1327
void fib_api_path_encode(const fib_route_path_t *rpath, vl_api_fib_path_t *out)
Definition: fib_api.c:359
static void vl_api_ip_table_replace_begin_t_handler(vl_api_ip_table_replace_begin_t *mp)
Definition: ip_api.c:1305
vnet_api_error_t ip4_sv_reass_get(u32 *timeout_ms, u32 *max_reassemblies, u32 *max_reassembly_length, u32 *expire_walk_interval_ms)
get ip4 reassembly configuration
Definition: ip4_sv_reass.c:904
vl_api_ip_table_t table
Definition: ip.api:120
#define REPLY_MACRO2(t, body)
#define NULL
Definition: clib.h:58
iOAM disable
Definition: ip.api:566
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
Dump IP multicast fib table.
Definition: ip.api:306
void mfib_table_sweep(u32 fib_index, fib_protocol_t proto, mfib_source_t source)
Signal that the table has converged, i.e.
Definition: mfib_table.c:731
u32 fib_table_get_index_for_sw_if_index(fib_protocol_t proto, u32 sw_if_index)
Get the index of the FIB bound to the interface.
Definition: fib_table.c:989
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:35
bool is_ipv6
Definition: ip.api:369
void ip6_address_decode(const vl_api_ip6_address_t in, ip6_address_t *out)
Definition: ip_types_api.c:117
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Definition: dpo.h:41
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:523
IPv4 Reassembly.
vl_api_punt_redirect_t punt
Definition: ip.api:429
int i
vl_api_ip_reass_type_t type
Definition: ip.api:624
void ip_table_delete(fib_protocol_t fproto, u32 table_id, u8 is_api)
Definition: ip_api.c:457
ip_lookup_main_t lookup_main
Definition: ip4.h:107
void vl_api_ip_reassembly_set_t_handler(vl_api_ip_reassembly_set_t *mp)
Definition: ip_api.c:1391
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
Add / del route request.
Definition: ip.api:158
const fib_prefix_t * fib_entry_get_prefix(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:1691
fib_node_index_t mfib_table_entry_update(u32 fib_index, const mfib_prefix_t *prefix, mfib_source_t source, fib_rpf_id_t rpf_id, mfib_entry_flags_t entry_flags)
Add a new (with no replication) or lock an existing entry.
Definition: mfib_table.c:237
void mfib_api_path_encode(const fib_route_path_t *in, vl_api_mfib_path_t *out)
Definition: mfib_api.c:69
vnet_api_error_t ip4_sv_reass_enable_disable(u32 sw_if_index, u8 enable_disable)
bool is_add[default=true]
Definition: ip.api:56
vl_api_registration_t * reg
Definition: ip_api.c:1042
vl_api_prefix_t prefix
Definition: ip.api:144
vl_api_interface_index_t sw_if_index
Definition: ip.api:325
void vl_api_ip_reassembly_enable_disable_t_handler(vl_api_ip_reassembly_enable_disable_t *mp)
Definition: ip_api.c:1506
void * vl_msg_api_alloc(int nbytes)
unsigned char u8
Definition: types.h:56
vl_api_interface_index_t sw_if_index
Definition: ip.api:333
void vl_api_ip_reassembly_get_t_handler(vl_api_ip_reassembly_get_t *mp)
Definition: ip_api.c:1446
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
index_t ip_punt_redirect_find(fib_protocol_t fproto, u32 rx_sw_if_index)
Definition: ip_punt_drop.c:61
struct vl_api_ip_mfib_dump_ctx_t_ vl_api_ip_mfib_dump_ctx_t
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
enum walk_rc_t_ walk_rc_t
Walk return code.
static int vl_api_can_send_msg(vl_api_registration_t *rp)
Definition: api.h:48
IP FIB table response.
Definition: ip.api:127
vl_api_interface_index_t sw_if_index
Definition: ip.api:621
fib_node_index_t mfib_table_entry_paths_update(u32 fib_index, const mfib_prefix_t *prefix, mfib_source_t source, const fib_route_path_t *rpaths)
Definition: mfib_table.c:343
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:498
u32 frp_sw_if_index
The interface.
Definition: fib_types.h:525
vl_api_interface_index_t sw_if_index
Definition: gre.api:59
Add / del table request A table can be added multiple times, but need be deleted only once...
Definition: ip.api:52
vl_api_ip_mroute_t route
Definition: ip.api:294
clib_error_t * vnet_ip_container_proxy_add_del(vnet_ip_container_proxy_args_t *args)
Definition: lookup.c:1029
struct _vnet_ip_container_proxy_args vnet_ip_container_proxy_args_t
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
Definition: vec.h:312
Set interface source and L4 port-range request.
Definition: ip.api:500
u32 mfib_table_find_or_create_and_lock_w_name(fib_protocol_t proto, u32 table_id, mfib_source_t src, const u8 *name)
Get the index of the FIB for a Table-ID.
Definition: mfib_table.c:622
fib_node_index_t pl
Definition: ip_punt_drop.h:203
void fib_table_flush(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Flush all entries from a table for the source.
Definition: fib_table.c:1398
void vl_api_ip_route_add_del_t_handler(vl_api_ip_route_add_del_t *mp)
Definition: ip_api.c:562
Aggregate type for a prefix.
Definition: fib_types.h:203
static void vl_api_ip_dump_t_handler(vl_api_ip_dump_t *mp)
Definition: ip_api.c:877
vl_api_interface_index_t sw_if_index
Definition: ip.api:344
vl_api_ip_table_t table
Definition: ip.api:57
IPv6 interface enable / disable request.
Definition: ip.api:227
u32 mfib_entry_get_stats_index(fib_node_index_t fib_entry_index)
Definition: mfib_entry.c:1291
unsigned int u32
Definition: types.h:88
void mfib_table_mark(u32 fib_index, fib_protocol_t proto, mfib_source_t source)
Resync all entries from a table for the source this is the mark part of the mark and sweep algorithm...
Definition: mfib_table.c:698
struct mfib_table_t_ * mfibs
Vector of MFIBs.
Definition: ip4.h:116
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
Definition: fib_table.c:1097
u16 fp_len
The mask length.
Definition: fib_types.h:207
vl_api_interface_index_t sw_if_index
Definition: ip.api:231
static void vl_api_mfib_signal_dump_t_handler(vl_api_mfib_signal_dump_t *mp)
Definition: ip_api.c:1004
ip46_type_t ip_address_decode(const vl_api_address_t *in, ip46_address_t *out)
Definition: ip_types_api.c:161
vl_api_address_with_prefix_t prefix
Definition: ip.api:326
u32 mfib_entry_get_fib_index(fib_node_index_t mfib_entry_index)
Definition: mfib_entry.c:1445
Definition: fib_entry.h:112
Configure IP source and L4 port-range check.
Definition: ip.api:481
int mfib_api_path_decode(vl_api_mfib_path_t *in, fib_route_path_t *out)
Definition: mfib_api.c:96
static int api_mroute_add_del_t_handler(vl_api_ip_mroute_add_del_t *mp, u32 *stats_index)
Definition: ip_api.c:653
IP table flush Flush a table of all routes.
Definition: ip.api:116
Set interface source check request.
Definition: ip.api:519
IP table replace end.
Definition: ip.api:103
u32 rpf_id
Definition: fib_types.api:119
Definition: fib_entry.h:117
vnet_api_error_t ip4_sv_reass_set(u32 timeout_ms, u32 max_reassemblies, u32 max_reassembly_length, u32 expire_walk_interval_ms)
set ip4 reassembly configuration
Definition: ip4_sv_reass.c:866
#define hash_get(h, key)
Definition: hash.h:249
static fib_table_walk_rc_t vl_api_ip_fib_dump_walk(fib_node_index_t fei, void *arg)
Definition: ip_api.c:178
vl_api_ip_route_t route
Definition: ip.api:164
uword * fib_index_by_table_id
Hash table mapping table id to fib index.
Definition: ip4.h:131
static mfib_itf_t * mfib_itf_get(index_t mi)
Get the MFIB interface representation.
Definition: mfib_itf.h:78
void mfib_table_unlock(u32 fib_index, fib_protocol_t proto, mfib_source_t source)
Take a reference counting lock on the table.
Definition: mfib_table.c:777
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:226
IPv6 shallow virtual reassembly.
IPv4 shallow virtual reassembly.
vnet_api_error_t ip6_sv_reass_enable_disable(u32 sw_if_index, u8 enable_disable)
bool is_add[default=true]
Definition: ip.api:400
long ctx[MAX_CONNS]
Definition: main.c:144
static void vl_api_ip_mroute_dump_t_handler(vl_api_ip_mroute_dump_t *mp)
Definition: ip_api.c:364
unsigned short u16
Definition: types.h:57
void vl_api_ip_table_add_del_t_handler(vl_api_ip_table_add_del_t *mp)
Definition: ip_api.c:492
static u32 mroute_add_del_handler(u8 is_add, u8 is_multipath, u32 fib_index, const mfib_prefix_t *prefix, u32 entry_flags, u32 rpf_id, fib_route_path_t *rpaths)
Definition: ip_api.c:619
IP Multicast Route Details.
Definition: ip.api:316
fib_node_index_t * entries
Definition: ip_api.c:311
bool is_add[default=true]
Definition: ip.api:453
vl_api_interface_index_t sw_if_index
Definition: ip.api:452
int mfib_entry_cmp_for_sort(void *i1, void *i2)
Definition: mfib_entry.c:1259
#define REPLY_MACRO(t)
vnet_sw_interface_flags_t flags
Definition: interface.h:720
ip6_main_t ip6_main
Definition: ip6_forward.c:2703
IP FIB table entry response.
Definition: ip.api:187
fib_node_index_t * entries
Definition: ip_api.c:232
VLIB_API_INIT_FUNCTION(ip_api_hookup)
void fib_table_unlock(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Take a reference counting lock on the table.
Definition: fib_table.c:1291
static void vl_api_sw_interface_ip6_enable_disable_t_handler(vl_api_sw_interface_ip6_enable_disable_t *mp)
Definition: ip_api.c:108
static void vl_api_set_ip_flow_hash_t_handler(vl_api_set_ip_flow_hash_t *mp)
Definition: ip_api.c:957
vlib_main_t * vm
Definition: in2out_ed.c:1810
static walk_rc_t mfib_route_dump_walk(fib_node_index_t fei, void *arg)
Definition: ip_api.c:315
IOAM enable : Enable in-band OAM.
Definition: ip.api:549
static void vl_api_ip_unnumbered_dump_t_handler(vl_api_ip_unnumbered_dump_t *mp)
Definition: ip_api.c:827
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:225
void mfib_table_flush(u32 mfib_index, fib_protocol_t proto, mfib_source_t source)
Flush all entries from a table for the source.
Definition: mfib_table.c:662
An API client registration, only in vpp/vlib.
Definition: api_common.h:46
#define BAD_SW_IF_INDEX_LABEL
static uword vnet_sw_if_index_is_api_valid(u32 sw_if_index)
void mfib_table_walk(u32 fib_index, fib_protocol_t proto, mfib_table_walk_fn_t fn, void *ctx)
Walk all entries in a FIB table N.B: This is NOT safe to deletes.
Definition: mfib_table.c:829
Set the ip flow hash config for a fib request.
Definition: ip.api:206
vl_api_mprefix_t prefix
Definition: ip.api:383
From the CLI.
Definition: fib_source.h:76
u32 ft_table_id
Table ID (hash key) for this FIB.
Definition: fib_table.h:92
static void vl_api_ip_table_flush_t_handler(vl_api_ip_table_flush_t *mp)
Definition: ip_api.c:1350
static void vl_api_ip_punt_redirect_t_handler(vl_api_ip_punt_redirect_t *mp, vlib_main_t *vm)
Definition: ip_api.c:414
static_always_inline ip_punt_redirect_rx_t * ip_punt_redirect_get(index_t rrxi)
Definition: ip_punt_drop.h:271
static void vl_api_ip_container_proxy_dump_t_handler(vl_api_ip_container_proxy_dump_t *mp)
Definition: ip_api.c:1070
enum fib_table_walk_rc_t_ fib_table_walk_rc_t
return code controlling how a table walk proceeds
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:342
struct vl_api_ip_fib_dump_walk_ctx_t_ vl_api_ip_fib_dump_walk_ctx_t
IP4 punt redirect per-rx interface configuration redirect punted traffic to another location...
Definition: ip_punt_drop.h:194
u8 * ft_desc
Table description.
Definition: fib_table.h:122
void ip_mprefix_encode(const mfib_prefix_t *in, vl_api_mprefix_t *out)
Definition: ip_types_api.c:225
static void send_ip_details(vpe_api_main_t *am, vl_api_registration_t *reg, u32 sw_if_index, u8 is_ipv6, u32 context)
Definition: ip_api.c:714
vnet_api_error_t ip4_full_reass_get(u32 *timeout_ms, u32 *max_reassemblies, u32 *max_reassembly_length, u32 *expire_walk_interval_ms)
get ip4 reassembly configuration
static void vl_api_ip_source_and_port_range_check_add_del_t_handler(vl_api_ip_source_and_port_range_check_add_del_t *mp)
Definition: ip_api.c:1126
void fib_table_mark(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Resync all entries from a table for the source this is the mark part of the mark and sweep algorithm...
Definition: fib_table.c:1434
clib_error_t * ip6_ioam_enable(int has_trace_option, int has_pot_option, int has_seqno_option, int has_analyse_option)
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:30
static void set_ip6_flow_hash(vl_api_set_ip_flow_hash_t *mp)
Definition: ip_api.c:918
vnet_api_error_t ip6_sv_reass_set(u32 timeout_ms, u32 max_reassemblies, u32 max_reassembly_length, u32 expire_walk_interval_ms)
set ip6 reassembly configuration
Definition: ip6_sv_reass.c:900
void ip4_punt_policer_add_del(u8 is_add, u32 policer_index)
void ip_container_proxy_walk(ip_container_proxy_cb_t cb, void *ctx)
Definition: lookup.c:1115
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:57
string name[64]
Definition: ip.api:44
IP unnumbered configurations.
Definition: ip.api:341
Aggregate type for a prefix.
Definition: mfib_types.h:24
enum fib_entry_flag_t_ fib_entry_flag_t
void ip6_punt_redirect_add(u32 rx_sw_if_index, u32 tx_sw_if_index, ip46_address_t *nh)
void ip6_punt_redirect_del(u32 rx_sw_if_index)
static void vl_api_ioam_disable_t_handler(vl_api_ioam_disable_t *mp)
Definition: ip_api.c:1108
#define foreach_flow_hash_bit
Definition: lookup.h:72
void ip6_punt_policer_add_del(u8 is_add, u32 policer_index)
IP table replace being.
Definition: ip.api:88
vl_api_interface_index_t sw_if_index
Definition: ip.api:465
void vl_api_ip_mroute_add_del_t_handler(vl_api_ip_mroute_add_del_t *mp)
Definition: ip_api.c:697
u32 stats_index
Definition: ip.api:143
vl_api_ip_mroute_t route
Definition: ip.api:319
Dump IP multicast fib table.
Definition: ip.api:238
static void vl_api_ip_table_dump_t_handler(vl_api_ip_table_dump_t *mp)
Definition: ip_api.c:147
int mfib_signal_send_one(struct vl_api_registration_ *reg, u32 context)
Definition: mfib_signal.c:94
ip_lookup_main_t lookup_main
Definition: ip6.h:180
index_t mfs_itf
Definition: mfib_signal.h:32
vnet_api_error_t ip6_sv_reass_get(u32 *timeout_ms, u32 *max_reassemblies, u32 *max_reassembly_length, u32 *expire_walk_interval_ms)
get ip6 reassembly configuration
Definition: ip6_sv_reass.c:938
static int ip_container_proxy_send_details(const fib_prefix_t *pfx, u32 sw_if_index, void *args)
Definition: ip_api.c:1047
void fib_table_walk(u32 fib_index, fib_protocol_t proto, fib_table_walk_fn_t fn, void *ctx)
Walk all entries in a FIB table N.B: This is NOT safe to deletes.
Definition: fib_table.c:1230
u32 fib_table_get_table_id(u32 fib_index, fib_protocol_t proto)
Get the Table-ID of the FIB from protocol and index.
Definition: fib_table.c:1086
IPv4 main type.
Definition: ip4.h:105
vnet_api_error_t ip4_full_reass_set(u32 timeout_ms, u32 max_reassemblies, u32 max_reassembly_length, u32 expire_walk_interval_ms)
set ip4 reassembly configuration
static void set_ip4_flow_hash(vl_api_set_ip_flow_hash_t *mp)
Definition: ip_api.c:937
int fib_api_path_decode(vl_api_fib_path_t *in, fib_route_path_t *out)
Definition: fib_api.c:151
An interface associated with a particular MFIB entry.
Definition: mfib_itf.h:25
Path encode context to use when walking a path-list to encode paths.
Definition: fib_path.h:213
static void vl_api_ip_source_check_interface_add_del_t_handler(vl_api_ip_source_check_interface_add_del_t *mp)
Definition: ip_api.c:1280
static void vl_api_ioam_enable_t_handler(vl_api_ioam_enable_t *mp)
Definition: ip_api.c:1088
From the control plane API.
Definition: fib_source.h:72
vl_api_interface_index_t sw_if_index
Definition: ip.api:355
struct mfib_table_t_ * mfibs
Vector of MFIBs.
Definition: ip6.h:189
fib_protocol_t mft_proto
Which protocol this table serves.
Definition: mfib_table.h:92
#define clib_error_report(e)
Definition: error.h:113
vl_api_interface_index_t ip_sw_if_index
Definition: ip.api:345
u32 mft_table_id
Table ID (hash key) for this FIB.
Definition: mfib_table.h:107
u32 mfib_table_get_table_id(u32 fib_index, fib_protocol_t proto)
Get the Table-ID of the FIB from protocol and index.
Definition: mfib_table.c:544
static clib_error_t * ip_api_hookup(vlib_main_t *vm)
Definition: ip_api.c:1624
u32 flow_hash_config_t
A flow hash configuration is a mask of the flow hash options.
Definition: lookup.h:84
u32 fib_table_entry_get_stats_index(u32 fib_index, const fib_prefix_t *prefix)
Return the stats index for a FIB entry.
Definition: fib_table.c:922
vl_api_ip_table_t table
Definition: ip.api:247
int vnet_set_ip6_flow_hash(u32 table_id, flow_hash_config_t flow_hash_config)
Definition: ip6_forward.c:2773
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
vl_api_punt_redirect_t punt
Definition: ip.api:444
static void send_ip_mtable_details(vl_api_registration_t *reg, u32 context, const mfib_table_t *mfib_table)
Definition: ip_api.c:269
fib_route_path_t * rpaths
Definition: fib_path.h:215
vl_api_interface_index_t sw_if_index
Definition: ip.api:381
void ip_prefix_encode(const fib_prefix_t *in, vl_api_prefix_t *out)
Definition: ip_types_api.c:217
int mfib_api_table_id_decode(fib_protocol_t fproto, u32 table_id, u32 *fib_index)
Definition: mfib_api.c:105
fib_protocol_t fp_proto
protocol type
Definition: mfib_types.h:33
static void setup_message_id_table(api_main_t *am)
Definition: ip_api.c:1616
vl_api_address_t ip
Definition: l2.api:490
int fib_api_table_id_decode(fib_protocol_t fproto, u32 table_id, u32 *fib_index)
Definition: fib_api.c:45
mfib_table_t * mfib_table_get(fib_node_index_t index, fib_protocol_t proto)
Get a pointer to a FIB table.
Definition: mfib_table.c:30
static void vl_api_ip_punt_police_t_handler(vl_api_ip_punt_police_t *mp, vlib_main_t *vm)
Definition: ip_api.c:399
A for-us/local path.
Definition: fib_types.h:338
fib_route_path_t * fib_entry_encode(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:1661
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
const mfib_prefix_t * mfib_entry_get_prefix(fib_node_index_t mfib_entry_index)
Definition: mfib_entry.c:1435
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
Definition: dpo.h:47
static fib_protocol_t fib_ip_proto(bool is_ip6)
Convert from boolean is_ip6 to FIB protocol.
Definition: fib_types.h:80
Definition: fib_entry.h:113
u32 mfib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
Definition: mfib_table.c:555
u64 uword
Definition: types.h:112
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:983
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:854
#define clib_error_get_code(err)
Definition: error.h:77
vnet_api_error_t ip6_full_reass_set(u32 timeout_ms, u32 max_reassemblies, u32 max_reassembly_length, u32 expire_walk_interval_ms)
set ip6 reassembly configuration
u8 mfs_buffer[MFIB_SIGNAL_BUFFER_SIZE]
A buffer copied from the DP plane that triggered the signal.
Definition: mfib_signal.h:37
int ip4_source_and_port_range_check_add_del(ip4_address_t *address, u32 length, u32 vrf_id, u16 *low_ports, u16 *high_ports, int is_add)
vl_api_ip_table_t table
Definition: ip.api:130
vl_api_ip_table_t table
Definition: ip.api:92
vl_api_ip_reass_type_t type
Definition: ip.api:588
vl_api_ip_route_t route
Definition: ip.api:190
void ip_address_encode(const ip46_address_t *in, ip46_type_t type, vl_api_address_t *out)
Definition: ip_types_api.c:178
u32 client_index
Definition: ip.api:367
Dump IP routes from a table.
Definition: ip.api:177
static api_main_t * vlibapi_get_main(void)
Definition: api_common.h:378
u32 mfi_sw_if_index
The SW IF index that this MFIB interface represents.
Definition: mfib_itf.h:40
u8 * is_mp_safe
Message is mp safe vector.
Definition: api_common.h:248
u32 entry_flags
Definition: ip.api:281
A protocol Independent IP multicast FIB table.
Definition: mfib_table.h:71
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1079
vl_api_interface_index_t sw_if_index
Definition: ip.api:361
struct fib_table_t_ * fibs
Vector of FIBs.
Definition: ip4.h:110
Enable/disable reassembly feature.
Definition: ip.api:617
IP punt policer.
Definition: ip.api:395
#define vec_foreach(var, vec)
Vector iterator.
clib_error_t * clear_ioam_rewrite_fn(void)
static void vl_api_ip_punt_redirect_dump_t_handler(vl_api_ip_punt_redirect_dump_t *mp)
Definition: ip_api.c:1577
void ip_table_create(fib_protocol_t fproto, u32 table_id, u8 is_api, const u8 *name)
Definition: ip_api.c:579
vl_api_interface_index_t sw_if_index
Definition: ip.api:525
vnet_api_error_t ip6_full_reass_enable_disable(u32 sw_if_index, u8 enable_disable)
static void vl_api_sw_interface_ip6_set_link_local_address_t_handler(vl_api_sw_interface_ip6_set_link_local_address_t *mp)
Definition: ip_api.c:1257
void fib_path_list_walk_w_ext(fib_node_index_t path_list_index, const fib_path_ext_list_t *ext_list, fib_path_list_walk_w_ext_fn_t func, void *ctx)
struct ip_punt_redirect_walk_ctx_t_ ip_punt_redirect_walk_ctx_t
fib_route_path_t * mfib_entry_encode(fib_node_index_t mfib_entry_index)
Definition: mfib_entry.c:1399
static void vl_api_ip_address_dump_t_handler(vl_api_ip_address_dump_t *mp)
Definition: ip_api.c:751
u32 vrf_id
Definition: nat.api:821
static void send_ip_table_details(vpe_api_main_t *am, vl_api_registration_t *reg, u32 context, const fib_table_t *table)
Definition: ip_api.c:125
vl_api_ip_table_t table
Definition: ip.api:107
static void * ip_interface_address_get_address(ip_lookup_main_t *lm, ip_interface_address_t *a)
Definition: lookup.h:199
static int ip_route_add_del_t_handler(vl_api_ip_route_add_del_t *mp, u32 *stats_index)
Definition: ip_api.c:513
struct apt_ip6_fib_show_ctx_t_ api_ip6_fib_show_ctx_t
u32 table_id
Definition: fib_types.api:118
fib_node_index_t mfs_entry
Definition: mfib_signal.h:31
void ip_mprefix_decode(const vl_api_mprefix_t *in, mfib_prefix_t *out)
Definition: ip_types_api.c:236
int ip6_source_and_port_range_check_add_del(ip6_address_t *address, u32 length, u32 vrf_id, u16 *low_ports, u16 *high_ports, int is_add)
vl_api_registration_t * reg
Definition: ip_api.c:1539
vpe_api_main_t vpe_api_main
Definition: interface_api.c:54
vl_api_interface_index_t sw_if_index
Definition: ip.api:437
void ip_punt_redirect_walk(fib_protocol_t fproto, ip_punt_redirect_walk_cb_t cb, void *ctx)
Definition: ip_punt_drop.c:160
void mfib_table_entry_paths_remove(u32 fib_index, const mfib_prefix_t *prefix, mfib_source_t source, const fib_route_path_t *rpaths)
Definition: mfib_table.c:395
void vl_mfib_signal_send_one(vl_api_registration_t *reg, u32 context, const mfib_signal_t *mfs)
Definition: ip_api.c:966
struct fib_table_t_ * fibs
Definition: ip6.h:183
static void vl_api_ip_source_and_port_range_check_interface_add_del_t_handler(vl_api_ip_source_and_port_range_check_interface_add_del_t *mp)
Definition: ip_api.c:1202
#define foreach_ip_api_msg
Definition: ip_api.c:70
static void send_ip_mroute_details(vpe_api_main_t *am, vl_api_registration_t *reg, u32 context, fib_node_index_t mfib_entry_index)
Definition: ip_api.c:325
static void send_ip_route_details(vpe_api_main_t *am, vl_api_registration_t *reg, u32 context, fib_node_index_t fib_entry_index)
Definition: ip_api.c:188
Dump IP all fib tables.
Definition: ip.api:64
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:304
#define VALIDATE_SW_IF_INDEX(mp)
fib_path_list_walk_rc_t fib_path_encode(fib_node_index_t path_list_index, fib_node_index_t path_index, const fib_path_ext_t *path_ext, void *args)
Definition: fib_path.c:2705
A protocol Independent FIB table.
Definition: fib_table.h:71
fib_node_index_t * feis
Definition: ip_api.c:174
ip46_type_t
Definition: ip46_address.h:22
IPv6 Reassembly.
u8 is_ipv6
Definition: acl_types.api:38
static void send_ip_unnumbered_details(vpe_api_main_t *am, vl_api_registration_t *reg, u32 sw_if_index, u32 ip_sw_if_index, u32 context)
Definition: ip_api.c:809
struct ip_container_proxy_walk_ctx_t_ ip_container_proxy_walk_ctx_t
int set_ip_source_and_port_range_check(vlib_main_t *vm, u32 *fib_index, u32 sw_if_index, u32 is_add)
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:128