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/ip/ip.h>
27 #include <vnet/ip/ip6_neighbor.h>
28 #include <vnet/fib/fib_table.h>
29 #include <vnet/fib/fib_api.h>
30 #include <vnet/dpo/drop_dpo.h>
31 #include <vnet/dpo/receive_dpo.h>
32 #include <vnet/dpo/lookup_dpo.h>
33 #include <vnet/dpo/classify_dpo.h>
34 #include <vnet/dpo/ip_null_dpo.h>
35 #include <vnet/ethernet/arp_packet.h>
36 #include <vnet/mfib/ip6_mfib.h>
37 #include <vnet/mfib/ip4_mfib.h>
38 #include <vnet/mfib/mfib_signal.h>
39 #include <vnet/mfib/mfib_entry.h>
41 #include <vnet/vnet_msg_enum.h>
43 #define vl_typedefs /* define message structures */
44 #include <vnet/vnet_all_api_h.h>
47 #define vl_endianfun /* define message structures */
48 #include <vnet/vnet_all_api_h.h>
51 /* instantiate all the print functions we know about */
52 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
54 #include <vnet/vnet_all_api_h.h>
57 #include <vlibapi/api_helper_macros.h>
60 #define foreach_ip_api_msg \
61 _(IP_FIB_DUMP, ip_fib_dump) \
62 _(IP6_FIB_DUMP, ip6_fib_dump) \
63 _(IP_MFIB_DUMP, ip_mfib_dump) \
64 _(IP6_MFIB_DUMP, ip6_mfib_dump) \
65 _(IP_NEIGHBOR_DUMP, ip_neighbor_dump) \
66 _(IP_MROUTE_ADD_DEL, ip_mroute_add_del) \
67 _(MFIB_SIGNAL_DUMP, mfib_signal_dump) \
68 _(IP_ADDRESS_DUMP, ip_address_dump) \
70 _(IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del) \
71 _(IP_ADD_DEL_ROUTE, ip_add_del_route) \
72 _(SET_IP_FLOW_HASH,set_ip_flow_hash) \
73 _(SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config) \
74 _(SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix) \
75 _(IP6ND_PROXY_ADD_DEL, ip6nd_proxy_add_del) \
76 _(IP6ND_PROXY_DUMP, ip6nd_proxy_dump) \
77 _(SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable ) \
78 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, \
79 sw_interface_ip6_set_link_local_address)
81 extern void stats_dslock_with_hint (int hint, int tag);
82 extern void stats_dsunlock (void);
85 send_ip_neighbor_details (u8 is_ipv6,
89 unix_shared_memory_queue_t * q, u32 context)
91 vl_api_ip_neighbor_details_t *mp;
93 mp = vl_msg_api_alloc (sizeof (*mp));
94 memset (mp, 0, sizeof (*mp));
95 mp->_vl_msg_id = ntohs (VL_API_IP_NEIGHBOR_DETAILS);
96 mp->context = context;
97 mp->is_ipv6 = is_ipv6;
98 mp->is_static = is_static;
99 memcpy (mp->mac_address, mac_address, 6);
100 memcpy (mp->ip_address, ip_address, (is_ipv6) ? 16 : 4);
102 vl_msg_api_send_shmem (q, (u8 *) & mp);
106 vl_api_ip_neighbor_dump_t_handler (vl_api_ip_neighbor_dump_t * mp)
108 unix_shared_memory_queue_t *q;
110 q = vl_api_client_index_to_input_queue (mp->client_index);
114 u32 sw_if_index = ntohl (mp->sw_if_index);
118 ip6_neighbor_t *n, *ns;
120 ns = ip6_neighbors_entries (sw_if_index);
124 send_ip_neighbor_details
125 (mp->is_ipv6, ((n->flags & IP6_NEIGHBOR_FLAG_STATIC) ? 1 : 0),
126 (u8 *) n->link_layer_address,
127 (u8 *) & (n->key.ip6_address.as_u8),
135 ethernet_arp_ip4_entry_t *n, *ns;
137 ns = ip4_neighbor_entries (sw_if_index);
141 send_ip_neighbor_details (mp->is_ipv6,
142 ((n->flags & ETHERNET_ARP_IP4_ENTRY_FLAG_STATIC) ? 1 : 0),
143 (u8*) n->ethernet_address,
144 (u8*) & (n->ip4_address.as_u8),
154 copy_fib_next_hop (fib_route_path_encode_t * api_rpath, void *fp_arg)
157 vl_api_fib_path_t *fp = (vl_api_fib_path_t *) fp_arg;
159 if (api_rpath->rpath.frp_proto == FIB_PROTOCOL_IP4)
160 fp->afi = IP46_TYPE_IP4;
161 else if (api_rpath->rpath.frp_proto == FIB_PROTOCOL_IP6)
162 fp->afi = IP46_TYPE_IP6;
165 is_ip4 = ip46_address_is_ip4 (&api_rpath->rpath.frp_addr);
167 fp->afi = IP46_TYPE_IP4;
169 fp->afi = IP46_TYPE_IP6;
171 if (fp->afi == IP46_TYPE_IP4)
172 memcpy (fp->next_hop, &api_rpath->rpath.frp_addr.ip4,
173 sizeof (api_rpath->rpath.frp_addr.ip4));
175 memcpy (fp->next_hop, &api_rpath->rpath.frp_addr.ip6,
176 sizeof (api_rpath->rpath.frp_addr.ip6));
180 send_ip_fib_details (vpe_api_main_t * am,
181 unix_shared_memory_queue_t * q,
182 u32 table_id, fib_prefix_t * pfx,
183 fib_route_path_encode_t * api_rpaths, u32 context)
185 vl_api_ip_fib_details_t *mp;
186 fib_route_path_encode_t *api_rpath;
187 vl_api_fib_path_t *fp;
190 path_count = vec_len (api_rpaths);
191 mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
194 memset (mp, 0, sizeof (*mp));
195 mp->_vl_msg_id = ntohs (VL_API_IP_FIB_DETAILS);
196 mp->context = context;
198 mp->table_id = htonl (table_id);
199 mp->address_length = pfx->fp_len;
200 memcpy (mp->address, &pfx->fp_addr.ip4, sizeof (pfx->fp_addr.ip4));
202 mp->count = htonl (path_count);
204 vec_foreach (api_rpath, api_rpaths)
206 memset (fp, 0, sizeof (*fp));
207 switch (api_rpath->dpo.dpoi_type)
216 switch (api_rpath->dpo.dpoi_index)
218 case IP_NULL_ACTION_NONE:
221 case IP_NULL_ACTION_SEND_ICMP_UNREACH:
222 fp->is_unreach = true;
224 case IP_NULL_ACTION_SEND_ICMP_PROHIBIT:
225 fp->is_prohibit = true;
234 fp->weight = htonl (api_rpath->rpath.frp_weight);
235 fp->sw_if_index = htonl (api_rpath->rpath.frp_sw_if_index);
236 copy_fib_next_hop (api_rpath, fp);
240 vl_msg_api_send_shmem (q, (u8 *) & mp);
243 typedef struct vl_api_ip_fib_dump_walk_ctx_t_
245 fib_node_index_t *feis;
246 } vl_api_ip_fib_dump_walk_ctx_t;
249 vl_api_ip_fib_dump_walk (fib_node_index_t fei, void *arg)
251 vl_api_ip_fib_dump_walk_ctx_t *ctx = arg;
253 vec_add1 (ctx->feis, fei);
259 vl_api_ip_fib_dump_t_handler (vl_api_ip_fib_dump_t * mp)
261 vpe_api_main_t *am = &vpe_api_main;
262 unix_shared_memory_queue_t *q;
263 ip4_main_t *im = &ip4_main;
264 fib_table_t *fib_table;
265 fib_node_index_t *lfeip;
268 fib_route_path_encode_t *api_rpaths;
269 vl_api_ip_fib_dump_walk_ctx_t ctx = {
273 q = vl_api_client_index_to_input_queue (mp->client_index);
278 pool_foreach (fib_table, im->fibs,
280 fib_table_walk(fib_table->ft_index,
282 vl_api_ip_fib_dump_walk,
287 vec_sort_with_function (ctx.feis, fib_entry_cmp_for_sort);
289 vec_foreach (lfeip, ctx.feis)
291 fib_entry_get_prefix (*lfeip, &pfx);
292 fib_index = fib_entry_get_fib_index (*lfeip);
293 fib_table = fib_table_get (fib_index, pfx.fp_proto);
295 fib_entry_encode (*lfeip, &api_rpaths);
296 send_ip_fib_details (am, q,
297 fib_table->ft_table_id, &pfx, api_rpaths,
299 vec_free (api_rpaths);
306 send_ip6_fib_details (vpe_api_main_t * am,
307 unix_shared_memory_queue_t * q,
308 u32 table_id, fib_prefix_t * pfx,
309 fib_route_path_encode_t * api_rpaths, u32 context)
311 vl_api_ip6_fib_details_t *mp;
312 fib_route_path_encode_t *api_rpath;
313 vl_api_fib_path_t *fp;
316 path_count = vec_len (api_rpaths);
317 mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
320 memset (mp, 0, sizeof (*mp));
321 mp->_vl_msg_id = ntohs (VL_API_IP6_FIB_DETAILS);
322 mp->context = context;
324 mp->table_id = htonl (table_id);
325 mp->address_length = pfx->fp_len;
326 memcpy (mp->address, &pfx->fp_addr.ip6, sizeof (pfx->fp_addr.ip6));
328 mp->count = htonl (path_count);
330 vec_foreach (api_rpath, api_rpaths)
332 memset (fp, 0, sizeof (*fp));
333 switch (api_rpath->dpo.dpoi_type)
342 switch (api_rpath->dpo.dpoi_index)
344 case IP_NULL_DPO_ACTION_NUM + IP_NULL_ACTION_NONE:
347 case IP_NULL_DPO_ACTION_NUM + IP_NULL_ACTION_SEND_ICMP_UNREACH:
348 fp->is_unreach = true;
350 case IP_NULL_DPO_ACTION_NUM + IP_NULL_ACTION_SEND_ICMP_PROHIBIT:
351 fp->is_prohibit = true;
360 fp->weight = htonl (api_rpath->rpath.frp_weight);
361 fp->sw_if_index = htonl (api_rpath->rpath.frp_sw_if_index);
362 copy_fib_next_hop (api_rpath, fp);
366 vl_msg_api_send_shmem (q, (u8 *) & mp);
369 typedef struct apt_ip6_fib_show_ctx_t_
372 fib_node_index_t *entries;
373 } api_ip6_fib_show_ctx_t;
376 api_ip6_fib_table_put_entries (clib_bihash_kv_24_8_t * kvp, void *arg)
378 api_ip6_fib_show_ctx_t *ctx = arg;
380 if ((kvp->key[2] >> 32) == ctx->fib_index)
382 vec_add1 (ctx->entries, kvp->value);
387 api_ip6_fib_table_get_all (unix_shared_memory_queue_t * q,
388 vl_api_ip6_fib_dump_t * mp,
389 fib_table_t * fib_table)
391 vpe_api_main_t *am = &vpe_api_main;
392 ip6_main_t *im6 = &ip6_main;
393 fib_node_index_t *fib_entry_index;
394 api_ip6_fib_show_ctx_t ctx = {
395 .fib_index = fib_table->ft_index,
398 fib_route_path_encode_t *api_rpaths;
401 BV (clib_bihash_foreach_key_value_pair)
402 ((BVT (clib_bihash) *) & im6->ip6_table[IP6_FIB_TABLE_NON_FWDING].
403 ip6_hash, api_ip6_fib_table_put_entries, &ctx);
405 vec_sort_with_function (ctx.entries, fib_entry_cmp_for_sort);
407 vec_foreach (fib_entry_index, ctx.entries)
409 fib_entry_get_prefix (*fib_entry_index, &pfx);
411 fib_entry_encode (*fib_entry_index, &api_rpaths);
412 send_ip6_fib_details (am, q,
413 fib_table->ft_table_id,
414 &pfx, api_rpaths, mp->context);
415 vec_free (api_rpaths);
418 vec_free (ctx.entries);
422 vl_api_ip6_fib_dump_t_handler (vl_api_ip6_fib_dump_t * mp)
424 unix_shared_memory_queue_t *q;
425 ip6_main_t *im6 = &ip6_main;
426 fib_table_t *fib_table;
428 q = vl_api_client_index_to_input_queue (mp->client_index);
433 pool_foreach (fib_table, im6->fibs,
435 api_ip6_fib_table_get_all(q, mp, fib_table);
441 send_ip_mfib_details (unix_shared_memory_queue_t * q,
442 u32 context, u32 table_id, fib_node_index_t mfei)
444 fib_route_path_encode_t *api_rpath, *api_rpaths = NULL;
445 vl_api_ip_mfib_details_t *mp;
446 mfib_entry_t *mfib_entry;
447 vl_api_fib_path_t *fp;
451 mfib_entry = mfib_entry_get (mfei);
452 mfib_entry_get_prefix (mfei, &pfx);
453 mfib_entry_encode (mfei, &api_rpaths);
455 path_count = vec_len (api_rpaths);
456 mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
459 memset (mp, 0, sizeof (*mp));
460 mp->_vl_msg_id = ntohs (VL_API_IP_FIB_DETAILS);
461 mp->context = context;
463 mp->rpf_id = mfib_entry->mfe_rpf_id;
464 mp->entry_flags = mfib_entry->mfe_flags;
465 mp->table_id = htonl (table_id);
466 mp->address_length = pfx.fp_len;
467 memcpy (mp->grp_address, &pfx.fp_grp_addr.ip4,
468 sizeof (pfx.fp_grp_addr.ip4));
469 memcpy (mp->src_address, &pfx.fp_src_addr.ip4,
470 sizeof (pfx.fp_src_addr.ip4));
472 mp->count = htonl (path_count);
474 vec_foreach (api_rpath, api_rpaths)
476 memset (fp, 0, sizeof (*fp));
479 fp->sw_if_index = htonl (api_rpath->rpath.frp_sw_if_index);
480 copy_fib_next_hop (api_rpath, fp);
483 vec_free (api_rpaths);
485 vl_msg_api_send_shmem (q, (u8 *) & mp);
488 typedef struct vl_api_ip_mfib_dump_ctc_t_
490 fib_node_index_t *entries;
491 } vl_api_ip_mfib_dump_ctc_t;
494 vl_api_ip_mfib_table_dump_walk (fib_node_index_t fei, void *arg)
496 vl_api_ip_mfib_dump_ctc_t *ctx = arg;
498 vec_add1 (ctx->entries, fei);
504 vl_api_ip_mfib_dump_t_handler (vl_api_ip_mfib_dump_t * mp)
506 unix_shared_memory_queue_t *q;
507 ip4_main_t *im = &ip4_main;
508 mfib_table_t *mfib_table;
509 fib_node_index_t *mfeip;
510 vl_api_ip_mfib_dump_ctc_t ctx = {
514 q = vl_api_client_index_to_input_queue (mp->client_index);
520 pool_foreach (mfib_table, im->mfibs,
522 ip4_mfib_table_walk(&mfib_table->v4,
523 vl_api_ip_mfib_table_dump_walk,
526 vec_sort_with_function (ctx.entries, mfib_entry_cmp_for_sort);
528 vec_foreach (mfeip, ctx.entries)
530 send_ip_mfib_details (q, mp->context,
531 mfib_table->mft_table_id,
534 vec_reset_length (ctx.entries);
539 vec_free (ctx.entries);
543 send_ip6_mfib_details (vpe_api_main_t * am,
544 unix_shared_memory_queue_t * q,
547 fib_route_path_encode_t * api_rpaths, u32 context)
549 vl_api_ip6_mfib_details_t *mp;
550 fib_route_path_encode_t *api_rpath;
551 vl_api_fib_path_t *fp;
554 path_count = vec_len (api_rpaths);
555 mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
558 memset (mp, 0, sizeof (*mp));
559 mp->_vl_msg_id = ntohs (VL_API_IP6_FIB_DETAILS);
560 mp->context = context;
562 mp->table_id = htonl (table_id);
563 mp->address_length = pfx->fp_len;
564 memcpy (mp->grp_address, &pfx->fp_grp_addr.ip6,
565 sizeof (pfx->fp_grp_addr.ip6));
566 memcpy (mp->src_address, &pfx->fp_src_addr.ip6,
567 sizeof (pfx->fp_src_addr.ip6));
569 mp->count = htonl (path_count);
571 vec_foreach (api_rpath, api_rpaths)
573 memset (fp, 0, sizeof (*fp));
576 fp->sw_if_index = htonl (api_rpath->rpath.frp_sw_if_index);
577 copy_fib_next_hop (api_rpath, fp);
581 vl_msg_api_send_shmem (q, (u8 *) & mp);
584 typedef struct vl_api_ip6_mfib_dump_ctc_t_
586 fib_node_index_t *entries;
587 } vl_api_ip6_mfib_dump_ctc_t;
590 vl_api_ip6_mfib_table_dump_walk (fib_node_index_t fei, void *arg)
592 vl_api_ip6_mfib_dump_ctc_t *ctx = arg;
594 vec_add1 (ctx->entries, fei);
600 vl_api_ip6_mfib_dump_t_handler (vl_api_ip6_mfib_dump_t * mp)
602 vpe_api_main_t *am = &vpe_api_main;
603 unix_shared_memory_queue_t *q;
604 ip6_main_t *im = &ip6_main;
605 mfib_table_t *mfib_table;
606 fib_node_index_t *mfeip;
608 fib_route_path_encode_t *api_rpaths = NULL;
609 vl_api_ip6_mfib_dump_ctc_t ctx = {
613 q = vl_api_client_index_to_input_queue (mp->client_index);
619 pool_foreach (mfib_table, im->mfibs,
621 ip6_mfib_table_walk(&mfib_table->v6,
622 vl_api_ip6_mfib_table_dump_walk,
625 vec_sort_with_function (ctx.entries, mfib_entry_cmp_for_sort);
627 vec_foreach(mfeip, ctx.entries)
629 mfib_entry_get_prefix (*mfeip, &pfx);
630 mfib_entry_encode (*mfeip, &api_rpaths);
631 send_ip6_mfib_details (am, q,
632 mfib_table->mft_table_id,
636 vec_reset_length (api_rpaths);
637 vec_reset_length (ctx.entries);
642 vec_free (ctx.entries);
643 vec_free (api_rpaths);
647 vl_api_ip_neighbor_add_del_t_handler (vl_api_ip_neighbor_add_del_t * mp,
650 vl_api_ip_neighbor_add_del_reply_t *rmp;
651 vnet_main_t *vnm = vnet_get_main ();
654 VALIDATE_SW_IF_INDEX (mp);
656 stats_dslock_with_hint (1 /* release hint */ , 7 /* tag */ );
659 * there's no validation here of the ND/ARP entry being added.
660 * The expectation is that the FIB will ensure that nothing bad
661 * will come of adding bogus entries.
666 rv = vnet_set_ip6_ethernet_neighbor
667 (vm, ntohl (mp->sw_if_index),
668 (ip6_address_t *) (mp->dst_address),
669 mp->mac_address, sizeof (mp->mac_address), mp->is_static,
672 rv = vnet_unset_ip6_ethernet_neighbor
673 (vm, ntohl (mp->sw_if_index),
674 (ip6_address_t *) (mp->dst_address),
675 mp->mac_address, sizeof (mp->mac_address));
679 ethernet_arp_ip4_over_ethernet_address_t a;
681 clib_memcpy (&a.ethernet, mp->mac_address, 6);
682 clib_memcpy (&a.ip4, mp->dst_address, 4);
685 rv = vnet_arp_set_ip4_over_ethernet (vnm, ntohl (mp->sw_if_index),
690 vnet_arp_unset_ip4_over_ethernet (vnm, ntohl (mp->sw_if_index), &a);
693 BAD_SW_IF_INDEX_LABEL;
696 REPLY_MACRO (VL_API_IP_NEIGHBOR_ADD_DEL_REPLY);
700 add_del_route_t_handler (u8 is_multipath,
708 u32 classify_table_index,
710 u8 is_resolve_attached,
714 const fib_prefix_t * prefix,
715 u8 next_hop_proto_is_ip4,
716 const ip46_address_t * next_hop,
717 u32 next_hop_sw_if_index,
718 u8 next_hop_fib_index,
720 u16 next_hop_preference,
721 mpls_label_t next_hop_via_label,
722 mpls_label_t * next_hop_out_label_stack)
724 vnet_classify_main_t *cm = &vnet_classify_main;
725 fib_route_path_flags_t path_flags = FIB_ROUTE_PATH_FLAG_NONE;
726 fib_route_path_t path = {
727 .frp_proto = (next_hop_proto_is_ip4 ?
728 FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6),
729 .frp_addr = (NULL == next_hop ? zero_addr : *next_hop),
730 .frp_sw_if_index = next_hop_sw_if_index,
731 .frp_fib_index = next_hop_fib_index,
732 .frp_weight = next_hop_weight,
733 .frp_preference = next_hop_preference,
734 .frp_label_stack = next_hop_out_label_stack,
736 fib_route_path_t *paths = NULL;
737 fib_entry_flag_t entry_flags = FIB_ENTRY_FLAG_NONE;
739 if (MPLS_LABEL_INVALID != next_hop_via_label)
741 path.frp_proto = FIB_PROTOCOL_MPLS;
742 path.frp_local_label = next_hop_via_label;
743 path.frp_eos = MPLS_NON_EOS;
746 path_flags |= FIB_ROUTE_PATH_RESOLVE_VIA_HOST;
747 if (is_resolve_attached)
748 path_flags |= FIB_ROUTE_PATH_RESOLVE_VIA_ATTACHED;
750 path_flags |= FIB_ROUTE_PATH_INTF_RX;
752 path_flags |= FIB_ROUTE_PATH_RPF_ID;
754 entry_flags |= FIB_ENTRY_FLAG_MULTICAST;
756 path.frp_flags = path_flags;
760 stats_dslock_with_hint (1 /* release hint */ , 10 /* tag */ );
763 vec_add1 (paths, path);
766 fib_table_entry_path_add2 (fib_index,
768 FIB_SOURCE_API, entry_flags, paths);
770 fib_table_entry_path_remove2 (fib_index,
771 prefix, FIB_SOURCE_API, paths);
778 stats_dslock_with_hint (1 /* release hint */ , 2 /* tag */ );
780 if (is_drop || is_local || is_classify || is_unreach || is_prohibit)
783 * special route types that link directly to the adj
787 dpo_id_t dpo = DPO_INVALID;
790 dproto = fib_proto_to_dpo (prefix->fp_proto);
793 ip_null_dpo_add_and_lock (dproto, IP_NULL_ACTION_NONE, &dpo);
795 receive_dpo_add_or_lock (dproto, ~0, NULL, &dpo);
797 ip_null_dpo_add_and_lock (dproto,
798 IP_NULL_ACTION_SEND_ICMP_UNREACH, &dpo);
799 else if (is_prohibit)
800 ip_null_dpo_add_and_lock (dproto,
801 IP_NULL_ACTION_SEND_ICMP_PROHIBIT,
803 else if (is_classify)
805 if (pool_is_free_index (cm->tables,
806 ntohl (classify_table_index)))
809 return VNET_API_ERROR_NO_SUCH_TABLE;
812 dpo_set (&dpo, DPO_CLASSIFY, dproto,
813 classify_dpo_create (dproto,
814 ntohl (classify_table_index)));
819 return VNET_API_ERROR_NO_SUCH_TABLE;
822 fib_table_entry_special_dpo_update (fib_index,
825 FIB_ENTRY_FLAG_EXCLUSIVE, &dpo);
830 fib_table_entry_special_remove (fib_index, prefix, FIB_SOURCE_API);
837 vec_add1 (paths, path);
838 fib_table_entry_update (fib_index,
839 prefix, FIB_SOURCE_API, entry_flags, paths);
844 fib_table_entry_delete (fib_index, prefix, FIB_SOURCE_API);
853 add_del_route_check (fib_protocol_t table_proto,
855 u32 next_hop_sw_if_index,
856 fib_protocol_t next_hop_table_proto,
857 u32 next_hop_table_id,
858 u8 create_missing_tables,
859 u8 is_rpf_id, u32 * fib_index, u32 * next_hop_fib_index)
861 vnet_main_t *vnm = vnet_get_main ();
863 *fib_index = fib_table_find (table_proto, ntohl (table_id));
864 if (~0 == *fib_index)
866 if (create_missing_tables)
868 *fib_index = fib_table_find_or_create_and_lock (table_proto,
873 /* No such VRF, and we weren't asked to create one */
874 return VNET_API_ERROR_NO_SUCH_FIB;
878 if (!is_rpf_id && ~0 != ntohl (next_hop_sw_if_index))
880 if (pool_is_free_index (vnm->interface_main.sw_interfaces,
881 ntohl (next_hop_sw_if_index)))
883 return VNET_API_ERROR_NO_MATCHING_INTERFACE;
889 *next_hop_fib_index = mfib_table_find (next_hop_table_proto,
890 ntohl (next_hop_table_id));
892 *next_hop_fib_index = fib_table_find (next_hop_table_proto,
893 ntohl (next_hop_table_id));
895 if (~0 == *next_hop_fib_index)
897 if (create_missing_tables)
900 *next_hop_fib_index =
901 mfib_table_find_or_create_and_lock (next_hop_table_proto,
903 (next_hop_table_id));
905 *next_hop_fib_index =
906 fib_table_find_or_create_and_lock (next_hop_table_proto,
908 (next_hop_table_id));
912 /* No such VRF, and we weren't asked to create one */
913 return VNET_API_ERROR_NO_SUCH_FIB;
922 ip4_add_del_route_t_handler (vl_api_ip_add_del_route_t * mp)
924 u32 fib_index, next_hop_fib_index;
925 mpls_label_t *label_stack = NULL;
926 int rv, ii, n_labels;;
928 rv = add_del_route_check (FIB_PROTOCOL_IP4,
930 mp->next_hop_sw_if_index,
932 mp->next_hop_table_id,
933 mp->create_vrf_if_needed, 0,
934 &fib_index, &next_hop_fib_index);
940 .fp_len = mp->dst_address_length,
941 .fp_proto = FIB_PROTOCOL_IP4,
943 clib_memcpy (&pfx.fp_addr.ip4, mp->dst_address, sizeof (pfx.fp_addr.ip4));
946 memset (&nh, 0, sizeof (nh));
947 memcpy (&nh.ip4, mp->next_hop_address, sizeof (nh.ip4));
949 n_labels = mp->next_hop_n_out_labels;
952 else if (1 == n_labels)
953 vec_add1 (label_stack, ntohl (mp->next_hop_out_label_stack[0]));
956 vec_validate (label_stack, n_labels - 1);
957 for (ii = 0; ii < n_labels; ii++)
958 label_stack[ii] = ntohl (mp->next_hop_out_label_stack[ii]);
961 return (add_del_route_t_handler (mp->is_multipath,
968 mp->classify_table_index,
970 mp->is_resolve_attached, 0, 0,
973 ntohl (mp->next_hop_sw_if_index),
976 mp->next_hop_preference,
977 ntohl (mp->next_hop_via_label),
982 ip6_add_del_route_t_handler (vl_api_ip_add_del_route_t * mp)
984 u32 fib_index, next_hop_fib_index;
985 mpls_label_t *label_stack = NULL;
986 int rv, ii, n_labels;;
988 rv = add_del_route_check (FIB_PROTOCOL_IP6,
990 mp->next_hop_sw_if_index,
992 mp->next_hop_table_id,
993 mp->create_vrf_if_needed, 0,
994 &fib_index, &next_hop_fib_index);
1000 .fp_len = mp->dst_address_length,
1001 .fp_proto = FIB_PROTOCOL_IP6,
1003 clib_memcpy (&pfx.fp_addr.ip6, mp->dst_address, sizeof (pfx.fp_addr.ip6));
1006 memset (&nh, 0, sizeof (nh));
1007 memcpy (&nh.ip6, mp->next_hop_address, sizeof (nh.ip6));
1009 n_labels = mp->next_hop_n_out_labels;
1012 else if (1 == n_labels)
1013 vec_add1 (label_stack, ntohl (mp->next_hop_out_label_stack[0]));
1016 vec_validate (label_stack, n_labels - 1);
1017 for (ii = 0; ii < n_labels; ii++)
1018 label_stack[ii] = ntohl (mp->next_hop_out_label_stack[ii]);
1021 return (add_del_route_t_handler (mp->is_multipath,
1028 mp->classify_table_index,
1029 mp->is_resolve_host,
1030 mp->is_resolve_attached, 0, 0,
1032 &nh, ntohl (mp->next_hop_sw_if_index),
1034 mp->next_hop_weight,
1035 mp->next_hop_preference,
1036 ntohl (mp->next_hop_via_label),
1041 vl_api_ip_add_del_route_t_handler (vl_api_ip_add_del_route_t * mp)
1043 vl_api_ip_add_del_route_reply_t *rmp;
1045 vnet_main_t *vnm = vnet_get_main ();
1050 rv = ip6_add_del_route_t_handler (mp);
1052 rv = ip4_add_del_route_t_handler (mp);
1054 rv = (rv == 0) ? vnm->api_errno : rv;
1056 REPLY_MACRO (VL_API_IP_ADD_DEL_ROUTE_REPLY);
1060 add_del_mroute_check (fib_protocol_t table_proto,
1062 u32 next_hop_sw_if_index,
1063 u8 is_local, u8 create_missing_tables, u32 * fib_index)
1065 vnet_main_t *vnm = vnet_get_main ();
1067 *fib_index = mfib_table_find (table_proto, ntohl (table_id));
1068 if (~0 == *fib_index)
1070 if (create_missing_tables)
1072 *fib_index = mfib_table_find_or_create_and_lock (table_proto,
1077 /* No such VRF, and we weren't asked to create one */
1078 return VNET_API_ERROR_NO_SUCH_FIB;
1082 if (~0 != ntohl (next_hop_sw_if_index))
1084 if (pool_is_free_index (vnm->interface_main.sw_interfaces,
1085 ntohl (next_hop_sw_if_index)))
1087 return VNET_API_ERROR_NO_MATCHING_INTERFACE;
1095 mroute_add_del_handler (u8 is_add,
1098 const mfib_prefix_t * prefix,
1100 fib_rpf_id_t rpf_id,
1101 u32 next_hop_sw_if_index, u32 itf_flags)
1103 stats_dslock_with_hint (1 /* release hint */ , 2 /* tag */ );
1105 fib_route_path_t path = {
1106 .frp_sw_if_index = next_hop_sw_if_index,
1107 .frp_proto = prefix->fp_proto,
1111 path.frp_flags |= FIB_ROUTE_PATH_LOCAL;
1114 if (!is_local && ~0 == next_hop_sw_if_index)
1116 mfib_table_entry_update (fib_index, prefix,
1117 MFIB_SOURCE_API, rpf_id, entry_flags);
1123 mfib_table_entry_path_update (fib_index, prefix,
1124 MFIB_SOURCE_API, &path, itf_flags);
1128 mfib_table_entry_path_remove (fib_index, prefix,
1129 MFIB_SOURCE_API, &path);
1138 api_mroute_add_del_t_handler (vl_api_ip_mroute_add_del_t * mp)
1140 fib_protocol_t fproto;
1144 fproto = (mp->is_ipv6 ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4);
1145 rv = add_del_mroute_check (fproto,
1147 mp->next_hop_sw_if_index,
1149 mp->create_vrf_if_needed, &fib_index);
1154 mfib_prefix_t pfx = {
1155 .fp_len = ntohs (mp->grp_address_length),
1159 if (FIB_PROTOCOL_IP4 == fproto)
1161 clib_memcpy (&pfx.fp_grp_addr.ip4, mp->grp_address,
1162 sizeof (pfx.fp_grp_addr.ip4));
1163 clib_memcpy (&pfx.fp_src_addr.ip4, mp->src_address,
1164 sizeof (pfx.fp_src_addr.ip4));
1168 clib_memcpy (&pfx.fp_grp_addr.ip6, mp->grp_address,
1169 sizeof (pfx.fp_grp_addr.ip6));
1170 clib_memcpy (&pfx.fp_src_addr.ip6, mp->src_address,
1171 sizeof (pfx.fp_src_addr.ip6));
1174 return (mroute_add_del_handler (mp->is_add,
1177 ntohl (mp->entry_flags),
1179 ntohl (mp->next_hop_sw_if_index),
1180 ntohl (mp->itf_flags)));
1184 vl_api_ip_mroute_add_del_t_handler (vl_api_ip_mroute_add_del_t * mp)
1186 vl_api_ip_mroute_add_del_reply_t *rmp;
1188 vnet_main_t *vnm = vnet_get_main ();
1192 rv = api_mroute_add_del_t_handler (mp);
1194 rv = (rv == 0) ? vnm->api_errno : rv;
1196 REPLY_MACRO (VL_API_IP_MROUTE_ADD_DEL_REPLY);
1200 send_ip_details (vpe_api_main_t * am,
1201 unix_shared_memory_queue_t * q, u32 sw_if_index,
1202 u8 is_ipv6, u32 context)
1204 vl_api_ip_details_t *mp;
1206 mp = vl_msg_api_alloc (sizeof (*mp));
1207 memset (mp, 0, sizeof (*mp));
1208 mp->_vl_msg_id = ntohs (VL_API_IP_DETAILS);
1210 mp->sw_if_index = ntohl (sw_if_index);
1211 mp->is_ipv6 = is_ipv6;
1212 mp->context = context;
1214 vl_msg_api_send_shmem (q, (u8 *) & mp);
1218 send_ip_address_details (vpe_api_main_t * am,
1219 unix_shared_memory_queue_t * q,
1220 u8 * ip, u16 prefix_length,
1221 u32 sw_if_index, u8 is_ipv6, u32 context)
1223 vl_api_ip_address_details_t *mp;
1225 mp = vl_msg_api_alloc (sizeof (*mp));
1226 memset (mp, 0, sizeof (*mp));
1227 mp->_vl_msg_id = ntohs (VL_API_IP_ADDRESS_DETAILS);
1231 clib_memcpy (&mp->ip, ip, sizeof (mp->ip));
1235 u32 *tp = (u32 *) mp->ip;
1238 mp->prefix_length = prefix_length;
1239 mp->context = context;
1240 mp->sw_if_index = htonl (sw_if_index);
1241 mp->is_ipv6 = is_ipv6;
1243 vl_msg_api_send_shmem (q, (u8 *) & mp);
1247 vl_api_ip_address_dump_t_handler (vl_api_ip_address_dump_t * mp)
1249 vpe_api_main_t *am = &vpe_api_main;
1250 unix_shared_memory_queue_t *q;
1253 ip6_main_t *im6 = &ip6_main;
1254 ip4_main_t *im4 = &ip4_main;
1255 ip_lookup_main_t *lm6 = &im6->lookup_main;
1256 ip_lookup_main_t *lm4 = &im4->lookup_main;
1257 ip_interface_address_t *ia = 0;
1258 u32 sw_if_index = ~0;
1259 int rv __attribute__ ((unused)) = 0;
1261 VALIDATE_SW_IF_INDEX (mp);
1263 sw_if_index = ntohl (mp->sw_if_index);
1265 q = vl_api_client_index_to_input_queue (mp->client_index);
1272 foreach_ip_interface_address (lm6, ia, sw_if_index,
1273 1 /* honor unnumbered */,
1275 r6 = ip_interface_address_get_address (lm6, ia);
1276 u16 prefix_length = ia->address_length;
1277 send_ip_address_details(am, q, (u8*)r6, prefix_length,
1278 sw_if_index, 1, mp->context);
1285 foreach_ip_interface_address (lm4, ia, sw_if_index,
1286 1 /* honor unnumbered */,
1288 r4 = ip_interface_address_get_address (lm4, ia);
1289 u16 prefix_length = ia->address_length;
1290 send_ip_address_details(am, q, (u8*)r4, prefix_length,
1291 sw_if_index, 0, mp->context);
1295 BAD_SW_IF_INDEX_LABEL;
1299 vl_api_ip_dump_t_handler (vl_api_ip_dump_t * mp)
1301 vpe_api_main_t *am = &vpe_api_main;
1302 vnet_main_t *vnm = vnet_get_main ();
1303 vlib_main_t *vm = vlib_get_main ();
1304 vnet_interface_main_t *im = &vnm->interface_main;
1305 unix_shared_memory_queue_t *q;
1306 vnet_sw_interface_t *si, *sorted_sis;
1307 u32 sw_if_index = ~0;
1309 q = vl_api_client_index_to_input_queue (mp->client_index);
1315 /* Gather interfaces. */
1316 sorted_sis = vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
1317 _vec_len (sorted_sis) = 0;
1319 pool_foreach (si, im->sw_interfaces,
1321 vec_add1 (sorted_sis, si[0]);
1325 vec_foreach (si, sorted_sis)
1327 if (!(si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED))
1329 if (mp->is_ipv6 && !ip6_interface_enabled (vm, si->sw_if_index))
1333 sw_if_index = si->sw_if_index;
1334 send_ip_details (am, q, sw_if_index, mp->is_ipv6, mp->context);
1340 set_ip6_flow_hash (vl_api_set_ip_flow_hash_t * mp)
1342 vl_api_set_ip_flow_hash_reply_t *rmp;
1345 flow_hash_config_t flow_hash_config = 0;
1347 table_id = ntohl (mp->vrf_id);
1349 #define _(a,b) if (mp->a) flow_hash_config |= b;
1350 foreach_flow_hash_bit;
1353 rv = vnet_set_ip6_flow_hash (table_id, flow_hash_config);
1355 REPLY_MACRO (VL_API_SET_IP_FLOW_HASH_REPLY);
1359 set_ip4_flow_hash (vl_api_set_ip_flow_hash_t * mp)
1361 vl_api_set_ip_flow_hash_reply_t *rmp;
1364 flow_hash_config_t flow_hash_config = 0;
1366 table_id = ntohl (mp->vrf_id);
1368 #define _(a,b) if (mp->a) flow_hash_config |= b;
1369 foreach_flow_hash_bit;
1372 rv = vnet_set_ip4_flow_hash (table_id, flow_hash_config);
1374 REPLY_MACRO (VL_API_SET_IP_FLOW_HASH_REPLY);
1379 vl_api_set_ip_flow_hash_t_handler (vl_api_set_ip_flow_hash_t * mp)
1381 if (mp->is_ipv6 == 0)
1382 set_ip4_flow_hash (mp);
1384 set_ip6_flow_hash (mp);
1388 vl_api_sw_interface_ip6nd_ra_config_t_handler
1389 (vl_api_sw_interface_ip6nd_ra_config_t * mp)
1391 vl_api_sw_interface_ip6nd_ra_config_reply_t *rmp;
1392 vlib_main_t *vm = vlib_get_main ();
1394 u8 is_no, suppress, managed, other, ll_option, send_unicast, cease,
1397 is_no = mp->is_no == 1;
1398 suppress = mp->suppress == 1;
1399 managed = mp->managed == 1;
1400 other = mp->other == 1;
1401 ll_option = mp->ll_option == 1;
1402 send_unicast = mp->send_unicast == 1;
1403 cease = mp->cease == 1;
1404 default_router = mp->default_router == 1;
1406 VALIDATE_SW_IF_INDEX (mp);
1408 rv = ip6_neighbor_ra_config (vm, ntohl (mp->sw_if_index),
1409 suppress, managed, other,
1410 ll_option, send_unicast, cease,
1411 default_router, ntohl (mp->lifetime),
1412 ntohl (mp->initial_count),
1413 ntohl (mp->initial_interval),
1414 ntohl (mp->max_interval),
1415 ntohl (mp->min_interval), is_no);
1417 BAD_SW_IF_INDEX_LABEL;
1419 REPLY_MACRO (VL_API_SW_INTERFACE_IP6ND_RA_CONFIG_REPLY);
1423 vl_api_sw_interface_ip6nd_ra_prefix_t_handler
1424 (vl_api_sw_interface_ip6nd_ra_prefix_t * mp)
1426 vlib_main_t *vm = vlib_get_main ();
1427 vl_api_sw_interface_ip6nd_ra_prefix_reply_t *rmp;
1429 u8 is_no, use_default, no_advertise, off_link, no_autoconfig, no_onlink;
1431 VALIDATE_SW_IF_INDEX (mp);
1433 is_no = mp->is_no == 1;
1434 use_default = mp->use_default == 1;
1435 no_advertise = mp->no_advertise == 1;
1436 off_link = mp->off_link == 1;
1437 no_autoconfig = mp->no_autoconfig == 1;
1438 no_onlink = mp->no_onlink == 1;
1440 rv = ip6_neighbor_ra_prefix (vm, ntohl (mp->sw_if_index),
1441 (ip6_address_t *) mp->address,
1442 mp->address_length, use_default,
1443 ntohl (mp->val_lifetime),
1444 ntohl (mp->pref_lifetime), no_advertise,
1445 off_link, no_autoconfig, no_onlink, is_no);
1447 BAD_SW_IF_INDEX_LABEL;
1448 REPLY_MACRO (VL_API_SW_INTERFACE_IP6ND_RA_PREFIX_REPLY);
1452 send_ip6nd_proxy_details (unix_shared_memory_queue_t * q,
1454 const ip46_address_t * addr, u32 sw_if_index)
1456 vl_api_ip6nd_proxy_details_t *mp;
1458 mp = vl_msg_api_alloc (sizeof (*mp));
1459 memset (mp, 0, sizeof (*mp));
1460 mp->_vl_msg_id = ntohs (VL_API_IP6ND_PROXY_DETAILS);
1461 mp->context = context;
1462 mp->sw_if_index = htonl (sw_if_index);
1463 memcpy (mp->address, addr, 16);
1465 vl_msg_api_send_shmem (q, (u8 *) & mp);
1468 typedef struct api_ip6nd_proxy_fib_table_walk_ctx_t_
1471 } api_ip6nd_proxy_fib_table_walk_ctx_t;
1474 api_ip6nd_proxy_fib_table_walk (fib_node_index_t fei, void *arg)
1476 api_ip6nd_proxy_fib_table_walk_ctx_t *ctx = arg;
1478 if (fib_entry_is_sourced (fei, FIB_SOURCE_IP6_ND_PROXY))
1480 vec_add1 (ctx->indices, fei);
1487 vl_api_ip6nd_proxy_dump_t_handler (vl_api_ip6nd_proxy_dump_t * mp)
1489 ip6_main_t *im6 = &ip6_main;
1490 fib_table_t *fib_table;
1491 api_ip6nd_proxy_fib_table_walk_ctx_t ctx = {
1494 fib_node_index_t *feip;
1496 unix_shared_memory_queue_t *q;
1498 q = vl_api_client_index_to_input_queue (mp->client_index);
1505 pool_foreach (fib_table, im6->fibs,
1507 fib_table_walk(fib_table->ft_index,
1509 api_ip6nd_proxy_fib_table_walk,
1514 vec_sort_with_function (ctx.indices, fib_entry_cmp_for_sort);
1516 vec_foreach (feip, ctx.indices)
1518 fib_entry_get_prefix (*feip, &pfx);
1520 send_ip6nd_proxy_details (q,
1523 fib_entry_get_resolving_interface (*feip));
1526 vec_free (ctx.indices);
1530 vl_api_ip6nd_proxy_add_del_t_handler (vl_api_ip6nd_proxy_add_del_t * mp)
1532 vl_api_ip6nd_proxy_add_del_reply_t *rmp;
1535 VALIDATE_SW_IF_INDEX (mp);
1537 rv = ip6_neighbor_proxy_add_del (ntohl (mp->sw_if_index),
1538 (ip6_address_t *) mp->address, mp->is_del);
1540 BAD_SW_IF_INDEX_LABEL;
1541 REPLY_MACRO (VL_API_IP6ND_PROXY_ADD_DEL_REPLY);
1545 vl_api_sw_interface_ip6_enable_disable_t_handler
1546 (vl_api_sw_interface_ip6_enable_disable_t * mp)
1548 vlib_main_t *vm = vlib_get_main ();
1549 vl_api_sw_interface_ip6_enable_disable_reply_t *rmp;
1550 vnet_main_t *vnm = vnet_get_main ();
1552 clib_error_t *error;
1556 VALIDATE_SW_IF_INDEX (mp);
1559 (mp->enable == 1) ? enable_ip6_interface (vm,
1560 ntohl (mp->sw_if_index)) :
1561 disable_ip6_interface (vm, ntohl (mp->sw_if_index));
1565 clib_error_report (error);
1566 rv = VNET_API_ERROR_UNSPECIFIED;
1570 rv = vnm->api_errno;
1573 BAD_SW_IF_INDEX_LABEL;
1575 REPLY_MACRO (VL_API_SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY);
1579 vl_api_sw_interface_ip6_set_link_local_address_t_handler
1580 (vl_api_sw_interface_ip6_set_link_local_address_t * mp)
1582 vlib_main_t *vm = vlib_get_main ();
1583 vl_api_sw_interface_ip6_set_link_local_address_reply_t *rmp;
1585 clib_error_t *error;
1586 vnet_main_t *vnm = vnet_get_main ();
1590 VALIDATE_SW_IF_INDEX (mp);
1592 error = set_ip6_link_local_address (vm,
1593 ntohl (mp->sw_if_index),
1594 (ip6_address_t *) mp->address);
1597 clib_error_report (error);
1598 rv = VNET_API_ERROR_UNSPECIFIED;
1602 rv = vnm->api_errno;
1605 BAD_SW_IF_INDEX_LABEL;
1607 REPLY_MACRO (VL_API_SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY);
1611 vl_mfib_signal_send_one (unix_shared_memory_queue_t * q,
1612 u32 context, const mfib_signal_t * mfs)
1614 vl_api_mfib_signal_details_t *mp;
1615 mfib_prefix_t prefix;
1619 mp = vl_msg_api_alloc (sizeof (*mp));
1621 memset (mp, 0, sizeof (*mp));
1622 mp->_vl_msg_id = ntohs (VL_API_MFIB_SIGNAL_DETAILS);
1623 mp->context = context;
1625 mfi = mfib_itf_get (mfs->mfs_itf);
1626 mfib_entry_get_prefix (mfs->mfs_entry, &prefix);
1627 mfib = mfib_table_get (mfib_entry_get_fib_index (mfs->mfs_entry),
1629 mp->table_id = ntohl (mfib->mft_table_id);
1630 mp->sw_if_index = ntohl (mfi->mfi_sw_if_index);
1632 if (FIB_PROTOCOL_IP4 == prefix.fp_proto)
1634 mp->grp_address_len = ntohs (prefix.fp_len);
1636 memcpy (mp->grp_address, &prefix.fp_grp_addr.ip4, 4);
1637 if (prefix.fp_len > 32)
1639 memcpy (mp->src_address, &prefix.fp_src_addr.ip4, 4);
1644 mp->grp_address_len = ntohs (prefix.fp_len);
1649 if (0 != mfs->mfs_buffer_len)
1651 mp->ip_packet_len = ntohs (mfs->mfs_buffer_len);
1653 memcpy (mp->ip_packet_data, mfs->mfs_buffer, mfs->mfs_buffer_len);
1657 mp->ip_packet_len = 0;
1660 vl_msg_api_send_shmem (q, (u8 *) & mp);
1664 vl_api_mfib_signal_dump_t_handler (vl_api_mfib_signal_dump_t * mp)
1666 unix_shared_memory_queue_t *q;
1668 q = vl_api_client_index_to_input_queue (mp->client_index);
1674 while (q->cursize < q->maxsize && mfib_signal_send_one (q, mp->context))
1678 #define vl_msg_name_crc_list
1679 #include <vnet/ip/ip.api.h>
1680 #undef vl_msg_name_crc_list
1683 setup_message_id_table (api_main_t * am)
1685 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
1686 foreach_vl_msg_name_crc_ip;
1690 static clib_error_t *
1691 ip_api_hookup (vlib_main_t * vm)
1693 api_main_t *am = &api_main;
1696 vl_msg_api_set_handlers(VL_API_##N, #n, \
1697 vl_api_##n##_t_handler, \
1699 vl_api_##n##_t_endian, \
1700 vl_api_##n##_t_print, \
1701 sizeof(vl_api_##n##_t), 1);
1706 * Set up the (msg_name, crc, message-id) table
1708 setup_message_id_table (am);
1713 VLIB_API_INIT_FUNCTION (ip_api_hookup);
1716 * fd.io coding-style-patch-verification: ON
1719 * eval: (c-set-style "gnu")