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>
55 #include <vnet/dhcp/proxy.h>
56 #include <vnet/dhcp/client.h>
58 #include <vnet/sr/sr.h>
60 #include <vnet/dhcpv6/proxy.h>
61 #include <vlib/vlib.h>
62 #include <vlib/unix/unix.h>
63 #include <vlibapi/api.h>
64 #include <vlibmemory/api.h>
65 #include <vnet/classify/input_acl.h>
66 #include <vnet/l2/l2_classify.h>
67 #include <vnet/vxlan/vxlan.h>
68 #include <vnet/l2/l2_vtr.h>
69 #include <vnet/vxlan-gpe/vxlan_gpe.h>
70 #include <vnet/map/map.h>
71 #include <vnet/cop/cop.h>
72 #include <vnet/ip/ip6_hop_by_hop.h>
73 #include <vnet/ip/ip_source_and_port_range_check.h>
74 #include <vnet/policer/policer.h>
75 #include <vnet/ip/punt.h>
76 #include <vnet/feature/feature.h>
79 #undef __included_bihash_template_h__
80 #include <vnet/l2/l2_fib.h>
82 #include <vpp/stats/stats.h>
83 #include <vpp/oam/oam.h>
85 #include <vnet/ethernet/ethernet.h>
86 #include <vnet/ethernet/arp_packet.h>
87 #include <vnet/interface.h>
88 #include <vnet/l2/l2_fib.h>
89 #include <vnet/l2/l2_bd.h>
90 #include <vpp/api/vpe_msg_enum.h>
91 #include <vnet/span/span.h>
92 #include <vnet/fib/ip6_fib.h>
93 #include <vnet/fib/ip4_fib.h>
94 #include <vnet/fib/fib_api.h>
95 #include <vnet/dpo/drop_dpo.h>
96 #include <vnet/dpo/receive_dpo.h>
97 #include <vnet/dpo/lookup_dpo.h>
98 #include <vnet/dpo/classify_dpo.h>
99 #include <vnet/dpo/ip_null_dpo.h>
100 #define vl_typedefs /* define message structures */
101 #include <vpp/api/vpe_all_api_h.h>
103 #define vl_endianfun /* define message structures */
104 #include <vpp/api/vpe_all_api_h.h>
106 /* instantiate all the print functions we know about */
107 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
109 #include <vpp/api/vpe_all_api_h.h>
111 #include <vlibapi/api_helper_macros.h>
112 #define foreach_vpe_api_msg \
113 _(WANT_OAM_EVENTS, want_oam_events) \
114 _(OAM_ADD_DEL, oam_add_del) \
115 _(IS_ADDRESS_REACHABLE, is_address_reachable) \
116 _(SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable) \
117 _(SW_INTERFACE_SET_VPATH, sw_interface_set_vpath) \
118 _(SW_INTERFACE_SET_VXLAN_BYPASS, sw_interface_set_vxlan_bypass) \
119 _(SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect) \
120 _(SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge) \
121 _(CREATE_VLAN_SUBIF, create_vlan_subif) \
122 _(CREATE_SUBIF, create_subif) \
123 _(PROXY_ARP_ADD_DEL, proxy_arp_add_del) \
124 _(PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable) \
125 _(VNET_GET_SUMMARY_STATS, vnet_get_summary_stats) \
126 _(RESET_FIB, reset_fib) \
127 _(DHCP_PROXY_CONFIG,dhcp_proxy_config) \
128 _(DHCP_PROXY_CONFIG_2,dhcp_proxy_config_2) \
129 _(DHCP_PROXY_SET_VSS,dhcp_proxy_set_vss) \
130 _(DHCP_CLIENT_CONFIG, dhcp_client_config) \
131 _(CREATE_LOOPBACK, create_loopback) \
132 _(CONTROL_PING, control_ping) \
133 _(CLI_REQUEST, cli_request) \
134 _(CLI_INBAND, cli_inband) \
135 _(SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit) \
136 _(L2_PATCH_ADD_DEL, l2_patch_add_del) \
137 _(CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table) \
138 _(CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables) \
139 _(GET_NODE_INDEX, get_node_index) \
140 _(ADD_NODE_NEXT, add_node_next) \
141 _(VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel) \
142 _(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump) \
143 _(L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter) \
144 _(L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite) \
145 _(SHOW_VERSION, show_version) \
146 _(VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel) \
147 _(VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump) \
148 _(INTERFACE_NAME_RENUMBER, interface_name_renumber) \
149 _(WANT_IP4_ARP_EVENTS, want_ip4_arp_events) \
150 _(WANT_IP6_ND_EVENTS, want_ip6_nd_events) \
151 _(INPUT_ACL_SET_INTERFACE, input_acl_set_interface) \
152 _(DELETE_LOOPBACK, delete_loopback) \
153 _(BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del) \
154 _(COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable) \
155 _(COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable) \
156 _(GET_NODE_GRAPH, get_node_graph) \
157 _(IOAM_ENABLE, ioam_enable) \
158 _(IOAM_DISABLE, ioam_disable) \
159 _(POLICER_ADD_DEL, policer_add_del) \
160 _(POLICER_DUMP, policer_dump) \
161 _(GET_NEXT_INDEX, get_next_index) \
162 _(PG_CREATE_INTERFACE, pg_create_interface) \
163 _(PG_CAPTURE, pg_capture) \
164 _(PG_ENABLE_DISABLE, pg_enable_disable) \
165 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, \
166 ip_source_and_port_range_check_add_del) \
167 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, \
168 ip_source_and_port_range_check_interface_add_del) \
169 _(DELETE_SUBIF, delete_subif) \
170 _(L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite) \
172 _(FEATURE_ENABLE_DISABLE, feature_enable_disable)
175 #define QUOTE(x) QUOTE_(x)
178 RESOLVE_IP4_ADD_DEL_ROUTE = 1,
179 RESOLVE_IP6_ADD_DEL_ROUTE,
182 static vlib_node_registration_t vpe_resolver_process_node;
183 vpe_api_main_t vpe_api_main;
185 static int arp_change_delete_callback (u32 pool_index, u8 * notused);
186 static int nd_change_delete_callback (u32 pool_index, u8 * notused);
188 /* Clean up all registrations belonging to the indicated client */
190 vl_api_memclnt_delete_callback (u32 client_index)
192 vpe_api_main_t *vam = &vpe_api_main;
193 vpe_client_registration_t *rp;
195 int stats_memclnt_delete_callback (u32 client_index);
197 stats_memclnt_delete_callback (client_index);
200 p = hash_get (vam->a##_registration_hash, client_index); \
202 rp = pool_elt_at_index (vam->a##_registrations, p[0]); \
203 pool_put (vam->a##_registrations, rp); \
204 hash_unset (vam->a##_registration_hash, client_index); \
206 foreach_registration_hash;
211 pub_sub_handler (oam_events, OAM_EVENTS);
213 #define RESOLUTION_EVENT 1
214 #define RESOLUTION_PENDING_EVENT 2
215 #define IP4_ARP_EVENT 3
216 #define IP6_ND_EVENT 4
218 int ip4_add_del_route_t_handler (vl_api_ip_add_del_route_t * mp);
220 int ip6_add_del_route_t_handler (vl_api_ip_add_del_route_t * mp);
223 handle_ip4_arp_event (u32 pool_index)
225 vpe_api_main_t *vam = &vpe_api_main;
226 vnet_main_t *vnm = vam->vnet_main;
227 vlib_main_t *vm = vam->vlib_main;
228 vl_api_ip4_arp_event_t *event;
229 vl_api_ip4_arp_event_t *mp;
230 unix_shared_memory_queue_t *q;
232 /* Client can cancel, die, etc. */
233 if (pool_is_free_index (vam->arp_events, pool_index))
236 event = pool_elt_at_index (vam->arp_events, pool_index);
238 q = vl_api_client_index_to_input_queue (event->client_index);
241 (void) vnet_add_del_ip4_arp_change_event
242 (vnm, arp_change_delete_callback,
243 event->pid, &event->address,
244 vpe_resolver_process_node.index, IP4_ARP_EVENT,
245 ~0 /* pool index, notused */ , 0 /* is_add */ );
249 if (q->cursize < q->maxsize)
251 mp = vl_msg_api_alloc (sizeof (*mp));
252 clib_memcpy (mp, event, sizeof (*mp));
253 vl_msg_api_send_shmem (q, (u8 *) & mp);
257 static f64 last_time;
259 * Throttle syslog msgs.
260 * It's pretty tempting to just revoke the registration...
262 if (vlib_time_now (vm) > last_time + 10.0)
264 clib_warning ("arp event for %U to pid %d: queue stuffed!",
265 format_ip4_address, &event->address, event->pid);
266 last_time = vlib_time_now (vm);
272 handle_ip6_nd_event (u32 pool_index)
274 vpe_api_main_t *vam = &vpe_api_main;
275 vnet_main_t *vnm = vam->vnet_main;
276 vlib_main_t *vm = vam->vlib_main;
277 vl_api_ip6_nd_event_t *event;
278 vl_api_ip6_nd_event_t *mp;
279 unix_shared_memory_queue_t *q;
281 /* Client can cancel, die, etc. */
282 if (pool_is_free_index (vam->nd_events, pool_index))
285 event = pool_elt_at_index (vam->nd_events, pool_index);
287 q = vl_api_client_index_to_input_queue (event->client_index);
290 (void) vnet_add_del_ip6_nd_change_event
291 (vnm, nd_change_delete_callback,
292 event->pid, &event->address,
293 vpe_resolver_process_node.index, IP6_ND_EVENT,
294 ~0 /* pool index, notused */ , 0 /* is_add */ );
298 if (q->cursize < q->maxsize)
300 mp = vl_msg_api_alloc (sizeof (*mp));
301 clib_memcpy (mp, event, sizeof (*mp));
302 vl_msg_api_send_shmem (q, (u8 *) & mp);
306 static f64 last_time;
308 * Throttle syslog msgs.
309 * It's pretty tempting to just revoke the registration...
311 if (vlib_time_now (vm) > last_time + 10.0)
313 clib_warning ("ip6 nd event for %U to pid %d: queue stuffed!",
314 format_ip6_address, &event->address, event->pid);
315 last_time = vlib_time_now (vm);
321 resolver_process (vlib_main_t * vm,
322 vlib_node_runtime_t * rt, vlib_frame_t * f)
325 uword *event_data = 0;
331 vlib_process_wait_for_event_or_clock (vm, timeout);
333 event_type = vlib_process_get_events (vm, &event_data);
337 case RESOLUTION_PENDING_EVENT:
341 case RESOLUTION_EVENT:
342 clib_warning ("resolver: BOGUS TYPE");
346 for (i = 0; i < vec_len (event_data); i++)
347 handle_ip4_arp_event (event_data[i]);
351 for (i = 0; i < vec_len (event_data); i++)
352 handle_ip6_nd_event (event_data[i]);
355 case ~0: /* timeout */
359 vec_reset_length (event_data);
361 return 0; /* or not */
365 VLIB_REGISTER_NODE (vpe_resolver_process_node,static) = {
366 .function = resolver_process,
367 .type = VLIB_NODE_TYPE_PROCESS,
368 .name = "vpe-route-resolver-process",
373 vl_api_sw_interface_set_vpath_t_handler (vl_api_sw_interface_set_vpath_t * mp)
375 vl_api_sw_interface_set_vpath_reply_t *rmp;
377 u32 sw_if_index = ntohl (mp->sw_if_index);
379 VALIDATE_SW_IF_INDEX (mp);
381 l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_VPATH, mp->enable);
382 vnet_feature_enable_disable ("ip4-unicast", "vpath-input-ip4",
383 sw_if_index, mp->enable, 0, 0);
384 vnet_feature_enable_disable ("ip4-multicast", "vpath-input-ip4",
385 sw_if_index, mp->enable, 0, 0);
386 vnet_feature_enable_disable ("ip6-unicast", "vpath-input-ip6",
387 sw_if_index, mp->enable, 0, 0);
388 vnet_feature_enable_disable ("ip6-multicast", "vpath-input-ip6",
389 sw_if_index, mp->enable, 0, 0);
391 BAD_SW_IF_INDEX_LABEL;
393 REPLY_MACRO (VL_API_SW_INTERFACE_SET_VPATH_REPLY);
397 vl_api_sw_interface_set_vxlan_bypass_t_handler
398 (vl_api_sw_interface_set_vxlan_bypass_t * mp)
400 vl_api_sw_interface_set_vxlan_bypass_reply_t *rmp;
402 u32 sw_if_index = ntohl (mp->sw_if_index);
404 VALIDATE_SW_IF_INDEX (mp);
408 /* not yet implemented */
411 vnet_feature_enable_disable ("ip4-unicast", "ip4-vxlan-bypass",
412 sw_if_index, mp->enable, 0, 0);
414 BAD_SW_IF_INDEX_LABEL;
416 REPLY_MACRO (VL_API_SW_INTERFACE_SET_VXLAN_BYPASS_REPLY);
420 vl_api_sw_interface_set_l2_xconnect_t_handler
421 (vl_api_sw_interface_set_l2_xconnect_t * mp)
423 vl_api_sw_interface_set_l2_xconnect_reply_t *rmp;
425 u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index);
426 u32 tx_sw_if_index = ntohl (mp->tx_sw_if_index);
427 vlib_main_t *vm = vlib_get_main ();
428 vnet_main_t *vnm = vnet_get_main ();
430 VALIDATE_RX_SW_IF_INDEX (mp);
434 VALIDATE_TX_SW_IF_INDEX (mp);
435 rv = set_int_l2_mode (vm, vnm, MODE_L2_XC,
436 rx_sw_if_index, 0, 0, 0, tx_sw_if_index);
440 rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, 0, 0, 0);
443 BAD_RX_SW_IF_INDEX_LABEL;
444 BAD_TX_SW_IF_INDEX_LABEL;
446 REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_XCONNECT_REPLY);
450 vl_api_sw_interface_set_l2_bridge_t_handler
451 (vl_api_sw_interface_set_l2_bridge_t * mp)
453 bd_main_t *bdm = &bd_main;
454 vl_api_sw_interface_set_l2_bridge_reply_t *rmp;
456 u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index);
457 u32 bd_id = ntohl (mp->bd_id);
461 vlib_main_t *vm = vlib_get_main ();
462 vnet_main_t *vnm = vnet_get_main ();
464 VALIDATE_RX_SW_IF_INDEX (mp);
466 bd_index = bd_find_or_add_bd_index (bdm, bd_id);
470 //VALIDATE_TX_SW_IF_INDEX(mp);
471 rv = set_int_l2_mode (vm, vnm, MODE_L2_BRIDGE,
472 rx_sw_if_index, bd_index, bvi, shg, 0);
476 rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, 0, 0, 0);
479 BAD_RX_SW_IF_INDEX_LABEL;
481 REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_BRIDGE_REPLY);
485 vl_api_bd_ip_mac_add_del_t_handler (vl_api_bd_ip_mac_add_del_t * mp)
487 bd_main_t *bdm = &bd_main;
488 vl_api_bd_ip_mac_add_del_reply_t *rmp;
490 u32 bd_id = ntohl (mp->bd_id);
494 p = hash_get (bdm->bd_index_by_bd_id, bd_id);
497 rv = VNET_API_ERROR_NO_SUCH_ENTRY;
502 if (bd_add_del_ip_mac (bd_index, mp->ip_address,
503 mp->mac_address, mp->is_ipv6, mp->is_add))
504 rv = VNET_API_ERROR_UNSPECIFIED;
507 REPLY_MACRO (VL_API_BD_IP_MAC_ADD_DEL_REPLY);
511 vl_api_create_vlan_subif_t_handler (vl_api_create_vlan_subif_t * mp)
513 vl_api_create_vlan_subif_reply_t *rmp;
514 vnet_main_t *vnm = vnet_get_main ();
515 u32 hw_if_index, sw_if_index = (u32) ~ 0;
516 vnet_hw_interface_t *hi;
519 vnet_sw_interface_t template;
521 vnet_interface_main_t *im = &vnm->interface_main;
524 unix_shared_memory_queue_t *q;
527 VALIDATE_SW_IF_INDEX (mp);
529 hw_if_index = ntohl (mp->sw_if_index);
530 hi = vnet_get_hw_interface (vnm, hw_if_index);
532 id = ntohl (mp->vlan_id);
533 if (id == 0 || id > 4095)
535 rv = VNET_API_ERROR_INVALID_VLAN;
539 sup_and_sub_key = ((u64) (hi->sw_if_index) << 32) | (u64) id;
541 p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
544 rv = VNET_API_ERROR_VLAN_ALREADY_EXISTS;
548 kp = clib_mem_alloc (sizeof (*kp));
549 *kp = sup_and_sub_key;
551 memset (&template, 0, sizeof (template));
552 template.type = VNET_SW_INTERFACE_TYPE_SUB;
553 template.sup_sw_if_index = hi->sw_if_index;
554 template.sub.id = id;
555 template.sub.eth.raw_flags = 0;
556 template.sub.eth.flags.one_tag = 1;
557 template.sub.eth.outer_vlan_id = id;
558 template.sub.eth.flags.exact_match = 1;
560 error = vnet_create_sw_interface (vnm, &template, &sw_if_index);
563 clib_error_report (error);
564 rv = VNET_API_ERROR_INVALID_REGISTRATION;
567 hash_set (hi->sub_interface_sw_if_index_by_id, id, sw_if_index);
568 hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index);
570 BAD_SW_IF_INDEX_LABEL;
573 q = vl_api_client_index_to_input_queue (mp->client_index);
577 rmp = vl_msg_api_alloc (sizeof (*rmp));
578 rmp->_vl_msg_id = ntohs (VL_API_CREATE_VLAN_SUBIF_REPLY);
579 rmp->context = mp->context;
580 rmp->retval = ntohl (rv);
581 rmp->sw_if_index = ntohl (sw_if_index);
582 vl_msg_api_send_shmem (q, (u8 *) & rmp);
586 vl_api_create_subif_t_handler (vl_api_create_subif_t * mp)
588 vl_api_create_subif_reply_t *rmp;
589 vnet_main_t *vnm = vnet_get_main ();
590 u32 sw_if_index = ~0;
593 vnet_sw_interface_t *si;
594 vnet_hw_interface_t *hi;
595 vnet_sw_interface_t template;
597 vnet_interface_main_t *im = &vnm->interface_main;
602 VALIDATE_SW_IF_INDEX (mp);
604 si = vnet_get_sup_sw_interface (vnm, ntohl (mp->sw_if_index));
605 hi = vnet_get_sup_hw_interface (vnm, ntohl (mp->sw_if_index));
607 if (hi->bond_info == VNET_HW_INTERFACE_BOND_INFO_SLAVE)
609 rv = VNET_API_ERROR_BOND_SLAVE_NOT_ALLOWED;
613 sw_if_index = si->sw_if_index;
614 sub_id = ntohl (mp->sub_id);
616 sup_and_sub_key = ((u64) (sw_if_index) << 32) | (u64) sub_id;
618 p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
622 clib_warning ("sup sw_if_index %d, sub id %d already exists\n",
623 sw_if_index, sub_id);
624 rv = VNET_API_ERROR_SUBIF_ALREADY_EXISTS;
628 kp = clib_mem_alloc (sizeof (*kp));
629 *kp = sup_and_sub_key;
631 memset (&template, 0, sizeof (template));
632 template.type = VNET_SW_INTERFACE_TYPE_SUB;
633 template.sup_sw_if_index = sw_if_index;
634 template.sub.id = sub_id;
635 template.sub.eth.flags.no_tags = mp->no_tags;
636 template.sub.eth.flags.one_tag = mp->one_tag;
637 template.sub.eth.flags.two_tags = mp->two_tags;
638 template.sub.eth.flags.dot1ad = mp->dot1ad;
639 template.sub.eth.flags.exact_match = mp->exact_match;
640 template.sub.eth.flags.default_sub = mp->default_sub;
641 template.sub.eth.flags.outer_vlan_id_any = mp->outer_vlan_id_any;
642 template.sub.eth.flags.inner_vlan_id_any = mp->inner_vlan_id_any;
643 template.sub.eth.outer_vlan_id = ntohs (mp->outer_vlan_id);
644 template.sub.eth.inner_vlan_id = ntohs (mp->inner_vlan_id);
646 error = vnet_create_sw_interface (vnm, &template, &sw_if_index);
649 clib_error_report (error);
650 rv = VNET_API_ERROR_SUBIF_CREATE_FAILED;
654 hash_set (hi->sub_interface_sw_if_index_by_id, sub_id, sw_if_index);
655 hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index);
657 BAD_SW_IF_INDEX_LABEL;
662 REPLY_MACRO2(VL_API_CREATE_SUBIF_REPLY,
664 rmp->sw_if_index = ntohl(sw_if_index);
670 vl_api_proxy_arp_add_del_t_handler (vl_api_proxy_arp_add_del_t * mp)
672 vl_api_proxy_arp_add_del_reply_t *rmp;
675 ip4_main_t *im = &ip4_main;
676 stats_main_t *sm = &stats_main;
677 int vnet_proxy_arp_add_del (ip4_address_t * lo_addr,
678 ip4_address_t * hi_addr,
679 u32 fib_index, int is_del);
682 dslock (sm, 1 /* release hint */ , 6 /* tag */ );
684 p = hash_get (im->fib_index_by_table_id, ntohl (mp->vrf_id));
688 rv = VNET_API_ERROR_NO_SUCH_FIB;
694 rv = vnet_proxy_arp_add_del ((ip4_address_t *) mp->low_address,
695 (ip4_address_t *) mp->hi_address,
696 fib_index, mp->is_add == 0);
700 REPLY_MACRO (VL_API_PROXY_ARP_ADD_DEL_REPLY);
704 vl_api_proxy_arp_intfc_enable_disable_t_handler
705 (vl_api_proxy_arp_intfc_enable_disable_t * mp)
708 vnet_main_t *vnm = vnet_get_main ();
709 vl_api_proxy_arp_intfc_enable_disable_reply_t *rmp;
710 vnet_sw_interface_t *si;
713 VALIDATE_SW_IF_INDEX (mp);
715 sw_if_index = ntohl (mp->sw_if_index);
717 if (pool_is_free_index (vnm->interface_main.sw_interfaces, sw_if_index))
719 rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
723 si = vnet_get_sw_interface (vnm, sw_if_index);
727 if (mp->enable_disable)
728 si->flags |= VNET_SW_INTERFACE_FLAG_PROXY_ARP;
730 si->flags &= ~VNET_SW_INTERFACE_FLAG_PROXY_ARP;
732 BAD_SW_IF_INDEX_LABEL;
735 REPLY_MACRO (VL_API_PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY);
739 vl_api_is_address_reachable_t_handler (vl_api_is_address_reachable_t * mp)
742 vpe_main_t *rm = &vpe_main;
743 ip4_main_t *im4 = &ip4_main;
744 ip6_main_t *im6 = &ip6_main;
745 ip_lookup_main_t *lm;
751 u32 adj_index, sw_if_index;
752 vl_api_is_address_reachable_t *rmp;
754 unix_shared_memory_queue_t *q;
756 q = vl_api_client_index_to_input_queue (mp->client_index);
759 increment_missing_api_client_counter (rm->vlib_main);
763 rmp = vl_msg_api_alloc (sizeof (*rmp));
764 clib_memcpy (rmp, mp, sizeof (*rmp));
766 sw_if_index = mp->next_hop_sw_if_index;
767 clib_memcpy (&addr, mp->address, sizeof (addr));
770 lm = &im6->lookup_main;
771 adj_index = ip6_fib_lookup (im6, sw_if_index, &addr.ip6);
775 lm = &im4->lookup_main;
777 adj_index = ip4_fib_lookup (im4, sw_if_index, &addr.ip4);
784 adj = ip_get_adjacency (lm, adj_index);
786 if (adj->lookup_next_index == IP_LOOKUP_NEXT_REWRITE
787 && adj->rewrite_header.sw_if_index == sw_if_index)
793 if (adj->lookup_next_index == IP_LOOKUP_NEXT_ARP
794 && adj->rewrite_header.sw_if_index == sw_if_index)
797 ip6_probe_neighbor (rm->vlib_main, &addr.ip6, sw_if_index);
799 ip4_probe_neighbor (rm->vlib_main, &addr.ip4, sw_if_index);
801 else if (adj->lookup_next_index == IP_LOOKUP_NEXT_DROP)
810 vl_msg_api_send_shmem (q, (u8 *) & rmp);
815 vl_api_sw_interface_set_mpls_enable_t_handler
816 (vl_api_sw_interface_set_mpls_enable_t * mp)
818 vl_api_sw_interface_set_mpls_enable_reply_t *rmp;
821 VALIDATE_SW_IF_INDEX (mp);
823 mpls_sw_interface_enable_disable (&mpls_main,
824 ntohl (mp->sw_if_index), mp->enable);
826 BAD_SW_IF_INDEX_LABEL;
827 REPLY_MACRO (VL_API_SW_INTERFACE_SET_MPLS_ENABLE_REPLY);
831 send_oam_event (oam_target_t * t)
833 vpe_api_main_t *vam = &vpe_api_main;
834 unix_shared_memory_queue_t *q;
835 vpe_client_registration_t *reg;
836 vl_api_oam_event_t *mp;
839 pool_foreach(reg, vam->oam_events_registrations,
841 q = vl_api_client_index_to_input_queue (reg->client_index);
844 mp = vl_msg_api_alloc (sizeof (*mp));
845 mp->_vl_msg_id = ntohs (VL_API_OAM_EVENT);
846 clib_memcpy (mp->dst_address, &t->dst_address,
847 sizeof (mp->dst_address));
848 mp->state = t->state;
849 vl_msg_api_send_shmem (q, (u8 *)&mp);
856 vl_api_oam_add_del_t_handler (vl_api_oam_add_del_t * mp)
858 vl_api_oam_add_del_reply_t *rmp;
861 rv = vpe_oam_add_del_target ((ip4_address_t *) mp->src_address,
862 (ip4_address_t *) mp->dst_address,
863 ntohl (mp->vrf_id), (int) (mp->is_add));
865 REPLY_MACRO (VL_API_OAM_ADD_DEL_REPLY);
869 vl_api_vnet_get_summary_stats_t_handler (vl_api_vnet_get_summary_stats_t * mp)
871 stats_main_t *sm = &stats_main;
872 vnet_interface_main_t *im = sm->interface_main;
873 vl_api_vnet_summary_stats_reply_t *rmp;
874 vlib_combined_counter_main_t *cm;
877 u64 total_pkts[VLIB_N_RX_TX];
878 u64 total_bytes[VLIB_N_RX_TX];
880 unix_shared_memory_queue_t *q =
881 vl_api_client_index_to_input_queue (mp->client_index);
886 rmp = vl_msg_api_alloc (sizeof (*rmp));
887 rmp->_vl_msg_id = ntohs (VL_API_VNET_SUMMARY_STATS_REPLY);
888 rmp->context = mp->context;
891 memset (total_pkts, 0, sizeof (total_pkts));
892 memset (total_bytes, 0, sizeof (total_bytes));
894 vnet_interface_counter_lock (im);
896 vec_foreach (cm, im->combined_sw_if_counters)
898 which = cm - im->combined_sw_if_counters;
900 for (i = 0; i < vec_len (cm->maxi); i++)
902 vlib_get_combined_counter (cm, i, &v);
903 total_pkts[which] += v.packets;
904 total_bytes[which] += v.bytes;
907 vnet_interface_counter_unlock (im);
909 rmp->total_pkts[VLIB_RX] = clib_host_to_net_u64 (total_pkts[VLIB_RX]);
910 rmp->total_bytes[VLIB_RX] = clib_host_to_net_u64 (total_bytes[VLIB_RX]);
911 rmp->total_pkts[VLIB_TX] = clib_host_to_net_u64 (total_pkts[VLIB_TX]);
912 rmp->total_bytes[VLIB_TX] = clib_host_to_net_u64 (total_bytes[VLIB_TX]);
914 clib_host_to_net_u64 (vlib_last_vector_length_per_node (sm->vlib_main));
916 vl_msg_api_send_shmem (q, (u8 *) & rmp);
920 typedef CLIB_PACKED (struct {
921 ip4_address_t address;
922 u32 address_length: 6;
928 ip4_reset_fib_t_handler (vl_api_reset_fib_t * mp)
930 vnet_main_t *vnm = vnet_get_main ();
931 vnet_interface_main_t *im = &vnm->interface_main;
932 ip4_main_t *im4 = &ip4_main;
933 static u32 *sw_if_indices_to_shut;
934 stats_main_t *sm = &stats_main;
935 fib_table_t *fib_table;
939 int rv = VNET_API_ERROR_NO_SUCH_FIB;
940 u32 target_fib_id = ntohl (mp->vrf_id);
942 dslock (sm, 1 /* release hint */ , 8 /* tag */ );
945 pool_foreach (fib_table, im4->fibs,
947 fib = &fib_table->v4;
948 vnet_sw_interface_t * si;
950 if (fib->table_id != target_fib_id)
953 /* remove any mpls encap/decap labels */
954 mpls_fib_reset_labels (fib->table_id);
956 /* remove any proxy arps in this fib */
957 vnet_proxy_arp_fib_reset (fib->table_id);
959 /* Set the flow hash for this fib to the default */
960 vnet_set_ip4_flow_hash (fib->table_id, IP_FLOW_HASH_DEFAULT);
962 vec_reset_length (sw_if_indices_to_shut);
964 /* Shut down interfaces in this FIB / clean out intfc routes */
965 pool_foreach (si, im->sw_interfaces,
967 u32 sw_if_index = si->sw_if_index;
969 if (sw_if_index < vec_len (im4->fib_index_by_sw_if_index)
970 && (im4->fib_index_by_sw_if_index[si->sw_if_index] ==
972 vec_add1 (sw_if_indices_to_shut, si->sw_if_index);
975 for (i = 0; i < vec_len (sw_if_indices_to_shut); i++) {
976 sw_if_index = sw_if_indices_to_shut[i];
977 // vec_foreach (sw_if_index, sw_if_indices_to_shut) {
979 u32 flags = vnet_sw_interface_get_flags (vnm, sw_if_index);
980 flags &= ~(VNET_SW_INTERFACE_FLAG_ADMIN_UP);
981 vnet_sw_interface_set_flags (vnm, sw_if_index, flags);
984 fib_table_flush(fib->index, FIB_PROTOCOL_IP4, FIB_SOURCE_API);
985 fib_table_flush(fib->index, FIB_PROTOCOL_IP4, FIB_SOURCE_INTERFACE);
989 })); /* pool_foreach (fib) */
997 ip6_reset_fib_t_handler (vl_api_reset_fib_t * mp)
999 vnet_main_t *vnm = vnet_get_main ();
1000 vnet_interface_main_t *im = &vnm->interface_main;
1001 ip6_main_t *im6 = &ip6_main;
1002 stats_main_t *sm = &stats_main;
1003 static u32 *sw_if_indices_to_shut;
1004 fib_table_t *fib_table;
1008 int rv = VNET_API_ERROR_NO_SUCH_FIB;
1009 u32 target_fib_id = ntohl (mp->vrf_id);
1011 dslock (sm, 1 /* release hint */ , 9 /* tag */ );
1014 pool_foreach (fib_table, im6->fibs,
1016 vnet_sw_interface_t * si;
1017 fib = &(fib_table->v6);
1019 if (fib->table_id != target_fib_id)
1022 vec_reset_length (sw_if_indices_to_shut);
1024 /* Shut down interfaces in this FIB / clean out intfc routes */
1025 pool_foreach (si, im->sw_interfaces,
1027 if (im6->fib_index_by_sw_if_index[si->sw_if_index] ==
1029 vec_add1 (sw_if_indices_to_shut, si->sw_if_index);
1032 for (i = 0; i < vec_len (sw_if_indices_to_shut); i++) {
1033 sw_if_index = sw_if_indices_to_shut[i];
1034 // vec_foreach (sw_if_index, sw_if_indices_to_shut) {
1036 u32 flags = vnet_sw_interface_get_flags (vnm, sw_if_index);
1037 flags &= ~(VNET_SW_INTERFACE_FLAG_ADMIN_UP);
1038 vnet_sw_interface_set_flags (vnm, sw_if_index, flags);
1041 fib_table_flush(fib->index, FIB_PROTOCOL_IP6, FIB_SOURCE_API);
1042 fib_table_flush(fib->index, FIB_PROTOCOL_IP6, FIB_SOURCE_INTERFACE);
1046 })); /* pool_foreach (fib) */
1054 vl_api_reset_fib_t_handler (vl_api_reset_fib_t * mp)
1057 vl_api_reset_fib_reply_t *rmp;
1060 rv = ip6_reset_fib_t_handler (mp);
1062 rv = ip4_reset_fib_t_handler (mp);
1064 REPLY_MACRO (VL_API_RESET_FIB_REPLY);
1069 dhcpv4_proxy_config (vl_api_dhcp_proxy_config_t * mp)
1071 vl_api_dhcp_proxy_config_reply_t *rmp;
1074 rv = dhcp_proxy_set_server ((ip4_address_t *) (&mp->dhcp_server),
1075 (ip4_address_t *) (&mp->dhcp_src_address),
1076 (u32) ntohl (mp->vrf_id),
1077 (int) mp->insert_circuit_id,
1078 (int) (mp->is_add == 0));
1080 REPLY_MACRO (VL_API_DHCP_PROXY_CONFIG_REPLY);
1085 dhcpv6_proxy_config (vl_api_dhcp_proxy_config_t * mp)
1087 vl_api_dhcp_proxy_config_reply_t *rmp;
1090 rv = dhcpv6_proxy_set_server ((ip6_address_t *) (&mp->dhcp_server),
1091 (ip6_address_t *) (&mp->dhcp_src_address),
1092 (u32) ntohl (mp->vrf_id),
1093 (int) mp->insert_circuit_id,
1094 (int) (mp->is_add == 0));
1096 REPLY_MACRO (VL_API_DHCP_PROXY_CONFIG_REPLY);
1100 dhcpv4_proxy_config_2 (vl_api_dhcp_proxy_config_2_t * mp)
1102 vl_api_dhcp_proxy_config_reply_t *rmp;
1105 rv = dhcp_proxy_set_server_2 ((ip4_address_t *) (&mp->dhcp_server),
1106 (ip4_address_t *) (&mp->dhcp_src_address),
1107 (u32) ntohl (mp->rx_vrf_id),
1108 (u32) ntohl (mp->server_vrf_id),
1109 (int) mp->insert_circuit_id,
1110 (int) (mp->is_add == 0));
1112 REPLY_MACRO (VL_API_DHCP_PROXY_CONFIG_2_REPLY);
1117 dhcpv6_proxy_config_2 (vl_api_dhcp_proxy_config_2_t * mp)
1119 vl_api_dhcp_proxy_config_reply_t *rmp;
1122 rv = dhcpv6_proxy_set_server_2 ((ip6_address_t *) (&mp->dhcp_server),
1123 (ip6_address_t *) (&mp->dhcp_src_address),
1124 (u32) ntohl (mp->rx_vrf_id),
1125 (u32) ntohl (mp->server_vrf_id),
1126 (int) mp->insert_circuit_id,
1127 (int) (mp->is_add == 0));
1129 REPLY_MACRO (VL_API_DHCP_PROXY_CONFIG_2_REPLY);
1134 vl_api_dhcp_proxy_set_vss_t_handler (vl_api_dhcp_proxy_set_vss_t * mp)
1136 vl_api_dhcp_proxy_set_vss_reply_t *rmp;
1139 rv = dhcp_proxy_set_option82_vss (ntohl (mp->tbl_id),
1142 (int) mp->is_add == 0);
1144 rv = dhcpv6_proxy_set_vss (ntohl (mp->tbl_id),
1146 ntohl (mp->fib_id), (int) mp->is_add == 0);
1148 REPLY_MACRO (VL_API_DHCP_PROXY_SET_VSS_REPLY);
1152 static void vl_api_dhcp_proxy_config_t_handler
1153 (vl_api_dhcp_proxy_config_t * mp)
1155 if (mp->is_ipv6 == 0)
1156 dhcpv4_proxy_config (mp);
1158 dhcpv6_proxy_config (mp);
1161 static void vl_api_dhcp_proxy_config_2_t_handler
1162 (vl_api_dhcp_proxy_config_2_t * mp)
1164 if (mp->is_ipv6 == 0)
1165 dhcpv4_proxy_config_2 (mp);
1167 dhcpv6_proxy_config_2 (mp);
1171 dhcp_compl_event_callback (u32 client_index, u32 pid, u8 * hostname,
1172 u8 is_ipv6, u8 * host_address, u8 * router_address,
1175 unix_shared_memory_queue_t *q;
1176 vl_api_dhcp_compl_event_t *mp;
1178 q = vl_api_client_index_to_input_queue (client_index);
1182 mp = vl_msg_api_alloc (sizeof (*mp));
1183 mp->client_index = client_index;
1185 mp->is_ipv6 = is_ipv6;
1186 clib_memcpy (&mp->hostname, hostname, vec_len (hostname));
1187 mp->hostname[vec_len (hostname) + 1] = '\n';
1188 clib_memcpy (&mp->host_address[0], host_address, 16);
1189 clib_memcpy (&mp->router_address[0], router_address, 16);
1191 if (NULL != host_mac)
1192 clib_memcpy (&mp->host_mac[0], host_mac, 6);
1194 mp->_vl_msg_id = ntohs (VL_API_DHCP_COMPL_EVENT);
1196 vl_msg_api_send_shmem (q, (u8 *) & mp);
1199 static void vl_api_dhcp_client_config_t_handler
1200 (vl_api_dhcp_client_config_t * mp)
1202 vlib_main_t *vm = vlib_get_main ();
1203 vl_api_dhcp_client_config_reply_t *rmp;
1206 VALIDATE_SW_IF_INDEX (mp);
1208 rv = dhcp_client_config (vm, ntohl (mp->sw_if_index),
1209 mp->hostname, mp->is_add, mp->client_index,
1210 mp->want_dhcp_event ? dhcp_compl_event_callback :
1213 BAD_SW_IF_INDEX_LABEL;
1215 REPLY_MACRO (VL_API_DHCP_CLIENT_CONFIG_REPLY);
1219 vl_api_create_loopback_t_handler (vl_api_create_loopback_t * mp)
1221 vl_api_create_loopback_reply_t *rmp;
1225 rv = vnet_create_loopback_interface (&sw_if_index, mp->mac_address);
1228 REPLY_MACRO2(VL_API_CREATE_LOOPBACK_REPLY,
1230 rmp->sw_if_index = ntohl (sw_if_index);
1236 vl_api_delete_loopback_t_handler (vl_api_delete_loopback_t * mp)
1238 vl_api_delete_loopback_reply_t *rmp;
1242 sw_if_index = ntohl (mp->sw_if_index);
1243 rv = vnet_delete_loopback_interface (sw_if_index);
1245 REPLY_MACRO (VL_API_DELETE_LOOPBACK_REPLY);
1249 vl_api_control_ping_t_handler (vl_api_control_ping_t * mp)
1251 vl_api_control_ping_reply_t *rmp;
1255 REPLY_MACRO2(VL_API_CONTROL_PING_REPLY,
1257 rmp->vpe_pid = ntohl (getpid());
1263 shmem_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
1265 u8 **shmem_vecp = (u8 **) arg;
1268 api_main_t *am = &api_main;
1271 shmem_vec = *shmem_vecp;
1273 offset = vec_len (shmem_vec);
1275 pthread_mutex_lock (&am->vlib_rp->mutex);
1276 oldheap = svm_push_data_heap (am->vlib_rp);
1278 vec_validate (shmem_vec, offset + buffer_bytes - 1);
1280 clib_memcpy (shmem_vec + offset, buffer, buffer_bytes);
1282 svm_pop_heap (oldheap);
1283 pthread_mutex_unlock (&am->vlib_rp->mutex);
1285 *shmem_vecp = shmem_vec;
1290 vl_api_cli_request_t_handler (vl_api_cli_request_t * mp)
1292 vl_api_cli_reply_t *rp;
1293 unix_shared_memory_queue_t *q;
1294 vlib_main_t *vm = vlib_get_main ();
1295 api_main_t *am = &api_main;
1296 unformat_input_t input;
1300 q = vl_api_client_index_to_input_queue (mp->client_index);
1304 rp = vl_msg_api_alloc (sizeof (*rp));
1305 rp->_vl_msg_id = ntohs (VL_API_CLI_REPLY);
1306 rp->context = mp->context;
1308 unformat_init_vector (&input, (u8 *) (uword) mp->cmd_in_shmem);
1310 vlib_cli_input (vm, &input, shmem_cli_output, (uword) & shmem_vec);
1312 pthread_mutex_lock (&am->vlib_rp->mutex);
1313 oldheap = svm_push_data_heap (am->vlib_rp);
1315 vec_add1 (shmem_vec, 0);
1317 svm_pop_heap (oldheap);
1318 pthread_mutex_unlock (&am->vlib_rp->mutex);
1320 rp->reply_in_shmem = (uword) shmem_vec;
1322 vl_msg_api_send_shmem (q, (u8 *) & rp);
1326 inband_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
1328 u8 **mem_vecp = (u8 **) arg;
1329 u8 *mem_vec = *mem_vecp;
1330 u32 offset = vec_len (mem_vec);
1332 vec_validate (mem_vec, offset + buffer_bytes - 1);
1333 clib_memcpy (mem_vec + offset, buffer, buffer_bytes);
1334 *mem_vecp = mem_vec;
1338 vl_api_cli_inband_t_handler (vl_api_cli_inband_t * mp)
1340 vl_api_cli_inband_reply_t *rmp;
1342 unix_shared_memory_queue_t *q;
1343 vlib_main_t *vm = vlib_get_main ();
1344 unformat_input_t input;
1347 q = vl_api_client_index_to_input_queue (mp->client_index);
1351 unformat_init_string (&input, (char *) mp->cmd, ntohl (mp->length));
1352 vlib_cli_input (vm, &input, inband_cli_output, (uword) & out_vec);
1354 u32 len = vec_len (out_vec);
1356 REPLY_MACRO3(VL_API_CLI_INBAND_REPLY, len,
1358 rmp->length = htonl (len);
1359 clib_memcpy (rmp->reply, out_vec, len);
1366 vl_api_set_arp_neighbor_limit_t_handler (vl_api_set_arp_neighbor_limit_t * mp)
1369 vl_api_set_arp_neighbor_limit_reply_t *rmp;
1370 vnet_main_t *vnm = vnet_get_main ();
1371 clib_error_t *error;
1376 error = ip6_set_neighbor_limit (ntohl (mp->arp_neighbor_limit));
1378 error = ip4_set_arp_limit (ntohl (mp->arp_neighbor_limit));
1382 clib_error_report (error);
1383 rv = VNET_API_ERROR_UNSPECIFIED;
1387 rv = vnm->api_errno;
1390 REPLY_MACRO (VL_API_SET_ARP_NEIGHBOR_LIMIT_REPLY);
1393 static void vl_api_classify_set_interface_ip_table_t_handler
1394 (vl_api_classify_set_interface_ip_table_t * mp)
1396 vlib_main_t *vm = vlib_get_main ();
1397 vl_api_classify_set_interface_ip_table_reply_t *rmp;
1399 u32 table_index, sw_if_index;
1401 table_index = ntohl (mp->table_index);
1402 sw_if_index = ntohl (mp->sw_if_index);
1404 VALIDATE_SW_IF_INDEX (mp);
1407 rv = vnet_set_ip6_classify_intfc (vm, sw_if_index, table_index);
1409 rv = vnet_set_ip4_classify_intfc (vm, sw_if_index, table_index);
1411 BAD_SW_IF_INDEX_LABEL;
1413 REPLY_MACRO (VL_API_CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY);
1416 static void vl_api_classify_set_interface_l2_tables_t_handler
1417 (vl_api_classify_set_interface_l2_tables_t * mp)
1419 vl_api_classify_set_interface_l2_tables_reply_t *rmp;
1421 u32 sw_if_index, ip4_table_index, ip6_table_index, other_table_index;
1424 ip4_table_index = ntohl (mp->ip4_table_index);
1425 ip6_table_index = ntohl (mp->ip6_table_index);
1426 other_table_index = ntohl (mp->other_table_index);
1427 sw_if_index = ntohl (mp->sw_if_index);
1429 VALIDATE_SW_IF_INDEX (mp);
1432 rv = vnet_l2_input_classify_set_tables (sw_if_index, ip4_table_index,
1436 rv = vnet_l2_output_classify_set_tables (sw_if_index, ip4_table_index,
1442 if (ip4_table_index != ~0 || ip6_table_index != ~0
1443 || other_table_index != ~0)
1449 vnet_l2_input_classify_enable_disable (sw_if_index, enable);
1451 vnet_l2_output_classify_enable_disable (sw_if_index, enable);
1454 BAD_SW_IF_INDEX_LABEL;
1456 REPLY_MACRO (VL_API_CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY);
1459 extern void l2_efp_filter_configure (vnet_main_t * vnet_main,
1460 u32 sw_if_index, u32 enable);
1463 vl_api_l2_interface_efp_filter_t_handler (vl_api_l2_interface_efp_filter_t *
1467 vl_api_l2_interface_efp_filter_reply_t *rmp;
1468 vnet_main_t *vnm = vnet_get_main ();
1470 // enable/disable the feature
1471 l2_efp_filter_configure (vnm, mp->sw_if_index, mp->enable_disable);
1472 rv = vnm->api_errno;
1474 REPLY_MACRO (VL_API_L2_INTERFACE_EFP_FILTER_REPLY);
1478 vl_api_l2_interface_vlan_tag_rewrite_t_handler
1479 (vl_api_l2_interface_vlan_tag_rewrite_t * mp)
1482 vl_api_l2_interface_vlan_tag_rewrite_reply_t *rmp;
1483 vnet_main_t *vnm = vnet_get_main ();
1484 vlib_main_t *vm = vlib_get_main ();
1487 VALIDATE_SW_IF_INDEX (mp);
1489 vtr_op = ntohl (mp->vtr_op);
1491 /* The L2 code is unsuspicious */
1494 case L2_VTR_DISABLED:
1499 case L2_VTR_TRANSLATE_1_1:
1500 case L2_VTR_TRANSLATE_1_2:
1501 case L2_VTR_TRANSLATE_2_1:
1502 case L2_VTR_TRANSLATE_2_2:
1506 rv = VNET_API_ERROR_INVALID_VALUE;
1507 goto bad_sw_if_index;
1510 rv = l2vtr_configure (vm, vnm, ntohl (mp->sw_if_index), vtr_op,
1511 ntohl (mp->push_dot1q), ntohl (mp->tag1),
1514 BAD_SW_IF_INDEX_LABEL;
1516 REPLY_MACRO (VL_API_L2_INTERFACE_VLAN_TAG_REWRITE_REPLY);
1520 vl_api_show_version_t_handler (vl_api_show_version_t * mp)
1522 vl_api_show_version_reply_t *rmp;
1524 char *vpe_api_get_build_directory (void);
1525 char *vpe_api_get_version (void);
1526 char *vpe_api_get_build_date (void);
1528 unix_shared_memory_queue_t *q =
1529 vl_api_client_index_to_input_queue (mp->client_index);
1535 REPLY_MACRO2(VL_API_SHOW_VERSION_REPLY,
1537 strncpy ((char *) rmp->program, "vpe", ARRAY_LEN(rmp->program)-1);
1538 strncpy ((char *) rmp->build_directory, vpe_api_get_build_directory(),
1539 ARRAY_LEN(rmp->build_directory)-1);
1540 strncpy ((char *) rmp->version, vpe_api_get_version(),
1541 ARRAY_LEN(rmp->version)-1);
1542 strncpy ((char *) rmp->build_date, vpe_api_get_build_date(),
1543 ARRAY_LEN(rmp->build_date)-1);
1549 vl_api_get_node_index_t_handler (vl_api_get_node_index_t * mp)
1551 vlib_main_t *vm = vlib_get_main ();
1552 vl_api_get_node_index_reply_t *rmp;
1555 u32 node_index = ~0;
1557 n = vlib_get_node_by_name (vm, mp->node_name);
1560 rv = VNET_API_ERROR_NO_SUCH_NODE;
1562 node_index = n->index;
1565 REPLY_MACRO2(VL_API_GET_NODE_INDEX_REPLY,
1567 rmp->node_index = ntohl(node_index);
1573 vl_api_get_next_index_t_handler (vl_api_get_next_index_t * mp)
1575 vlib_main_t *vm = vlib_get_main ();
1576 vl_api_get_next_index_reply_t *rmp;
1577 vlib_node_t *node, *next_node;
1579 u32 next_node_index = ~0, next_index = ~0;
1582 node = vlib_get_node_by_name (vm, mp->node_name);
1586 rv = VNET_API_ERROR_NO_SUCH_NODE;
1590 next_node = vlib_get_node_by_name (vm, mp->next_name);
1594 rv = VNET_API_ERROR_NO_SUCH_NODE2;
1598 next_node_index = next_node->index;
1600 p = hash_get (node->next_slot_by_node, next_node_index);
1604 rv = VNET_API_ERROR_NO_SUCH_ENTRY;
1612 REPLY_MACRO2(VL_API_GET_NEXT_INDEX_REPLY,
1614 rmp->next_index = ntohl(next_index);
1620 vl_api_add_node_next_t_handler (vl_api_add_node_next_t * mp)
1622 vlib_main_t *vm = vlib_get_main ();
1623 vl_api_add_node_next_reply_t *rmp;
1624 vlib_node_t *n, *next;
1626 u32 next_index = ~0;
1628 n = vlib_get_node_by_name (vm, mp->node_name);
1632 rv = VNET_API_ERROR_NO_SUCH_NODE;
1636 next = vlib_get_node_by_name (vm, mp->next_name);
1639 rv = VNET_API_ERROR_NO_SUCH_NODE2;
1641 next_index = vlib_node_add_next (vm, n->index, next->index);
1645 REPLY_MACRO2(VL_API_GET_NODE_INDEX_REPLY,
1647 rmp->next_index = ntohl(next_index);
1652 static void vl_api_vxlan_add_del_tunnel_t_handler
1653 (vl_api_vxlan_add_del_tunnel_t * mp)
1655 vl_api_vxlan_add_del_tunnel_reply_t *rmp;
1657 vnet_vxlan_add_del_tunnel_args_t _a, *a = &_a;
1658 u32 encap_fib_index;
1660 ip4_main_t *im = &ip4_main;
1661 vnet_main_t *vnm = vnet_get_main ();
1662 u32 sw_if_index = ~0;
1664 p = hash_get (im->fib_index_by_table_id, ntohl (mp->encap_vrf_id));
1667 rv = VNET_API_ERROR_NO_SUCH_FIB;
1670 encap_fib_index = p[0];
1671 memset (a, 0, sizeof (*a));
1673 a->is_add = mp->is_add;
1674 a->is_ip6 = mp->is_ipv6;
1676 /* ip addresses sent in network byte order */
1677 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &a->dst);
1678 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &a->src);
1680 /* Check src & dst are different */
1681 if (ip46_address_cmp (&a->dst, &a->src) == 0)
1683 rv = VNET_API_ERROR_SAME_SRC_DST;
1686 a->mcast_sw_if_index = ntohl (mp->mcast_sw_if_index);
1687 if (ip46_address_is_multicast (&a->dst) &&
1688 pool_is_free_index (vnm->interface_main.sw_interfaces,
1689 a->mcast_sw_if_index))
1691 rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
1694 a->encap_fib_index = encap_fib_index;
1695 a->decap_next_index = ntohl (mp->decap_next_index);
1696 a->vni = ntohl (mp->vni);
1697 rv = vnet_vxlan_add_del_tunnel (a, &sw_if_index);
1701 REPLY_MACRO2(VL_API_VXLAN_ADD_DEL_TUNNEL_REPLY,
1703 rmp->sw_if_index = ntohl (sw_if_index);
1708 static void send_vxlan_tunnel_details
1709 (vxlan_tunnel_t * t, unix_shared_memory_queue_t * q, u32 context)
1711 vl_api_vxlan_tunnel_details_t *rmp;
1712 ip4_main_t *im4 = &ip4_main;
1713 ip6_main_t *im6 = &ip6_main;
1714 u8 is_ipv6 = !ip46_address_is_ip4 (&t->dst);
1716 rmp = vl_msg_api_alloc (sizeof (*rmp));
1717 memset (rmp, 0, sizeof (*rmp));
1718 rmp->_vl_msg_id = ntohs (VL_API_VXLAN_TUNNEL_DETAILS);
1721 memcpy (rmp->src_address, t->src.ip6.as_u8, 16);
1722 memcpy (rmp->dst_address, t->dst.ip6.as_u8, 16);
1723 rmp->encap_vrf_id = htonl (im6->fibs[t->encap_fib_index].ft_table_id);
1727 memcpy (rmp->src_address, t->src.ip4.as_u8, 4);
1728 memcpy (rmp->dst_address, t->dst.ip4.as_u8, 4);
1729 rmp->encap_vrf_id = htonl (im4->fibs[t->encap_fib_index].ft_table_id);
1731 rmp->mcast_sw_if_index = htonl (t->mcast_sw_if_index);
1732 rmp->vni = htonl (t->vni);
1733 rmp->decap_next_index = htonl (t->decap_next_index);
1734 rmp->sw_if_index = htonl (t->sw_if_index);
1735 rmp->is_ipv6 = is_ipv6;
1736 rmp->context = context;
1738 vl_msg_api_send_shmem (q, (u8 *) & rmp);
1741 static void vl_api_vxlan_tunnel_dump_t_handler
1742 (vl_api_vxlan_tunnel_dump_t * mp)
1744 unix_shared_memory_queue_t *q;
1745 vxlan_main_t *vxm = &vxlan_main;
1749 q = vl_api_client_index_to_input_queue (mp->client_index);
1755 sw_if_index = ntohl (mp->sw_if_index);
1757 if (~0 == sw_if_index)
1760 pool_foreach (t, vxm->tunnels,
1762 send_vxlan_tunnel_details(t, q, mp->context);
1768 if ((sw_if_index >= vec_len (vxm->tunnel_index_by_sw_if_index)) ||
1769 (~0 == vxm->tunnel_index_by_sw_if_index[sw_if_index]))
1773 t = &vxm->tunnels[vxm->tunnel_index_by_sw_if_index[sw_if_index]];
1774 send_vxlan_tunnel_details (t, q, mp->context);
1779 vl_api_l2_patch_add_del_t_handler (vl_api_l2_patch_add_del_t * mp)
1781 extern int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index,
1783 vl_api_l2_patch_add_del_reply_t *rmp;
1784 int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index,
1788 VALIDATE_RX_SW_IF_INDEX (mp);
1789 VALIDATE_TX_SW_IF_INDEX (mp);
1791 rv = vnet_l2_patch_add_del (ntohl (mp->rx_sw_if_index),
1792 ntohl (mp->tx_sw_if_index),
1793 (int) (mp->is_add != 0));
1795 BAD_RX_SW_IF_INDEX_LABEL;
1796 BAD_TX_SW_IF_INDEX_LABEL;
1798 REPLY_MACRO (VL_API_L2_PATCH_ADD_DEL_REPLY);
1802 vl_api_vxlan_gpe_add_del_tunnel_t_handler
1803 (vl_api_vxlan_gpe_add_del_tunnel_t * mp)
1805 vl_api_vxlan_gpe_add_del_tunnel_reply_t *rmp;
1807 vnet_vxlan_gpe_add_del_tunnel_args_t _a, *a = &_a;
1808 u32 encap_fib_index, decap_fib_index;
1811 ip4_main_t *im = &ip4_main;
1812 u32 sw_if_index = ~0;
1815 p = hash_get (im->fib_index_by_table_id, ntohl (mp->encap_vrf_id));
1818 rv = VNET_API_ERROR_NO_SUCH_FIB;
1821 encap_fib_index = p[0];
1823 protocol = mp->protocol;
1825 /* Interpret decap_vrf_id as an opaque if sending to other-than-ip4-input */
1826 if (protocol == VXLAN_GPE_INPUT_NEXT_IP4_INPUT)
1828 p = hash_get (im->fib_index_by_table_id, ntohl (mp->decap_vrf_id));
1831 rv = VNET_API_ERROR_NO_SUCH_INNER_FIB;
1834 decap_fib_index = p[0];
1838 decap_fib_index = ntohl (mp->decap_vrf_id);
1841 /* Check src & dst are different */
1842 if ((mp->is_ipv6 && memcmp (mp->local, mp->remote, 16) == 0) ||
1843 (!mp->is_ipv6 && memcmp (mp->local, mp->remote, 4) == 0))
1845 rv = VNET_API_ERROR_SAME_SRC_DST;
1848 memset (a, 0, sizeof (*a));
1850 a->is_add = mp->is_add;
1851 a->is_ip6 = mp->is_ipv6;
1852 /* ip addresses sent in network byte order */
1855 clib_memcpy (&(a->local.ip6), mp->local, 16);
1856 clib_memcpy (&(a->remote.ip6), mp->remote, 16);
1860 clib_memcpy (&(a->local.ip4), mp->local, 4);
1861 clib_memcpy (&(a->remote.ip4), mp->remote, 4);
1863 a->encap_fib_index = encap_fib_index;
1864 a->decap_fib_index = decap_fib_index;
1865 a->protocol = protocol;
1866 a->vni = ntohl (mp->vni);
1867 rv = vnet_vxlan_gpe_add_del_tunnel (a, &sw_if_index);
1871 REPLY_MACRO2(VL_API_VXLAN_GPE_ADD_DEL_TUNNEL_REPLY,
1873 rmp->sw_if_index = ntohl (sw_if_index);
1878 static void send_vxlan_gpe_tunnel_details
1879 (vxlan_gpe_tunnel_t * t, unix_shared_memory_queue_t * q, u32 context)
1881 vl_api_vxlan_gpe_tunnel_details_t *rmp;
1882 ip4_main_t *im4 = &ip4_main;
1883 ip6_main_t *im6 = &ip6_main;
1884 u8 is_ipv6 = !(t->flags & VXLAN_GPE_TUNNEL_IS_IPV4);
1886 rmp = vl_msg_api_alloc (sizeof (*rmp));
1887 memset (rmp, 0, sizeof (*rmp));
1888 rmp->_vl_msg_id = ntohs (VL_API_VXLAN_GPE_TUNNEL_DETAILS);
1891 memcpy (rmp->local, &(t->local.ip6), 16);
1892 memcpy (rmp->remote, &(t->remote.ip6), 16);
1893 rmp->encap_vrf_id = htonl (im6->fibs[t->encap_fib_index].ft_table_id);
1894 rmp->decap_vrf_id = htonl (im6->fibs[t->decap_fib_index].ft_table_id);
1898 memcpy (rmp->local, &(t->local.ip4), 4);
1899 memcpy (rmp->remote, &(t->remote.ip4), 4);
1900 rmp->encap_vrf_id = htonl (im4->fibs[t->encap_fib_index].ft_table_id);
1901 rmp->decap_vrf_id = htonl (im4->fibs[t->decap_fib_index].ft_table_id);
1903 rmp->vni = htonl (t->vni);
1904 rmp->protocol = t->protocol;
1905 rmp->sw_if_index = htonl (t->sw_if_index);
1906 rmp->is_ipv6 = is_ipv6;
1907 rmp->context = context;
1909 vl_msg_api_send_shmem (q, (u8 *) & rmp);
1912 static void vl_api_vxlan_gpe_tunnel_dump_t_handler
1913 (vl_api_vxlan_gpe_tunnel_dump_t * mp)
1915 unix_shared_memory_queue_t *q;
1916 vxlan_gpe_main_t *vgm = &vxlan_gpe_main;
1917 vxlan_gpe_tunnel_t *t;
1920 q = vl_api_client_index_to_input_queue (mp->client_index);
1926 sw_if_index = ntohl (mp->sw_if_index);
1928 if (~0 == sw_if_index)
1931 pool_foreach (t, vgm->tunnels,
1933 send_vxlan_gpe_tunnel_details(t, q, mp->context);
1939 if ((sw_if_index >= vec_len (vgm->tunnel_index_by_sw_if_index)) ||
1940 (~0 == vgm->tunnel_index_by_sw_if_index[sw_if_index]))
1944 t = &vgm->tunnels[vgm->tunnel_index_by_sw_if_index[sw_if_index]];
1945 send_vxlan_gpe_tunnel_details (t, q, mp->context);
1950 vl_api_interface_name_renumber_t_handler (vl_api_interface_name_renumber_t *
1953 vl_api_interface_name_renumber_reply_t *rmp;
1956 VALIDATE_SW_IF_INDEX (mp);
1958 rv = vnet_interface_name_renumber
1959 (ntohl (mp->sw_if_index), ntohl (mp->new_show_dev_instance));
1961 BAD_SW_IF_INDEX_LABEL;
1963 REPLY_MACRO (VL_API_INTERFACE_NAME_RENUMBER_REPLY);
1967 arp_change_data_callback (u32 pool_index, u8 * new_mac,
1968 u32 sw_if_index, u32 address)
1970 vpe_api_main_t *am = &vpe_api_main;
1971 vlib_main_t *vm = am->vlib_main;
1972 vl_api_ip4_arp_event_t *event;
1973 static f64 arp_event_last_time;
1974 f64 now = vlib_time_now (vm);
1976 if (pool_is_free_index (am->arp_events, pool_index))
1979 event = pool_elt_at_index (am->arp_events, pool_index);
1981 if (memcmp (&event->new_mac, new_mac, sizeof (event->new_mac)))
1983 clib_memcpy (event->new_mac, new_mac, sizeof (event->new_mac));
1987 if (sw_if_index == event->sw_if_index &&
1989 /* for BD case, also check IP address with 10 sec timeout */
1990 (address == event->address &&
1991 (now - arp_event_last_time) < 10.0)))
1996 arp_event_last_time = now;
1997 event->sw_if_index = sw_if_index;
1999 event->address = address;
2004 nd_change_data_callback (u32 pool_index, u8 * new_mac,
2005 u32 sw_if_index, ip6_address_t * address)
2007 vpe_api_main_t *am = &vpe_api_main;
2008 vlib_main_t *vm = am->vlib_main;
2009 vl_api_ip6_nd_event_t *event;
2010 static f64 nd_event_last_time;
2011 f64 now = vlib_time_now (vm);
2013 if (pool_is_free_index (am->nd_events, pool_index))
2016 event = pool_elt_at_index (am->nd_events, pool_index);
2019 if (memcmp (&event->new_mac, new_mac, sizeof (event->new_mac)))
2021 clib_memcpy (event->new_mac, new_mac, sizeof (event->new_mac));
2025 if (sw_if_index == event->sw_if_index &&
2027 /* for BD case, also check IP address with 10 sec timeout */
2028 (ip6_address_is_equal (address,
2029 (ip6_address_t *) event->address) &&
2030 (now - nd_event_last_time) < 10.0)))
2035 nd_event_last_time = now;
2036 event->sw_if_index = sw_if_index;
2038 clib_memcpy (event->address, address, sizeof (event->address));
2043 arp_change_delete_callback (u32 pool_index, u8 * notused)
2045 vpe_api_main_t *am = &vpe_api_main;
2047 if (pool_is_free_index (am->arp_events, pool_index))
2050 pool_put_index (am->arp_events, pool_index);
2055 nd_change_delete_callback (u32 pool_index, u8 * notused)
2057 vpe_api_main_t *am = &vpe_api_main;
2059 if (pool_is_free_index (am->nd_events, pool_index))
2062 pool_put_index (am->nd_events, pool_index);
2067 vl_api_want_ip4_arp_events_t_handler (vl_api_want_ip4_arp_events_t * mp)
2069 vpe_api_main_t *am = &vpe_api_main;
2070 vnet_main_t *vnm = vnet_get_main ();
2071 vl_api_want_ip4_arp_events_reply_t *rmp;
2072 vl_api_ip4_arp_event_t *event;
2075 if (mp->enable_disable)
2077 pool_get (am->arp_events, event);
2078 memset (event, 0, sizeof (*event));
2080 event->_vl_msg_id = ntohs (VL_API_IP4_ARP_EVENT);
2081 event->client_index = mp->client_index;
2082 event->context = mp->context;
2083 event->address = mp->address;
2084 event->pid = mp->pid;
2085 if (mp->address == 0)
2088 rv = vnet_add_del_ip4_arp_change_event
2089 (vnm, arp_change_data_callback,
2090 mp->pid, &mp->address /* addr, in net byte order */ ,
2091 vpe_resolver_process_node.index,
2092 IP4_ARP_EVENT, event - am->arp_events, 1 /* is_add */ );
2096 rv = vnet_add_del_ip4_arp_change_event
2097 (vnm, arp_change_delete_callback,
2098 mp->pid, &mp->address /* addr, in net byte order */ ,
2099 vpe_resolver_process_node.index,
2100 IP4_ARP_EVENT, ~0 /* pool index */ , 0 /* is_add */ );
2102 REPLY_MACRO (VL_API_WANT_IP4_ARP_EVENTS_REPLY);
2106 vl_api_want_ip6_nd_events_t_handler (vl_api_want_ip6_nd_events_t * mp)
2108 vpe_api_main_t *am = &vpe_api_main;
2109 vnet_main_t *vnm = vnet_get_main ();
2110 vl_api_want_ip6_nd_events_reply_t *rmp;
2111 vl_api_ip6_nd_event_t *event;
2114 if (mp->enable_disable)
2116 pool_get (am->nd_events, event);
2117 memset (event, 0, sizeof (*event));
2119 event->_vl_msg_id = ntohs (VL_API_IP6_ND_EVENT);
2120 event->client_index = mp->client_index;
2121 event->context = mp->context;
2122 clib_memcpy (event->address, mp->address, 16);
2123 event->pid = mp->pid;
2124 if (ip6_address_is_zero ((ip6_address_t *) mp->address))
2127 rv = vnet_add_del_ip6_nd_change_event
2128 (vnm, nd_change_data_callback,
2129 mp->pid, mp->address /* addr, in net byte order */ ,
2130 vpe_resolver_process_node.index,
2131 IP6_ND_EVENT, event - am->nd_events, 1 /* is_add */ );
2135 rv = vnet_add_del_ip6_nd_change_event
2136 (vnm, nd_change_delete_callback,
2137 mp->pid, mp->address /* addr, in net byte order */ ,
2138 vpe_resolver_process_node.index,
2139 IP6_ND_EVENT, ~0 /* pool index */ , 0 /* is_add */ );
2141 REPLY_MACRO (VL_API_WANT_IP6_ND_EVENTS_REPLY);
2144 static void vl_api_input_acl_set_interface_t_handler
2145 (vl_api_input_acl_set_interface_t * mp)
2147 vlib_main_t *vm = vlib_get_main ();
2148 vl_api_input_acl_set_interface_reply_t *rmp;
2150 u32 sw_if_index, ip4_table_index, ip6_table_index, l2_table_index;
2152 ip4_table_index = ntohl (mp->ip4_table_index);
2153 ip6_table_index = ntohl (mp->ip6_table_index);
2154 l2_table_index = ntohl (mp->l2_table_index);
2155 sw_if_index = ntohl (mp->sw_if_index);
2157 VALIDATE_SW_IF_INDEX (mp);
2159 rv = vnet_set_input_acl_intfc (vm, sw_if_index, ip4_table_index,
2160 ip6_table_index, l2_table_index, mp->is_add);
2162 BAD_SW_IF_INDEX_LABEL;
2164 REPLY_MACRO (VL_API_INPUT_ACL_SET_INTERFACE_REPLY);
2167 static void vl_api_cop_interface_enable_disable_t_handler
2168 (vl_api_cop_interface_enable_disable_t * mp)
2170 vl_api_cop_interface_enable_disable_reply_t *rmp;
2172 u32 sw_if_index = ntohl (mp->sw_if_index);
2175 VALIDATE_SW_IF_INDEX (mp);
2177 enable_disable = (int) mp->enable_disable;
2179 rv = cop_interface_enable_disable (sw_if_index, enable_disable);
2181 BAD_SW_IF_INDEX_LABEL;
2183 REPLY_MACRO (VL_API_COP_INTERFACE_ENABLE_DISABLE_REPLY);
2186 static void vl_api_cop_whitelist_enable_disable_t_handler
2187 (vl_api_cop_whitelist_enable_disable_t * mp)
2189 vl_api_cop_whitelist_enable_disable_reply_t *rmp;
2190 cop_whitelist_enable_disable_args_t _a, *a = &_a;
2191 u32 sw_if_index = ntohl (mp->sw_if_index);
2194 VALIDATE_SW_IF_INDEX (mp);
2196 a->sw_if_index = sw_if_index;
2199 a->default_cop = mp->default_cop;
2200 a->fib_id = ntohl (mp->fib_id);
2202 rv = cop_whitelist_enable_disable (a);
2204 BAD_SW_IF_INDEX_LABEL;
2206 REPLY_MACRO (VL_API_COP_WHITELIST_ENABLE_DISABLE_REPLY);
2210 vl_api_get_node_graph_t_handler (vl_api_get_node_graph_t * mp)
2214 api_main_t *am = &api_main;
2215 vlib_main_t *vm = vlib_get_main ();
2217 vl_api_get_node_graph_reply_t *rmp;
2219 pthread_mutex_lock (&am->vlib_rp->mutex);
2220 oldheap = svm_push_data_heap (am->vlib_rp);
2223 * Keep the number of memcpy ops to a minimum (e.g. 1).
2225 vec_validate (vector, 16384);
2226 vec_reset_length (vector);
2229 vector = vlib_node_serialize (&vm->node_main, vector,
2230 (u32) ~ 0 /* all threads */ ,
2231 1 /* include nexts */ ,
2232 1 /* include stats */ );
2234 svm_pop_heap (oldheap);
2235 pthread_mutex_unlock (&am->vlib_rp->mutex);
2238 REPLY_MACRO2(VL_API_GET_NODE_GRAPH_REPLY,
2240 rmp->reply_in_shmem = (uword) vector;
2246 vl_api_ioam_enable_t_handler (vl_api_ioam_enable_t * mp)
2249 vl_api_ioam_enable_reply_t *rmp;
2250 clib_error_t *error;
2252 /* Ignoring the profile id as currently a single profile
2254 error = ip6_ioam_enable (mp->trace_enable, mp->pot_enable,
2255 mp->seqno, mp->analyse);
2258 clib_error_report (error);
2259 rv = clib_error_get_code (error);
2262 REPLY_MACRO (VL_API_IOAM_ENABLE_REPLY);
2266 vl_api_ioam_disable_t_handler (vl_api_ioam_disable_t * mp)
2269 vl_api_ioam_disable_reply_t *rmp;
2270 clib_error_t *error;
2272 error = clear_ioam_rewrite_fn ();
2275 clib_error_report (error);
2276 rv = clib_error_get_code (error);
2279 REPLY_MACRO (VL_API_IOAM_DISABLE_REPLY);
2283 vl_api_policer_add_del_t_handler (vl_api_policer_add_del_t * mp)
2285 vlib_main_t *vm = vlib_get_main ();
2286 vl_api_policer_add_del_reply_t *rmp;
2289 sse2_qos_pol_cfg_params_st cfg;
2290 clib_error_t *error;
2293 name = format (0, "%s", mp->name);
2295 memset (&cfg, 0, sizeof (cfg));
2297 cfg.rnd_type = mp->round_type;
2298 cfg.rate_type = mp->rate_type;
2299 cfg.rb.kbps.cir_kbps = mp->cir;
2300 cfg.rb.kbps.eir_kbps = mp->eir;
2301 cfg.rb.kbps.cb_bytes = mp->cb;
2302 cfg.rb.kbps.eb_bytes = mp->eb;
2303 cfg.conform_action.action_type = mp->conform_action_type;
2304 cfg.conform_action.dscp = mp->conform_dscp;
2305 cfg.exceed_action.action_type = mp->exceed_action_type;
2306 cfg.exceed_action.dscp = mp->exceed_dscp;
2307 cfg.violate_action.action_type = mp->violate_action_type;
2308 cfg.violate_action.dscp = mp->violate_dscp;
2309 cfg.color_aware = mp->color_aware;
2311 error = policer_add_del (vm, name, &cfg, &policer_index, mp->is_add);
2314 rv = VNET_API_ERROR_UNSPECIFIED;
2317 REPLY_MACRO2(VL_API_POLICER_ADD_DEL_REPLY,
2319 if (rv == 0 && mp->is_add)
2320 rmp->policer_index = ntohl(policer_index);
2322 rmp->policer_index = ~0;
2328 send_policer_details (u8 * name,
2329 sse2_qos_pol_cfg_params_st * config,
2330 policer_read_response_type_st * templ,
2331 unix_shared_memory_queue_t * q, u32 context)
2333 vl_api_policer_details_t *mp;
2335 mp = vl_msg_api_alloc (sizeof (*mp));
2336 memset (mp, 0, sizeof (*mp));
2337 mp->_vl_msg_id = ntohs (VL_API_POLICER_DETAILS);
2338 mp->context = context;
2339 mp->cir = htonl (config->rb.kbps.cir_kbps);
2340 mp->eir = htonl (config->rb.kbps.eir_kbps);
2341 mp->cb = htonl (config->rb.kbps.cb_bytes);
2342 mp->eb = htonl (config->rb.kbps.eb_bytes);
2343 mp->rate_type = config->rate_type;
2344 mp->round_type = config->rnd_type;
2345 mp->type = config->rfc;
2346 mp->conform_action_type = config->conform_action.action_type;
2347 mp->conform_dscp = config->conform_action.dscp;
2348 mp->exceed_action_type = config->exceed_action.action_type;
2349 mp->exceed_dscp = config->exceed_action.dscp;
2350 mp->violate_action_type = config->violate_action.action_type;
2351 mp->violate_dscp = config->violate_action.dscp;
2352 mp->single_rate = templ->single_rate ? 1 : 0;
2353 mp->color_aware = templ->color_aware ? 1 : 0;
2354 mp->scale = htonl (templ->scale);
2355 mp->cir_tokens_per_period = htonl (templ->cir_tokens_per_period);
2356 mp->pir_tokens_per_period = htonl (templ->pir_tokens_per_period);
2357 mp->current_limit = htonl (templ->current_limit);
2358 mp->current_bucket = htonl (templ->current_bucket);
2359 mp->extended_limit = htonl (templ->extended_limit);
2360 mp->extended_bucket = htonl (templ->extended_bucket);
2361 mp->last_update_time = clib_host_to_net_u64 (templ->last_update_time);
2363 strncpy ((char *) mp->name, (char *) name, ARRAY_LEN (mp->name) - 1);
2365 vl_msg_api_send_shmem (q, (u8 *) & mp);
2369 vl_api_policer_dump_t_handler (vl_api_policer_dump_t * mp)
2371 unix_shared_memory_queue_t *q;
2372 vnet_policer_main_t *pm = &vnet_policer_main;
2378 sse2_qos_pol_cfg_params_st *config;
2379 policer_read_response_type_st *templ;
2381 q = vl_api_client_index_to_input_queue (mp->client_index);
2385 if (mp->match_name_valid)
2387 match_name = format (0, "%s%c", mp->match_name, 0);
2390 if (mp->match_name_valid)
2392 p = hash_get_mem (pm->policer_config_by_name, match_name);
2396 config = pool_elt_at_index (pm->configs, pool_index);
2397 templ = pool_elt_at_index (pm->policer_templates, pool_index);
2398 send_policer_details (match_name, config, templ, q, mp->context);
2404 hash_foreach_pair (hp, pm->policer_config_by_name,
2406 name = (u8 *) hp->key;
2407 pool_index = hp->value[0];
2408 config = pool_elt_at_index (pm->configs, pool_index);
2409 templ = pool_elt_at_index (pm->policer_templates, pool_index);
2410 send_policer_details(name, config, templ, q, mp->context);
2418 vl_api_pg_create_interface_t_handler (vl_api_pg_create_interface_t * mp)
2420 vl_api_pg_create_interface_reply_t *rmp;
2423 pg_main_t *pg = &pg_main;
2424 u32 pg_if_id = pg_interface_add_or_get (pg, ntohl (mp->interface_id));
2425 pg_interface_t *pi = pool_elt_at_index (pg->interfaces, pg_if_id);
2428 REPLY_MACRO2(VL_API_PG_CREATE_INTERFACE_REPLY,
2430 rmp->sw_if_index = ntohl(pi->sw_if_index);
2436 vl_api_pg_capture_t_handler (vl_api_pg_capture_t * mp)
2438 vl_api_pg_capture_reply_t *rmp;
2441 vnet_main_t *vnm = vnet_get_main ();
2442 vnet_interface_main_t *im = &vnm->interface_main;
2443 vnet_hw_interface_t *hi = 0;
2445 u8 *intf_name = format (0, "pg%d", ntohl (mp->interface_id), 0);
2446 u32 hw_if_index = ~0;
2447 uword *p = hash_get_mem (im->hw_interface_by_name, intf_name);
2450 vec_free (intf_name);
2452 if (hw_if_index != ~0)
2454 pg_capture_args_t _a, *a = &_a;
2456 u32 len = ntohl (mp->pcap_name_length);
2457 u8 *pcap_file_name = vec_new (u8, len);
2458 clib_memcpy (pcap_file_name, mp->pcap_file_name, len);
2460 hi = vnet_get_sup_hw_interface (vnm, hw_if_index);
2461 a->hw_if_index = hw_if_index;
2462 a->dev_instance = hi->dev_instance;
2463 a->is_enabled = mp->is_enabled;
2464 a->pcap_file_name = pcap_file_name;
2465 a->count = ntohl (mp->count);
2467 clib_error_t *e = pg_capture (a);
2470 clib_error_report (e);
2471 rv = VNET_API_ERROR_CANNOT_CREATE_PCAP_FILE;
2474 vec_free (pcap_file_name);
2476 REPLY_MACRO (VL_API_PG_CAPTURE_REPLY);
2480 vl_api_pg_enable_disable_t_handler (vl_api_pg_enable_disable_t * mp)
2482 vl_api_pg_enable_disable_reply_t *rmp;
2485 pg_main_t *pg = &pg_main;
2486 u32 stream_index = ~0;
2488 int is_enable = mp->is_enabled != 0;
2489 u32 len = ntohl (mp->stream_name_length) - 1;
2493 u8 *stream_name = vec_new (u8, len);
2494 clib_memcpy (stream_name, mp->stream_name, len);
2495 uword *p = hash_get_mem (pg->stream_index_by_name, stream_name);
2498 vec_free (stream_name);
2501 pg_enable_disable (stream_index, is_enable);
2503 REPLY_MACRO (VL_API_PG_ENABLE_DISABLE_REPLY);
2507 vl_api_ip_source_and_port_range_check_add_del_t_handler
2508 (vl_api_ip_source_and_port_range_check_add_del_t * mp)
2510 vl_api_ip_source_and_port_range_check_add_del_reply_t *rmp;
2513 u8 is_ipv6 = mp->is_ipv6;
2514 u8 is_add = mp->is_add;
2515 u8 mask_length = mp->mask_length;
2516 ip4_address_t ip4_addr;
2517 ip6_address_t ip6_addr;
2519 u16 *high_ports = 0;
2521 u16 tmp_low, tmp_high;
2525 // Validate port range
2526 num_ranges = mp->number_of_ranges;
2527 if (num_ranges > 32)
2528 { // This is size of array in VPE.API
2529 rv = VNET_API_ERROR_EXCEEDED_NUMBER_OF_RANGES_CAPACITY;
2533 vec_reset_length (low_ports);
2534 vec_reset_length (high_ports);
2536 for (i = 0; i < num_ranges; i++)
2538 tmp_low = mp->low_ports[i];
2539 tmp_high = mp->high_ports[i];
2540 // If tmp_low <= tmp_high then only need to check tmp_low = 0
2541 // If tmp_low <= tmp_high then only need to check tmp_high > 65535
2542 if (tmp_low > tmp_high || tmp_low == 0 || tmp_high > 65535)
2544 rv = VNET_API_ERROR_INVALID_VALUE;
2547 vec_add1 (low_ports, tmp_low);
2548 vec_add1 (high_ports, tmp_high + 1);
2551 // Validate mask_length
2552 if ((is_ipv6 && mask_length > 128) || (!is_ipv6 && mask_length > 32))
2554 rv = VNET_API_ERROR_ADDRESS_LENGTH_MISMATCH;
2558 vrf_id = ntohl (mp->vrf_id);
2562 rv = VNET_API_ERROR_INVALID_VALUE;
2569 clib_memcpy (ip6_addr.as_u8, mp->address, sizeof (ip6_addr.as_u8));
2570 rv = ip6_source_and_port_range_check_add_del (&ip6_addr,
2574 high_ports, is_add);
2578 clib_memcpy (ip4_addr.data, mp->address, sizeof (ip4_addr));
2579 rv = ip4_source_and_port_range_check_add_del (&ip4_addr,
2583 high_ports, is_add);
2587 vec_free (low_ports);
2588 vec_free (high_ports);
2589 REPLY_MACRO (VL_API_IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY);
2593 vl_api_ip_source_and_port_range_check_interface_add_del_t_handler
2594 (vl_api_ip_source_and_port_range_check_interface_add_del_t * mp)
2596 vlib_main_t *vm = vlib_get_main ();
2597 vl_api_ip_source_and_port_range_check_interface_add_del_reply_t *rmp;
2598 ip4_main_t *im = &ip4_main;
2601 u32 fib_index[IP_SOURCE_AND_PORT_RANGE_CHECK_N_PROTOCOLS];
2602 u32 vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_N_PROTOCOLS];
2606 vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_PROTOCOL_TCP_OUT] =
2607 ntohl (mp->tcp_out_vrf_id);
2608 vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_PROTOCOL_UDP_OUT] =
2609 ntohl (mp->udp_out_vrf_id);
2610 vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_PROTOCOL_TCP_IN] =
2611 ntohl (mp->tcp_in_vrf_id);
2612 vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_PROTOCOL_UDP_IN] =
2613 ntohl (mp->udp_in_vrf_id);
2616 for (i = 0; i < IP_SOURCE_AND_PORT_RANGE_CHECK_N_PROTOCOLS; i++)
2618 if (vrf_id[i] != 0 && vrf_id[i] != ~0)
2620 p = hash_get (im->fib_index_by_table_id, vrf_id[i]);
2624 rv = VNET_API_ERROR_INVALID_VALUE;
2628 fib_index[i] = p[0];
2633 sw_if_index = ntohl (mp->sw_if_index);
2635 VALIDATE_SW_IF_INDEX (mp);
2638 set_ip_source_and_port_range_check (vm, fib_index, sw_if_index,
2641 BAD_SW_IF_INDEX_LABEL;
2644 REPLY_MACRO (VL_API_IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY);
2648 vl_api_delete_subif_t_handler (vl_api_delete_subif_t * mp)
2650 vl_api_delete_subif_reply_t *rmp;
2653 rv = vnet_delete_sub_interface (ntohl (mp->sw_if_index));
2655 REPLY_MACRO (VL_API_DELETE_SUBIF_REPLY);
2659 vl_api_l2_interface_pbb_tag_rewrite_t_handler
2660 (vl_api_l2_interface_pbb_tag_rewrite_t * mp)
2662 vl_api_l2_interface_pbb_tag_rewrite_reply_t *rmp;
2663 vnet_main_t *vnm = vnet_get_main ();
2664 vlib_main_t *vm = vlib_get_main ();
2668 VALIDATE_SW_IF_INDEX (mp);
2670 vtr_op = ntohl (mp->vtr_op);
2674 case L2_VTR_DISABLED:
2677 case L2_VTR_TRANSLATE_2_1:
2681 rv = VNET_API_ERROR_INVALID_VALUE;
2682 goto bad_sw_if_index;
2685 rv = l2pbb_configure (vm, vnm, ntohl (mp->sw_if_index), vtr_op,
2686 mp->b_dmac, mp->b_smac, ntohs (mp->b_vlanid),
2687 ntohl (mp->i_sid), ntohs (mp->outer_tag));
2689 BAD_SW_IF_INDEX_LABEL;
2691 REPLY_MACRO (VL_API_L2_INTERFACE_PBB_TAG_REWRITE_REPLY);
2696 vl_api_punt_t_handler (vl_api_punt_t * mp)
2698 vl_api_punt_reply_t *rmp;
2699 vlib_main_t *vm = vlib_get_main ();
2701 clib_error_t *error;
2703 error = vnet_punt_add_del (vm, mp->ipv, mp->l4_protocol,
2704 ntohs (mp->l4_port), mp->is_add);
2708 clib_error_report (error);
2711 REPLY_MACRO (VL_API_PUNT_REPLY);
2715 vl_api_feature_enable_disable_t_handler (vl_api_feature_enable_disable_t * mp)
2717 vl_api_feature_enable_disable_reply_t *rmp;
2719 u8 *arc_name, *feature_name;
2721 VALIDATE_SW_IF_INDEX (mp);
2723 arc_name = format (0, "%s%c", mp->arc_name, 0);
2724 feature_name = format (0, "%s%c", mp->feature_name, 0);
2726 vnet_feature_registration_t *reg;
2728 vnet_get_feature_reg ((const char *) arc_name,
2729 (const char *) feature_name);
2731 rv = VNET_API_ERROR_INVALID_VALUE;
2735 clib_error_t *error = 0;
2737 sw_if_index = ntohl (mp->sw_if_index);
2738 if (reg->enable_disable_cb)
2739 error = reg->enable_disable_cb (sw_if_index, mp->enable);
2741 vnet_feature_enable_disable ((const char *) arc_name,
2742 (const char *) feature_name,
2743 sw_if_index, mp->enable, 0, 0);
2746 clib_error_report (error);
2747 rv = VNET_API_ERROR_CANNOT_ENABLE_DISABLE_FEATURE;
2751 vec_free (feature_name);
2752 vec_free (arc_name);
2754 BAD_SW_IF_INDEX_LABEL;
2756 REPLY_MACRO (VL_API_FEATURE_ENABLE_DISABLE_REPLY);
2759 #define BOUNCE_HANDLER(nn) \
2760 static void vl_api_##nn##_t_handler ( \
2761 vl_api_##nn##_t *mp) \
2763 vpe_client_registration_t *reg; \
2764 vpe_api_main_t * vam = &vpe_api_main; \
2765 unix_shared_memory_queue_t * q; \
2767 /* One registration only... */ \
2768 pool_foreach(reg, vam->nn##_registrations, \
2770 q = vl_api_client_index_to_input_queue (reg->client_index); \
2773 * If the queue is stuffed, turf the msg and complain \
2774 * It's unlikely that the intended recipient is \
2775 * alive; avoid deadlock at all costs. \
2777 if (q->cursize == q->maxsize) { \
2778 clib_warning ("ERROR: receiver queue full, drop msg"); \
2779 vl_msg_api_free (mp); \
2782 vl_msg_api_send_shmem (q, (u8 *)&mp); \
2786 vl_msg_api_free (mp); \
2789 static void setup_message_id_table (api_main_t * am);
2793 * Add vpe's API message handlers to the table.
2794 * vlib has alread mapped shared memory and
2795 * added the client registration handlers.
2796 * See .../open-repo/vlib/memclnt_vlib.c:memclnt_process()
2798 static clib_error_t *
2799 vpe_api_hookup (vlib_main_t * vm)
2801 api_main_t *am = &api_main;
2804 vl_msg_api_set_handlers(VL_API_##N, #n, \
2805 vl_api_##n##_t_handler, \
2807 vl_api_##n##_t_endian, \
2808 vl_api_##n##_t_print, \
2809 sizeof(vl_api_##n##_t), 1);
2810 foreach_vpe_api_msg;
2814 * Trace space for classifier mask+match
2816 am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_TABLE].size += 5 * sizeof (u32x4);
2817 am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_SESSION].size
2818 += 5 * sizeof (u32x4);
2819 am->api_trace_cfg[VL_API_VXLAN_ADD_DEL_TUNNEL].size += 16 * sizeof (u32);
2822 * Thread-safe API messages
2824 am->is_mp_safe[VL_API_IP_ADD_DEL_ROUTE] = 1;
2825 am->is_mp_safe[VL_API_GET_NODE_GRAPH] = 1;
2828 * Set up the (msg_name, crc, message-id) table
2830 setup_message_id_table (am);
2835 VLIB_API_INIT_FUNCTION (vpe_api_hookup);
2837 static clib_error_t *
2838 vpe_api_init (vlib_main_t * vm)
2840 vpe_api_main_t *am = &vpe_api_main;
2843 am->vnet_main = vnet_get_main ();
2844 am->interface_events_registration_hash = hash_create (0, sizeof (uword));
2845 am->to_netconf_server_registration_hash = hash_create (0, sizeof (uword));
2846 am->from_netconf_server_registration_hash = hash_create (0, sizeof (uword));
2847 am->to_netconf_client_registration_hash = hash_create (0, sizeof (uword));
2848 am->from_netconf_client_registration_hash = hash_create (0, sizeof (uword));
2849 am->oam_events_registration_hash = hash_create (0, sizeof (uword));
2850 am->bfd_events_registration_hash = hash_create (0, sizeof (uword));
2853 vl_set_memory_region_name ("/vpe-api");
2854 vl_enable_disable_memory_api (vm, 1 /* enable it */ );
2859 VLIB_INIT_FUNCTION (vpe_api_init);
2862 static clib_error_t *
2863 api_segment_config (vlib_main_t * vm, unformat_input_t * input)
2866 u64 baseva, size, pvt_heap_size;
2868 const int max_buf_size = 4096;
2870 struct passwd _pw, *pw;
2871 struct group _grp, *grp;
2873 buf = vec_new (char, 128);
2874 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2876 if (unformat (input, "prefix %s", &chroot_path))
2878 vec_add1 (chroot_path, 0);
2879 vl_set_memory_root_path ((char *) chroot_path);
2881 else if (unformat (input, "uid %d", &uid))
2882 vl_set_memory_uid (uid);
2883 else if (unformat (input, "gid %d", &gid))
2884 vl_set_memory_gid (gid);
2885 else if (unformat (input, "baseva %llx", &baseva))
2886 vl_set_global_memory_baseva (baseva);
2887 else if (unformat (input, "global-size %lldM", &size))
2888 vl_set_global_memory_size (size * (1ULL << 20));
2889 else if (unformat (input, "global-size %lldG", &size))
2890 vl_set_global_memory_size (size * (1ULL << 30));
2891 else if (unformat (input, "global-size %lld", &size))
2892 vl_set_global_memory_size (size);
2893 else if (unformat (input, "global-pvt-heap-size %lldM", &pvt_heap_size))
2894 vl_set_global_pvt_heap_size (pvt_heap_size * (1ULL << 20));
2895 else if (unformat (input, "global-pvt-heap-size size %lld",
2897 vl_set_global_pvt_heap_size (pvt_heap_size);
2898 else if (unformat (input, "api-pvt-heap-size %lldM", &pvt_heap_size))
2899 vl_set_api_pvt_heap_size (pvt_heap_size * (1ULL << 20));
2900 else if (unformat (input, "api-pvt-heap-size size %lld",
2902 vl_set_api_pvt_heap_size (pvt_heap_size);
2903 else if (unformat (input, "api-size %lldM", &size))
2904 vl_set_api_memory_size (size * (1ULL << 20));
2905 else if (unformat (input, "api-size %lldG", &size))
2906 vl_set_api_memory_size (size * (1ULL << 30));
2907 else if (unformat (input, "api-size %lld", &size))
2908 vl_set_api_memory_size (size);
2909 else if (unformat (input, "uid %s", &s))
2911 /* lookup the username */
2914 getpwnam_r (s, &_pw, buf, vec_len (buf), &pw)) == ERANGE)
2915 && (vec_len (buf) <= max_buf_size))
2917 vec_resize (buf, vec_len (buf) * 2);
2921 e = clib_error_return_code (0, rv,
2922 CLIB_ERROR_ERRNO_VALID |
2924 "cannot fetch username %s", s);
2932 clib_error_return_fatal (0, "username %s does not exist", s);
2938 vl_set_memory_uid (pw->pw_uid);
2940 else if (unformat (input, "gid %s", &s))
2942 /* lookup the group name */
2945 getgrnam_r (s, &_grp, buf, vec_len (buf), &grp)) == ERANGE)
2946 && (vec_len (buf) <= max_buf_size))
2948 vec_resize (buf, vec_len (buf) * 2);
2952 e = clib_error_return_code (0, rv,
2953 CLIB_ERROR_ERRNO_VALID |
2955 "cannot fetch group %s", s);
2962 e = clib_error_return_fatal (0, "group %s does not exist", s);
2969 vl_set_memory_gid (grp->gr_gid);
2972 return clib_error_return (0, "unknown input `%U'",
2973 format_unformat_error, input);
2978 VLIB_EARLY_CONFIG_FUNCTION (api_segment_config, "api-segment");
2981 get_unformat_vnet_sw_interface (void)
2983 return (void *) &unformat_vnet_sw_interface;
2987 format_arp_event (u8 * s, va_list * args)
2989 vl_api_ip4_arp_event_t *event = va_arg (*args, vl_api_ip4_arp_event_t *);
2991 s = format (s, "pid %d: ", event->pid);
2993 s = format (s, "bd mac/ip4 binding events");
2995 s = format (s, "resolution for %U", format_ip4_address, &event->address);
3000 format_nd_event (u8 * s, va_list * args)
3002 vl_api_ip6_nd_event_t *event = va_arg (*args, vl_api_ip6_nd_event_t *);
3004 s = format (s, "pid %d: ", event->pid);
3006 s = format (s, "bd mac/ip6 binding events");
3008 s = format (s, "resolution for %U", format_ip6_address, event->address);
3012 static clib_error_t *
3013 show_ip_arp_nd_events_fn (vlib_main_t * vm,
3014 unformat_input_t * input, vlib_cli_command_t * cmd)
3016 vpe_api_main_t *am = &vpe_api_main;
3017 vl_api_ip4_arp_event_t *arp_event;
3018 vl_api_ip6_nd_event_t *nd_event;
3020 if ((pool_elts (am->arp_events) == 0) && (pool_elts (am->nd_events) == 0))
3022 vlib_cli_output (vm, "No active arp or nd event registrations");
3027 pool_foreach (arp_event, am->arp_events,
3029 vlib_cli_output (vm, "%U", format_arp_event, arp_event);
3032 pool_foreach (nd_event, am->nd_events,
3034 vlib_cli_output (vm, "%U", format_nd_event, nd_event);
3042 VLIB_CLI_COMMAND (show_ip_arp_nd_events, static) = {
3043 .path = "show arp-nd-event registrations",
3044 .function = show_ip_arp_nd_events_fn,
3045 .short_help = "Show ip4 arp and ip6 nd event registrations",
3049 #define vl_msg_name_crc_list
3050 #include <vpp/api/vpe_all_api_h.h>
3051 #undef vl_msg_name_crc_list
3054 setup_message_id_table (api_main_t * am)
3056 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
3057 foreach_vl_msg_name_crc_memclnt;
3058 foreach_vl_msg_name_crc_vpe;
3064 * fd.io coding-style-patch-verification: ON
3067 * eval: (c-set-style "gnu")