2 *------------------------------------------------------------------
3 * api.c - message handler registration
5 * Copyright (c) 2010-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 *------------------------------------------------------------------
23 #include <sys/types.h>
26 #include <netinet/in.h>
36 #include <vppinfra/clib.h>
37 #include <vppinfra/vec.h>
38 #include <vppinfra/hash.h>
39 #include <vppinfra/bitmap.h>
40 #include <vppinfra/fifo.h>
41 #include <vppinfra/time.h>
42 #include <vppinfra/mheap.h>
43 #include <vppinfra/heap.h>
44 #include <vppinfra/pool.h>
45 #include <vppinfra/format.h>
46 #include <vppinfra/error.h>
48 #include <vnet/api_errno.h>
49 #include <vnet/vnet.h>
50 #include <vnet/l2/l2_input.h>
51 #include <vnet/l2/l2_bd.h>
52 #include <vnet/ip/ip.h>
53 #include <vnet/ip/ip6.h>
54 #include <vnet/ip/ip6_neighbor.h>
56 #include <vnet/srv6/sr.h>
58 #include <vlib/vlib.h>
59 #include <vlib/unix/unix.h>
60 #include <vlibapi/api.h>
61 #include <vlibmemory/api.h>
62 #include <vnet/classify/input_acl.h>
63 #include <vnet/l2/l2_classify.h>
64 #include <vnet/map/map.h>
65 #include <vnet/ip/ip6_hop_by_hop.h>
66 #include <vnet/ip/ip_source_and_port_range_check.h>
67 #include <vnet/ip/punt.h>
68 #include <vnet/feature/feature.h>
71 #undef __included_bihash_template_h__
72 #include <vnet/l2/l2_fib.h>
74 #include <vpp/stats/stats.h>
75 #include <vpp/oam/oam.h>
77 #include <vnet/ethernet/ethernet.h>
78 #include <vnet/ethernet/arp_packet.h>
79 #include <vnet/interface.h>
80 #include <vnet/l2/l2_fib.h>
81 #include <vnet/l2/l2_bd.h>
82 #include <vpp/api/vpe_msg_enum.h>
83 #include <vnet/span/span.h>
84 #include <vnet/fib/fib_api.h>
85 #include <vnet/dpo/drop_dpo.h>
86 #include <vnet/dpo/receive_dpo.h>
87 #include <vnet/dpo/lookup_dpo.h>
88 #include <vnet/dpo/classify_dpo.h>
89 #include <vnet/dpo/ip_null_dpo.h>
90 #define vl_typedefs /* define message structures */
91 #include <vpp/api/vpe_all_api_h.h>
93 #define vl_endianfun /* define message structures */
94 #include <vpp/api/vpe_all_api_h.h>
96 /* instantiate all the print functions we know about */
97 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
99 #include <vpp/api/vpe_all_api_h.h>
101 #include <vlibapi/api_helper_macros.h>
102 #define foreach_vpe_api_msg \
103 _(WANT_OAM_EVENTS, want_oam_events) \
104 _(OAM_ADD_DEL, oam_add_del) \
105 _(SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable) \
106 _(SW_INTERFACE_SET_VPATH, sw_interface_set_vpath) \
107 _(SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect) \
108 _(SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge) \
109 _(CREATE_VLAN_SUBIF, create_vlan_subif) \
110 _(CREATE_SUBIF, create_subif) \
111 _(PROXY_ARP_ADD_DEL, proxy_arp_add_del) \
112 _(PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable) \
113 _(VNET_GET_SUMMARY_STATS, vnet_get_summary_stats) \
114 _(RESET_FIB, reset_fib) \
115 _(CREATE_LOOPBACK, create_loopback) \
116 _(CREATE_LOOPBACK_INSTANCE, create_loopback_instance) \
117 _(CONTROL_PING, control_ping) \
119 _(CLI_INBAND, cli_inband) \
120 _(SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit) \
121 _(L2_PATCH_ADD_DEL, l2_patch_add_del) \
122 _(CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table) \
123 _(CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables) \
124 _(GET_NODE_INDEX, get_node_index) \
125 _(ADD_NODE_NEXT, add_node_next) \
126 _(L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter) \
127 _(SHOW_VERSION, show_version) \
128 _(INTERFACE_NAME_RENUMBER, interface_name_renumber) \
129 _(WANT_IP4_ARP_EVENTS, want_ip4_arp_events) \
130 _(WANT_IP6_ND_EVENTS, want_ip6_nd_events) \
131 _(INPUT_ACL_SET_INTERFACE, input_acl_set_interface) \
132 _(DELETE_LOOPBACK, delete_loopback) \
133 _(BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del) \
134 _(GET_NODE_GRAPH, get_node_graph) \
135 _(IOAM_ENABLE, ioam_enable) \
136 _(IOAM_DISABLE, ioam_disable) \
137 _(GET_NEXT_INDEX, get_next_index) \
138 _(PG_CREATE_INTERFACE, pg_create_interface) \
139 _(PG_CAPTURE, pg_capture) \
140 _(PG_ENABLE_DISABLE, pg_enable_disable) \
141 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, \
142 ip_source_and_port_range_check_add_del) \
143 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, \
144 ip_source_and_port_range_check_interface_add_del) \
145 _(DELETE_SUBIF, delete_subif) \
147 _(PUNT_SOCKET_REGISTER, punt_socket_register) \
148 _(PUNT_SOCKET_DEREGISTER, punt_socket_deregister) \
149 _(FEATURE_ENABLE_DISABLE, feature_enable_disable)
152 #define QUOTE(x) QUOTE_(x)
155 RESOLVE_IP4_ADD_DEL_ROUTE = 1,
156 RESOLVE_IP6_ADD_DEL_ROUTE,
159 static vlib_node_registration_t vpe_resolver_process_node;
160 extern vpe_api_main_t vpe_api_main;
162 static int arp_change_delete_callback (u32 pool_index, u8 * notused);
163 static int nd_change_delete_callback (u32 pool_index, u8 * notused);
165 /* Clean up all registrations belonging to the indicated client */
166 static clib_error_t *
167 memclnt_delete_callback (u32 client_index)
169 vpe_api_main_t *vam = &vpe_api_main;
170 vpe_client_registration_t *rp;
172 int stats_memclnt_delete_callback (u32 client_index);
174 stats_memclnt_delete_callback (client_index);
177 p = hash_get (vam->a##_registration_hash, client_index); \
179 rp = pool_elt_at_index (vam->a##_registrations, p[0]); \
180 pool_put (vam->a##_registrations, rp); \
181 hash_unset (vam->a##_registration_hash, client_index); \
183 foreach_registration_hash;
188 VL_MSG_API_REAPER_FUNCTION (memclnt_delete_callback);
190 pub_sub_handler (oam_events, OAM_EVENTS);
192 #define RESOLUTION_EVENT 1
193 #define RESOLUTION_PENDING_EVENT 2
194 #define IP4_ARP_EVENT 3
195 #define IP6_ND_EVENT 4
197 int ip4_add_del_route_t_handler (vl_api_ip_add_del_route_t * mp);
199 int ip6_add_del_route_t_handler (vl_api_ip_add_del_route_t * mp);
202 handle_ip4_arp_event (u32 pool_index)
204 vpe_api_main_t *vam = &vpe_api_main;
205 vnet_main_t *vnm = vam->vnet_main;
206 vlib_main_t *vm = vam->vlib_main;
207 vl_api_ip4_arp_event_t *event;
208 vl_api_ip4_arp_event_t *mp;
209 unix_shared_memory_queue_t *q;
211 /* Client can cancel, die, etc. */
212 if (pool_is_free_index (vam->arp_events, pool_index))
215 event = pool_elt_at_index (vam->arp_events, pool_index);
217 q = vl_api_client_index_to_input_queue (event->client_index);
220 (void) vnet_add_del_ip4_arp_change_event
221 (vnm, arp_change_delete_callback,
222 event->pid, &event->address,
223 vpe_resolver_process_node.index, IP4_ARP_EVENT,
224 ~0 /* pool index, notused */ , 0 /* is_add */ );
228 if (q->cursize < q->maxsize)
230 mp = vl_msg_api_alloc (sizeof (*mp));
231 clib_memcpy (mp, event, sizeof (*mp));
232 vl_msg_api_send_shmem (q, (u8 *) & mp);
236 static f64 last_time;
238 * Throttle syslog msgs.
239 * It's pretty tempting to just revoke the registration...
241 if (vlib_time_now (vm) > last_time + 10.0)
243 clib_warning ("arp event for %U to pid %d: queue stuffed!",
244 format_ip4_address, &event->address, event->pid);
245 last_time = vlib_time_now (vm);
251 handle_ip6_nd_event (u32 pool_index)
253 vpe_api_main_t *vam = &vpe_api_main;
254 vnet_main_t *vnm = vam->vnet_main;
255 vlib_main_t *vm = vam->vlib_main;
256 vl_api_ip6_nd_event_t *event;
257 vl_api_ip6_nd_event_t *mp;
258 unix_shared_memory_queue_t *q;
260 /* Client can cancel, die, etc. */
261 if (pool_is_free_index (vam->nd_events, pool_index))
264 event = pool_elt_at_index (vam->nd_events, pool_index);
266 q = vl_api_client_index_to_input_queue (event->client_index);
269 (void) vnet_add_del_ip6_nd_change_event
270 (vnm, nd_change_delete_callback,
271 event->pid, &event->address,
272 vpe_resolver_process_node.index, IP6_ND_EVENT,
273 ~0 /* pool index, notused */ , 0 /* is_add */ );
277 if (q->cursize < q->maxsize)
279 mp = vl_msg_api_alloc (sizeof (*mp));
280 clib_memcpy (mp, event, sizeof (*mp));
281 vl_msg_api_send_shmem (q, (u8 *) & mp);
285 static f64 last_time;
287 * Throttle syslog msgs.
288 * It's pretty tempting to just revoke the registration...
290 if (vlib_time_now (vm) > last_time + 10.0)
292 clib_warning ("ip6 nd event for %U to pid %d: queue stuffed!",
293 format_ip6_address, &event->address, event->pid);
294 last_time = vlib_time_now (vm);
300 resolver_process (vlib_main_t * vm,
301 vlib_node_runtime_t * rt, vlib_frame_t * f)
304 uword *event_data = 0;
310 vlib_process_wait_for_event_or_clock (vm, timeout);
312 event_type = vlib_process_get_events (vm, &event_data);
316 case RESOLUTION_PENDING_EVENT:
320 case RESOLUTION_EVENT:
321 clib_warning ("resolver: BOGUS TYPE");
325 for (i = 0; i < vec_len (event_data); i++)
326 handle_ip4_arp_event (event_data[i]);
330 for (i = 0; i < vec_len (event_data); i++)
331 handle_ip6_nd_event (event_data[i]);
334 case ~0: /* timeout */
338 vec_reset_length (event_data);
340 return 0; /* or not */
344 VLIB_REGISTER_NODE (vpe_resolver_process_node,static) = {
345 .function = resolver_process,
346 .type = VLIB_NODE_TYPE_PROCESS,
347 .name = "vpe-route-resolver-process",
352 vl_api_sw_interface_set_vpath_t_handler (vl_api_sw_interface_set_vpath_t * mp)
354 vl_api_sw_interface_set_vpath_reply_t *rmp;
356 u32 sw_if_index = ntohl (mp->sw_if_index);
358 VALIDATE_SW_IF_INDEX (mp);
360 l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_VPATH, mp->enable);
361 vnet_feature_enable_disable ("ip4-unicast", "vpath-input-ip4",
362 sw_if_index, mp->enable, 0, 0);
363 vnet_feature_enable_disable ("ip4-multicast", "vpath-input-ip4",
364 sw_if_index, mp->enable, 0, 0);
365 vnet_feature_enable_disable ("ip6-unicast", "vpath-input-ip6",
366 sw_if_index, mp->enable, 0, 0);
367 vnet_feature_enable_disable ("ip6-multicast", "vpath-input-ip6",
368 sw_if_index, mp->enable, 0, 0);
370 BAD_SW_IF_INDEX_LABEL;
372 REPLY_MACRO (VL_API_SW_INTERFACE_SET_VPATH_REPLY);
376 vl_api_sw_interface_set_l2_xconnect_t_handler
377 (vl_api_sw_interface_set_l2_xconnect_t * mp)
379 vl_api_sw_interface_set_l2_xconnect_reply_t *rmp;
381 u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index);
382 u32 tx_sw_if_index = ntohl (mp->tx_sw_if_index);
383 vlib_main_t *vm = vlib_get_main ();
384 vnet_main_t *vnm = vnet_get_main ();
386 VALIDATE_RX_SW_IF_INDEX (mp);
390 VALIDATE_TX_SW_IF_INDEX (mp);
391 rv = set_int_l2_mode (vm, vnm, MODE_L2_XC,
392 rx_sw_if_index, 0, 0, 0, tx_sw_if_index);
396 rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, 0, 0, 0);
399 BAD_RX_SW_IF_INDEX_LABEL;
400 BAD_TX_SW_IF_INDEX_LABEL;
402 REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_XCONNECT_REPLY);
406 vl_api_sw_interface_set_l2_bridge_t_handler
407 (vl_api_sw_interface_set_l2_bridge_t * mp)
409 bd_main_t *bdm = &bd_main;
410 vl_api_sw_interface_set_l2_bridge_reply_t *rmp;
412 vlib_main_t *vm = vlib_get_main ();
413 vnet_main_t *vnm = vnet_get_main ();
415 VALIDATE_RX_SW_IF_INDEX (mp);
416 u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index);
422 u32 bd_id = ntohl (mp->bd_id);
423 u32 bd_index = bd_find_or_add_bd_index (bdm, bd_id);
426 rv = set_int_l2_mode (vm, vnm, MODE_L2_BRIDGE,
427 rx_sw_if_index, bd_index, bvi, shg, 0);
431 rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, 0, 0, 0);
434 BAD_RX_SW_IF_INDEX_LABEL;
437 REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_BRIDGE_REPLY);
441 vl_api_bd_ip_mac_add_del_t_handler (vl_api_bd_ip_mac_add_del_t * mp)
443 bd_main_t *bdm = &bd_main;
444 vl_api_bd_ip_mac_add_del_reply_t *rmp;
446 u32 bd_id = ntohl (mp->bd_id);
452 rv = VNET_API_ERROR_BD_NOT_MODIFIABLE;
456 p = hash_get (bdm->bd_index_by_bd_id, bd_id);
459 rv = VNET_API_ERROR_NO_SUCH_ENTRY;
464 if (bd_add_del_ip_mac (bd_index, mp->ip_address,
465 mp->mac_address, mp->is_ipv6, mp->is_add))
466 rv = VNET_API_ERROR_UNSPECIFIED;
469 REPLY_MACRO (VL_API_BD_IP_MAC_ADD_DEL_REPLY);
473 vl_api_create_vlan_subif_t_handler (vl_api_create_vlan_subif_t * mp)
475 vl_api_create_vlan_subif_reply_t *rmp;
476 vnet_main_t *vnm = vnet_get_main ();
477 u32 sw_if_index = (u32) ~ 0;
478 vnet_hw_interface_t *hi;
481 vnet_sw_interface_t template;
483 vnet_interface_main_t *im = &vnm->interface_main;
485 unix_shared_memory_queue_t *q;
488 VALIDATE_SW_IF_INDEX (mp);
490 hi = vnet_get_sup_hw_interface (vnm, ntohl (mp->sw_if_index));
492 if (hi->bond_info == VNET_HW_INTERFACE_BOND_INFO_SLAVE)
494 rv = VNET_API_ERROR_BOND_SLAVE_NOT_ALLOWED;
498 id = ntohl (mp->vlan_id);
499 if (id == 0 || id > 4095)
501 rv = VNET_API_ERROR_INVALID_VLAN;
505 sup_and_sub_key = ((u64) (hi->sw_if_index) << 32) | (u64) id;
507 p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
510 rv = VNET_API_ERROR_VLAN_ALREADY_EXISTS;
514 memset (&template, 0, sizeof (template));
515 template.type = VNET_SW_INTERFACE_TYPE_SUB;
516 template.sup_sw_if_index = hi->sw_if_index;
517 template.sub.id = id;
518 template.sub.eth.raw_flags = 0;
519 template.sub.eth.flags.one_tag = 1;
520 template.sub.eth.outer_vlan_id = id;
521 template.sub.eth.flags.exact_match = 1;
523 error = vnet_create_sw_interface (vnm, &template, &sw_if_index);
526 clib_error_report (error);
527 rv = VNET_API_ERROR_INVALID_REGISTRATION;
531 u64 *kp = clib_mem_alloc (sizeof (*kp));
532 *kp = sup_and_sub_key;
534 hash_set (hi->sub_interface_sw_if_index_by_id, id, sw_if_index);
535 hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index);
537 BAD_SW_IF_INDEX_LABEL;
540 q = vl_api_client_index_to_input_queue (mp->client_index);
544 rmp = vl_msg_api_alloc (sizeof (*rmp));
545 rmp->_vl_msg_id = htons (VL_API_CREATE_VLAN_SUBIF_REPLY);
546 rmp->context = mp->context;
547 rmp->retval = htonl (rv);
548 rmp->sw_if_index = htonl (sw_if_index);
549 vl_msg_api_send_shmem (q, (u8 *) & rmp);
553 vl_api_create_subif_t_handler (vl_api_create_subif_t * mp)
555 vl_api_create_subif_reply_t *rmp;
556 vnet_main_t *vnm = vnet_get_main ();
557 u32 sw_if_index = ~0;
560 vnet_sw_interface_t *si;
561 vnet_hw_interface_t *hi;
562 vnet_sw_interface_t template;
564 vnet_interface_main_t *im = &vnm->interface_main;
568 VALIDATE_SW_IF_INDEX (mp);
570 si = vnet_get_sup_sw_interface (vnm, ntohl (mp->sw_if_index));
571 hi = vnet_get_sup_hw_interface (vnm, ntohl (mp->sw_if_index));
573 if (hi->bond_info == VNET_HW_INTERFACE_BOND_INFO_SLAVE)
575 rv = VNET_API_ERROR_BOND_SLAVE_NOT_ALLOWED;
579 sw_if_index = si->sw_if_index;
580 sub_id = ntohl (mp->sub_id);
582 sup_and_sub_key = ((u64) (sw_if_index) << 32) | (u64) sub_id;
584 p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
588 clib_warning ("sup sw_if_index %d, sub id %d already exists\n",
589 sw_if_index, sub_id);
590 rv = VNET_API_ERROR_SUBIF_ALREADY_EXISTS;
594 memset (&template, 0, sizeof (template));
595 template.type = VNET_SW_INTERFACE_TYPE_SUB;
596 template.sup_sw_if_index = sw_if_index;
597 template.sub.id = sub_id;
598 template.sub.eth.flags.no_tags = mp->no_tags;
599 template.sub.eth.flags.one_tag = mp->one_tag;
600 template.sub.eth.flags.two_tags = mp->two_tags;
601 template.sub.eth.flags.dot1ad = mp->dot1ad;
602 template.sub.eth.flags.exact_match = mp->exact_match;
603 template.sub.eth.flags.default_sub = mp->default_sub;
604 template.sub.eth.flags.outer_vlan_id_any = mp->outer_vlan_id_any;
605 template.sub.eth.flags.inner_vlan_id_any = mp->inner_vlan_id_any;
606 template.sub.eth.outer_vlan_id = ntohs (mp->outer_vlan_id);
607 template.sub.eth.inner_vlan_id = ntohs (mp->inner_vlan_id);
609 error = vnet_create_sw_interface (vnm, &template, &sw_if_index);
612 clib_error_report (error);
613 rv = VNET_API_ERROR_SUBIF_CREATE_FAILED;
617 u64 *kp = clib_mem_alloc (sizeof (*kp));
618 *kp = sup_and_sub_key;
620 hash_set (hi->sub_interface_sw_if_index_by_id, sub_id, sw_if_index);
621 hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index);
623 BAD_SW_IF_INDEX_LABEL;
628 REPLY_MACRO2(VL_API_CREATE_SUBIF_REPLY,
630 rmp->sw_if_index = ntohl(sw_if_index);
636 vl_api_proxy_arp_add_del_t_handler (vl_api_proxy_arp_add_del_t * mp)
638 vl_api_proxy_arp_add_del_reply_t *rmp;
641 ip4_main_t *im = &ip4_main;
642 stats_main_t *sm = &stats_main;
643 int vnet_proxy_arp_add_del (ip4_address_t * lo_addr,
644 ip4_address_t * hi_addr,
645 u32 fib_index, int is_del);
648 dslock (sm, 1 /* release hint */ , 6 /* tag */ );
650 p = hash_get (im->fib_index_by_table_id, ntohl (mp->vrf_id));
654 rv = VNET_API_ERROR_NO_SUCH_FIB;
660 rv = vnet_proxy_arp_add_del ((ip4_address_t *) mp->low_address,
661 (ip4_address_t *) mp->hi_address,
662 fib_index, mp->is_add == 0);
666 REPLY_MACRO (VL_API_PROXY_ARP_ADD_DEL_REPLY);
670 vl_api_proxy_arp_intfc_enable_disable_t_handler
671 (vl_api_proxy_arp_intfc_enable_disable_t * mp)
674 vnet_main_t *vnm = vnet_get_main ();
675 vl_api_proxy_arp_intfc_enable_disable_reply_t *rmp;
677 VALIDATE_SW_IF_INDEX (mp);
679 vnet_sw_interface_t *si =
680 vnet_get_sw_interface (vnm, ntohl (mp->sw_if_index));
684 if (mp->enable_disable)
685 si->flags |= VNET_SW_INTERFACE_FLAG_PROXY_ARP;
687 si->flags &= ~VNET_SW_INTERFACE_FLAG_PROXY_ARP;
689 BAD_SW_IF_INDEX_LABEL;
691 REPLY_MACRO (VL_API_PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY);
695 vl_api_sw_interface_set_mpls_enable_t_handler
696 (vl_api_sw_interface_set_mpls_enable_t * mp)
698 vl_api_sw_interface_set_mpls_enable_reply_t *rmp;
701 VALIDATE_SW_IF_INDEX (mp);
703 mpls_sw_interface_enable_disable (&mpls_main,
704 ntohl (mp->sw_if_index), mp->enable);
706 BAD_SW_IF_INDEX_LABEL;
707 REPLY_MACRO (VL_API_SW_INTERFACE_SET_MPLS_ENABLE_REPLY);
711 send_oam_event (oam_target_t * t)
713 vpe_api_main_t *vam = &vpe_api_main;
714 unix_shared_memory_queue_t *q;
715 vpe_client_registration_t *reg;
716 vl_api_oam_event_t *mp;
719 pool_foreach(reg, vam->oam_events_registrations,
721 q = vl_api_client_index_to_input_queue (reg->client_index);
724 mp = vl_msg_api_alloc (sizeof (*mp));
725 mp->_vl_msg_id = ntohs (VL_API_OAM_EVENT);
726 clib_memcpy (mp->dst_address, &t->dst_address,
727 sizeof (mp->dst_address));
728 mp->state = t->state;
729 vl_msg_api_send_shmem (q, (u8 *)&mp);
736 vl_api_oam_add_del_t_handler (vl_api_oam_add_del_t * mp)
738 vl_api_oam_add_del_reply_t *rmp;
741 rv = vpe_oam_add_del_target ((ip4_address_t *) mp->src_address,
742 (ip4_address_t *) mp->dst_address,
743 ntohl (mp->vrf_id), (int) (mp->is_add));
745 REPLY_MACRO (VL_API_OAM_ADD_DEL_REPLY);
749 vl_api_vnet_get_summary_stats_t_handler (vl_api_vnet_get_summary_stats_t * mp)
751 stats_main_t *sm = &stats_main;
752 vnet_interface_main_t *im = sm->interface_main;
753 vl_api_vnet_get_summary_stats_reply_t *rmp;
754 vlib_combined_counter_main_t *cm;
757 u64 total_pkts[VLIB_N_RX_TX];
758 u64 total_bytes[VLIB_N_RX_TX];
760 unix_shared_memory_queue_t *q =
761 vl_api_client_index_to_input_queue (mp->client_index);
766 rmp = vl_msg_api_alloc (sizeof (*rmp));
767 rmp->_vl_msg_id = ntohs (VL_API_VNET_GET_SUMMARY_STATS_REPLY);
768 rmp->context = mp->context;
771 memset (total_pkts, 0, sizeof (total_pkts));
772 memset (total_bytes, 0, sizeof (total_bytes));
774 vnet_interface_counter_lock (im);
776 vec_foreach (cm, im->combined_sw_if_counters)
778 which = cm - im->combined_sw_if_counters;
780 for (i = 0; i < vlib_combined_counter_n_counters (cm); i++)
782 vlib_get_combined_counter (cm, i, &v);
783 total_pkts[which] += v.packets;
784 total_bytes[which] += v.bytes;
787 vnet_interface_counter_unlock (im);
789 rmp->total_pkts[VLIB_RX] = clib_host_to_net_u64 (total_pkts[VLIB_RX]);
790 rmp->total_bytes[VLIB_RX] = clib_host_to_net_u64 (total_bytes[VLIB_RX]);
791 rmp->total_pkts[VLIB_TX] = clib_host_to_net_u64 (total_pkts[VLIB_TX]);
792 rmp->total_bytes[VLIB_TX] = clib_host_to_net_u64 (total_bytes[VLIB_TX]);
794 clib_host_to_net_u64 (vlib_last_vector_length_per_node (sm->vlib_main));
796 vl_msg_api_send_shmem (q, (u8 *) & rmp);
800 typedef CLIB_PACKED (struct {
801 ip4_address_t address;
802 u32 address_length: 6;
808 ip4_reset_fib_t_handler (vl_api_reset_fib_t * mp)
810 vnet_main_t *vnm = vnet_get_main ();
811 vnet_interface_main_t *im = &vnm->interface_main;
812 ip4_main_t *im4 = &ip4_main;
813 static u32 *sw_if_indices_to_shut;
814 stats_main_t *sm = &stats_main;
815 fib_table_t *fib_table;
819 int rv = VNET_API_ERROR_NO_SUCH_FIB;
820 u32 target_fib_id = ntohl (mp->vrf_id);
822 dslock (sm, 1 /* release hint */ , 8 /* tag */ );
825 pool_foreach (fib_table, im4->fibs,
827 vnet_sw_interface_t * si;
829 fib = pool_elt_at_index (im4->v4_fibs, fib_table->ft_index);
831 if (fib->table_id != target_fib_id)
834 /* remove any mpls encap/decap labels */
835 mpls_fib_reset_labels (fib->table_id);
837 /* remove any proxy arps in this fib */
838 vnet_proxy_arp_fib_reset (fib->table_id);
840 /* Set the flow hash for this fib to the default */
841 vnet_set_ip4_flow_hash (fib->table_id, IP_FLOW_HASH_DEFAULT);
843 vec_reset_length (sw_if_indices_to_shut);
845 /* Shut down interfaces in this FIB / clean out intfc routes */
846 pool_foreach (si, im->sw_interfaces,
848 u32 sw_if_index = si->sw_if_index;
850 if (sw_if_index < vec_len (im4->fib_index_by_sw_if_index)
851 && (im4->fib_index_by_sw_if_index[si->sw_if_index] ==
853 vec_add1 (sw_if_indices_to_shut, si->sw_if_index);
856 for (i = 0; i < vec_len (sw_if_indices_to_shut); i++) {
857 sw_if_index = sw_if_indices_to_shut[i];
859 u32 flags = vnet_sw_interface_get_flags (vnm, sw_if_index);
860 flags &= ~(VNET_SW_INTERFACE_FLAG_ADMIN_UP);
861 vnet_sw_interface_set_flags (vnm, sw_if_index, flags);
864 fib_table_flush(fib->index, FIB_PROTOCOL_IP4, FIB_SOURCE_API);
868 })); /* pool_foreach (fib) */
876 ip6_reset_fib_t_handler (vl_api_reset_fib_t * mp)
878 vnet_main_t *vnm = vnet_get_main ();
879 vnet_interface_main_t *im = &vnm->interface_main;
880 ip6_main_t *im6 = &ip6_main;
881 stats_main_t *sm = &stats_main;
882 static u32 *sw_if_indices_to_shut;
883 fib_table_t *fib_table;
887 int rv = VNET_API_ERROR_NO_SUCH_FIB;
888 u32 target_fib_id = ntohl (mp->vrf_id);
890 dslock (sm, 1 /* release hint */ , 9 /* tag */ );
893 pool_foreach (fib_table, im6->fibs,
895 vnet_sw_interface_t * si;
897 fib = pool_elt_at_index (im6->v6_fibs, fib_table->ft_index);
899 if (fib->table_id != target_fib_id)
902 vec_reset_length (sw_if_indices_to_shut);
904 /* Set the flow hash for this fib to the default */
905 vnet_set_ip6_flow_hash (fib->table_id, IP_FLOW_HASH_DEFAULT);
907 /* Shut down interfaces in this FIB / clean out intfc routes */
908 pool_foreach (si, im->sw_interfaces,
910 if (im6->fib_index_by_sw_if_index[si->sw_if_index] ==
912 vec_add1 (sw_if_indices_to_shut, si->sw_if_index);
915 for (i = 0; i < vec_len (sw_if_indices_to_shut); i++) {
916 sw_if_index = sw_if_indices_to_shut[i];
918 u32 flags = vnet_sw_interface_get_flags (vnm, sw_if_index);
919 flags &= ~(VNET_SW_INTERFACE_FLAG_ADMIN_UP);
920 vnet_sw_interface_set_flags (vnm, sw_if_index, flags);
923 fib_table_flush(fib->index, FIB_PROTOCOL_IP6, FIB_SOURCE_API);
927 })); /* pool_foreach (fib) */
935 vl_api_reset_fib_t_handler (vl_api_reset_fib_t * mp)
938 vl_api_reset_fib_reply_t *rmp;
941 rv = ip6_reset_fib_t_handler (mp);
943 rv = ip4_reset_fib_t_handler (mp);
945 REPLY_MACRO (VL_API_RESET_FIB_REPLY);
949 vl_api_create_loopback_t_handler (vl_api_create_loopback_t * mp)
951 vl_api_create_loopback_reply_t *rmp;
955 rv = vnet_create_loopback_interface (&sw_if_index, mp->mac_address, 0, 0);
958 REPLY_MACRO2(VL_API_CREATE_LOOPBACK_REPLY,
960 rmp->sw_if_index = ntohl (sw_if_index);
965 static void vl_api_create_loopback_instance_t_handler
966 (vl_api_create_loopback_instance_t * mp)
968 vl_api_create_loopback_instance_reply_t *rmp;
970 u8 is_specified = mp->is_specified;
971 u32 user_instance = ntohl (mp->user_instance);
974 rv = vnet_create_loopback_interface (&sw_if_index, mp->mac_address,
975 is_specified, user_instance);
978 REPLY_MACRO2(VL_API_CREATE_LOOPBACK_INSTANCE_REPLY,
980 rmp->sw_if_index = ntohl (sw_if_index);
986 vl_api_delete_loopback_t_handler (vl_api_delete_loopback_t * mp)
988 vl_api_delete_loopback_reply_t *rmp;
992 sw_if_index = ntohl (mp->sw_if_index);
993 rv = vnet_delete_loopback_interface (sw_if_index);
995 REPLY_MACRO (VL_API_DELETE_LOOPBACK_REPLY);
999 vl_api_control_ping_t_handler (vl_api_control_ping_t * mp)
1001 vl_api_control_ping_reply_t *rmp;
1005 REPLY_MACRO2(VL_API_CONTROL_PING_REPLY,
1007 rmp->vpe_pid = ntohl (getpid());
1013 shmem_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
1015 u8 **shmem_vecp = (u8 **) arg;
1018 api_main_t *am = &api_main;
1021 shmem_vec = *shmem_vecp;
1023 offset = vec_len (shmem_vec);
1025 pthread_mutex_lock (&am->vlib_rp->mutex);
1026 oldheap = svm_push_data_heap (am->vlib_rp);
1028 vec_validate (shmem_vec, offset + buffer_bytes - 1);
1030 clib_memcpy (shmem_vec + offset, buffer, buffer_bytes);
1032 svm_pop_heap (oldheap);
1033 pthread_mutex_unlock (&am->vlib_rp->mutex);
1035 *shmem_vecp = shmem_vec;
1040 vl_api_cli_t_handler (vl_api_cli_t * mp)
1042 vl_api_cli_reply_t *rp;
1043 unix_shared_memory_queue_t *q;
1044 vlib_main_t *vm = vlib_get_main ();
1045 api_main_t *am = &api_main;
1046 unformat_input_t input;
1050 q = vl_api_client_index_to_input_queue (mp->client_index);
1054 rp = vl_msg_api_alloc (sizeof (*rp));
1055 rp->_vl_msg_id = ntohs (VL_API_CLI_REPLY);
1056 rp->context = mp->context;
1058 unformat_init_vector (&input, (u8 *) (uword) mp->cmd_in_shmem);
1060 vlib_cli_input (vm, &input, shmem_cli_output, (uword) & shmem_vec);
1062 pthread_mutex_lock (&am->vlib_rp->mutex);
1063 oldheap = svm_push_data_heap (am->vlib_rp);
1065 vec_add1 (shmem_vec, 0);
1067 svm_pop_heap (oldheap);
1068 pthread_mutex_unlock (&am->vlib_rp->mutex);
1070 rp->reply_in_shmem = (uword) shmem_vec;
1072 vl_msg_api_send_shmem (q, (u8 *) & rp);
1076 inband_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
1078 u8 **mem_vecp = (u8 **) arg;
1079 u8 *mem_vec = *mem_vecp;
1080 u32 offset = vec_len (mem_vec);
1082 vec_validate (mem_vec, offset + buffer_bytes - 1);
1083 clib_memcpy (mem_vec + offset, buffer, buffer_bytes);
1084 *mem_vecp = mem_vec;
1088 vl_api_cli_inband_t_handler (vl_api_cli_inband_t * mp)
1090 vl_api_cli_inband_reply_t *rmp;
1092 unix_shared_memory_queue_t *q;
1093 vlib_main_t *vm = vlib_get_main ();
1094 unformat_input_t input;
1097 q = vl_api_client_index_to_input_queue (mp->client_index);
1101 unformat_init_string (&input, (char *) mp->cmd, ntohl (mp->length));
1102 vlib_cli_input (vm, &input, inband_cli_output, (uword) & out_vec);
1104 u32 len = vec_len (out_vec);
1106 REPLY_MACRO3(VL_API_CLI_INBAND_REPLY, len,
1108 rmp->length = htonl (len);
1109 clib_memcpy (rmp->reply, out_vec, len);
1116 vl_api_set_arp_neighbor_limit_t_handler (vl_api_set_arp_neighbor_limit_t * mp)
1119 vl_api_set_arp_neighbor_limit_reply_t *rmp;
1120 vnet_main_t *vnm = vnet_get_main ();
1121 clib_error_t *error;
1126 error = ip6_set_neighbor_limit (ntohl (mp->arp_neighbor_limit));
1128 error = ip4_set_arp_limit (ntohl (mp->arp_neighbor_limit));
1132 clib_error_report (error);
1133 rv = VNET_API_ERROR_UNSPECIFIED;
1137 rv = vnm->api_errno;
1140 REPLY_MACRO (VL_API_SET_ARP_NEIGHBOR_LIMIT_REPLY);
1143 static void vl_api_classify_set_interface_ip_table_t_handler
1144 (vl_api_classify_set_interface_ip_table_t * mp)
1146 vlib_main_t *vm = vlib_get_main ();
1147 vl_api_classify_set_interface_ip_table_reply_t *rmp;
1150 VALIDATE_SW_IF_INDEX (mp);
1152 u32 table_index = ntohl (mp->table_index);
1153 u32 sw_if_index = ntohl (mp->sw_if_index);
1156 rv = vnet_set_ip6_classify_intfc (vm, sw_if_index, table_index);
1158 rv = vnet_set_ip4_classify_intfc (vm, sw_if_index, table_index);
1160 BAD_SW_IF_INDEX_LABEL;
1162 REPLY_MACRO (VL_API_CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY);
1165 static void vl_api_classify_set_interface_l2_tables_t_handler
1166 (vl_api_classify_set_interface_l2_tables_t * mp)
1168 vl_api_classify_set_interface_l2_tables_reply_t *rmp;
1170 u32 sw_if_index, ip4_table_index, ip6_table_index, other_table_index;
1173 ip4_table_index = ntohl (mp->ip4_table_index);
1174 ip6_table_index = ntohl (mp->ip6_table_index);
1175 other_table_index = ntohl (mp->other_table_index);
1176 sw_if_index = ntohl (mp->sw_if_index);
1178 VALIDATE_SW_IF_INDEX (mp);
1181 rv = vnet_l2_input_classify_set_tables (sw_if_index, ip4_table_index,
1185 rv = vnet_l2_output_classify_set_tables (sw_if_index, ip4_table_index,
1191 if (ip4_table_index != ~0 || ip6_table_index != ~0
1192 || other_table_index != ~0)
1198 vnet_l2_input_classify_enable_disable (sw_if_index, enable);
1200 vnet_l2_output_classify_enable_disable (sw_if_index, enable);
1203 BAD_SW_IF_INDEX_LABEL;
1205 REPLY_MACRO (VL_API_CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY);
1208 extern void l2_efp_filter_configure (vnet_main_t * vnet_main,
1209 u32 sw_if_index, u32 enable);
1212 vl_api_l2_interface_efp_filter_t_handler (vl_api_l2_interface_efp_filter_t *
1216 vl_api_l2_interface_efp_filter_reply_t *rmp;
1217 vnet_main_t *vnm = vnet_get_main ();
1219 // enable/disable the feature
1220 l2_efp_filter_configure (vnm, mp->sw_if_index, mp->enable_disable);
1221 rv = vnm->api_errno;
1223 REPLY_MACRO (VL_API_L2_INTERFACE_EFP_FILTER_REPLY);
1227 vl_api_show_version_t_handler (vl_api_show_version_t * mp)
1229 vl_api_show_version_reply_t *rmp;
1231 char *vpe_api_get_build_directory (void);
1232 char *vpe_api_get_version (void);
1233 char *vpe_api_get_build_date (void);
1235 unix_shared_memory_queue_t *q =
1236 vl_api_client_index_to_input_queue (mp->client_index);
1242 REPLY_MACRO2(VL_API_SHOW_VERSION_REPLY,
1244 strncpy ((char *) rmp->program, "vpe", ARRAY_LEN(rmp->program)-1);
1245 strncpy ((char *) rmp->build_directory, vpe_api_get_build_directory(),
1246 ARRAY_LEN(rmp->build_directory)-1);
1247 strncpy ((char *) rmp->version, vpe_api_get_version(),
1248 ARRAY_LEN(rmp->version)-1);
1249 strncpy ((char *) rmp->build_date, vpe_api_get_build_date(),
1250 ARRAY_LEN(rmp->build_date)-1);
1256 vl_api_get_node_index_t_handler (vl_api_get_node_index_t * mp)
1258 vlib_main_t *vm = vlib_get_main ();
1259 vl_api_get_node_index_reply_t *rmp;
1262 u32 node_index = ~0;
1264 n = vlib_get_node_by_name (vm, mp->node_name);
1267 rv = VNET_API_ERROR_NO_SUCH_NODE;
1269 node_index = n->index;
1272 REPLY_MACRO2(VL_API_GET_NODE_INDEX_REPLY,
1274 rmp->node_index = ntohl(node_index);
1280 vl_api_get_next_index_t_handler (vl_api_get_next_index_t * mp)
1282 vlib_main_t *vm = vlib_get_main ();
1283 vl_api_get_next_index_reply_t *rmp;
1284 vlib_node_t *node, *next_node;
1286 u32 next_node_index = ~0, next_index = ~0;
1289 node = vlib_get_node_by_name (vm, mp->node_name);
1293 rv = VNET_API_ERROR_NO_SUCH_NODE;
1297 next_node = vlib_get_node_by_name (vm, mp->next_name);
1301 rv = VNET_API_ERROR_NO_SUCH_NODE2;
1305 next_node_index = next_node->index;
1307 p = hash_get (node->next_slot_by_node, next_node_index);
1311 rv = VNET_API_ERROR_NO_SUCH_ENTRY;
1319 REPLY_MACRO2(VL_API_GET_NEXT_INDEX_REPLY,
1321 rmp->next_index = ntohl(next_index);
1327 vl_api_add_node_next_t_handler (vl_api_add_node_next_t * mp)
1329 vlib_main_t *vm = vlib_get_main ();
1330 vl_api_add_node_next_reply_t *rmp;
1331 vlib_node_t *n, *next;
1333 u32 next_index = ~0;
1335 n = vlib_get_node_by_name (vm, mp->node_name);
1339 rv = VNET_API_ERROR_NO_SUCH_NODE;
1343 next = vlib_get_node_by_name (vm, mp->next_name);
1346 rv = VNET_API_ERROR_NO_SUCH_NODE2;
1348 next_index = vlib_node_add_next (vm, n->index, next->index);
1352 REPLY_MACRO2(VL_API_GET_NODE_INDEX_REPLY,
1354 rmp->next_index = ntohl(next_index);
1360 vl_api_l2_patch_add_del_t_handler (vl_api_l2_patch_add_del_t * mp)
1362 extern int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index,
1364 vl_api_l2_patch_add_del_reply_t *rmp;
1365 int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index,
1369 VALIDATE_RX_SW_IF_INDEX (mp);
1370 VALIDATE_TX_SW_IF_INDEX (mp);
1372 rv = vnet_l2_patch_add_del (ntohl (mp->rx_sw_if_index),
1373 ntohl (mp->tx_sw_if_index),
1374 (int) (mp->is_add != 0));
1376 BAD_RX_SW_IF_INDEX_LABEL;
1377 BAD_TX_SW_IF_INDEX_LABEL;
1379 REPLY_MACRO (VL_API_L2_PATCH_ADD_DEL_REPLY);
1383 vl_api_interface_name_renumber_t_handler (vl_api_interface_name_renumber_t *
1386 vl_api_interface_name_renumber_reply_t *rmp;
1389 VALIDATE_SW_IF_INDEX (mp);
1391 rv = vnet_interface_name_renumber
1392 (ntohl (mp->sw_if_index), ntohl (mp->new_show_dev_instance));
1394 BAD_SW_IF_INDEX_LABEL;
1396 REPLY_MACRO (VL_API_INTERFACE_NAME_RENUMBER_REPLY);
1400 arp_change_data_callback (u32 pool_index, u8 * new_mac,
1401 u32 sw_if_index, u32 address)
1403 vpe_api_main_t *am = &vpe_api_main;
1404 vlib_main_t *vm = am->vlib_main;
1405 vl_api_ip4_arp_event_t *event;
1406 static f64 arp_event_last_time;
1407 f64 now = vlib_time_now (vm);
1409 if (pool_is_free_index (am->arp_events, pool_index))
1412 event = pool_elt_at_index (am->arp_events, pool_index);
1414 if (memcmp (&event->new_mac, new_mac, sizeof (event->new_mac)))
1416 clib_memcpy (event->new_mac, new_mac, sizeof (event->new_mac));
1420 if (sw_if_index == ntohl(event->sw_if_index) &&
1422 /* for BD case, also check IP address with 10 sec timeout */
1423 (address == event->address &&
1424 (now - arp_event_last_time) < 10.0)))
1429 arp_event_last_time = now;
1430 event->sw_if_index = htonl (sw_if_index);
1432 event->address = address;
1437 nd_change_data_callback (u32 pool_index, u8 * new_mac,
1438 u32 sw_if_index, ip6_address_t * address)
1440 vpe_api_main_t *am = &vpe_api_main;
1441 vlib_main_t *vm = am->vlib_main;
1442 vl_api_ip6_nd_event_t *event;
1443 static f64 nd_event_last_time;
1444 f64 now = vlib_time_now (vm);
1446 if (pool_is_free_index (am->nd_events, pool_index))
1449 event = pool_elt_at_index (am->nd_events, pool_index);
1452 if (memcmp (&event->new_mac, new_mac, sizeof (event->new_mac)))
1454 clib_memcpy (event->new_mac, new_mac, sizeof (event->new_mac));
1458 if (sw_if_index == ntohl(event->sw_if_index) &&
1460 /* for BD case, also check IP address with 10 sec timeout */
1461 (ip6_address_is_equal (address,
1462 (ip6_address_t *) event->address) &&
1463 (now - nd_event_last_time) < 10.0)))
1468 nd_event_last_time = now;
1469 event->sw_if_index = htonl (sw_if_index);
1471 clib_memcpy (event->address, address, sizeof (event->address));
1476 arp_change_delete_callback (u32 pool_index, u8 * notused)
1478 vpe_api_main_t *am = &vpe_api_main;
1480 if (pool_is_free_index (am->arp_events, pool_index))
1483 pool_put_index (am->arp_events, pool_index);
1488 nd_change_delete_callback (u32 pool_index, u8 * notused)
1490 vpe_api_main_t *am = &vpe_api_main;
1492 if (pool_is_free_index (am->nd_events, pool_index))
1495 pool_put_index (am->nd_events, pool_index);
1500 vl_api_want_ip4_arp_events_t_handler (vl_api_want_ip4_arp_events_t * mp)
1502 vpe_api_main_t *am = &vpe_api_main;
1503 vnet_main_t *vnm = vnet_get_main ();
1504 vl_api_want_ip4_arp_events_reply_t *rmp;
1507 if (mp->enable_disable)
1509 vl_api_ip4_arp_event_t *event;
1510 pool_get (am->arp_events, event);
1511 rv = vnet_add_del_ip4_arp_change_event
1512 (vnm, arp_change_data_callback,
1513 mp->pid, &mp->address /* addr, in net byte order */ ,
1514 vpe_resolver_process_node.index,
1515 IP4_ARP_EVENT, event - am->arp_events, 1 /* is_add */ );
1519 pool_put (am->arp_events, event);
1522 memset (event, 0, sizeof (*event));
1524 /* Python API expects events to have no context */
1525 event->_vl_msg_id = ntohs (VL_API_IP4_ARP_EVENT);
1526 event->client_index = mp->client_index;
1527 event->address = mp->address;
1528 event->pid = mp->pid;
1529 if (mp->address == 0)
1534 rv = vnet_add_del_ip4_arp_change_event
1535 (vnm, arp_change_delete_callback,
1536 mp->pid, &mp->address /* addr, in net byte order */ ,
1537 vpe_resolver_process_node.index,
1538 IP4_ARP_EVENT, ~0 /* pool index */ , 0 /* is_add */ );
1541 REPLY_MACRO (VL_API_WANT_IP4_ARP_EVENTS_REPLY);
1545 vl_api_want_ip6_nd_events_t_handler (vl_api_want_ip6_nd_events_t * mp)
1547 vpe_api_main_t *am = &vpe_api_main;
1548 vnet_main_t *vnm = vnet_get_main ();
1549 vl_api_want_ip6_nd_events_reply_t *rmp;
1552 if (mp->enable_disable)
1554 vl_api_ip6_nd_event_t *event;
1555 pool_get (am->nd_events, event);
1557 rv = vnet_add_del_ip6_nd_change_event
1558 (vnm, nd_change_data_callback,
1559 mp->pid, mp->address /* addr, in net byte order */ ,
1560 vpe_resolver_process_node.index,
1561 IP6_ND_EVENT, event - am->nd_events, 1 /* is_add */ );
1565 pool_put (am->nd_events, event);
1568 memset (event, 0, sizeof (*event));
1570 event->_vl_msg_id = ntohs (VL_API_IP6_ND_EVENT);
1571 event->client_index = mp->client_index;
1572 clib_memcpy (event->address, mp->address, 16);
1573 event->pid = mp->pid;
1574 if (ip6_address_is_zero ((ip6_address_t *) mp->address))
1580 rv = vnet_add_del_ip6_nd_change_event
1581 (vnm, nd_change_delete_callback,
1582 mp->pid, mp->address /* addr, in net byte order */ ,
1583 vpe_resolver_process_node.index,
1584 IP6_ND_EVENT, ~0 /* pool index */ , 0 /* is_add */ );
1587 REPLY_MACRO (VL_API_WANT_IP6_ND_EVENTS_REPLY);
1590 static void vl_api_input_acl_set_interface_t_handler
1591 (vl_api_input_acl_set_interface_t * mp)
1593 vlib_main_t *vm = vlib_get_main ();
1594 vl_api_input_acl_set_interface_reply_t *rmp;
1597 VALIDATE_SW_IF_INDEX (mp);
1599 u32 ip4_table_index = ntohl (mp->ip4_table_index);
1600 u32 ip6_table_index = ntohl (mp->ip6_table_index);
1601 u32 l2_table_index = ntohl (mp->l2_table_index);
1602 u32 sw_if_index = ntohl (mp->sw_if_index);
1604 rv = vnet_set_input_acl_intfc (vm, sw_if_index, ip4_table_index,
1605 ip6_table_index, l2_table_index, mp->is_add);
1607 BAD_SW_IF_INDEX_LABEL;
1609 REPLY_MACRO (VL_API_INPUT_ACL_SET_INTERFACE_REPLY);
1613 vl_api_get_node_graph_t_handler (vl_api_get_node_graph_t * mp)
1617 api_main_t *am = &api_main;
1618 vlib_main_t *vm = vlib_get_main ();
1620 vl_api_get_node_graph_reply_t *rmp;
1622 pthread_mutex_lock (&am->vlib_rp->mutex);
1623 oldheap = svm_push_data_heap (am->vlib_rp);
1626 * Keep the number of memcpy ops to a minimum (e.g. 1).
1628 vec_validate (vector, 16384);
1629 vec_reset_length (vector);
1632 vector = vlib_node_serialize (&vm->node_main, vector,
1633 (u32) ~ 0 /* all threads */ ,
1634 1 /* include nexts */ ,
1635 1 /* include stats */ );
1637 svm_pop_heap (oldheap);
1638 pthread_mutex_unlock (&am->vlib_rp->mutex);
1641 REPLY_MACRO2(VL_API_GET_NODE_GRAPH_REPLY,
1643 rmp->reply_in_shmem = (uword) vector;
1649 vl_api_ioam_enable_t_handler (vl_api_ioam_enable_t * mp)
1652 vl_api_ioam_enable_reply_t *rmp;
1653 clib_error_t *error;
1655 /* Ignoring the profile id as currently a single profile
1657 error = ip6_ioam_enable (mp->trace_enable, mp->pot_enable,
1658 mp->seqno, mp->analyse);
1661 clib_error_report (error);
1662 rv = clib_error_get_code (error);
1665 REPLY_MACRO (VL_API_IOAM_ENABLE_REPLY);
1669 vl_api_ioam_disable_t_handler (vl_api_ioam_disable_t * mp)
1672 vl_api_ioam_disable_reply_t *rmp;
1673 clib_error_t *error;
1675 error = clear_ioam_rewrite_fn ();
1678 clib_error_report (error);
1679 rv = clib_error_get_code (error);
1682 REPLY_MACRO (VL_API_IOAM_DISABLE_REPLY);
1686 vl_api_pg_create_interface_t_handler (vl_api_pg_create_interface_t * mp)
1688 vl_api_pg_create_interface_reply_t *rmp;
1691 pg_main_t *pg = &pg_main;
1692 u32 pg_if_id = pg_interface_add_or_get (pg, ntohl (mp->interface_id));
1693 pg_interface_t *pi = pool_elt_at_index (pg->interfaces, pg_if_id);
1696 REPLY_MACRO2(VL_API_PG_CREATE_INTERFACE_REPLY,
1698 rmp->sw_if_index = ntohl(pi->sw_if_index);
1704 vl_api_pg_capture_t_handler (vl_api_pg_capture_t * mp)
1706 vl_api_pg_capture_reply_t *rmp;
1709 vnet_main_t *vnm = vnet_get_main ();
1710 vnet_interface_main_t *im = &vnm->interface_main;
1711 vnet_hw_interface_t *hi = 0;
1713 u8 *intf_name = format (0, "pg%d", ntohl (mp->interface_id), 0);
1714 u32 hw_if_index = ~0;
1715 uword *p = hash_get_mem (im->hw_interface_by_name, intf_name);
1718 vec_free (intf_name);
1720 if (hw_if_index != ~0)
1722 pg_capture_args_t _a, *a = &_a;
1724 u32 len = ntohl (mp->pcap_name_length);
1725 u8 *pcap_file_name = vec_new (u8, len);
1726 clib_memcpy (pcap_file_name, mp->pcap_file_name, len);
1728 hi = vnet_get_sup_hw_interface (vnm, hw_if_index);
1729 a->hw_if_index = hw_if_index;
1730 a->dev_instance = hi->dev_instance;
1731 a->is_enabled = mp->is_enabled;
1732 a->pcap_file_name = pcap_file_name;
1733 a->count = ntohl (mp->count);
1735 clib_error_t *e = pg_capture (a);
1738 clib_error_report (e);
1739 rv = VNET_API_ERROR_CANNOT_CREATE_PCAP_FILE;
1742 vec_free (pcap_file_name);
1744 REPLY_MACRO (VL_API_PG_CAPTURE_REPLY);
1748 vl_api_pg_enable_disable_t_handler (vl_api_pg_enable_disable_t * mp)
1750 vl_api_pg_enable_disable_reply_t *rmp;
1753 pg_main_t *pg = &pg_main;
1754 u32 stream_index = ~0;
1756 int is_enable = mp->is_enabled != 0;
1757 u32 len = ntohl (mp->stream_name_length) - 1;
1761 u8 *stream_name = vec_new (u8, len);
1762 clib_memcpy (stream_name, mp->stream_name, len);
1763 uword *p = hash_get_mem (pg->stream_index_by_name, stream_name);
1766 vec_free (stream_name);
1769 pg_enable_disable (stream_index, is_enable);
1771 REPLY_MACRO (VL_API_PG_ENABLE_DISABLE_REPLY);
1775 vl_api_ip_source_and_port_range_check_add_del_t_handler
1776 (vl_api_ip_source_and_port_range_check_add_del_t * mp)
1778 vl_api_ip_source_and_port_range_check_add_del_reply_t *rmp;
1781 u8 is_ipv6 = mp->is_ipv6;
1782 u8 is_add = mp->is_add;
1783 u8 mask_length = mp->mask_length;
1784 ip4_address_t ip4_addr;
1785 ip6_address_t ip6_addr;
1787 u16 *high_ports = 0;
1789 u16 tmp_low, tmp_high;
1793 // Validate port range
1794 num_ranges = mp->number_of_ranges;
1795 if (num_ranges > 32)
1796 { // This is size of array in VPE.API
1797 rv = VNET_API_ERROR_EXCEEDED_NUMBER_OF_RANGES_CAPACITY;
1801 vec_reset_length (low_ports);
1802 vec_reset_length (high_ports);
1804 for (i = 0; i < num_ranges; i++)
1806 tmp_low = mp->low_ports[i];
1807 tmp_high = mp->high_ports[i];
1808 // If tmp_low <= tmp_high then only need to check tmp_low = 0
1809 // If tmp_low <= tmp_high then only need to check tmp_high > 65535
1810 if (tmp_low > tmp_high || tmp_low == 0 || tmp_high > 65535)
1812 rv = VNET_API_ERROR_INVALID_VALUE;
1815 vec_add1 (low_ports, tmp_low);
1816 vec_add1 (high_ports, tmp_high + 1);
1819 // Validate mask_length
1820 if ((is_ipv6 && mask_length > 128) || (!is_ipv6 && mask_length > 32))
1822 rv = VNET_API_ERROR_ADDRESS_LENGTH_MISMATCH;
1826 vrf_id = ntohl (mp->vrf_id);
1830 rv = VNET_API_ERROR_INVALID_VALUE;
1837 clib_memcpy (ip6_addr.as_u8, mp->address, sizeof (ip6_addr.as_u8));
1838 rv = ip6_source_and_port_range_check_add_del (&ip6_addr,
1842 high_ports, is_add);
1846 clib_memcpy (ip4_addr.data, mp->address, sizeof (ip4_addr));
1847 rv = ip4_source_and_port_range_check_add_del (&ip4_addr,
1851 high_ports, is_add);
1855 vec_free (low_ports);
1856 vec_free (high_ports);
1857 REPLY_MACRO (VL_API_IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY);
1861 vl_api_ip_source_and_port_range_check_interface_add_del_t_handler
1862 (vl_api_ip_source_and_port_range_check_interface_add_del_t * mp)
1864 vlib_main_t *vm = vlib_get_main ();
1865 vl_api_ip_source_and_port_range_check_interface_add_del_reply_t *rmp;
1866 ip4_main_t *im = &ip4_main;
1869 u32 fib_index[IP_SOURCE_AND_PORT_RANGE_CHECK_N_PROTOCOLS];
1870 u32 vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_N_PROTOCOLS];
1874 vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_PROTOCOL_TCP_OUT] =
1875 ntohl (mp->tcp_out_vrf_id);
1876 vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_PROTOCOL_UDP_OUT] =
1877 ntohl (mp->udp_out_vrf_id);
1878 vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_PROTOCOL_TCP_IN] =
1879 ntohl (mp->tcp_in_vrf_id);
1880 vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_PROTOCOL_UDP_IN] =
1881 ntohl (mp->udp_in_vrf_id);
1884 for (i = 0; i < IP_SOURCE_AND_PORT_RANGE_CHECK_N_PROTOCOLS; i++)
1886 if (vrf_id[i] != 0 && vrf_id[i] != ~0)
1888 p = hash_get (im->fib_index_by_table_id, vrf_id[i]);
1892 rv = VNET_API_ERROR_INVALID_VALUE;
1896 fib_index[i] = p[0];
1901 sw_if_index = ntohl (mp->sw_if_index);
1903 VALIDATE_SW_IF_INDEX (mp);
1906 set_ip_source_and_port_range_check (vm, fib_index, sw_if_index,
1909 BAD_SW_IF_INDEX_LABEL;
1912 REPLY_MACRO (VL_API_IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY);
1916 vl_api_delete_subif_t_handler (vl_api_delete_subif_t * mp)
1918 vl_api_delete_subif_reply_t *rmp;
1921 rv = vnet_delete_sub_interface (ntohl (mp->sw_if_index));
1923 REPLY_MACRO (VL_API_DELETE_SUBIF_REPLY);
1927 vl_api_punt_t_handler (vl_api_punt_t * mp)
1929 vl_api_punt_reply_t *rmp;
1930 vlib_main_t *vm = vlib_get_main ();
1932 clib_error_t *error;
1934 error = vnet_punt_add_del (vm, mp->ipv, mp->l4_protocol,
1935 ntohs (mp->l4_port), mp->is_add);
1939 clib_error_report (error);
1942 REPLY_MACRO (VL_API_PUNT_REPLY);
1946 vl_api_punt_socket_register_t_handler (vl_api_punt_socket_register_t * mp)
1948 vl_api_punt_socket_register_reply_t *rmp;
1949 vlib_main_t *vm = vlib_get_main ();
1951 clib_error_t *error;
1952 unix_shared_memory_queue_t *q;
1955 error = vnet_punt_socket_add (vm, ntohl (mp->header_version),
1956 mp->is_ip4, mp->l4_protocol,
1957 ntohs (mp->l4_port), (char *) mp->pathname);
1961 clib_error_report (error);
1964 q = vl_api_client_index_to_input_queue (mp->client_index);
1968 rmp = vl_msg_api_alloc (sizeof (*rmp));
1969 rmp->_vl_msg_id = htons (VL_API_PUNT_SOCKET_REGISTER_REPLY);
1970 rmp->context = mp->context;
1971 rmp->retval = htonl (rv);
1972 char *p = vnet_punt_get_server_pathname ();
1973 /* Abstract pathnames start with \0 */
1974 memcpy ((char *) rmp->pathname, p, sizeof (rmp->pathname));
1975 vl_msg_api_send_shmem (q, (u8 *) & rmp);
1979 vl_api_punt_socket_deregister_t_handler (vl_api_punt_socket_deregister_t * mp)
1981 vl_api_punt_socket_deregister_reply_t *rmp;
1982 vlib_main_t *vm = vlib_get_main ();
1984 clib_error_t *error;
1985 unix_shared_memory_queue_t *q;
1988 error = vnet_punt_socket_del (vm, mp->is_ip4, mp->l4_protocol,
1989 ntohs (mp->l4_port));
1993 clib_error_report (error);
1996 q = vl_api_client_index_to_input_queue (mp->client_index);
2000 rmp = vl_msg_api_alloc (sizeof (*rmp));
2001 rmp->_vl_msg_id = htons (VL_API_PUNT_SOCKET_DEREGISTER_REPLY);
2002 rmp->context = mp->context;
2003 rmp->retval = htonl (rv);
2004 vl_msg_api_send_shmem (q, (u8 *) & rmp);
2008 vl_api_feature_enable_disable_t_handler (vl_api_feature_enable_disable_t * mp)
2010 vl_api_feature_enable_disable_reply_t *rmp;
2013 VALIDATE_SW_IF_INDEX (mp);
2015 u8 *arc_name = format (0, "%s%c", mp->arc_name, 0);
2016 u8 *feature_name = format (0, "%s%c", mp->feature_name, 0);
2018 vnet_feature_registration_t *reg =
2019 vnet_get_feature_reg ((const char *) arc_name,
2020 (const char *) feature_name);
2022 rv = VNET_API_ERROR_INVALID_VALUE;
2025 u32 sw_if_index = ntohl (mp->sw_if_index);
2026 clib_error_t *error = 0;
2028 if (reg->enable_disable_cb)
2029 error = reg->enable_disable_cb (sw_if_index, mp->enable);
2031 vnet_feature_enable_disable ((const char *) arc_name,
2032 (const char *) feature_name,
2033 sw_if_index, mp->enable, 0, 0);
2036 clib_error_report (error);
2037 rv = VNET_API_ERROR_CANNOT_ENABLE_DISABLE_FEATURE;
2041 vec_free (feature_name);
2042 vec_free (arc_name);
2044 BAD_SW_IF_INDEX_LABEL;
2046 REPLY_MACRO (VL_API_FEATURE_ENABLE_DISABLE_REPLY);
2049 #define BOUNCE_HANDLER(nn) \
2050 static void vl_api_##nn##_t_handler ( \
2051 vl_api_##nn##_t *mp) \
2053 vpe_client_registration_t *reg; \
2054 vpe_api_main_t * vam = &vpe_api_main; \
2055 unix_shared_memory_queue_t * q; \
2057 /* One registration only... */ \
2058 pool_foreach(reg, vam->nn##_registrations, \
2060 q = vl_api_client_index_to_input_queue (reg->client_index); \
2063 * If the queue is stuffed, turf the msg and complain \
2064 * It's unlikely that the intended recipient is \
2065 * alive; avoid deadlock at all costs. \
2067 if (q->cursize == q->maxsize) { \
2068 clib_warning ("ERROR: receiver queue full, drop msg"); \
2069 vl_msg_api_free (mp); \
2072 vl_msg_api_send_shmem (q, (u8 *)&mp); \
2076 vl_msg_api_free (mp); \
2079 static void setup_message_id_table (api_main_t * am);
2083 * Add vpe's API message handlers to the table.
2084 * vlib has alread mapped shared memory and
2085 * added the client registration handlers.
2086 * See .../open-repo/vlib/memclnt_vlib.c:memclnt_process()
2088 static clib_error_t *
2089 vpe_api_hookup (vlib_main_t * vm)
2091 api_main_t *am = &api_main;
2094 vl_msg_api_set_handlers(VL_API_##N, #n, \
2095 vl_api_##n##_t_handler, \
2097 vl_api_##n##_t_endian, \
2098 vl_api_##n##_t_print, \
2099 sizeof(vl_api_##n##_t), 1);
2100 foreach_vpe_api_msg;
2104 * Trace space for classifier mask+match
2106 am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_TABLE].size += 5 * sizeof (u32x4);
2107 am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_SESSION].size
2108 += 5 * sizeof (u32x4);
2111 * Thread-safe API messages
2113 am->is_mp_safe[VL_API_IP_ADD_DEL_ROUTE] = 1;
2114 am->is_mp_safe[VL_API_GET_NODE_GRAPH] = 1;
2117 * Set up the (msg_name, crc, message-id) table
2119 setup_message_id_table (am);
2124 VLIB_API_INIT_FUNCTION (vpe_api_hookup);
2126 static clib_error_t *
2127 vpe_api_init (vlib_main_t * vm)
2129 vpe_api_main_t *am = &vpe_api_main;
2132 am->vnet_main = vnet_get_main ();
2133 am->interface_events_registration_hash = hash_create (0, sizeof (uword));
2134 am->to_netconf_server_registration_hash = hash_create (0, sizeof (uword));
2135 am->from_netconf_server_registration_hash = hash_create (0, sizeof (uword));
2136 am->to_netconf_client_registration_hash = hash_create (0, sizeof (uword));
2137 am->from_netconf_client_registration_hash = hash_create (0, sizeof (uword));
2138 am->oam_events_registration_hash = hash_create (0, sizeof (uword));
2139 am->bfd_events_registration_hash = hash_create (0, sizeof (uword));
2141 vl_set_memory_region_name ("/vpe-api");
2142 vl_enable_disable_memory_api (vm, 1 /* enable it */ );
2147 VLIB_INIT_FUNCTION (vpe_api_init);
2150 static clib_error_t *
2151 api_segment_config (vlib_main_t * vm, unformat_input_t * input)
2154 u64 baseva, size, pvt_heap_size;
2156 const int max_buf_size = 4096;
2158 struct passwd _pw, *pw;
2159 struct group _grp, *grp;
2161 buf = vec_new (char, 128);
2162 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2164 if (unformat (input, "prefix %s", &chroot_path))
2166 vec_add1 (chroot_path, 0);
2167 vl_set_memory_root_path ((char *) chroot_path);
2169 else if (unformat (input, "uid %d", &uid))
2170 vl_set_memory_uid (uid);
2171 else if (unformat (input, "gid %d", &gid))
2172 vl_set_memory_gid (gid);
2173 else if (unformat (input, "baseva %llx", &baseva))
2174 vl_set_global_memory_baseva (baseva);
2175 else if (unformat (input, "global-size %lldM", &size))
2176 vl_set_global_memory_size (size * (1ULL << 20));
2177 else if (unformat (input, "global-size %lldG", &size))
2178 vl_set_global_memory_size (size * (1ULL << 30));
2179 else if (unformat (input, "global-size %lld", &size))
2180 vl_set_global_memory_size (size);
2181 else if (unformat (input, "global-pvt-heap-size %lldM", &pvt_heap_size))
2182 vl_set_global_pvt_heap_size (pvt_heap_size * (1ULL << 20));
2183 else if (unformat (input, "global-pvt-heap-size size %lld",
2185 vl_set_global_pvt_heap_size (pvt_heap_size);
2186 else if (unformat (input, "api-pvt-heap-size %lldM", &pvt_heap_size))
2187 vl_set_api_pvt_heap_size (pvt_heap_size * (1ULL << 20));
2188 else if (unformat (input, "api-pvt-heap-size size %lld",
2190 vl_set_api_pvt_heap_size (pvt_heap_size);
2191 else if (unformat (input, "api-size %lldM", &size))
2192 vl_set_api_memory_size (size * (1ULL << 20));
2193 else if (unformat (input, "api-size %lldG", &size))
2194 vl_set_api_memory_size (size * (1ULL << 30));
2195 else if (unformat (input, "api-size %lld", &size))
2196 vl_set_api_memory_size (size);
2197 else if (unformat (input, "uid %s", &s))
2199 /* lookup the username */
2202 getpwnam_r (s, &_pw, buf, vec_len (buf), &pw)) == ERANGE)
2203 && (vec_len (buf) <= max_buf_size))
2205 vec_resize (buf, vec_len (buf) * 2);
2209 e = clib_error_return_code (0, rv,
2210 CLIB_ERROR_ERRNO_VALID |
2212 "cannot fetch username %s", s);
2220 clib_error_return_fatal (0, "username %s does not exist", s);
2226 vl_set_memory_uid (pw->pw_uid);
2228 else if (unformat (input, "gid %s", &s))
2230 /* lookup the group name */
2233 getgrnam_r (s, &_grp, buf, vec_len (buf), &grp)) == ERANGE)
2234 && (vec_len (buf) <= max_buf_size))
2236 vec_resize (buf, vec_len (buf) * 2);
2240 e = clib_error_return_code (0, rv,
2241 CLIB_ERROR_ERRNO_VALID |
2243 "cannot fetch group %s", s);
2250 e = clib_error_return_fatal (0, "group %s does not exist", s);
2257 vl_set_memory_gid (grp->gr_gid);
2260 return clib_error_return (0, "unknown input `%U'",
2261 format_unformat_error, input);
2266 VLIB_EARLY_CONFIG_FUNCTION (api_segment_config, "api-segment");
2269 get_unformat_vnet_sw_interface (void)
2271 return (void *) &unformat_vnet_sw_interface;
2275 format_arp_event (u8 * s, va_list * args)
2277 vl_api_ip4_arp_event_t *event = va_arg (*args, vl_api_ip4_arp_event_t *);
2279 s = format (s, "pid %d: ", ntohl (event->pid));
2281 s = format (s, "bd mac/ip4 binding events");
2283 s = format (s, "resolution for %U", format_ip4_address, &event->address);
2288 format_nd_event (u8 * s, va_list * args)
2290 vl_api_ip6_nd_event_t *event = va_arg (*args, vl_api_ip6_nd_event_t *);
2292 s = format (s, "pid %d: ", ntohl (event->pid));
2294 s = format (s, "bd mac/ip6 binding events");
2296 s = format (s, "resolution for %U", format_ip6_address, event->address);
2300 static clib_error_t *
2301 show_ip_arp_nd_events_fn (vlib_main_t * vm,
2302 unformat_input_t * input, vlib_cli_command_t * cmd)
2304 vpe_api_main_t *am = &vpe_api_main;
2305 vl_api_ip4_arp_event_t *arp_event;
2306 vl_api_ip6_nd_event_t *nd_event;
2308 if ((pool_elts (am->arp_events) == 0) && (pool_elts (am->nd_events) == 0))
2310 vlib_cli_output (vm, "No active arp or nd event registrations");
2315 pool_foreach (arp_event, am->arp_events,
2317 vlib_cli_output (vm, "%U", format_arp_event, arp_event);
2320 pool_foreach (nd_event, am->nd_events,
2322 vlib_cli_output (vm, "%U", format_nd_event, nd_event);
2330 VLIB_CLI_COMMAND (show_ip_arp_nd_events, static) = {
2331 .path = "show arp-nd-event registrations",
2332 .function = show_ip_arp_nd_events_fn,
2333 .short_help = "Show ip4 arp and ip6 nd event registrations",
2337 #define vl_msg_name_crc_list
2338 #include <vpp/api/vpe_all_api_h.h>
2339 #undef vl_msg_name_crc_list
2342 setup_message_id_table (api_main_t * am)
2344 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
2345 foreach_vl_msg_name_crc_memclnt;
2346 foreach_vl_msg_name_crc_vpe;
2352 * fd.io coding-style-patch-verification: ON
2355 * eval: (c-set-style "gnu")