2 *------------------------------------------------------------------
3 * ip_api.c - vnet ip api
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:
10 * http://www.apache.org/licenses/LICENSE-2.0
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 *------------------------------------------------------------------
20 #include <vnet/vnet.h>
21 #include <vlibmemory/api.h>
23 #include <vnet/interface.h>
24 #include <vnet/api_errno.h>
25 #include <vnet/ethernet/ethernet.h>
26 #include <vnet/ethernet/ethernet_types_api.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>
33 #include <vnet/ethernet/arp_packet.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>
39 #include <vnet/ip/ip_source_and_port_range_check.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>
45 #include <vnet/ip/reass/ip4_sv_reass.h>
46 #include <vnet/ip/reass/ip4_full_reass.h>
47 #include <vnet/ip/reass/ip6_sv_reass.h>
48 #include <vnet/ip/reass/ip6_full_reass.h>
50 #include <vnet/vnet_msg_enum.h>
52 #define vl_typedefs /* define message structures */
53 #include <vnet/vnet_all_api_h.h>
56 #define vl_endianfun /* define message structures */
57 #include <vnet/vnet_all_api_h.h>
60 /* instantiate all the print functions we know about */
61 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
63 #include <vnet/vnet_all_api_h.h>
66 #include <vlibapi/api_helper_macros.h>
68 #include <vnet/format_fns.h>
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) \
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)
107 vl_api_sw_interface_ip6_enable_disable_t_handler
108 (vl_api_sw_interface_ip6_enable_disable_t * mp)
110 vl_api_sw_interface_ip6_enable_disable_reply_t *rmp;
113 VALIDATE_SW_IF_INDEX (mp);
115 rv = ((mp->enable == 1) ?
116 ip6_link_enable (ntohl (mp->sw_if_index)) :
117 ip6_link_disable (ntohl (mp->sw_if_index)));
119 BAD_SW_IF_INDEX_LABEL;
121 REPLY_MACRO (VL_API_SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY);
125 send_ip_table_details (vpe_api_main_t * am,
126 vl_api_registration_t * reg,
127 u32 context, const fib_table_t * table)
129 vl_api_ip_table_details_t *mp;
131 mp = vl_msg_api_alloc (sizeof (*mp));
134 clib_memset (mp, 0, sizeof (*mp));
135 mp->_vl_msg_id = ntohs (VL_API_IP_TABLE_DETAILS);
136 mp->context = context;
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)));
143 vl_api_send_msg (reg, (u8 *) mp);
147 vl_api_ip_table_dump_t_handler (vl_api_ip_table_dump_t * mp)
149 vpe_api_main_t *am = &vpe_api_main;
150 vl_api_registration_t *reg;
151 fib_table_t *fib_table;
153 reg = vl_api_client_index_to_registration (mp->client_index);
158 pool_foreach (fib_table, ip4_main.fibs,
160 send_ip_table_details(am, reg, mp->context, fib_table);
162 pool_foreach (fib_table, ip6_main.fibs,
164 /* don't send link locals */
165 if (fib_table->ft_flags & FIB_TABLE_FLAG_IP6_LL)
167 send_ip_table_details(am, reg, mp->context, fib_table);
172 typedef struct vl_api_ip_fib_dump_walk_ctx_t_
174 fib_node_index_t *feis;
175 } vl_api_ip_fib_dump_walk_ctx_t;
177 static fib_table_walk_rc_t
178 vl_api_ip_fib_dump_walk (fib_node_index_t fei, void *arg)
180 vl_api_ip_fib_dump_walk_ctx_t *ctx = arg;
182 vec_add1 (ctx->feis, fei);
184 return (FIB_TABLE_WALK_CONTINUE);
188 send_ip_route_details (vpe_api_main_t * am,
189 vl_api_registration_t * reg,
190 u32 context, fib_node_index_t fib_entry_index)
192 fib_route_path_t *rpaths, *rpath;
193 vl_api_ip_route_details_t *mp;
194 const fib_prefix_t *pfx;
195 vl_api_fib_path_t *fp;
199 pfx = fib_entry_get_prefix (fib_entry_index);
200 rpaths = fib_entry_encode (fib_entry_index);
202 path_count = vec_len (rpaths);
203 mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
206 clib_memset (mp, 0, sizeof (*mp));
207 mp->_vl_msg_id = ntohs (VL_API_IP_ROUTE_DETAILS);
208 mp->context = context;
210 ip_prefix_encode (pfx, &mp->route.prefix);
212 htonl (fib_table_get_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 =
216 htonl (fib_table_entry_get_stats_index
217 (fib_entry_get_fib_index (fib_entry_index), pfx));
219 fp = mp->route.paths;
220 vec_foreach (rpath, rpaths)
222 fib_api_path_encode (rpath, fp);
226 vl_api_send_msg (reg, (u8 *) mp);
230 typedef struct apt_ip6_fib_show_ctx_t_
232 fib_node_index_t *entries;
233 } api_ip6_fib_show_ctx_t;
236 vl_api_ip_route_dump_t_handler (vl_api_ip_route_dump_t * mp)
238 vpe_api_main_t *am = &vpe_api_main;
239 fib_node_index_t *fib_entry_index;
240 vl_api_registration_t *reg;
241 fib_protocol_t fproto;
244 reg = vl_api_client_index_to_registration (mp->client_index);
248 vl_api_ip_fib_dump_walk_ctx_t ctx = {
252 fproto = (mp->table.is_ip6 ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4);
253 fib_index = fib_table_find (fproto, ntohl (mp->table.table_id));
255 if (INDEX_INVALID == fib_index)
258 fib_table_walk (fib_index, fproto, vl_api_ip_fib_dump_walk, &ctx);
260 vec_foreach (fib_entry_index, ctx.feis)
262 send_ip_route_details (am, reg, mp->context, *fib_entry_index);
269 send_ip_mtable_details (vl_api_registration_t * reg,
270 u32 context, const mfib_table_t * mfib_table)
272 vl_api_ip_mtable_details_t *mp;
274 mp = vl_msg_api_alloc (sizeof (*mp));
277 memset (mp, 0, sizeof (*mp));
278 mp->_vl_msg_id = ntohs (VL_API_IP_MTABLE_DETAILS);
279 mp->context = context;
281 mp->table.table_id = htonl (mfib_table->mft_table_id);
282 mp->table.is_ip6 = (FIB_PROTOCOL_IP6 == mfib_table->mft_proto);
284 vl_api_send_msg (reg, (u8 *) mp);
288 vl_api_ip_mtable_dump_t_handler (vl_api_ip_mtable_dump_t * mp)
290 vl_api_registration_t *reg;
291 mfib_table_t *mfib_table;
293 reg = vl_api_client_index_to_registration (mp->client_index);
298 pool_foreach (mfib_table, ip4_main.mfibs,
300 send_ip_mtable_details (reg, mp->context, mfib_table);
302 pool_foreach (mfib_table, ip6_main.mfibs,
304 send_ip_mtable_details (reg, mp->context, mfib_table);
309 typedef struct vl_api_ip_mfib_dump_ctx_t_
311 fib_node_index_t *entries;
312 } vl_api_ip_mfib_dump_ctx_t;
315 mfib_route_dump_walk (fib_node_index_t fei, void *arg)
317 vl_api_ip_mfib_dump_ctx_t *ctx = arg;
319 vec_add1 (ctx->entries, fei);
321 return (WALK_CONTINUE);
325 send_ip_mroute_details (vpe_api_main_t * am,
326 vl_api_registration_t * reg,
327 u32 context, fib_node_index_t mfib_entry_index)
329 fib_route_path_t *rpaths, *rpath;
330 vl_api_ip_mroute_details_t *mp;
331 const mfib_prefix_t *pfx;
332 vl_api_mfib_path_t *fp;
336 pfx = mfib_entry_get_prefix (mfib_entry_index);
337 rpaths = mfib_entry_encode (mfib_entry_index);
339 path_count = vec_len (rpaths);
340 mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
343 clib_memset (mp, 0, sizeof (*mp));
344 mp->_vl_msg_id = ntohs (VL_API_IP_MROUTE_DETAILS);
345 mp->context = context;
347 ip_mprefix_encode (pfx, &mp->route.prefix);
349 htonl (mfib_table_get_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)
355 mfib_api_path_encode (rpath, fp);
359 vl_api_send_msg (reg, (u8 *) mp);
364 vl_api_ip_mroute_dump_t_handler (vl_api_ip_mroute_dump_t * mp)
366 vpe_api_main_t *am = &vpe_api_main;
367 vl_api_registration_t *reg;
368 fib_node_index_t *mfeip;
369 fib_protocol_t fproto;
372 vl_api_ip_mfib_dump_ctx_t ctx = {
376 reg = vl_api_client_index_to_registration (mp->client_index);
380 fproto = fib_ip_proto (mp->table.is_ip6);
381 fib_index = mfib_table_find (fproto, ntohl (mp->table.table_id));
383 if (INDEX_INVALID == fib_index)
386 mfib_table_walk (fib_index, fproto, mfib_route_dump_walk, &ctx);
388 vec_sort_with_function (ctx.entries, mfib_entry_cmp_for_sort);
390 vec_foreach (mfeip, ctx.entries)
392 send_ip_mroute_details (am, reg, mp->context, *mfeip);
395 vec_free (ctx.entries);
399 vl_api_ip_punt_police_t_handler (vl_api_ip_punt_police_t * mp,
402 vl_api_ip_punt_police_reply_t *rmp;
406 ip6_punt_policer_add_del (mp->is_add, ntohl (mp->policer_index));
408 ip4_punt_policer_add_del (mp->is_add, ntohl (mp->policer_index));
410 REPLY_MACRO (VL_API_IP_PUNT_POLICE_REPLY);
414 vl_api_ip_punt_redirect_t_handler (vl_api_ip_punt_redirect_t * mp,
417 vl_api_ip_punt_redirect_reply_t *rmp;
422 if (!vnet_sw_if_index_is_api_valid (ntohl (mp->punt.tx_sw_if_index)))
423 goto bad_sw_if_index;
425 ipv = ip_address_decode (&mp->punt.nh, &nh);
428 if (ipv == IP46_TYPE_IP6)
430 ip6_punt_redirect_add (ntohl (mp->punt.rx_sw_if_index),
431 ntohl (mp->punt.tx_sw_if_index), &nh);
433 else if (ipv == IP46_TYPE_IP4)
435 ip4_punt_redirect_add (ntohl (mp->punt.rx_sw_if_index),
436 ntohl (mp->punt.tx_sw_if_index), &nh);
441 if (ipv == IP46_TYPE_IP6)
443 ip6_punt_redirect_del (ntohl (mp->punt.rx_sw_if_index));
445 else if (ipv == IP46_TYPE_IP4)
447 ip4_punt_redirect_del (ntohl (mp->punt.rx_sw_if_index));
451 BAD_SW_IF_INDEX_LABEL;
453 REPLY_MACRO (VL_API_IP_PUNT_REDIRECT_REPLY);
457 ip_table_delete (fib_protocol_t fproto, u32 table_id, u8 is_api)
459 u32 fib_index, mfib_index;
462 * ignore action on the default table - this is always present
463 * and cannot be added nor deleted from the API
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
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.
475 fib_index = fib_table_find (fproto, table_id);
476 mfib_index = mfib_table_find (fproto, table_id);
480 fib_table_unlock (fib_index, fproto,
481 (is_api ? FIB_SOURCE_API : FIB_SOURCE_CLI));
483 if (~0 != mfib_index)
485 mfib_table_unlock (mfib_index, fproto,
486 (is_api ? MFIB_SOURCE_API : MFIB_SOURCE_CLI));
492 vl_api_ip_table_add_del_t_handler (vl_api_ip_table_add_del_t * mp)
494 vl_api_ip_table_add_del_reply_t *rmp;
495 fib_protocol_t fproto = (mp->table.is_ip6 ?
496 FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4);
497 u32 table_id = ntohl (mp->table.table_id);
502 ip_table_create (fproto, table_id, 1, mp->table.name);
506 ip_table_delete (fproto, table_id, 1);
509 REPLY_MACRO (VL_API_IP_TABLE_ADD_DEL_REPLY);
513 ip_route_add_del_t_handler (vl_api_ip_route_add_del_t * mp, u32 * stats_index)
515 fib_route_path_t *rpaths = NULL, *rpath;
516 fib_entry_flag_t entry_flags;
517 vl_api_fib_path_t *apath;
522 entry_flags = FIB_ENTRY_FLAG_NONE;
523 ip_prefix_decode (&mp->route.prefix, &pfx);
525 rv = fib_api_table_id_decode (pfx.fp_proto,
526 ntohl (mp->route.table_id), &fib_index);
530 if (0 != mp->route.n_paths)
531 vec_validate (rpaths, mp->route.n_paths - 1);
533 for (ii = 0; ii < mp->route.n_paths; ii++)
535 apath = &mp->route.paths[ii];
538 rv = fib_api_path_decode (apath, rpath);
540 if ((rpath->frp_flags & FIB_ROUTE_PATH_LOCAL) &&
541 (~0 == rpath->frp_sw_if_index))
542 entry_flags |= (FIB_ENTRY_FLAG_CONNECTED | FIB_ENTRY_FLAG_LOCAL);
548 rv = fib_api_route_add_del (mp->is_add,
550 fib_index, &pfx, entry_flags, rpaths);
552 if (mp->is_add && 0 == rv)
553 *stats_index = fib_table_entry_get_stats_index (fib_index, &pfx);
562 vl_api_ip_route_add_del_t_handler (vl_api_ip_route_add_del_t * mp)
564 vl_api_ip_route_add_del_reply_t *rmp;
565 u32 stats_index = ~0;
568 rv = ip_route_add_del_t_handler (mp, &stats_index);
571 REPLY_MACRO2 (VL_API_IP_ROUTE_ADD_DEL_REPLY,
573 rmp->stats_index = htonl (stats_index);
579 ip_table_create (fib_protocol_t fproto,
580 u32 table_id, u8 is_api, const u8 * name)
582 u32 fib_index, mfib_index;
585 * ignore action on the default table - this is always present
586 * and cannot be added nor deleted from the API
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
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.
598 fib_index = fib_table_find (fproto, table_id);
599 mfib_index = mfib_table_find (fproto, table_id);
603 fib_table_find_or_create_and_lock_w_name (fproto, table_id,
606 FIB_SOURCE_CLI), name);
608 if (~0 == mfib_index)
610 mfib_table_find_or_create_and_lock_w_name (fproto, table_id,
613 MFIB_SOURCE_CLI), name);
619 mroute_add_del_handler (u8 is_add,
622 const mfib_prefix_t * prefix,
624 u32 rpf_id, fib_route_path_t * rpaths)
626 u32 mfib_entry_index = ~0;
628 if (0 == vec_len (rpaths))
630 mfib_entry_index = mfib_table_entry_update (fib_index, prefix,
632 rpf_id, entry_flags);
639 mfib_table_entry_paths_update (fib_index, prefix,
640 MFIB_SOURCE_API, rpaths);
644 mfib_table_entry_paths_remove (fib_index, prefix,
645 MFIB_SOURCE_API, rpaths);
649 return (mfib_entry_index);
653 api_mroute_add_del_t_handler (vl_api_ip_mroute_add_del_t * mp,
656 fib_route_path_t *rpath, *rpaths = NULL;
657 fib_node_index_t mfib_entry_index;
663 ip_mprefix_decode (&mp->route.prefix, &pfx);
665 rv = mfib_api_table_id_decode (pfx.fp_proto,
666 ntohl (mp->route.table_id), &fib_index);
670 vec_validate (rpaths, mp->route.n_paths - 1);
672 for (ii = 0; ii < mp->route.n_paths; ii++)
676 rv = mfib_api_path_decode (&mp->route.paths[ii], rpath);
682 mfib_entry_index = mroute_add_del_handler (mp->is_add,
685 ntohl (mp->route.entry_flags),
686 ntohl (mp->route.rpf_id),
689 if (~0 != mfib_entry_index)
690 *stats_index = mfib_entry_get_stats_index (mfib_entry_index);
697 vl_api_ip_mroute_add_del_t_handler (vl_api_ip_mroute_add_del_t * mp)
699 vl_api_ip_mroute_add_del_reply_t *rmp;
700 u32 stats_index = ~0;
703 rv = api_mroute_add_del_t_handler (mp, &stats_index);
706 REPLY_MACRO2 (VL_API_IP_MROUTE_ADD_DEL_REPLY,
708 rmp->stats_index = htonl (stats_index);
714 send_ip_details (vpe_api_main_t * am,
715 vl_api_registration_t * reg, u32 sw_if_index, u8 is_ipv6,
718 vl_api_ip_details_t *mp;
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);
724 mp->sw_if_index = ntohl (sw_if_index);
725 mp->is_ipv6 = is_ipv6;
726 mp->context = context;
728 vl_api_send_msg (reg, (u8 *) mp);
732 send_ip_address_details (vpe_api_main_t * am,
733 vl_api_registration_t * reg,
734 const fib_prefix_t * pfx,
735 u32 sw_if_index, u32 context)
737 vl_api_ip_address_details_t *mp;
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);
743 ip_prefix_encode (pfx, &mp->prefix);
744 mp->context = context;
745 mp->sw_if_index = htonl (sw_if_index);
747 vl_api_send_msg (reg, (u8 *) mp);
751 vl_api_ip_address_dump_t_handler (vl_api_ip_address_dump_t * mp)
753 vpe_api_main_t *am = &vpe_api_main;
754 vl_api_registration_t *reg;
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;
763 VALIDATE_SW_IF_INDEX (mp);
765 sw_if_index = ntohl (mp->sw_if_index);
767 reg = vl_api_client_index_to_registration (mp->client_index);
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,
781 .fp_addr.ip6 = *(ip6_address_t *)ip_interface_address_get_address (lm6, ia),
782 .fp_len = ia->address_length,
783 .fp_proto = FIB_PROTOCOL_IP6,
785 send_ip_address_details(am, reg, &pfx, sw_if_index, mp->context);
792 foreach_ip_interface_address (lm4, ia, sw_if_index, 0,
795 .fp_addr.ip4 = *(ip4_address_t *)ip_interface_address_get_address (lm4, ia),
796 .fp_len = ia->address_length,
797 .fp_proto = FIB_PROTOCOL_IP4,
800 send_ip_address_details(am, reg, &pfx, sw_if_index, mp->context);
805 BAD_SW_IF_INDEX_LABEL;
809 send_ip_unnumbered_details (vpe_api_main_t * am,
810 vl_api_registration_t * reg,
811 u32 sw_if_index, u32 ip_sw_if_index, u32 context)
813 vl_api_ip_unnumbered_details_t *mp;
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);
819 mp->context = context;
820 mp->sw_if_index = htonl (sw_if_index);
821 mp->ip_sw_if_index = htonl (ip_sw_if_index);
823 vl_api_send_msg (reg, (u8 *) mp);
827 vl_api_ip_unnumbered_dump_t_handler (vl_api_ip_unnumbered_dump_t * mp)
829 vnet_main_t *vnm = vnet_get_main ();
830 vnet_interface_main_t *im = &vnm->interface_main;
831 int rv __attribute__ ((unused)) = 0;
832 vpe_api_main_t *am = &vpe_api_main;
833 vl_api_registration_t *reg;
834 vnet_sw_interface_t *si;
837 sw_if_index = ntohl (mp->sw_if_index);
839 reg = vl_api_client_index_to_registration (mp->client_index);
843 if (~0 != sw_if_index)
845 VALIDATE_SW_IF_INDEX (mp);
847 si = vnet_get_sw_interface (vnm, ntohl (mp->sw_if_index));
849 if (si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED)
851 send_ip_unnumbered_details (am, reg,
853 si->unnumbered_sw_if_index,
860 pool_foreach (si, im->sw_interfaces,
862 if ((si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED))
864 send_ip_unnumbered_details(am, reg,
866 si->unnumbered_sw_if_index,
873 BAD_SW_IF_INDEX_LABEL;
877 vl_api_ip_dump_t_handler (vl_api_ip_dump_t * mp)
879 vpe_api_main_t *am = &vpe_api_main;
880 vnet_main_t *vnm = vnet_get_main ();
881 //vlib_main_t *vm = vlib_get_main ();
882 vnet_interface_main_t *im = &vnm->interface_main;
883 vl_api_registration_t *reg;
884 vnet_sw_interface_t *si, *sorted_sis;
885 u32 sw_if_index = ~0;
887 reg = vl_api_client_index_to_registration (mp->client_index);
891 /* Gather interfaces. */
892 sorted_sis = vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
893 _vec_len (sorted_sis) = 0;
895 pool_foreach (si, im->sw_interfaces,
897 vec_add1 (sorted_sis, si[0]);
901 vec_foreach (si, sorted_sis)
903 if (!(si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED))
905 /* if (mp->is_ipv6 && !ip6_interface_enabled (vm, si->sw_if_index)) */
909 sw_if_index = si->sw_if_index;
910 send_ip_details (am, reg, sw_if_index, mp->is_ipv6, mp->context);
914 vec_free (sorted_sis);
918 set_ip6_flow_hash (vl_api_set_ip_flow_hash_t * mp)
920 vl_api_set_ip_flow_hash_reply_t *rmp;
923 flow_hash_config_t flow_hash_config = 0;
925 table_id = ntohl (mp->vrf_id);
927 #define _(a,b) if (mp->a) flow_hash_config |= b;
928 foreach_flow_hash_bit;
931 rv = vnet_set_ip6_flow_hash (table_id, flow_hash_config);
933 REPLY_MACRO (VL_API_SET_IP_FLOW_HASH_REPLY);
937 set_ip4_flow_hash (vl_api_set_ip_flow_hash_t * mp)
939 vl_api_set_ip_flow_hash_reply_t *rmp;
942 flow_hash_config_t flow_hash_config = 0;
944 table_id = ntohl (mp->vrf_id);
946 #define _(a,b) if (mp->a) flow_hash_config |= b;
947 foreach_flow_hash_bit;
950 rv = vnet_set_ip4_flow_hash (table_id, flow_hash_config);
952 REPLY_MACRO (VL_API_SET_IP_FLOW_HASH_REPLY);
957 vl_api_set_ip_flow_hash_t_handler (vl_api_set_ip_flow_hash_t * mp)
959 if (mp->is_ipv6 == 0)
960 set_ip4_flow_hash (mp);
962 set_ip6_flow_hash (mp);
966 vl_mfib_signal_send_one (vl_api_registration_t * reg,
967 u32 context, const mfib_signal_t * mfs)
969 vl_api_mfib_signal_details_t *mp;
970 const mfib_prefix_t *prefix;
974 mp = vl_msg_api_alloc (sizeof (*mp));
976 clib_memset (mp, 0, sizeof (*mp));
977 mp->_vl_msg_id = ntohs (VL_API_MFIB_SIGNAL_DETAILS);
978 mp->context = context;
980 mfi = mfib_itf_get (mfs->mfs_itf);
981 prefix = mfib_entry_get_prefix (mfs->mfs_entry);
982 mfib = mfib_table_get (mfib_entry_get_fib_index (mfs->mfs_entry),
984 mp->table_id = ntohl (mfib->mft_table_id);
985 mp->sw_if_index = ntohl (mfi->mfi_sw_if_index);
987 ip_mprefix_encode (prefix, &mp->prefix);
989 if (0 != mfs->mfs_buffer_len)
991 mp->ip_packet_len = ntohs (mfs->mfs_buffer_len);
993 memcpy (mp->ip_packet_data, mfs->mfs_buffer, mfs->mfs_buffer_len);
997 mp->ip_packet_len = 0;
1000 vl_api_send_msg (reg, (u8 *) mp);
1004 vl_api_mfib_signal_dump_t_handler (vl_api_mfib_signal_dump_t * mp)
1006 vl_api_registration_t *reg;
1008 reg = vl_api_client_index_to_registration (mp->client_index);
1012 while (vl_api_can_send_msg (reg) && mfib_signal_send_one (reg, mp->context))
1017 vl_api_ip_container_proxy_add_del_t_handler
1018 (vl_api_ip_container_proxy_add_del_t * mp)
1020 vl_api_ip_container_proxy_add_del_reply_t *rmp;
1021 vnet_ip_container_proxy_args_t args;
1023 clib_error_t *error;
1025 clib_memset (&args, 0, sizeof (args));
1027 ip_prefix_decode (&mp->pfx, &args.prefix);
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)))
1033 rv = clib_error_get_code (error);
1034 clib_error_report (error);
1037 REPLY_MACRO (VL_API_IP_CONTAINER_PROXY_ADD_DEL_REPLY);
1040 typedef struct ip_container_proxy_walk_ctx_t_
1042 vl_api_registration_t *reg;
1044 } ip_container_proxy_walk_ctx_t;
1047 ip_container_proxy_send_details (const fib_prefix_t * pfx, u32 sw_if_index,
1050 vl_api_ip_container_proxy_details_t *mp;
1051 ip_container_proxy_walk_ctx_t *ctx = args;
1053 mp = vl_msg_api_alloc (sizeof (*mp));
1057 clib_memset (mp, 0, sizeof (*mp));
1058 mp->_vl_msg_id = ntohs (VL_API_IP_CONTAINER_PROXY_DETAILS);
1059 mp->context = ctx->context;
1061 mp->sw_if_index = ntohl (sw_if_index);
1062 ip_prefix_encode (pfx, &mp->prefix);
1064 vl_api_send_msg (ctx->reg, (u8 *) mp);
1070 vl_api_ip_container_proxy_dump_t_handler (vl_api_ip_container_proxy_dump_t *
1073 vl_api_registration_t *reg;
1075 reg = vl_api_client_index_to_registration (mp->client_index);
1079 ip_container_proxy_walk_ctx_t ctx = {
1080 .context = mp->context,
1084 ip_container_proxy_walk (ip_container_proxy_send_details, &ctx);
1088 vl_api_ioam_enable_t_handler (vl_api_ioam_enable_t * mp)
1091 vl_api_ioam_enable_reply_t *rmp;
1092 clib_error_t *error;
1094 /* Ignoring the profile id as currently a single profile
1096 error = ip6_ioam_enable (mp->trace_enable, mp->pot_enable,
1097 mp->seqno, mp->analyse);
1100 clib_error_report (error);
1101 rv = clib_error_get_code (error);
1104 REPLY_MACRO (VL_API_IOAM_ENABLE_REPLY);
1108 vl_api_ioam_disable_t_handler (vl_api_ioam_disable_t * mp)
1111 vl_api_ioam_disable_reply_t *rmp;
1112 clib_error_t *error;
1114 error = clear_ioam_rewrite_fn ();
1117 clib_error_report (error);
1118 rv = clib_error_get_code (error);
1121 REPLY_MACRO (VL_API_IOAM_DISABLE_REPLY);
1125 vl_api_ip_source_and_port_range_check_add_del_t_handler
1126 (vl_api_ip_source_and_port_range_check_add_del_t * mp)
1128 vl_api_ip_source_and_port_range_check_add_del_reply_t *rmp;
1131 u8 is_add = mp->is_add;
1134 u16 *high_ports = 0;
1136 u16 tmp_low, tmp_high;
1140 ip_prefix_decode (&mp->prefix, &pfx);
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;
1150 vec_reset_length (low_ports);
1151 vec_reset_length (high_ports);
1153 for (i = 0; i < num_ranges; i++)
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)
1161 rv = VNET_API_ERROR_INVALID_VALUE;
1164 vec_add1 (low_ports, tmp_low);
1165 vec_add1 (high_ports, tmp_high + 1);
1168 vrf_id = ntohl (mp->vrf_id);
1172 rv = VNET_API_ERROR_INVALID_VALUE;
1177 if (FIB_PROTOCOL_IP6 == pfx.fp_proto)
1179 rv = ip6_source_and_port_range_check_add_del (&pfx.fp_addr.ip6,
1183 high_ports, is_add);
1187 rv = ip4_source_and_port_range_check_add_del (&pfx.fp_addr.ip4,
1191 high_ports, is_add);
1195 vec_free (low_ports);
1196 vec_free (high_ports);
1197 REPLY_MACRO (VL_API_IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY);
1201 vl_api_ip_source_and_port_range_check_interface_add_del_t_handler
1202 (vl_api_ip_source_and_port_range_check_interface_add_del_t * mp)
1204 vlib_main_t *vm = vlib_get_main ();
1205 vl_api_ip_source_and_port_range_check_interface_add_del_reply_t *rmp;
1206 ip4_main_t *im = &ip4_main;
1209 u32 fib_index[IP_SOURCE_AND_PORT_RANGE_CHECK_N_PROTOCOLS];
1210 u32 vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_N_PROTOCOLS];
1214 vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_PROTOCOL_TCP_OUT] =
1215 ntohl (mp->tcp_out_vrf_id);
1216 vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_PROTOCOL_UDP_OUT] =
1217 ntohl (mp->udp_out_vrf_id);
1218 vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_PROTOCOL_TCP_IN] =
1219 ntohl (mp->tcp_in_vrf_id);
1220 vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_PROTOCOL_UDP_IN] =
1221 ntohl (mp->udp_in_vrf_id);
1224 for (i = 0; i < IP_SOURCE_AND_PORT_RANGE_CHECK_N_PROTOCOLS; i++)
1226 if (vrf_id[i] != 0 && vrf_id[i] != ~0)
1228 p = hash_get (im->fib_index_by_table_id, vrf_id[i]);
1232 rv = VNET_API_ERROR_INVALID_VALUE;
1236 fib_index[i] = p[0];
1241 sw_if_index = ntohl (mp->sw_if_index);
1243 VALIDATE_SW_IF_INDEX (mp);
1246 set_ip_source_and_port_range_check (vm, fib_index, sw_if_index,
1249 BAD_SW_IF_INDEX_LABEL;
1252 REPLY_MACRO (VL_API_IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY);
1256 vl_api_sw_interface_ip6_set_link_local_address_t_handler
1257 (vl_api_sw_interface_ip6_set_link_local_address_t * mp)
1259 vl_api_sw_interface_ip6_set_link_local_address_reply_t *rmp;
1263 VALIDATE_SW_IF_INDEX (mp);
1265 ip6_address_decode (mp->ip, &ip);
1267 rv = ip6_set_link_local_address (ntohl (mp->sw_if_index), &ip);
1269 BAD_SW_IF_INDEX_LABEL;
1270 REPLY_MACRO (VL_API_SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY);
1276 } ip4_source_check_config_t;
1279 vl_api_ip_source_check_interface_add_del_t_handler
1280 (vl_api_ip_source_check_interface_add_del_t * mp)
1282 vl_api_ip_source_check_interface_add_del_reply_t *rmp;
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";
1289 ip4_source_check_config_t config;
1291 VALIDATE_SW_IF_INDEX (mp);
1294 fib_table_get_index_for_sw_if_index (FIB_PROTOCOL_IP4, sw_if_index);
1296 vnet_feature_enable_disable ("ip4-unicast", feature_name, sw_if_index,
1297 is_add, &config, sizeof (config));
1298 BAD_SW_IF_INDEX_LABEL;
1300 REPLY_MACRO (VL_API_IP_SOURCE_CHECK_INTERFACE_ADD_DEL_REPLY);
1305 vl_api_ip_table_replace_begin_t_handler (vl_api_ip_table_replace_begin_t * mp)
1307 vl_api_ip_table_replace_begin_reply_t *rmp;
1308 fib_protocol_t fproto;
1312 fproto = (mp->table.is_ip6 ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4);
1313 fib_index = fib_table_find (fproto, ntohl (mp->table.table_id));
1315 if (INDEX_INVALID == fib_index)
1316 rv = VNET_API_ERROR_NO_SUCH_FIB;
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);
1323 REPLY_MACRO (VL_API_IP_TABLE_REPLACE_BEGIN_REPLY);
1327 vl_api_ip_table_replace_end_t_handler (vl_api_ip_table_replace_end_t * mp)
1329 vl_api_ip_table_replace_end_reply_t *rmp;
1330 fib_protocol_t fproto;
1334 fproto = (mp->table.is_ip6 ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4);
1335 fib_index = fib_table_find (fproto, ntohl (mp->table.table_id));
1337 if (INDEX_INVALID == fib_index)
1338 rv = VNET_API_ERROR_NO_SUCH_FIB;
1341 fib_table_sweep (fib_index, fproto, FIB_SOURCE_API);
1342 mfib_table_sweep (mfib_table_find
1343 (fproto, ntohl (mp->table.table_id)), fproto,
1346 REPLY_MACRO (VL_API_IP_TABLE_REPLACE_END_REPLY);
1350 vl_api_ip_table_flush_t_handler (vl_api_ip_table_flush_t * mp)
1352 vl_api_ip_table_flush_reply_t *rmp;
1353 fib_protocol_t fproto;
1357 fproto = (mp->table.is_ip6 ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4);
1358 fib_index = fib_table_find (fproto, ntohl (mp->table.table_id));
1360 if (INDEX_INVALID == fib_index)
1361 rv = VNET_API_ERROR_NO_SUCH_FIB;
1364 vnet_main_t *vnm = vnet_get_main ();
1365 vnet_interface_main_t *im = &vnm->interface_main;
1366 vnet_sw_interface_t *si;
1368 /* Shut down interfaces in this FIB / clean out intfc routes */
1370 pool_foreach (si, im->sw_interfaces,
1372 if (fib_index == fib_table_get_index_for_sw_if_index (fproto,
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);
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);
1387 REPLY_MACRO (VL_API_IP_TABLE_FLUSH_REPLY);
1391 vl_api_ip_reassembly_set_t_handler (vl_api_ip_reassembly_set_t * mp)
1393 vl_api_ip_reassembly_set_reply_t *rmp;
1395 switch ((vl_api_ip_reass_type_t) clib_net_to_host_u32 (mp->type))
1397 case IP_REASS_TYPE_FULL:
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));
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));
1419 case IP_REASS_TYPE_SHALLOW_VIRTUAL:
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));
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));
1442 REPLY_MACRO (VL_API_IP_REASSEMBLY_SET_REPLY);
1446 vl_api_ip_reassembly_get_t_handler (vl_api_ip_reassembly_get_t * mp)
1448 vl_api_registration_t *rp;
1450 rp = vl_api_client_index_to_registration (mp->client_index);
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;
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))
1465 case IP_REASS_TYPE_FULL:
1469 ip6_full_reass_get (&timeout_ms, &max_reassemblies,
1470 &max_reassembly_length,
1471 &expire_walk_interval_ms);
1476 ip4_full_reass_get (&timeout_ms, &max_reassemblies,
1477 &max_reassembly_length,
1478 &expire_walk_interval_ms);
1481 case IP_REASS_TYPE_SHALLOW_VIRTUAL:
1485 ip6_sv_reass_get (&timeout_ms, &max_reassemblies,
1486 &max_reassembly_length, &expire_walk_interval_ms);
1491 ip4_sv_reass_get (&timeout_ms, &max_reassemblies,
1492 &max_reassembly_length, &expire_walk_interval_ms);
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);
1499 rmp->expire_walk_interval_ms =
1500 clib_host_to_net_u32 (expire_walk_interval_ms);
1501 vl_api_send_msg (rp, (u8 *) rmp);
1505 vl_api_ip_reassembly_enable_disable_t_handler
1506 (vl_api_ip_reassembly_enable_disable_t * mp)
1508 vl_api_ip_reassembly_enable_disable_reply_t *rmp;
1510 switch ((vl_api_ip_reass_type_t) clib_net_to_host_u32 (mp->type))
1512 case IP_REASS_TYPE_FULL:
1514 ip4_full_reass_enable_disable (clib_net_to_host_u32 (mp->sw_if_index),
1518 ip6_full_reass_enable_disable (clib_net_to_host_u32
1519 (mp->sw_if_index), mp->enable_ip6);
1521 case IP_REASS_TYPE_SHALLOW_VIRTUAL:
1523 ip4_sv_reass_enable_disable (clib_net_to_host_u32 (mp->sw_if_index),
1528 ip6_sv_reass_enable_disable (clib_net_to_host_u32
1529 (mp->sw_if_index), mp->enable_ip6);
1534 REPLY_MACRO (VL_API_IP_REASSEMBLY_ENABLE_DISABLE_REPLY);
1537 typedef struct ip_punt_redirect_walk_ctx_t_
1539 vl_api_registration_t *reg;
1541 } ip_punt_redirect_walk_ctx_t;
1544 send_ip_punt_redirect_details (u32 rx_sw_if_index,
1545 const ip_punt_redirect_rx_t * ipr, void *arg)
1547 ip_punt_redirect_walk_ctx_t *ctx = arg;
1548 vl_api_ip_punt_redirect_details_t *mp;
1549 fib_path_encode_ctx_t path_ctx = {
1553 mp = vl_msg_api_alloc (sizeof (*mp));
1555 return (WALK_STOP);;
1557 clib_memset (mp, 0, sizeof (*mp));
1558 mp->_vl_msg_id = ntohs (VL_API_IP_PUNT_REDIRECT_DETAILS);
1559 mp->context = ctx->context;
1561 fib_path_list_walk_w_ext (ipr->pl, NULL, fib_path_encode, &path_ctx);
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);
1566 ip_address_encode (&path_ctx.rpaths[0].frp_addr,
1567 fib_proto_to_ip46 (ipr->fproto), &mp->punt.nh);
1569 vl_api_send_msg (ctx->reg, (u8 *) mp);
1571 vec_free (path_ctx.rpaths);
1573 return (WALK_CONTINUE);
1577 vl_api_ip_punt_redirect_dump_t_handler (vl_api_ip_punt_redirect_dump_t * mp)
1579 vl_api_registration_t *reg;
1580 fib_protocol_t fproto;
1582 reg = vl_api_client_index_to_registration (mp->client_index);
1586 fproto = mp->is_ipv6 ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4;
1588 ip_punt_redirect_walk_ctx_t ctx = {
1590 .context = mp->context,
1593 if (~0 != mp->sw_if_index)
1598 rx_sw_if_index = ntohl (mp->sw_if_index);
1599 pri = ip_punt_redirect_find (fproto, rx_sw_if_index);
1601 if (INDEX_INVALID == pri)
1604 send_ip_punt_redirect_details (rx_sw_if_index,
1605 ip_punt_redirect_get (pri), &ctx);
1608 ip_punt_redirect_walk (fproto, send_ip_punt_redirect_details, &ctx);
1611 #define vl_msg_name_crc_list
1612 #include <vnet/ip/ip.api.h>
1613 #undef vl_msg_name_crc_list
1616 setup_message_id_table (api_main_t * am)
1618 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
1619 foreach_vl_msg_name_crc_ip;
1623 static clib_error_t *
1624 ip_api_hookup (vlib_main_t * vm)
1626 api_main_t *am = vlibapi_get_main ();
1629 vl_msg_api_set_handlers(VL_API_##N, #n, \
1630 vl_api_##n##_t_handler, \
1632 vl_api_##n##_t_endian, \
1633 vl_api_##n##_t_print, \
1634 sizeof(vl_api_##n##_t), 1);
1639 * Mark the route add/del API as MP safe
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;
1645 * Set up the (msg_name, crc, message-id) table
1647 setup_message_id_table (am);
1652 VLIB_API_INIT_FUNCTION (ip_api_hookup);
1655 * fd.io coding-style-patch-verification: ON
1658 * eval: (c-set-style "gnu")