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/l2tp/l2tp.h>
53 #include <vnet/ip/ip.h>
54 #include <vnet/ip/ip6.h>
55 #include <vnet/ip/ip6_neighbor.h>
56 #include <vnet/mpls/mpls.h>
57 #include <vnet/mpls/mpls_tunnel.h>
58 #include <vnet/dhcp/proxy.h>
59 #include <vnet/dhcp/client.h>
61 #include <vnet/sr/sr.h>
63 #include <vnet/dhcpv6/proxy.h>
64 #include <vlib/vlib.h>
65 #include <vlib/unix/unix.h>
66 #include <vlibapi/api.h>
67 #include <vlibmemory/api.h>
68 #include <vnet/classify/vnet_classify.h>
69 #include <vnet/classify/input_acl.h>
70 #include <vnet/classify/policer_classify.h>
71 #include <vnet/classify/flow_classify.h>
72 #include <vnet/l2/l2_classify.h>
73 #include <vnet/vxlan/vxlan.h>
74 #include <vnet/gre/gre.h>
75 #include <vnet/l2/l2_vtr.h>
76 #include <vnet/vxlan-gpe/vxlan_gpe.h>
77 #include <vnet/lisp-gpe/lisp_gpe.h>
78 #include <vnet/lisp-gpe/lisp_gpe_fwd_entry.h>
79 #include <vnet/lisp-gpe/lisp_gpe_tenant.h>
80 #include <vnet/lisp-cp/control.h>
81 #include <vnet/map/map.h>
82 #include <vnet/cop/cop.h>
83 #include <vnet/ip/ip6_hop_by_hop.h>
84 #include <vnet/ip/ip_source_and_port_range_check.h>
85 #include <vnet/devices/af_packet/af_packet.h>
86 #include <vnet/policer/policer.h>
87 #include <vnet/devices/netmap/netmap.h>
88 #include <vnet/flow/flow_report.h>
89 #include <vnet/ipsec-gre/ipsec_gre.h>
90 #include <vnet/flow/flow_report_classify.h>
91 #include <vnet/ip/punt.h>
92 #include <vnet/feature/feature.h>
95 #undef __included_bihash_template_h__
96 #include <vnet/l2/l2_fib.h>
99 #include <vnet/devices/dpdk/dpdk.h>
103 #include <vnet/ipsec/ipsec.h>
104 #include <vnet/ipsec/ikev2.h>
106 #include <vnet/devices/virtio/vhost-user.h>
108 #include <stats/stats.h>
111 #include <vnet/ethernet/ethernet.h>
112 #include <vnet/ethernet/arp_packet.h>
113 #include <vnet/interface.h>
115 #include <vnet/l2/l2_fib.h>
116 #include <vnet/l2/l2_bd.h>
117 #include <vpp-api/vpe_msg_enum.h>
118 #include <vnet/span/span.h>
120 #include <vnet/bfd/bfd_main.h>
121 #include <vnet/bfd/bfd_api.h>
122 #include <vnet/fib/ip6_fib.h>
123 #include <vnet/fib/ip4_fib.h>
124 #include <vnet/fib/fib_api.h>
125 #include <vnet/dpo/drop_dpo.h>
126 #include <vnet/dpo/receive_dpo.h>
127 #include <vnet/dpo/lookup_dpo.h>
128 #include <vnet/dpo/classify_dpo.h>
129 #include <vnet/dpo/ip_null_dpo.h>
131 #define vl_typedefs /* define message structures */
132 #include <vpp-api/vpe_all_api_h.h>
135 #define vl_endianfun /* define message structures */
136 #include <vpp-api/vpe_all_api_h.h>
139 /* instantiate all the print functions we know about */
140 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
142 #include <vpp-api/vpe_all_api_h.h>
145 #include <vlibapi/api_helper_macros.h>
147 #define foreach_vpe_api_msg \
148 _(WANT_OAM_EVENTS, want_oam_events) \
149 _(OAM_ADD_DEL, oam_add_del) \
150 _(MPLS_ROUTE_ADD_DEL, mpls_route_add_del) \
151 _(MPLS_IP_BIND_UNBIND, mpls_ip_bind_unbind) \
152 _(IS_ADDRESS_REACHABLE, is_address_reachable) \
153 _(SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable) \
154 _(SW_INTERFACE_SET_VPATH, sw_interface_set_vpath) \
155 _(SW_INTERFACE_SET_VXLAN_BYPASS, sw_interface_set_vxlan_bypass) \
156 _(SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect) \
157 _(SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge) \
158 _(SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe) \
159 _(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport) \
160 _(SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl) \
161 _(BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del) \
162 _(BRIDGE_DOMAIN_DUMP, bridge_domain_dump) \
163 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
164 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
165 _(L2FIB_ADD_DEL, l2fib_add_del) \
166 _(L2_FLAGS, l2_flags) \
167 _(BRIDGE_FLAGS, bridge_flags) \
168 _(CREATE_VLAN_SUBIF, create_vlan_subif) \
169 _(CREATE_SUBIF, create_subif) \
170 _(MPLS_TUNNEL_ADD_DEL, mpls_tunnel_add_del) \
171 _(PROXY_ARP_ADD_DEL, proxy_arp_add_del) \
172 _(PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable) \
173 _(VNET_GET_SUMMARY_STATS, vnet_get_summary_stats) \
174 _(RESET_FIB, reset_fib) \
175 _(DHCP_PROXY_CONFIG,dhcp_proxy_config) \
176 _(DHCP_PROXY_CONFIG_2,dhcp_proxy_config_2) \
177 _(DHCP_PROXY_SET_VSS,dhcp_proxy_set_vss) \
178 _(DHCP_CLIENT_CONFIG, dhcp_client_config) \
179 _(CREATE_LOOPBACK, create_loopback) \
180 _(CONTROL_PING, control_ping) \
181 _(CLI_REQUEST, cli_request) \
182 _(CLI_INBAND, cli_inband) \
183 _(SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit) \
184 _(L2_PATCH_ADD_DEL, l2_patch_add_del) \
185 _(CLASSIFY_ADD_DEL_TABLE, classify_add_del_table) \
186 _(CLASSIFY_ADD_DEL_SESSION, classify_add_del_session) \
187 _(CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table) \
188 _(CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables) \
189 _(GET_NODE_INDEX, get_node_index) \
190 _(ADD_NODE_NEXT, add_node_next) \
191 _(L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel) \
192 _(L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies) \
193 _(L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable) \
194 _(L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key) \
195 _(SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump) \
196 _(VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel) \
197 _(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump) \
198 _(GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel) \
199 _(GRE_TUNNEL_DUMP, gre_tunnel_dump) \
200 _(L2_FIB_CLEAR_TABLE, l2_fib_clear_table) \
201 _(L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter) \
202 _(L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite) \
203 _(CREATE_VHOST_USER_IF, create_vhost_user_if) \
204 _(MODIFY_VHOST_USER_IF, modify_vhost_user_if) \
205 _(DELETE_VHOST_USER_IF, delete_vhost_user_if) \
206 _(SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump) \
207 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
208 _(SHOW_VERSION, show_version) \
209 _(L2_FIB_TABLE_DUMP, l2_fib_table_dump) \
210 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
211 _(VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel) \
212 _(VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump) \
213 _(INTERFACE_NAME_RENUMBER, interface_name_renumber) \
214 _(WANT_IP4_ARP_EVENTS, want_ip4_arp_events) \
215 _(WANT_IP6_ND_EVENTS, want_ip6_nd_events) \
216 _(INPUT_ACL_SET_INTERFACE, input_acl_set_interface) \
217 _(IPSEC_SPD_ADD_DEL, ipsec_spd_add_del) \
218 _(IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd) \
219 _(IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry) \
220 _(IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry) \
221 _(IPSEC_SA_SET_KEY, ipsec_sa_set_key) \
222 _(IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del) \
223 _(IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth) \
224 _(IKEV2_PROFILE_SET_ID, ikev2_profile_set_id) \
225 _(IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts) \
226 _(IKEV2_SET_LOCAL_KEY, ikev2_set_local_key) \
227 _(DELETE_LOOPBACK, delete_loopback) \
228 _(BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del) \
229 _(COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable) \
230 _(COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable) \
231 _(GET_NODE_GRAPH, get_node_graph) \
232 _(IOAM_ENABLE, ioam_enable) \
233 _(IOAM_DISABLE, ioam_disable) \
234 _(LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set) \
235 _(LISP_ADD_DEL_LOCATOR, lisp_add_del_locator) \
236 _(LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid) \
237 _(LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry) \
238 _(LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver) \
239 _(LISP_ADD_DEL_MAP_SERVER, lisp_add_del_map_server) \
240 _(LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable) \
241 _(LISP_ENABLE_DISABLE, lisp_enable_disable) \
242 _(LISP_RLOC_PROBE_ENABLE_DISABLE, lisp_rloc_probe_enable_disable) \
243 _(LISP_MAP_REGISTER_ENABLE_DISABLE, lisp_map_register_enable_disable) \
244 _(LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface) \
245 _(LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping) \
246 _(LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency) \
247 _(LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set) \
248 _(LISP_MAP_REQUEST_MODE, lisp_map_request_mode) \
249 _(LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map) \
250 _(LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump) \
251 _(LISP_LOCATOR_DUMP, lisp_locator_dump) \
252 _(LISP_EID_TABLE_DUMP, lisp_eid_table_dump) \
253 _(LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump) \
254 _(LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump) \
255 _(LISP_MAP_SERVER_DUMP, lisp_map_server_dump) \
256 _(LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump) \
257 _(LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump) \
258 _(LISP_ADJACENCIES_GET, lisp_adjacencies_get) \
259 _(SHOW_LISP_RLOC_PROBE_STATE, show_lisp_rloc_probe_state) \
260 _(SHOW_LISP_MAP_REGISTER_STATE, show_lisp_map_register_state) \
261 _(SHOW_LISP_STATUS, show_lisp_status) \
262 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, \
263 lisp_add_del_map_request_itr_rlocs) \
264 _(LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs) \
265 _(SHOW_LISP_PITR, show_lisp_pitr) \
266 _(SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode) \
267 _(SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del) \
268 _(AF_PACKET_CREATE, af_packet_create) \
269 _(AF_PACKET_DELETE, af_packet_delete) \
270 _(POLICER_ADD_DEL, policer_add_del) \
271 _(POLICER_DUMP, policer_dump) \
272 _(POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface) \
273 _(POLICER_CLASSIFY_DUMP, policer_classify_dump) \
274 _(NETMAP_CREATE, netmap_create) \
275 _(NETMAP_DELETE, netmap_delete) \
276 _(MPLS_TUNNEL_DUMP, mpls_tunnel_dump) \
277 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
278 _(MPLS_FIB_DUMP, mpls_fib_dump) \
279 _(MPLS_FIB_DETAILS, mpls_fib_details) \
280 _(CLASSIFY_TABLE_IDS,classify_table_ids) \
281 _(CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface) \
282 _(CLASSIFY_TABLE_INFO,classify_table_info) \
283 _(CLASSIFY_SESSION_DUMP,classify_session_dump) \
284 _(CLASSIFY_SESSION_DETAILS,classify_session_details) \
285 _(SET_IPFIX_EXPORTER, set_ipfix_exporter) \
286 _(IPFIX_EXPORTER_DUMP, ipfix_exporter_dump) \
287 _(SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream) \
288 _(IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump) \
289 _(IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del) \
290 _(IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump) \
291 _(GET_NEXT_INDEX, get_next_index) \
292 _(PG_CREATE_INTERFACE, pg_create_interface) \
293 _(PG_CAPTURE, pg_capture) \
294 _(PG_ENABLE_DISABLE, pg_enable_disable) \
295 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, \
296 ip_source_and_port_range_check_add_del) \
297 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, \
298 ip_source_and_port_range_check_interface_add_del) \
299 _(IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel) \
300 _(IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump) \
301 _(DELETE_SUBIF, delete_subif) \
302 _(L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite) \
304 _(FLOW_CLASSIFY_SET_INTERFACE, flow_classify_set_interface) \
305 _(FLOW_CLASSIFY_DUMP, flow_classify_dump) \
306 _(IPSEC_SPD_DUMP, ipsec_spd_dump) \
307 _(FEATURE_ENABLE_DISABLE, feature_enable_disable) \
308 _(BFD_UDP_ADD, bfd_udp_add) \
309 _(BFD_UDP_DEL, bfd_udp_del) \
310 _(BFD_UDP_SESSION_DUMP, bfd_udp_session_dump) \
311 _(BFD_SESSION_SET_FLAGS, bfd_session_set_flags) \
312 _(WANT_BFD_EVENTS, want_bfd_events)
315 #define QUOTE(x) QUOTE_(x)
319 RESOLVE_IP4_ADD_DEL_ROUTE = 1,
320 RESOLVE_IP6_ADD_DEL_ROUTE,
323 static vlib_node_registration_t vpe_resolver_process_node;
324 vpe_api_main_t vpe_api_main;
326 static int arp_change_delete_callback (u32 pool_index, u8 * notused);
327 static int nd_change_delete_callback (u32 pool_index, u8 * notused);
329 /* Clean up all registrations belonging to the indicated client */
331 vl_api_memclnt_delete_callback (u32 client_index)
333 vpe_api_main_t *vam = &vpe_api_main;
334 vpe_client_registration_t *rp;
336 int stats_memclnt_delete_callback (u32 client_index);
338 stats_memclnt_delete_callback (client_index);
341 p = hash_get (vam->a##_registration_hash, client_index); \
343 rp = pool_elt_at_index (vam->a##_registrations, p[0]); \
344 pool_put (vam->a##_registrations, rp); \
345 hash_unset (vam->a##_registration_hash, client_index); \
347 foreach_registration_hash;
352 pub_sub_handler (oam_events, OAM_EVENTS);
353 pub_sub_handler (bfd_events, BFD_EVENTS);
355 #define RESOLUTION_EVENT 1
356 #define RESOLUTION_PENDING_EVENT 2
357 #define IP4_ARP_EVENT 3
358 #define IP6_ND_EVENT 4
360 int ip4_add_del_route_t_handler (vl_api_ip_add_del_route_t * mp);
362 int ip6_add_del_route_t_handler (vl_api_ip_add_del_route_t * mp);
365 handle_ip4_arp_event (u32 pool_index)
367 vpe_api_main_t *vam = &vpe_api_main;
368 vnet_main_t *vnm = vam->vnet_main;
369 vlib_main_t *vm = vam->vlib_main;
370 vl_api_ip4_arp_event_t *event;
371 vl_api_ip4_arp_event_t *mp;
372 unix_shared_memory_queue_t *q;
374 /* Client can cancel, die, etc. */
375 if (pool_is_free_index (vam->arp_events, pool_index))
378 event = pool_elt_at_index (vam->arp_events, pool_index);
380 q = vl_api_client_index_to_input_queue (event->client_index);
383 (void) vnet_add_del_ip4_arp_change_event
384 (vnm, arp_change_delete_callback,
385 event->pid, &event->address,
386 vpe_resolver_process_node.index, IP4_ARP_EVENT,
387 ~0 /* pool index, notused */ , 0 /* is_add */ );
391 if (q->cursize < q->maxsize)
393 mp = vl_msg_api_alloc (sizeof (*mp));
394 clib_memcpy (mp, event, sizeof (*mp));
395 vl_msg_api_send_shmem (q, (u8 *) & mp);
399 static f64 last_time;
401 * Throttle syslog msgs.
402 * It's pretty tempting to just revoke the registration...
404 if (vlib_time_now (vm) > last_time + 10.0)
406 clib_warning ("arp event for %U to pid %d: queue stuffed!",
407 format_ip4_address, &event->address, event->pid);
408 last_time = vlib_time_now (vm);
414 handle_ip6_nd_event (u32 pool_index)
416 vpe_api_main_t *vam = &vpe_api_main;
417 vnet_main_t *vnm = vam->vnet_main;
418 vlib_main_t *vm = vam->vlib_main;
419 vl_api_ip6_nd_event_t *event;
420 vl_api_ip6_nd_event_t *mp;
421 unix_shared_memory_queue_t *q;
423 /* Client can cancel, die, etc. */
424 if (pool_is_free_index (vam->nd_events, pool_index))
427 event = pool_elt_at_index (vam->nd_events, pool_index);
429 q = vl_api_client_index_to_input_queue (event->client_index);
432 (void) vnet_add_del_ip6_nd_change_event
433 (vnm, nd_change_delete_callback,
434 event->pid, &event->address,
435 vpe_resolver_process_node.index, IP6_ND_EVENT,
436 ~0 /* pool index, notused */ , 0 /* is_add */ );
440 if (q->cursize < q->maxsize)
442 mp = vl_msg_api_alloc (sizeof (*mp));
443 clib_memcpy (mp, event, sizeof (*mp));
444 vl_msg_api_send_shmem (q, (u8 *) & mp);
448 static f64 last_time;
450 * Throttle syslog msgs.
451 * It's pretty tempting to just revoke the registration...
453 if (vlib_time_now (vm) > last_time + 10.0)
455 clib_warning ("ip6 nd event for %U to pid %d: queue stuffed!",
456 format_ip6_address, &event->address, event->pid);
457 last_time = vlib_time_now (vm);
463 resolver_process (vlib_main_t * vm,
464 vlib_node_runtime_t * rt, vlib_frame_t * f)
467 uword *event_data = 0;
473 vlib_process_wait_for_event_or_clock (vm, timeout);
475 event_type = vlib_process_get_events (vm, &event_data);
479 case RESOLUTION_PENDING_EVENT:
483 case RESOLUTION_EVENT:
484 clib_warning ("resolver: BOGUS TYPE");
488 for (i = 0; i < vec_len (event_data); i++)
489 handle_ip4_arp_event (event_data[i]);
493 for (i = 0; i < vec_len (event_data); i++)
494 handle_ip6_nd_event (event_data[i]);
497 case ~0: /* timeout */
501 vec_reset_length (event_data);
503 return 0; /* or not */
507 VLIB_REGISTER_NODE (vpe_resolver_process_node,static) = {
508 .function = resolver_process,
509 .type = VLIB_NODE_TYPE_PROCESS,
510 .name = "vpe-route-resolver-process",
515 mpls_route_add_del_t_handler (vnet_main_t * vnm,
516 vl_api_mpls_route_add_del_t * mp)
518 u32 fib_index, next_hop_fib_index;
519 mpls_label_t *label_stack = NULL;
520 int rv, ii, n_labels;;
524 .fp_proto = FIB_PROTOCOL_MPLS,
525 .fp_eos = mp->mr_eos,
526 .fp_label = ntohl (mp->mr_label),
530 if (mp->mr_next_hop_proto_is_ip4)
532 pfx.fp_payload_proto = DPO_PROTO_IP4;
536 pfx.fp_payload_proto = DPO_PROTO_IP6;
541 pfx.fp_payload_proto = DPO_PROTO_MPLS;
544 rv = add_del_route_check (FIB_PROTOCOL_MPLS,
546 mp->mr_next_hop_sw_if_index,
547 dpo_proto_to_fib (pfx.fp_payload_proto),
548 mp->mr_next_hop_table_id,
549 mp->mr_create_table_if_needed,
550 &fib_index, &next_hop_fib_index);
556 memset (&nh, 0, sizeof (nh));
558 if (mp->mr_next_hop_proto_is_ip4)
559 memcpy (&nh.ip4, mp->mr_next_hop, sizeof (nh.ip4));
561 memcpy (&nh.ip6, mp->mr_next_hop, sizeof (nh.ip6));
563 n_labels = mp->mr_next_hop_n_out_labels;
566 else if (1 == n_labels)
567 vec_add1 (label_stack, ntohl (mp->mr_next_hop_out_label_stack[0]));
570 vec_validate (label_stack, n_labels - 1);
571 for (ii = 0; ii < n_labels; ii++)
572 label_stack[ii] = ntohl (mp->mr_next_hop_out_label_stack[ii]);
575 return (add_del_route_t_handler (mp->mr_is_multipath, mp->mr_is_add, 0, // mp->is_drop,
576 0, // mp->is_unreach,
577 0, // mp->is_prohibit,
580 mp->mr_classify_table_index,
581 mp->mr_is_resolve_host,
582 mp->mr_is_resolve_attached,
584 mp->mr_next_hop_proto_is_ip4,
585 &nh, ntohl (mp->mr_next_hop_sw_if_index),
587 mp->mr_next_hop_weight,
588 ntohl (mp->mr_next_hop_via_label),
593 vl_api_mpls_route_add_del_t_handler (vl_api_mpls_route_add_del_t * mp)
595 vl_api_mpls_route_add_del_reply_t *rmp;
599 vnm = vnet_get_main ();
602 rv = mpls_route_add_del_t_handler (vnm, mp);
604 rv = (rv == 0) ? vnm->api_errno : rv;
606 REPLY_MACRO (VL_API_MPLS_ROUTE_ADD_DEL_REPLY);
610 mpls_ip_bind_unbind_handler (vnet_main_t * vnm,
611 vl_api_mpls_ip_bind_unbind_t * mp)
613 u32 mpls_fib_index, ip_fib_index;
616 fib_table_find (FIB_PROTOCOL_MPLS, ntohl (mp->mb_mpls_table_id));
618 if (~0 == mpls_fib_index)
620 if (mp->mb_create_table_if_needed)
623 fib_table_find_or_create_and_lock (FIB_PROTOCOL_MPLS,
624 ntohl (mp->mb_mpls_table_id));
627 return VNET_API_ERROR_NO_SUCH_FIB;
630 ip_fib_index = fib_table_find ((mp->mb_is_ip4 ?
633 ntohl (mp->mb_ip_table_id));
634 if (~0 == ip_fib_index)
635 return VNET_API_ERROR_NO_SUCH_FIB;
638 .fp_len = mp->mb_address_length,
643 pfx.fp_proto = FIB_PROTOCOL_IP4;
644 clib_memcpy (&pfx.fp_addr.ip4, mp->mb_address,
645 sizeof (pfx.fp_addr.ip4));
649 pfx.fp_proto = FIB_PROTOCOL_IP6;
650 clib_memcpy (&pfx.fp_addr.ip6, mp->mb_address,
651 sizeof (pfx.fp_addr.ip6));
655 fib_table_entry_local_label_add (ip_fib_index, &pfx,
656 ntohl (mp->mb_label));
658 fib_table_entry_local_label_remove (ip_fib_index, &pfx,
659 ntohl (mp->mb_label));
665 vl_api_mpls_ip_bind_unbind_t_handler (vl_api_mpls_ip_bind_unbind_t * mp)
667 vl_api_mpls_route_add_del_reply_t *rmp;
671 vnm = vnet_get_main ();
674 rv = mpls_ip_bind_unbind_handler (vnm, mp);
676 rv = (rv == 0) ? vnm->api_errno : rv;
678 REPLY_MACRO (VL_API_MPLS_ROUTE_ADD_DEL_REPLY);
682 vl_api_sw_interface_set_vpath_t_handler (vl_api_sw_interface_set_vpath_t * mp)
684 vl_api_sw_interface_set_vpath_reply_t *rmp;
686 u32 sw_if_index = ntohl (mp->sw_if_index);
688 VALIDATE_SW_IF_INDEX (mp);
690 l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_VPATH, mp->enable);
691 vnet_feature_enable_disable ("ip4-unicast", "vpath-input-ip4",
692 sw_if_index, mp->enable, 0, 0);
693 vnet_feature_enable_disable ("ip4-multicast", "vpath-input-ip4",
694 sw_if_index, mp->enable, 0, 0);
695 vnet_feature_enable_disable ("ip6-unicast", "vpath-input-ip6",
696 sw_if_index, mp->enable, 0, 0);
697 vnet_feature_enable_disable ("ip6-multicast", "vpath-input-ip6",
698 sw_if_index, mp->enable, 0, 0);
700 BAD_SW_IF_INDEX_LABEL;
702 REPLY_MACRO (VL_API_SW_INTERFACE_SET_VPATH_REPLY);
706 vl_api_sw_interface_set_vxlan_bypass_t_handler
707 (vl_api_sw_interface_set_vxlan_bypass_t * mp)
709 vl_api_sw_interface_set_vxlan_bypass_reply_t *rmp;
711 u32 sw_if_index = ntohl (mp->sw_if_index);
713 VALIDATE_SW_IF_INDEX (mp);
717 /* not yet implemented */
720 vnet_feature_enable_disable ("ip4-unicast", "ip4-vxlan-bypass",
721 sw_if_index, mp->enable, 0, 0);
723 BAD_SW_IF_INDEX_LABEL;
725 REPLY_MACRO (VL_API_SW_INTERFACE_SET_VXLAN_BYPASS_REPLY);
729 vl_api_sw_interface_set_l2_xconnect_t_handler
730 (vl_api_sw_interface_set_l2_xconnect_t * mp)
732 vl_api_sw_interface_set_l2_xconnect_reply_t *rmp;
734 u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index);
735 u32 tx_sw_if_index = ntohl (mp->tx_sw_if_index);
736 vlib_main_t *vm = vlib_get_main ();
737 vnet_main_t *vnm = vnet_get_main ();
739 VALIDATE_RX_SW_IF_INDEX (mp);
743 VALIDATE_TX_SW_IF_INDEX (mp);
744 rv = set_int_l2_mode (vm, vnm, MODE_L2_XC,
745 rx_sw_if_index, 0, 0, 0, tx_sw_if_index);
749 rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, 0, 0, 0);
752 BAD_RX_SW_IF_INDEX_LABEL;
753 BAD_TX_SW_IF_INDEX_LABEL;
755 REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_XCONNECT_REPLY);
759 vl_api_sw_interface_set_l2_bridge_t_handler
760 (vl_api_sw_interface_set_l2_bridge_t * mp)
762 bd_main_t *bdm = &bd_main;
763 vl_api_sw_interface_set_l2_bridge_reply_t *rmp;
765 u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index);
766 u32 bd_id = ntohl (mp->bd_id);
770 vlib_main_t *vm = vlib_get_main ();
771 vnet_main_t *vnm = vnet_get_main ();
773 VALIDATE_RX_SW_IF_INDEX (mp);
775 bd_index = bd_find_or_add_bd_index (bdm, bd_id);
779 //VALIDATE_TX_SW_IF_INDEX(mp);
780 rv = set_int_l2_mode (vm, vnm, MODE_L2_BRIDGE,
781 rx_sw_if_index, bd_index, bvi, shg, 0);
785 rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, 0, 0, 0);
788 BAD_RX_SW_IF_INDEX_LABEL;
790 REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_BRIDGE_REPLY);
794 vl_api_sw_interface_set_dpdk_hqos_pipe_t_handler
795 (vl_api_sw_interface_set_dpdk_hqos_pipe_t * mp)
797 vl_api_sw_interface_set_dpdk_hqos_pipe_reply_t *rmp;
801 dpdk_main_t *dm = &dpdk_main;
804 u32 sw_if_index = ntohl (mp->sw_if_index);
805 u32 subport = ntohl (mp->subport);
806 u32 pipe = ntohl (mp->pipe);
807 u32 profile = ntohl (mp->profile);
808 vnet_hw_interface_t *hw;
810 VALIDATE_SW_IF_INDEX (mp);
812 /* hw_if & dpdk device */
813 hw = vnet_get_sup_hw_interface (dm->vnet_main, sw_if_index);
815 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
817 rv = rte_sched_pipe_config (xd->hqos_ht->hqos, subport, pipe, profile);
819 BAD_SW_IF_INDEX_LABEL;
821 clib_warning ("setting HQoS pipe parameters without DPDK not implemented");
822 rv = VNET_API_ERROR_UNIMPLEMENTED;
825 REPLY_MACRO (VL_API_SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY);
829 vl_api_sw_interface_set_dpdk_hqos_subport_t_handler
830 (vl_api_sw_interface_set_dpdk_hqos_subport_t * mp)
832 vl_api_sw_interface_set_dpdk_hqos_subport_reply_t *rmp;
836 dpdk_main_t *dm = &dpdk_main;
838 struct rte_sched_subport_params p;
840 u32 sw_if_index = ntohl (mp->sw_if_index);
841 u32 subport = ntohl (mp->subport);
842 p.tb_rate = ntohl (mp->tb_rate);
843 p.tb_size = ntohl (mp->tb_size);
844 p.tc_rate[0] = ntohl (mp->tc_rate[0]);
845 p.tc_rate[1] = ntohl (mp->tc_rate[1]);
846 p.tc_rate[2] = ntohl (mp->tc_rate[2]);
847 p.tc_rate[3] = ntohl (mp->tc_rate[3]);
848 p.tc_period = ntohl (mp->tc_period);
850 vnet_hw_interface_t *hw;
852 VALIDATE_SW_IF_INDEX (mp);
854 /* hw_if & dpdk device */
855 hw = vnet_get_sup_hw_interface (dm->vnet_main, sw_if_index);
857 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
859 rv = rte_sched_subport_config (xd->hqos_ht->hqos, subport, &p);
861 BAD_SW_IF_INDEX_LABEL;
864 ("setting HQoS subport parameters without DPDK not implemented");
865 rv = VNET_API_ERROR_UNIMPLEMENTED;
868 REPLY_MACRO (VL_API_SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY);
872 vl_api_sw_interface_set_dpdk_hqos_tctbl_t_handler
873 (vl_api_sw_interface_set_dpdk_hqos_tctbl_t * mp)
875 vl_api_sw_interface_set_dpdk_hqos_tctbl_reply_t *rmp;
879 dpdk_main_t *dm = &dpdk_main;
880 vlib_thread_main_t *tm = vlib_get_thread_main ();
883 u32 sw_if_index = ntohl (mp->sw_if_index);
884 u32 entry = ntohl (mp->entry);
885 u32 tc = ntohl (mp->tc);
886 u32 queue = ntohl (mp->queue);
889 vnet_hw_interface_t *hw;
891 VALIDATE_SW_IF_INDEX (mp);
893 /* hw_if & dpdk device */
894 hw = vnet_get_sup_hw_interface (dm->vnet_main, sw_if_index);
896 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
898 if (tc >= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE)
900 clib_warning ("invalid traffic class !!");
901 rv = VNET_API_ERROR_INVALID_VALUE;
904 if (queue >= RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS)
906 clib_warning ("invalid queue !!");
907 rv = VNET_API_ERROR_INVALID_VALUE;
911 /* Detect the set of worker threads */
912 uword *p = hash_get_mem (tm->thread_registrations_by_name, "workers");
916 clib_warning ("worker thread registration AWOL !!");
917 rv = VNET_API_ERROR_INVALID_VALUE_2;
921 vlib_thread_registration_t *tr = (vlib_thread_registration_t *) p[0];
922 int worker_thread_first = tr->first_index;
923 int worker_thread_count = tr->count;
925 val = tc * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS + queue;
926 for (i = 0; i < worker_thread_count; i++)
927 xd->hqos_wt[worker_thread_first + i].hqos_tc_table[entry] = val;
929 BAD_SW_IF_INDEX_LABEL;
932 clib_warning ("setting HQoS DSCP table entry without DPDK not implemented");
933 rv = VNET_API_ERROR_UNIMPLEMENTED;
936 REPLY_MACRO (VL_API_SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY);
940 vl_api_bridge_domain_add_del_t_handler (vl_api_bridge_domain_add_del_t * mp)
942 vlib_main_t *vm = vlib_get_main ();
943 bd_main_t *bdm = &bd_main;
944 vl_api_bridge_domain_add_del_reply_t *rmp;
946 u32 enable_flags = 0, disable_flags = 0;
947 u32 bd_id = ntohl (mp->bd_id);
952 bd_index = bd_find_or_add_bd_index (bdm, bd_id);
955 enable_flags |= L2_FLOOD;
957 disable_flags |= L2_FLOOD;
960 enable_flags |= L2_UU_FLOOD;
962 disable_flags |= L2_UU_FLOOD;
965 enable_flags |= L2_FWD;
967 disable_flags |= L2_FWD;
970 enable_flags |= L2_ARP_TERM;
972 disable_flags |= L2_ARP_TERM;
975 enable_flags |= L2_LEARN;
977 disable_flags |= L2_LEARN;
980 bd_set_flags (vm, bd_index, enable_flags, 1 /* enable */ );
983 bd_set_flags (vm, bd_index, disable_flags, 0 /* disable */ );
985 bd_set_mac_age (vm, bd_index, mp->mac_age);
988 rv = bd_delete_bd_index (bdm, bd_id);
990 REPLY_MACRO (VL_API_BRIDGE_DOMAIN_ADD_DEL_REPLY);
994 vl_api_bridge_domain_details_t_handler (vl_api_bridge_domain_details_t * mp)
996 clib_warning ("BUG");
1000 vl_api_bridge_domain_sw_if_details_t_handler
1001 (vl_api_bridge_domain_sw_if_details_t * mp)
1003 clib_warning ("BUG");
1007 send_bridge_domain_details (unix_shared_memory_queue_t * q,
1008 l2_bridge_domain_t * bd_config,
1009 u32 n_sw_ifs, u32 context)
1011 vl_api_bridge_domain_details_t *mp;
1013 mp = vl_msg_api_alloc (sizeof (*mp));
1014 memset (mp, 0, sizeof (*mp));
1015 mp->_vl_msg_id = ntohs (VL_API_BRIDGE_DOMAIN_DETAILS);
1016 mp->bd_id = ntohl (bd_config->bd_id);
1017 mp->flood = bd_feature_flood (bd_config);
1018 mp->uu_flood = bd_feature_uu_flood (bd_config);
1019 mp->forward = bd_feature_forward (bd_config);
1020 mp->learn = bd_feature_learn (bd_config);
1021 mp->arp_term = bd_feature_arp_term (bd_config);
1022 mp->bvi_sw_if_index = ntohl (bd_config->bvi_sw_if_index);
1023 mp->mac_age = bd_config->mac_age;
1024 mp->n_sw_ifs = ntohl (n_sw_ifs);
1025 mp->context = context;
1027 vl_msg_api_send_shmem (q, (u8 *) & mp);
1031 send_bd_sw_if_details (l2input_main_t * l2im,
1032 unix_shared_memory_queue_t * q,
1033 l2_flood_member_t * member, u32 bd_id, u32 context)
1035 vl_api_bridge_domain_sw_if_details_t *mp;
1036 l2_input_config_t *input_cfg;
1038 mp = vl_msg_api_alloc (sizeof (*mp));
1039 memset (mp, 0, sizeof (*mp));
1040 mp->_vl_msg_id = ntohs (VL_API_BRIDGE_DOMAIN_SW_IF_DETAILS);
1041 mp->bd_id = ntohl (bd_id);
1042 mp->sw_if_index = ntohl (member->sw_if_index);
1043 input_cfg = vec_elt_at_index (l2im->configs, member->sw_if_index);
1044 mp->shg = input_cfg->shg;
1045 mp->context = context;
1047 vl_msg_api_send_shmem (q, (u8 *) & mp);
1051 vl_api_bridge_domain_dump_t_handler (vl_api_bridge_domain_dump_t * mp)
1053 bd_main_t *bdm = &bd_main;
1054 l2input_main_t *l2im = &l2input_main;
1055 unix_shared_memory_queue_t *q;
1056 l2_bridge_domain_t *bd_config;
1057 u32 bd_id, bd_index;
1060 q = vl_api_client_index_to_input_queue (mp->client_index);
1065 bd_id = ntohl (mp->bd_id);
1067 bd_index = (bd_id == ~0) ? 0 : bd_find_or_add_bd_index (bdm, bd_id);
1068 end = (bd_id == ~0) ? vec_len (l2im->bd_configs) : bd_index + 1;
1069 for (; bd_index < end; bd_index++)
1071 bd_config = l2input_bd_config_from_index (l2im, bd_index);
1072 /* skip dummy bd_id 0 */
1073 if (bd_config && (bd_config->bd_id > 0))
1076 l2_flood_member_t *m;
1078 n_sw_ifs = vec_len (bd_config->members);
1079 send_bridge_domain_details (q, bd_config, n_sw_ifs, mp->context);
1081 vec_foreach (m, bd_config->members)
1083 send_bd_sw_if_details (l2im, q, m, bd_config->bd_id, mp->context);
1090 vl_api_l2fib_add_del_t_handler (vl_api_l2fib_add_del_t * mp)
1092 bd_main_t *bdm = &bd_main;
1093 l2input_main_t *l2im = &l2input_main;
1094 vl_api_l2fib_add_del_reply_t *rmp;
1097 u32 sw_if_index = ntohl (mp->sw_if_index);
1098 u32 bd_id = ntohl (mp->bd_id);
1107 p = hash_get (bdm->bd_index_by_bd_id, bd_id);
1110 rv = VNET_API_ERROR_NO_SUCH_ENTRY;
1111 goto bad_sw_if_index;
1117 filter_mac = mp->filter_mac ? 1 : 0;
1118 if (filter_mac == 0)
1120 VALIDATE_SW_IF_INDEX (mp);
1121 if (vec_len (l2im->configs) <= sw_if_index)
1123 rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
1124 goto bad_sw_if_index;
1128 l2_input_config_t *config;
1129 config = vec_elt_at_index (l2im->configs, sw_if_index);
1130 if (config->bridge == 0)
1132 rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
1133 goto bad_sw_if_index;
1137 static_mac = mp->static_mac ? 1 : 0;
1138 bvi_mac = mp->bvi_mac ? 1 : 0;
1139 l2fib_add_entry (mac, bd_index, sw_if_index, static_mac, filter_mac,
1144 l2fib_del_entry (mac, bd_index);
1147 BAD_SW_IF_INDEX_LABEL;
1149 REPLY_MACRO (VL_API_L2FIB_ADD_DEL_REPLY);
1153 vl_api_l2_flags_t_handler (vl_api_l2_flags_t * mp)
1155 vl_api_l2_flags_reply_t *rmp;
1157 u32 sw_if_index = ntohl (mp->sw_if_index);
1158 u32 flags = ntohl (mp->feature_bitmap);
1161 VALIDATE_SW_IF_INDEX (mp);
1164 if (flags & L2INPUT_FEAT_ ## a) \
1165 rbm = l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_ ## a, mp->is_set);
1166 foreach_l2input_feat;
1169 BAD_SW_IF_INDEX_LABEL;
1172 REPLY_MACRO2(VL_API_L2_FLAGS_REPLY,
1174 rmp->resulting_feature_bitmap = ntohl(rbm);
1180 vl_api_bridge_flags_t_handler (vl_api_bridge_flags_t * mp)
1182 vlib_main_t *vm = vlib_get_main ();
1183 bd_main_t *bdm = &bd_main;
1184 vl_api_bridge_flags_reply_t *rmp;
1186 u32 bd_id = ntohl (mp->bd_id);
1188 u32 flags = ntohl (mp->feature_bitmap);
1191 p = hash_get (bdm->bd_index_by_bd_id, bd_id);
1194 rv = VNET_API_ERROR_NO_SUCH_ENTRY;
1200 bd_set_flags (vm, bd_index, flags, mp->is_set);
1204 REPLY_MACRO2(VL_API_BRIDGE_FLAGS_REPLY,
1206 rmp->resulting_feature_bitmap = ntohl(flags);
1212 vl_api_bd_ip_mac_add_del_t_handler (vl_api_bd_ip_mac_add_del_t * mp)
1214 bd_main_t *bdm = &bd_main;
1215 vl_api_bd_ip_mac_add_del_reply_t *rmp;
1217 u32 bd_id = ntohl (mp->bd_id);
1221 p = hash_get (bdm->bd_index_by_bd_id, bd_id);
1224 rv = VNET_API_ERROR_NO_SUCH_ENTRY;
1229 if (bd_add_del_ip_mac (bd_index, mp->ip_address,
1230 mp->mac_address, mp->is_ipv6, mp->is_add))
1231 rv = VNET_API_ERROR_UNSPECIFIED;
1234 REPLY_MACRO (VL_API_BD_IP_MAC_ADD_DEL_REPLY);
1238 vl_api_create_vlan_subif_t_handler (vl_api_create_vlan_subif_t * mp)
1240 vl_api_create_vlan_subif_reply_t *rmp;
1241 vnet_main_t *vnm = vnet_get_main ();
1242 u32 hw_if_index, sw_if_index = (u32) ~ 0;
1243 vnet_hw_interface_t *hi;
1246 vnet_sw_interface_t template;
1248 vnet_interface_main_t *im = &vnm->interface_main;
1249 u64 sup_and_sub_key;
1251 unix_shared_memory_queue_t *q;
1252 clib_error_t *error;
1254 VALIDATE_SW_IF_INDEX (mp);
1256 hw_if_index = ntohl (mp->sw_if_index);
1257 hi = vnet_get_hw_interface (vnm, hw_if_index);
1259 id = ntohl (mp->vlan_id);
1260 if (id == 0 || id > 4095)
1262 rv = VNET_API_ERROR_INVALID_VLAN;
1266 sup_and_sub_key = ((u64) (hi->sw_if_index) << 32) | (u64) id;
1268 p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
1271 rv = VNET_API_ERROR_VLAN_ALREADY_EXISTS;
1275 kp = clib_mem_alloc (sizeof (*kp));
1276 *kp = sup_and_sub_key;
1278 memset (&template, 0, sizeof (template));
1279 template.type = VNET_SW_INTERFACE_TYPE_SUB;
1280 template.sup_sw_if_index = hi->sw_if_index;
1281 template.sub.id = id;
1282 template.sub.eth.raw_flags = 0;
1283 template.sub.eth.flags.one_tag = 1;
1284 template.sub.eth.outer_vlan_id = id;
1285 template.sub.eth.flags.exact_match = 1;
1287 error = vnet_create_sw_interface (vnm, &template, &sw_if_index);
1290 clib_error_report (error);
1291 rv = VNET_API_ERROR_INVALID_REGISTRATION;
1294 hash_set (hi->sub_interface_sw_if_index_by_id, id, sw_if_index);
1295 hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index);
1297 BAD_SW_IF_INDEX_LABEL;
1300 q = vl_api_client_index_to_input_queue (mp->client_index);
1304 rmp = vl_msg_api_alloc (sizeof (*rmp));
1305 rmp->_vl_msg_id = ntohs (VL_API_CREATE_VLAN_SUBIF_REPLY);
1306 rmp->context = mp->context;
1307 rmp->retval = ntohl (rv);
1308 rmp->sw_if_index = ntohl (sw_if_index);
1309 vl_msg_api_send_shmem (q, (u8 *) & rmp);
1313 vl_api_create_subif_t_handler (vl_api_create_subif_t * mp)
1315 vl_api_create_subif_reply_t *rmp;
1316 vnet_main_t *vnm = vnet_get_main ();
1317 u32 sw_if_index = ~0;
1320 vnet_sw_interface_t *si;
1321 vnet_hw_interface_t *hi;
1322 vnet_sw_interface_t template;
1324 vnet_interface_main_t *im = &vnm->interface_main;
1325 u64 sup_and_sub_key;
1327 clib_error_t *error;
1329 VALIDATE_SW_IF_INDEX (mp);
1331 si = vnet_get_sup_sw_interface (vnm, ntohl (mp->sw_if_index));
1332 hi = vnet_get_sup_hw_interface (vnm, ntohl (mp->sw_if_index));
1334 if (hi->bond_info == VNET_HW_INTERFACE_BOND_INFO_SLAVE)
1336 rv = VNET_API_ERROR_BOND_SLAVE_NOT_ALLOWED;
1340 sw_if_index = si->sw_if_index;
1341 sub_id = ntohl (mp->sub_id);
1343 sup_and_sub_key = ((u64) (sw_if_index) << 32) | (u64) sub_id;
1345 p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
1349 clib_warning ("sup sw_if_index %d, sub id %d already exists\n",
1350 sw_if_index, sub_id);
1351 rv = VNET_API_ERROR_SUBIF_ALREADY_EXISTS;
1355 kp = clib_mem_alloc (sizeof (*kp));
1356 *kp = sup_and_sub_key;
1358 memset (&template, 0, sizeof (template));
1359 template.type = VNET_SW_INTERFACE_TYPE_SUB;
1360 template.sup_sw_if_index = sw_if_index;
1361 template.sub.id = sub_id;
1362 template.sub.eth.flags.no_tags = mp->no_tags;
1363 template.sub.eth.flags.one_tag = mp->one_tag;
1364 template.sub.eth.flags.two_tags = mp->two_tags;
1365 template.sub.eth.flags.dot1ad = mp->dot1ad;
1366 template.sub.eth.flags.exact_match = mp->exact_match;
1367 template.sub.eth.flags.default_sub = mp->default_sub;
1368 template.sub.eth.flags.outer_vlan_id_any = mp->outer_vlan_id_any;
1369 template.sub.eth.flags.inner_vlan_id_any = mp->inner_vlan_id_any;
1370 template.sub.eth.outer_vlan_id = ntohs (mp->outer_vlan_id);
1371 template.sub.eth.inner_vlan_id = ntohs (mp->inner_vlan_id);
1373 error = vnet_create_sw_interface (vnm, &template, &sw_if_index);
1376 clib_error_report (error);
1377 rv = VNET_API_ERROR_SUBIF_CREATE_FAILED;
1381 hash_set (hi->sub_interface_sw_if_index_by_id, sub_id, sw_if_index);
1382 hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index);
1384 BAD_SW_IF_INDEX_LABEL;
1389 REPLY_MACRO2(VL_API_CREATE_SUBIF_REPLY,
1391 rmp->sw_if_index = ntohl(sw_if_index);
1397 vl_api_mpls_tunnel_add_del_t_handler (vl_api_mpls_tunnel_add_del_t * mp)
1399 vl_api_mpls_tunnel_add_del_reply_t *rmp;
1401 stats_main_t *sm = &stats_main;
1402 u32 tunnel_sw_if_index;
1405 dslock (sm, 1 /* release hint */ , 5 /* tag */ );
1409 fib_route_path_t rpath, *rpaths = NULL;
1410 mpls_label_t *label_stack = NULL;
1412 memset (&rpath, 0, sizeof (rpath));
1414 if (mp->mt_next_hop_proto_is_ip4)
1416 rpath.frp_proto = FIB_PROTOCOL_IP4;
1417 clib_memcpy (&rpath.frp_addr.ip4,
1418 mp->mt_next_hop, sizeof (rpath.frp_addr.ip4));
1422 rpath.frp_proto = FIB_PROTOCOL_IP6;
1423 clib_memcpy (&rpath.frp_addr.ip6,
1424 mp->mt_next_hop, sizeof (rpath.frp_addr.ip6));
1426 rpath.frp_sw_if_index = ntohl (mp->mt_next_hop_sw_if_index);
1428 for (ii = 0; ii < mp->mt_next_hop_n_out_labels; ii++)
1429 vec_add1 (label_stack, ntohl (mp->mt_next_hop_out_label_stack[ii]));
1431 vec_add1 (rpaths, rpath);
1433 vnet_mpls_tunnel_add (rpaths, label_stack,
1434 mp->mt_l2_only, &tunnel_sw_if_index);
1436 vec_free (label_stack);
1440 tunnel_sw_if_index = ntohl (mp->mt_sw_if_index);
1441 vnet_mpls_tunnel_del (tunnel_sw_if_index);
1447 REPLY_MACRO2(VL_API_MPLS_TUNNEL_ADD_DEL_REPLY,
1449 rmp->sw_if_index = ntohl(tunnel_sw_if_index);
1455 vl_api_proxy_arp_add_del_t_handler (vl_api_proxy_arp_add_del_t * mp)
1457 vl_api_proxy_arp_add_del_reply_t *rmp;
1460 ip4_main_t *im = &ip4_main;
1461 stats_main_t *sm = &stats_main;
1462 int vnet_proxy_arp_add_del (ip4_address_t * lo_addr,
1463 ip4_address_t * hi_addr,
1464 u32 fib_index, int is_del);
1467 dslock (sm, 1 /* release hint */ , 6 /* tag */ );
1469 p = hash_get (im->fib_index_by_table_id, ntohl (mp->vrf_id));
1473 rv = VNET_API_ERROR_NO_SUCH_FIB;
1479 rv = vnet_proxy_arp_add_del ((ip4_address_t *) mp->low_address,
1480 (ip4_address_t *) mp->hi_address,
1481 fib_index, mp->is_add == 0);
1485 REPLY_MACRO (VL_API_PROXY_ARP_ADD_DEL_REPLY);
1489 vl_api_proxy_arp_intfc_enable_disable_t_handler
1490 (vl_api_proxy_arp_intfc_enable_disable_t * mp)
1493 vnet_main_t *vnm = vnet_get_main ();
1494 vl_api_proxy_arp_intfc_enable_disable_reply_t *rmp;
1495 vnet_sw_interface_t *si;
1498 VALIDATE_SW_IF_INDEX (mp);
1500 sw_if_index = ntohl (mp->sw_if_index);
1502 if (pool_is_free_index (vnm->interface_main.sw_interfaces, sw_if_index))
1504 rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
1508 si = vnet_get_sw_interface (vnm, sw_if_index);
1512 if (mp->enable_disable)
1513 si->flags |= VNET_SW_INTERFACE_FLAG_PROXY_ARP;
1515 si->flags &= ~VNET_SW_INTERFACE_FLAG_PROXY_ARP;
1517 BAD_SW_IF_INDEX_LABEL;
1520 REPLY_MACRO (VL_API_PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY);
1524 vl_api_is_address_reachable_t_handler (vl_api_is_address_reachable_t * mp)
1527 vpe_main_t *rm = &vpe_main;
1528 ip4_main_t *im4 = &ip4_main;
1529 ip6_main_t *im6 = &ip6_main;
1530 ip_lookup_main_t *lm;
1536 u32 adj_index, sw_if_index;
1537 vl_api_is_address_reachable_t *rmp;
1538 ip_adjacency_t *adj;
1539 unix_shared_memory_queue_t *q;
1541 q = vl_api_client_index_to_input_queue (mp->client_index);
1544 increment_missing_api_client_counter (rm->vlib_main);
1548 rmp = vl_msg_api_alloc (sizeof (*rmp));
1549 clib_memcpy (rmp, mp, sizeof (*rmp));
1551 sw_if_index = mp->next_hop_sw_if_index;
1552 clib_memcpy (&addr, mp->address, sizeof (addr));
1555 lm = &im6->lookup_main;
1556 adj_index = ip6_fib_lookup (im6, sw_if_index, &addr.ip6);
1560 lm = &im4->lookup_main;
1562 adj_index = ip4_fib_lookup (im4, sw_if_index, &addr.ip4);
1564 if (adj_index == ~0)
1569 adj = ip_get_adjacency (lm, adj_index);
1571 if (adj->lookup_next_index == IP_LOOKUP_NEXT_REWRITE
1572 && adj->rewrite_header.sw_if_index == sw_if_index)
1578 if (adj->lookup_next_index == IP_LOOKUP_NEXT_ARP
1579 && adj->rewrite_header.sw_if_index == sw_if_index)
1582 ip6_probe_neighbor (rm->vlib_main, &addr.ip6, sw_if_index);
1584 ip4_probe_neighbor (rm->vlib_main, &addr.ip4, sw_if_index);
1586 else if (adj->lookup_next_index == IP_LOOKUP_NEXT_DROP)
1595 vl_msg_api_send_shmem (q, (u8 *) & rmp);
1600 vl_api_sw_interface_set_mpls_enable_t_handler
1601 (vl_api_sw_interface_set_mpls_enable_t * mp)
1603 vl_api_sw_interface_set_mpls_enable_reply_t *rmp;
1606 VALIDATE_SW_IF_INDEX (mp);
1608 mpls_sw_interface_enable_disable (&mpls_main,
1609 ntohl (mp->sw_if_index), mp->enable);
1611 BAD_SW_IF_INDEX_LABEL;
1612 REPLY_MACRO (VL_API_SW_INTERFACE_SET_MPLS_ENABLE_REPLY);
1616 * WARNING: replicated pending api refactor completion
1619 send_sw_interface_flags_deleted (vpe_api_main_t * am,
1620 unix_shared_memory_queue_t * q,
1623 vl_api_sw_interface_set_flags_t *mp;
1625 mp = vl_msg_api_alloc (sizeof (*mp));
1626 memset (mp, 0, sizeof (*mp));
1627 mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_SET_FLAGS);
1628 mp->sw_if_index = ntohl (sw_if_index);
1630 mp->admin_up_down = 0;
1631 mp->link_up_down = 0;
1633 vl_msg_api_send_shmem (q, (u8 *) & mp);
1637 send_oam_event (oam_target_t * t)
1639 vpe_api_main_t *vam = &vpe_api_main;
1640 unix_shared_memory_queue_t *q;
1641 vpe_client_registration_t *reg;
1642 vl_api_oam_event_t *mp;
1645 pool_foreach(reg, vam->oam_events_registrations,
1647 q = vl_api_client_index_to_input_queue (reg->client_index);
1650 mp = vl_msg_api_alloc (sizeof (*mp));
1651 mp->_vl_msg_id = ntohs (VL_API_OAM_EVENT);
1652 clib_memcpy (mp->dst_address, &t->dst_address,
1653 sizeof (mp->dst_address));
1654 mp->state = t->state;
1655 vl_msg_api_send_shmem (q, (u8 *)&mp);
1662 vl_api_oam_add_del_t_handler (vl_api_oam_add_del_t * mp)
1664 vl_api_oam_add_del_reply_t *rmp;
1667 rv = vpe_oam_add_del_target ((ip4_address_t *) mp->src_address,
1668 (ip4_address_t *) mp->dst_address,
1669 ntohl (mp->vrf_id), (int) (mp->is_add));
1671 REPLY_MACRO (VL_API_OAM_ADD_DEL_REPLY);
1675 vl_api_vnet_get_summary_stats_t_handler (vl_api_vnet_get_summary_stats_t * mp)
1677 stats_main_t *sm = &stats_main;
1678 vnet_interface_main_t *im = sm->interface_main;
1679 vl_api_vnet_summary_stats_reply_t *rmp;
1680 vlib_combined_counter_main_t *cm;
1683 u64 total_pkts[VLIB_N_RX_TX];
1684 u64 total_bytes[VLIB_N_RX_TX];
1686 unix_shared_memory_queue_t *q =
1687 vl_api_client_index_to_input_queue (mp->client_index);
1692 rmp = vl_msg_api_alloc (sizeof (*rmp));
1693 rmp->_vl_msg_id = ntohs (VL_API_VNET_SUMMARY_STATS_REPLY);
1694 rmp->context = mp->context;
1697 memset (total_pkts, 0, sizeof (total_pkts));
1698 memset (total_bytes, 0, sizeof (total_bytes));
1700 vnet_interface_counter_lock (im);
1702 vec_foreach (cm, im->combined_sw_if_counters)
1704 which = cm - im->combined_sw_if_counters;
1706 for (i = 0; i < vec_len (cm->maxi); i++)
1708 vlib_get_combined_counter (cm, i, &v);
1709 total_pkts[which] += v.packets;
1710 total_bytes[which] += v.bytes;
1713 vnet_interface_counter_unlock (im);
1715 rmp->total_pkts[VLIB_RX] = clib_host_to_net_u64 (total_pkts[VLIB_RX]);
1716 rmp->total_bytes[VLIB_RX] = clib_host_to_net_u64 (total_bytes[VLIB_RX]);
1717 rmp->total_pkts[VLIB_TX] = clib_host_to_net_u64 (total_pkts[VLIB_TX]);
1718 rmp->total_bytes[VLIB_TX] = clib_host_to_net_u64 (total_bytes[VLIB_TX]);
1720 clib_host_to_net_u64 (vlib_last_vector_length_per_node (sm->vlib_main));
1722 vl_msg_api_send_shmem (q, (u8 *) & rmp);
1726 typedef CLIB_PACKED (struct {
1727 ip4_address_t address;
1728 u32 address_length: 6;
1734 ip4_reset_fib_t_handler (vl_api_reset_fib_t * mp)
1736 vnet_main_t *vnm = vnet_get_main ();
1737 vnet_interface_main_t *im = &vnm->interface_main;
1738 ip4_main_t *im4 = &ip4_main;
1739 static u32 *sw_if_indices_to_shut;
1740 stats_main_t *sm = &stats_main;
1741 fib_table_t *fib_table;
1745 int rv = VNET_API_ERROR_NO_SUCH_FIB;
1746 u32 target_fib_id = ntohl (mp->vrf_id);
1748 dslock (sm, 1 /* release hint */ , 8 /* tag */ );
1751 pool_foreach (fib_table, im4->fibs,
1753 fib = &fib_table->v4;
1754 vnet_sw_interface_t * si;
1756 if (fib->table_id != target_fib_id)
1759 /* remove any mpls encap/decap labels */
1760 mpls_fib_reset_labels (fib->table_id);
1762 /* remove any proxy arps in this fib */
1763 vnet_proxy_arp_fib_reset (fib->table_id);
1765 /* Set the flow hash for this fib to the default */
1766 vnet_set_ip4_flow_hash (fib->table_id, IP_FLOW_HASH_DEFAULT);
1768 vec_reset_length (sw_if_indices_to_shut);
1770 /* Shut down interfaces in this FIB / clean out intfc routes */
1771 pool_foreach (si, im->sw_interfaces,
1773 u32 sw_if_index = si->sw_if_index;
1775 if (sw_if_index < vec_len (im4->fib_index_by_sw_if_index)
1776 && (im4->fib_index_by_sw_if_index[si->sw_if_index] ==
1778 vec_add1 (sw_if_indices_to_shut, si->sw_if_index);
1781 for (i = 0; i < vec_len (sw_if_indices_to_shut); i++) {
1782 sw_if_index = sw_if_indices_to_shut[i];
1783 // vec_foreach (sw_if_index, sw_if_indices_to_shut) {
1785 u32 flags = vnet_sw_interface_get_flags (vnm, sw_if_index);
1786 flags &= ~(VNET_SW_INTERFACE_FLAG_ADMIN_UP);
1787 vnet_sw_interface_set_flags (vnm, sw_if_index, flags);
1790 fib_table_flush(fib->index, FIB_PROTOCOL_IP4, FIB_SOURCE_API);
1791 fib_table_flush(fib->index, FIB_PROTOCOL_IP4, FIB_SOURCE_INTERFACE);
1795 })); /* pool_foreach (fib) */
1803 ip6_reset_fib_t_handler (vl_api_reset_fib_t * mp)
1805 vnet_main_t *vnm = vnet_get_main ();
1806 vnet_interface_main_t *im = &vnm->interface_main;
1807 ip6_main_t *im6 = &ip6_main;
1808 stats_main_t *sm = &stats_main;
1809 static u32 *sw_if_indices_to_shut;
1810 fib_table_t *fib_table;
1814 int rv = VNET_API_ERROR_NO_SUCH_FIB;
1815 u32 target_fib_id = ntohl (mp->vrf_id);
1817 dslock (sm, 1 /* release hint */ , 9 /* tag */ );
1820 pool_foreach (fib_table, im6->fibs,
1822 vnet_sw_interface_t * si;
1823 fib = &(fib_table->v6);
1825 if (fib->table_id != target_fib_id)
1828 vec_reset_length (sw_if_indices_to_shut);
1830 /* Shut down interfaces in this FIB / clean out intfc routes */
1831 pool_foreach (si, im->sw_interfaces,
1833 if (im6->fib_index_by_sw_if_index[si->sw_if_index] ==
1835 vec_add1 (sw_if_indices_to_shut, si->sw_if_index);
1838 for (i = 0; i < vec_len (sw_if_indices_to_shut); i++) {
1839 sw_if_index = sw_if_indices_to_shut[i];
1840 // vec_foreach (sw_if_index, sw_if_indices_to_shut) {
1842 u32 flags = vnet_sw_interface_get_flags (vnm, sw_if_index);
1843 flags &= ~(VNET_SW_INTERFACE_FLAG_ADMIN_UP);
1844 vnet_sw_interface_set_flags (vnm, sw_if_index, flags);
1847 fib_table_flush(fib->index, FIB_PROTOCOL_IP6, FIB_SOURCE_API);
1848 fib_table_flush(fib->index, FIB_PROTOCOL_IP6, FIB_SOURCE_INTERFACE);
1852 })); /* pool_foreach (fib) */
1860 vl_api_reset_fib_t_handler (vl_api_reset_fib_t * mp)
1863 vl_api_reset_fib_reply_t *rmp;
1866 rv = ip6_reset_fib_t_handler (mp);
1868 rv = ip4_reset_fib_t_handler (mp);
1870 REPLY_MACRO (VL_API_RESET_FIB_REPLY);
1875 dhcpv4_proxy_config (vl_api_dhcp_proxy_config_t * mp)
1877 vl_api_dhcp_proxy_config_reply_t *rmp;
1880 rv = dhcp_proxy_set_server ((ip4_address_t *) (&mp->dhcp_server),
1881 (ip4_address_t *) (&mp->dhcp_src_address),
1882 (u32) ntohl (mp->vrf_id),
1883 (int) mp->insert_circuit_id,
1884 (int) (mp->is_add == 0));
1886 REPLY_MACRO (VL_API_DHCP_PROXY_CONFIG_REPLY);
1891 dhcpv6_proxy_config (vl_api_dhcp_proxy_config_t * mp)
1893 vl_api_dhcp_proxy_config_reply_t *rmp;
1896 rv = dhcpv6_proxy_set_server ((ip6_address_t *) (&mp->dhcp_server),
1897 (ip6_address_t *) (&mp->dhcp_src_address),
1898 (u32) ntohl (mp->vrf_id),
1899 (int) mp->insert_circuit_id,
1900 (int) (mp->is_add == 0));
1902 REPLY_MACRO (VL_API_DHCP_PROXY_CONFIG_REPLY);
1906 dhcpv4_proxy_config_2 (vl_api_dhcp_proxy_config_2_t * mp)
1908 vl_api_dhcp_proxy_config_reply_t *rmp;
1911 rv = dhcp_proxy_set_server_2 ((ip4_address_t *) (&mp->dhcp_server),
1912 (ip4_address_t *) (&mp->dhcp_src_address),
1913 (u32) ntohl (mp->rx_vrf_id),
1914 (u32) ntohl (mp->server_vrf_id),
1915 (int) mp->insert_circuit_id,
1916 (int) (mp->is_add == 0));
1918 REPLY_MACRO (VL_API_DHCP_PROXY_CONFIG_2_REPLY);
1923 dhcpv6_proxy_config_2 (vl_api_dhcp_proxy_config_2_t * mp)
1925 vl_api_dhcp_proxy_config_reply_t *rmp;
1928 rv = dhcpv6_proxy_set_server_2 ((ip6_address_t *) (&mp->dhcp_server),
1929 (ip6_address_t *) (&mp->dhcp_src_address),
1930 (u32) ntohl (mp->rx_vrf_id),
1931 (u32) ntohl (mp->server_vrf_id),
1932 (int) mp->insert_circuit_id,
1933 (int) (mp->is_add == 0));
1935 REPLY_MACRO (VL_API_DHCP_PROXY_CONFIG_2_REPLY);
1940 vl_api_dhcp_proxy_set_vss_t_handler (vl_api_dhcp_proxy_set_vss_t * mp)
1942 vl_api_dhcp_proxy_set_vss_reply_t *rmp;
1945 rv = dhcp_proxy_set_option82_vss (ntohl (mp->tbl_id),
1948 (int) mp->is_add == 0);
1950 rv = dhcpv6_proxy_set_vss (ntohl (mp->tbl_id),
1952 ntohl (mp->fib_id), (int) mp->is_add == 0);
1954 REPLY_MACRO (VL_API_DHCP_PROXY_SET_VSS_REPLY);
1958 static void vl_api_dhcp_proxy_config_t_handler
1959 (vl_api_dhcp_proxy_config_t * mp)
1961 if (mp->is_ipv6 == 0)
1962 dhcpv4_proxy_config (mp);
1964 dhcpv6_proxy_config (mp);
1967 static void vl_api_dhcp_proxy_config_2_t_handler
1968 (vl_api_dhcp_proxy_config_2_t * mp)
1970 if (mp->is_ipv6 == 0)
1971 dhcpv4_proxy_config_2 (mp);
1973 dhcpv6_proxy_config_2 (mp);
1977 dhcp_compl_event_callback (u32 client_index, u32 pid, u8 * hostname,
1978 u8 is_ipv6, u8 * host_address, u8 * router_address,
1981 unix_shared_memory_queue_t *q;
1982 vl_api_dhcp_compl_event_t *mp;
1984 q = vl_api_client_index_to_input_queue (client_index);
1988 mp = vl_msg_api_alloc (sizeof (*mp));
1989 mp->client_index = client_index;
1991 mp->is_ipv6 = is_ipv6;
1992 clib_memcpy (&mp->hostname, hostname, vec_len (hostname));
1993 mp->hostname[vec_len (hostname) + 1] = '\n';
1994 clib_memcpy (&mp->host_address[0], host_address, 16);
1995 clib_memcpy (&mp->router_address[0], router_address, 16);
1997 if (NULL != host_mac)
1998 clib_memcpy (&mp->host_mac[0], host_mac, 6);
2000 mp->_vl_msg_id = ntohs (VL_API_DHCP_COMPL_EVENT);
2002 vl_msg_api_send_shmem (q, (u8 *) & mp);
2005 static void vl_api_dhcp_client_config_t_handler
2006 (vl_api_dhcp_client_config_t * mp)
2008 vlib_main_t *vm = vlib_get_main ();
2009 vl_api_dhcp_client_config_reply_t *rmp;
2012 VALIDATE_SW_IF_INDEX (mp);
2014 rv = dhcp_client_config (vm, ntohl (mp->sw_if_index),
2015 mp->hostname, mp->is_add, mp->client_index,
2016 mp->want_dhcp_event ? dhcp_compl_event_callback :
2019 BAD_SW_IF_INDEX_LABEL;
2021 REPLY_MACRO (VL_API_DHCP_CLIENT_CONFIG_REPLY);
2025 vl_api_create_loopback_t_handler (vl_api_create_loopback_t * mp)
2027 vl_api_create_loopback_reply_t *rmp;
2031 rv = vnet_create_loopback_interface (&sw_if_index, mp->mac_address);
2034 REPLY_MACRO2(VL_API_CREATE_LOOPBACK_REPLY,
2036 rmp->sw_if_index = ntohl (sw_if_index);
2042 vl_api_delete_loopback_t_handler (vl_api_delete_loopback_t * mp)
2044 vl_api_delete_loopback_reply_t *rmp;
2048 sw_if_index = ntohl (mp->sw_if_index);
2049 rv = vnet_delete_loopback_interface (sw_if_index);
2051 REPLY_MACRO (VL_API_DELETE_LOOPBACK_REPLY);
2055 vl_api_control_ping_t_handler (vl_api_control_ping_t * mp)
2057 vl_api_control_ping_reply_t *rmp;
2061 REPLY_MACRO2(VL_API_CONTROL_PING_REPLY,
2063 rmp->vpe_pid = ntohl (getpid());
2069 shmem_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
2071 u8 **shmem_vecp = (u8 **) arg;
2074 api_main_t *am = &api_main;
2077 shmem_vec = *shmem_vecp;
2079 offset = vec_len (shmem_vec);
2081 pthread_mutex_lock (&am->vlib_rp->mutex);
2082 oldheap = svm_push_data_heap (am->vlib_rp);
2084 vec_validate (shmem_vec, offset + buffer_bytes - 1);
2086 clib_memcpy (shmem_vec + offset, buffer, buffer_bytes);
2088 svm_pop_heap (oldheap);
2089 pthread_mutex_unlock (&am->vlib_rp->mutex);
2091 *shmem_vecp = shmem_vec;
2096 vl_api_cli_request_t_handler (vl_api_cli_request_t * mp)
2098 vl_api_cli_reply_t *rp;
2099 unix_shared_memory_queue_t *q;
2100 vlib_main_t *vm = vlib_get_main ();
2101 api_main_t *am = &api_main;
2102 unformat_input_t input;
2106 q = vl_api_client_index_to_input_queue (mp->client_index);
2110 rp = vl_msg_api_alloc (sizeof (*rp));
2111 rp->_vl_msg_id = ntohs (VL_API_CLI_REPLY);
2112 rp->context = mp->context;
2114 unformat_init_vector (&input, (u8 *) (uword) mp->cmd_in_shmem);
2116 vlib_cli_input (vm, &input, shmem_cli_output, (uword) & shmem_vec);
2118 pthread_mutex_lock (&am->vlib_rp->mutex);
2119 oldheap = svm_push_data_heap (am->vlib_rp);
2121 vec_add1 (shmem_vec, 0);
2123 svm_pop_heap (oldheap);
2124 pthread_mutex_unlock (&am->vlib_rp->mutex);
2126 rp->reply_in_shmem = (uword) shmem_vec;
2128 vl_msg_api_send_shmem (q, (u8 *) & rp);
2132 inband_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
2134 u8 **mem_vecp = (u8 **) arg;
2135 u8 *mem_vec = *mem_vecp;
2136 u32 offset = vec_len (mem_vec);
2138 vec_validate (mem_vec, offset + buffer_bytes - 1);
2139 clib_memcpy (mem_vec + offset, buffer, buffer_bytes);
2140 *mem_vecp = mem_vec;
2144 vl_api_cli_inband_t_handler (vl_api_cli_inband_t * mp)
2146 vl_api_cli_inband_reply_t *rmp;
2148 unix_shared_memory_queue_t *q;
2149 vlib_main_t *vm = vlib_get_main ();
2150 unformat_input_t input;
2153 q = vl_api_client_index_to_input_queue (mp->client_index);
2157 unformat_init_string (&input, (char *) mp->cmd, ntohl (mp->length));
2158 vlib_cli_input (vm, &input, inband_cli_output, (uword) & out_vec);
2160 u32 len = vec_len (out_vec);
2162 REPLY_MACRO3(VL_API_CLI_INBAND_REPLY, len,
2164 rmp->length = htonl (len);
2165 clib_memcpy (rmp->reply, out_vec, len);
2172 vl_api_set_arp_neighbor_limit_t_handler (vl_api_set_arp_neighbor_limit_t * mp)
2175 vl_api_set_arp_neighbor_limit_reply_t *rmp;
2176 vnet_main_t *vnm = vnet_get_main ();
2177 clib_error_t *error;
2182 error = ip6_set_neighbor_limit (ntohl (mp->arp_neighbor_limit));
2184 error = ip4_set_arp_limit (ntohl (mp->arp_neighbor_limit));
2188 clib_error_report (error);
2189 rv = VNET_API_ERROR_UNSPECIFIED;
2193 rv = vnm->api_errno;
2196 REPLY_MACRO (VL_API_SET_ARP_NEIGHBOR_LIMIT_REPLY);
2199 static void vl_api_sr_tunnel_add_del_t_handler
2200 (vl_api_sr_tunnel_add_del_t * mp)
2203 clib_warning ("unimplemented");
2205 ip6_sr_add_del_tunnel_args_t _a, *a = &_a;
2207 vl_api_sr_tunnel_add_del_reply_t *rmp;
2208 ip6_address_t *segments = 0, *seg;
2209 ip6_address_t *tags = 0, *tag;
2210 ip6_address_t *this_address;
2213 if (mp->n_segments == 0)
2219 memset (a, 0, sizeof (*a));
2220 a->src_address = (ip6_address_t *) & mp->src_address;
2221 a->dst_address = (ip6_address_t *) & mp->dst_address;
2222 a->dst_mask_width = mp->dst_mask_width;
2223 a->flags_net_byte_order = mp->flags_net_byte_order;
2224 a->is_del = (mp->is_add == 0);
2225 a->rx_table_id = ntohl (mp->outer_vrf_id);
2226 a->tx_table_id = ntohl (mp->inner_vrf_id);
2228 a->name = format (0, "%s", mp->name);
2229 if (!(vec_len (a->name)))
2232 a->policy_name = format (0, "%s", mp->policy_name);
2233 if (!(vec_len (a->policy_name)))
2236 /* Yank segments and tags out of the API message */
2237 this_address = (ip6_address_t *) mp->segs_and_tags;
2238 for (i = 0; i < mp->n_segments; i++)
2240 vec_add2 (segments, seg, 1);
2241 clib_memcpy (seg->as_u8, this_address->as_u8, sizeof (*this_address));
2244 for (i = 0; i < mp->n_tags; i++)
2246 vec_add2 (tags, tag, 1);
2247 clib_memcpy (tag->as_u8, this_address->as_u8, sizeof (*this_address));
2251 a->segments = segments;
2254 rv = ip6_sr_add_del_tunnel (a);
2258 REPLY_MACRO (VL_API_SR_TUNNEL_ADD_DEL_REPLY);
2262 static void vl_api_sr_policy_add_del_t_handler
2263 (vl_api_sr_policy_add_del_t * mp)
2266 clib_warning ("unimplemented");
2268 ip6_sr_add_del_policy_args_t _a, *a = &_a;
2270 vl_api_sr_policy_add_del_reply_t *rmp;
2273 memset (a, 0, sizeof (*a));
2274 a->is_del = (mp->is_add == 0);
2276 a->name = format (0, "%s", mp->name);
2277 if (!(vec_len (a->name)))
2279 rv = VNET_API_ERROR_NO_SUCH_NODE2;
2283 if (!(mp->tunnel_names[0]))
2285 rv = VNET_API_ERROR_NO_SUCH_NODE2;
2289 // start deserializing tunnel_names
2290 int num_tunnels = mp->tunnel_names[0]; //number of tunnels
2291 u8 *deser_tun_names = mp->tunnel_names;
2292 deser_tun_names += 1; //moving along
2295 int tun_name_len = 0;
2297 for (i = 0; i < num_tunnels; i++)
2299 tun_name_len = *deser_tun_names;
2300 deser_tun_names += 1;
2301 vec_resize (tun_name, tun_name_len);
2302 memcpy (tun_name, deser_tun_names, tun_name_len);
2303 vec_add1 (a->tunnel_names, tun_name);
2304 deser_tun_names += tun_name_len;
2308 rv = ip6_sr_add_del_policy (a);
2312 REPLY_MACRO (VL_API_SR_POLICY_ADD_DEL_REPLY);
2316 static void vl_api_sr_multicast_map_add_del_t_handler
2317 (vl_api_sr_multicast_map_add_del_t * mp)
2320 clib_warning ("unimplemented");
2322 ip6_sr_add_del_multicastmap_args_t _a, *a = &_a;
2324 vl_api_sr_multicast_map_add_del_reply_t *rmp;
2326 memset (a, 0, sizeof (*a));
2327 a->is_del = (mp->is_add == 0);
2329 a->multicast_address = (ip6_address_t *) & mp->multicast_address;
2330 a->policy_name = format (0, "%s", mp->policy_name);
2332 if (a->multicast_address == 0)
2338 if (!(a->policy_name))
2344 #if DPDK > 0 /* Cannot call replicate without DPDK */
2345 rv = ip6_sr_add_del_multicastmap (a);
2347 clib_warning ("multicast replication without DPDK not implemented");
2348 rv = VNET_API_ERROR_UNIMPLEMENTED;
2353 REPLY_MACRO (VL_API_SR_MULTICAST_MAP_ADD_DEL_REPLY);
2357 #define foreach_classify_add_del_table_field \
2362 _(match_n_vectors) \
2363 _(next_table_index) \
2364 _(miss_next_index) \
2365 _(current_data_flag) \
2366 _(current_data_offset)
2368 static void vl_api_classify_add_del_table_t_handler
2369 (vl_api_classify_add_del_table_t * mp)
2371 vl_api_classify_add_del_table_reply_t *rmp;
2372 vnet_classify_main_t *cm = &vnet_classify_main;
2373 vnet_classify_table_t *t;
2377 foreach_classify_add_del_table_field;
2380 #define _(a) a = ntohl(mp->a);
2381 foreach_classify_add_del_table_field;
2384 /* The underlying API fails silently, on purpose, so check here */
2385 if (mp->is_add == 0) /* delete */
2387 if (pool_is_free_index (cm->tables, table_index))
2389 rv = VNET_API_ERROR_NO_SUCH_TABLE;
2393 else /* add or update */
2395 if (table_index != ~0 && pool_is_free_index (cm->tables, table_index))
2399 rv = vnet_classify_add_del_table
2400 (cm, mp->mask, nbuckets, memory_size,
2401 skip_n_vectors, match_n_vectors,
2402 next_table_index, miss_next_index, &table_index,
2403 current_data_flag, current_data_offset, mp->is_add, mp->del_chain);
2407 REPLY_MACRO2(VL_API_CLASSIFY_ADD_DEL_TABLE_REPLY,
2409 if (rv == 0 && mp->is_add)
2411 t = pool_elt_at_index (cm->tables, table_index);
2412 rmp->skip_n_vectors = ntohl(t->skip_n_vectors);
2413 rmp->match_n_vectors = ntohl(t->match_n_vectors);
2414 rmp->new_table_index = ntohl(table_index);
2418 rmp->skip_n_vectors = ~0;
2419 rmp->match_n_vectors = ~0;
2420 rmp->new_table_index = ~0;
2426 static void vl_api_classify_add_del_session_t_handler
2427 (vl_api_classify_add_del_session_t * mp)
2429 vnet_classify_main_t *cm = &vnet_classify_main;
2430 vl_api_classify_add_del_session_reply_t *rmp;
2432 u32 table_index, hit_next_index, opaque_index, metadata;
2436 table_index = ntohl (mp->table_index);
2437 hit_next_index = ntohl (mp->hit_next_index);
2438 opaque_index = ntohl (mp->opaque_index);
2439 advance = ntohl (mp->advance);
2440 action = mp->action;
2441 metadata = ntohl (mp->metadata);
2443 rv = vnet_classify_add_del_session
2444 (cm, table_index, mp->match, hit_next_index, opaque_index,
2445 advance, action, metadata, mp->is_add);
2447 REPLY_MACRO (VL_API_CLASSIFY_ADD_DEL_SESSION_REPLY);
2450 static void vl_api_classify_set_interface_ip_table_t_handler
2451 (vl_api_classify_set_interface_ip_table_t * mp)
2453 vlib_main_t *vm = vlib_get_main ();
2454 vl_api_classify_set_interface_ip_table_reply_t *rmp;
2456 u32 table_index, sw_if_index;
2458 table_index = ntohl (mp->table_index);
2459 sw_if_index = ntohl (mp->sw_if_index);
2461 VALIDATE_SW_IF_INDEX (mp);
2464 rv = vnet_set_ip6_classify_intfc (vm, sw_if_index, table_index);
2466 rv = vnet_set_ip4_classify_intfc (vm, sw_if_index, table_index);
2468 BAD_SW_IF_INDEX_LABEL;
2470 REPLY_MACRO (VL_API_CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY);
2473 static void vl_api_classify_set_interface_l2_tables_t_handler
2474 (vl_api_classify_set_interface_l2_tables_t * mp)
2476 vl_api_classify_set_interface_l2_tables_reply_t *rmp;
2478 u32 sw_if_index, ip4_table_index, ip6_table_index, other_table_index;
2481 ip4_table_index = ntohl (mp->ip4_table_index);
2482 ip6_table_index = ntohl (mp->ip6_table_index);
2483 other_table_index = ntohl (mp->other_table_index);
2484 sw_if_index = ntohl (mp->sw_if_index);
2486 VALIDATE_SW_IF_INDEX (mp);
2489 rv = vnet_l2_input_classify_set_tables (sw_if_index, ip4_table_index,
2493 rv = vnet_l2_output_classify_set_tables (sw_if_index, ip4_table_index,
2499 if (ip4_table_index != ~0 || ip6_table_index != ~0
2500 || other_table_index != ~0)
2506 vnet_l2_input_classify_enable_disable (sw_if_index, enable);
2508 vnet_l2_output_classify_enable_disable (sw_if_index, enable);
2511 BAD_SW_IF_INDEX_LABEL;
2513 REPLY_MACRO (VL_API_CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY);
2517 vl_api_l2_fib_clear_table_t_handler (vl_api_l2_fib_clear_table_t * mp)
2520 vl_api_l2_fib_clear_table_reply_t *rmp;
2522 /* DAW-FIXME: This API should only clear non-static l2fib entries, but
2523 * that is not currently implemented. When that TODO is fixed
2524 * this call should be changed to pass 1 instead of 0.
2526 l2fib_clear_table (0);
2528 REPLY_MACRO (VL_API_L2_FIB_CLEAR_TABLE_REPLY);
2531 extern void l2_efp_filter_configure (vnet_main_t * vnet_main,
2532 u32 sw_if_index, u32 enable);
2535 vl_api_l2_interface_efp_filter_t_handler (vl_api_l2_interface_efp_filter_t *
2539 vl_api_l2_interface_efp_filter_reply_t *rmp;
2540 vnet_main_t *vnm = vnet_get_main ();
2542 // enable/disable the feature
2543 l2_efp_filter_configure (vnm, mp->sw_if_index, mp->enable_disable);
2544 rv = vnm->api_errno;
2546 REPLY_MACRO (VL_API_L2_INTERFACE_EFP_FILTER_REPLY);
2550 vl_api_l2_interface_vlan_tag_rewrite_t_handler
2551 (vl_api_l2_interface_vlan_tag_rewrite_t * mp)
2554 vl_api_l2_interface_vlan_tag_rewrite_reply_t *rmp;
2555 vnet_main_t *vnm = vnet_get_main ();
2556 vlib_main_t *vm = vlib_get_main ();
2559 VALIDATE_SW_IF_INDEX (mp);
2561 vtr_op = ntohl (mp->vtr_op);
2563 /* The L2 code is unsuspicious */
2566 case L2_VTR_DISABLED:
2571 case L2_VTR_TRANSLATE_1_1:
2572 case L2_VTR_TRANSLATE_1_2:
2573 case L2_VTR_TRANSLATE_2_1:
2574 case L2_VTR_TRANSLATE_2_2:
2578 rv = VNET_API_ERROR_INVALID_VALUE;
2579 goto bad_sw_if_index;
2582 rv = l2vtr_configure (vm, vnm, ntohl (mp->sw_if_index), vtr_op,
2583 ntohl (mp->push_dot1q), ntohl (mp->tag1),
2586 BAD_SW_IF_INDEX_LABEL;
2588 REPLY_MACRO (VL_API_L2_INTERFACE_VLAN_TAG_REWRITE_REPLY);
2592 vl_api_create_vhost_user_if_t_handler (vl_api_create_vhost_user_if_t * mp)
2595 vl_api_create_vhost_user_if_reply_t *rmp;
2596 u32 sw_if_index = (u32) ~ 0;
2597 vnet_main_t *vnm = vnet_get_main ();
2598 vlib_main_t *vm = vlib_get_main ();
2600 rv = vhost_user_create_if (vnm, vm, (char *) mp->sock_filename,
2601 mp->is_server, &sw_if_index, (u64) ~ 0,
2602 mp->renumber, ntohl (mp->custom_dev_instance),
2603 (mp->use_custom_mac) ? mp->mac_address : NULL);
2605 /* Remember an interface tag for the new interface */
2608 /* If a tag was supplied... */
2611 /* Make sure it's a proper C-string */
2612 mp->tag[ARRAY_LEN (mp->tag) - 1] = 0;
2613 u8 *tag = format (0, "%s%c", mp->tag, 0);
2614 vnet_set_sw_interface_tag (vnm, tag, sw_if_index);
2619 REPLY_MACRO2(VL_API_CREATE_VHOST_USER_IF_REPLY,
2621 rmp->sw_if_index = ntohl (sw_if_index);
2627 vl_api_modify_vhost_user_if_t_handler (vl_api_modify_vhost_user_if_t * mp)
2630 vl_api_modify_vhost_user_if_reply_t *rmp;
2631 u32 sw_if_index = ntohl (mp->sw_if_index);
2633 vnet_main_t *vnm = vnet_get_main ();
2634 vlib_main_t *vm = vlib_get_main ();
2636 rv = vhost_user_modify_if (vnm, vm, (char *) mp->sock_filename,
2637 mp->is_server, sw_if_index, (u64) ~ 0,
2638 mp->renumber, ntohl (mp->custom_dev_instance));
2640 REPLY_MACRO (VL_API_MODIFY_VHOST_USER_IF_REPLY);
2644 vl_api_delete_vhost_user_if_t_handler (vl_api_delete_vhost_user_if_t * mp)
2647 vl_api_delete_vhost_user_if_reply_t *rmp;
2648 vpe_api_main_t *vam = &vpe_api_main;
2649 u32 sw_if_index = ntohl (mp->sw_if_index);
2651 vnet_main_t *vnm = vnet_get_main ();
2652 vlib_main_t *vm = vlib_get_main ();
2654 rv = vhost_user_delete_if (vnm, vm, sw_if_index);
2656 REPLY_MACRO (VL_API_DELETE_VHOST_USER_IF_REPLY);
2659 unix_shared_memory_queue_t *q =
2660 vl_api_client_index_to_input_queue (mp->client_index);
2664 vnet_clear_sw_interface_tag (vnm, sw_if_index);
2665 send_sw_interface_flags_deleted (vam, q, sw_if_index);
2670 vl_api_sw_interface_vhost_user_details_t_handler
2671 (vl_api_sw_interface_vhost_user_details_t * mp)
2673 clib_warning ("BUG");
2677 send_sw_interface_vhost_user_details (vpe_api_main_t * am,
2678 unix_shared_memory_queue_t * q,
2679 vhost_user_intf_details_t * vui,
2682 vl_api_sw_interface_vhost_user_details_t *mp;
2684 mp = vl_msg_api_alloc (sizeof (*mp));
2685 memset (mp, 0, sizeof (*mp));
2686 mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_VHOST_USER_DETAILS);
2687 mp->sw_if_index = ntohl (vui->sw_if_index);
2688 mp->virtio_net_hdr_sz = ntohl (vui->virtio_net_hdr_sz);
2689 mp->features = clib_net_to_host_u64 (vui->features);
2690 mp->is_server = vui->is_server;
2691 mp->num_regions = ntohl (vui->num_regions);
2692 mp->sock_errno = ntohl (vui->sock_errno);
2693 mp->context = context;
2695 strncpy ((char *) mp->sock_filename,
2696 (char *) vui->sock_filename, ARRAY_LEN (mp->sock_filename) - 1);
2697 strncpy ((char *) mp->interface_name,
2698 (char *) vui->if_name, ARRAY_LEN (mp->interface_name) - 1);
2700 vl_msg_api_send_shmem (q, (u8 *) & mp);
2704 vl_api_sw_interface_vhost_user_dump_t_handler
2705 (vl_api_sw_interface_vhost_user_dump_t * mp)
2708 vpe_api_main_t *am = &vpe_api_main;
2709 vnet_main_t *vnm = vnet_get_main ();
2710 vlib_main_t *vm = vlib_get_main ();
2711 vhost_user_intf_details_t *ifaces = NULL;
2712 vhost_user_intf_details_t *vuid = NULL;
2713 unix_shared_memory_queue_t *q;
2715 q = vl_api_client_index_to_input_queue (mp->client_index);
2719 rv = vhost_user_dump_ifs (vnm, vm, &ifaces);
2723 vec_foreach (vuid, ifaces)
2725 send_sw_interface_vhost_user_details (am, q, vuid, mp->context);
2731 send_sw_if_l2tpv3_tunnel_details (vpe_api_main_t * am,
2732 unix_shared_memory_queue_t * q,
2734 l2t_main_t * lm, u32 context)
2736 vl_api_sw_if_l2tpv3_tunnel_details_t *mp;
2738 vnet_sw_interface_t *si = NULL;
2740 si = vnet_get_hw_sw_interface (lm->vnet_main, s->hw_if_index);
2742 if_name = format (if_name, "%U",
2743 format_vnet_sw_interface_name, lm->vnet_main, si);
2745 mp = vl_msg_api_alloc (sizeof (*mp));
2746 memset (mp, 0, sizeof (*mp));
2747 mp->_vl_msg_id = ntohs (VL_API_SW_IF_L2TPV3_TUNNEL_DETAILS);
2748 strncpy ((char *) mp->interface_name,
2749 (char *) if_name, ARRAY_LEN (mp->interface_name) - 1);
2750 mp->sw_if_index = ntohl (si->sw_if_index);
2751 mp->local_session_id = s->local_session_id;
2752 mp->remote_session_id = s->remote_session_id;
2753 mp->local_cookie[0] = s->local_cookie[0];
2754 mp->local_cookie[1] = s->local_cookie[1];
2755 mp->remote_cookie = s->remote_cookie;
2756 clib_memcpy (mp->client_address, &s->client_address,
2757 sizeof (s->client_address));
2758 clib_memcpy (mp->our_address, &s->our_address, sizeof (s->our_address));
2759 mp->l2_sublayer_present = s->l2_sublayer_present;
2760 mp->context = context;
2762 vl_msg_api_send_shmem (q, (u8 *) & mp);
2767 vl_api_sw_if_l2tpv3_tunnel_dump_t_handler (vl_api_sw_if_l2tpv3_tunnel_dump_t *
2770 vpe_api_main_t *am = &vpe_api_main;
2771 l2t_main_t *lm = &l2t_main;
2772 unix_shared_memory_queue_t *q;
2773 l2t_session_t *session;
2775 q = vl_api_client_index_to_input_queue (mp->client_index);
2780 pool_foreach (session, lm->sessions,
2782 send_sw_if_l2tpv3_tunnel_details (am, q, session, lm, mp->context);
2788 vl_api_l2_fib_table_entry_t_handler (vl_api_l2_fib_table_entry_t * mp)
2790 clib_warning ("BUG");
2794 send_l2fib_table_entry (vpe_api_main_t * am,
2795 unix_shared_memory_queue_t * q,
2796 l2fib_entry_key_t * l2fe_key,
2797 l2fib_entry_result_t * l2fe_res, u32 context)
2799 vl_api_l2_fib_table_entry_t *mp;
2801 mp = vl_msg_api_alloc (sizeof (*mp));
2802 memset (mp, 0, sizeof (*mp));
2803 mp->_vl_msg_id = ntohs (VL_API_L2_FIB_TABLE_ENTRY);
2806 ntohl (l2input_main.bd_configs[l2fe_key->fields.bd_index].bd_id);
2808 mp->mac = l2fib_make_key (l2fe_key->fields.mac, 0);
2809 mp->sw_if_index = ntohl (l2fe_res->fields.sw_if_index);
2810 mp->static_mac = l2fe_res->fields.static_mac;
2811 mp->filter_mac = l2fe_res->fields.filter;
2812 mp->bvi_mac = l2fe_res->fields.bvi;
2813 mp->context = context;
2815 vl_msg_api_send_shmem (q, (u8 *) & mp);
2819 vl_api_l2_fib_table_dump_t_handler (vl_api_l2_fib_table_dump_t * mp)
2821 vpe_api_main_t *am = &vpe_api_main;
2822 bd_main_t *bdm = &bd_main;
2823 l2fib_entry_key_t *l2fe_key = NULL;
2824 l2fib_entry_result_t *l2fe_res = NULL;
2825 u32 ni, bd_id = ntohl (mp->bd_id);
2827 unix_shared_memory_queue_t *q;
2830 q = vl_api_client_index_to_input_queue (mp->client_index);
2834 /* see l2fib_table_dump: ~0 means "any" */
2839 p = hash_get (bdm->bd_index_by_bd_id, bd_id);
2846 l2fib_table_dump (bd_index, &l2fe_key, &l2fe_res);
2848 vec_foreach_index (ni, l2fe_key)
2850 send_l2fib_table_entry (am, q, vec_elt_at_index (l2fe_key, ni),
2851 vec_elt_at_index (l2fe_res, ni), mp->context);
2853 vec_free (l2fe_key);
2854 vec_free (l2fe_res);
2858 vl_api_show_version_t_handler (vl_api_show_version_t * mp)
2860 vl_api_show_version_reply_t *rmp;
2862 char *vpe_api_get_build_directory (void);
2863 char *vpe_api_get_version (void);
2864 char *vpe_api_get_build_date (void);
2866 unix_shared_memory_queue_t *q =
2867 vl_api_client_index_to_input_queue (mp->client_index);
2873 REPLY_MACRO2(VL_API_SHOW_VERSION_REPLY,
2875 strncpy ((char *) rmp->program, "vpe", ARRAY_LEN(rmp->program)-1);
2876 strncpy ((char *) rmp->build_directory, vpe_api_get_build_directory(),
2877 ARRAY_LEN(rmp->build_directory)-1);
2878 strncpy ((char *) rmp->version, vpe_api_get_version(),
2879 ARRAY_LEN(rmp->version)-1);
2880 strncpy ((char *) rmp->build_date, vpe_api_get_build_date(),
2881 ARRAY_LEN(rmp->build_date)-1);
2887 vl_api_get_node_index_t_handler (vl_api_get_node_index_t * mp)
2889 vlib_main_t *vm = vlib_get_main ();
2890 vl_api_get_node_index_reply_t *rmp;
2893 u32 node_index = ~0;
2895 n = vlib_get_node_by_name (vm, mp->node_name);
2898 rv = VNET_API_ERROR_NO_SUCH_NODE;
2900 node_index = n->index;
2903 REPLY_MACRO2(VL_API_GET_NODE_INDEX_REPLY,
2905 rmp->node_index = ntohl(node_index);
2911 vl_api_get_next_index_t_handler (vl_api_get_next_index_t * mp)
2913 vlib_main_t *vm = vlib_get_main ();
2914 vl_api_get_next_index_reply_t *rmp;
2915 vlib_node_t *node, *next_node;
2917 u32 next_node_index = ~0, next_index = ~0;
2920 node = vlib_get_node_by_name (vm, mp->node_name);
2924 rv = VNET_API_ERROR_NO_SUCH_NODE;
2928 next_node = vlib_get_node_by_name (vm, mp->next_name);
2932 rv = VNET_API_ERROR_NO_SUCH_NODE2;
2936 next_node_index = next_node->index;
2938 p = hash_get (node->next_slot_by_node, next_node_index);
2942 rv = VNET_API_ERROR_NO_SUCH_ENTRY;
2950 REPLY_MACRO2(VL_API_GET_NEXT_INDEX_REPLY,
2952 rmp->next_index = ntohl(next_index);
2958 vl_api_add_node_next_t_handler (vl_api_add_node_next_t * mp)
2960 vlib_main_t *vm = vlib_get_main ();
2961 vl_api_add_node_next_reply_t *rmp;
2962 vlib_node_t *n, *next;
2964 u32 next_index = ~0;
2966 n = vlib_get_node_by_name (vm, mp->node_name);
2970 rv = VNET_API_ERROR_NO_SUCH_NODE;
2974 next = vlib_get_node_by_name (vm, mp->next_name);
2977 rv = VNET_API_ERROR_NO_SUCH_NODE2;
2979 next_index = vlib_node_add_next (vm, n->index, next->index);
2983 REPLY_MACRO2(VL_API_GET_NODE_INDEX_REPLY,
2985 rmp->next_index = ntohl(next_index);
2990 static void vl_api_l2tpv3_create_tunnel_t_handler
2991 (vl_api_l2tpv3_create_tunnel_t * mp)
2993 vl_api_l2tpv3_create_tunnel_reply_t *rmp;
2994 l2t_main_t *lm = &l2t_main;
2995 u32 sw_if_index = (u32) ~ 0;
2998 if (mp->is_ipv6 != 1)
3000 rv = VNET_API_ERROR_UNIMPLEMENTED;
3004 u32 encap_fib_index;
3006 if (mp->encap_vrf_id != ~0)
3009 ip6_main_t *im = &ip6_main;
3012 hash_get (im->fib_index_by_table_id, ntohl (mp->encap_vrf_id))))
3014 rv = VNET_API_ERROR_NO_SUCH_FIB;
3017 encap_fib_index = p[0];
3021 encap_fib_index = ~0;
3024 rv = create_l2tpv3_ipv6_tunnel (lm,
3025 (ip6_address_t *) mp->client_address,
3026 (ip6_address_t *) mp->our_address,
3027 ntohl (mp->local_session_id),
3028 ntohl (mp->remote_session_id),
3029 clib_net_to_host_u64 (mp->local_cookie),
3030 clib_net_to_host_u64 (mp->remote_cookie),
3031 mp->l2_sublayer_present,
3032 encap_fib_index, &sw_if_index);
3036 REPLY_MACRO2(VL_API_L2TPV3_CREATE_TUNNEL_REPLY,
3038 rmp->sw_if_index = ntohl (sw_if_index);
3043 static void vl_api_l2tpv3_set_tunnel_cookies_t_handler
3044 (vl_api_l2tpv3_set_tunnel_cookies_t * mp)
3046 vl_api_l2tpv3_set_tunnel_cookies_reply_t *rmp;
3047 l2t_main_t *lm = &l2t_main;
3050 VALIDATE_SW_IF_INDEX (mp);
3052 rv = l2tpv3_set_tunnel_cookies (lm, ntohl (mp->sw_if_index),
3053 clib_net_to_host_u64 (mp->new_local_cookie),
3054 clib_net_to_host_u64
3055 (mp->new_remote_cookie));
3057 BAD_SW_IF_INDEX_LABEL;
3059 REPLY_MACRO (VL_API_L2TPV3_SET_TUNNEL_COOKIES_REPLY);
3062 static void vl_api_l2tpv3_interface_enable_disable_t_handler
3063 (vl_api_l2tpv3_interface_enable_disable_t * mp)
3066 vnet_main_t *vnm = vnet_get_main ();
3067 vl_api_l2tpv3_interface_enable_disable_reply_t *rmp;
3069 VALIDATE_SW_IF_INDEX (mp);
3071 rv = l2tpv3_interface_enable_disable
3072 (vnm, ntohl (mp->sw_if_index), mp->enable_disable);
3074 BAD_SW_IF_INDEX_LABEL;
3076 REPLY_MACRO (VL_API_L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY);
3079 static void vl_api_l2tpv3_set_lookup_key_t_handler
3080 (vl_api_l2tpv3_set_lookup_key_t * mp)
3083 l2t_main_t *lm = &l2t_main;
3084 vl_api_l2tpv3_set_lookup_key_reply_t *rmp;
3086 if (mp->key > L2T_LOOKUP_SESSION_ID)
3088 rv = VNET_API_ERROR_INVALID_VALUE;
3092 lm->lookup_type = mp->key;
3095 REPLY_MACRO (VL_API_L2TPV3_SET_LOOKUP_KEY_REPLY);
3098 static void vl_api_vxlan_add_del_tunnel_t_handler
3099 (vl_api_vxlan_add_del_tunnel_t * mp)
3101 vl_api_vxlan_add_del_tunnel_reply_t *rmp;
3103 vnet_vxlan_add_del_tunnel_args_t _a, *a = &_a;
3104 u32 encap_fib_index;
3106 ip4_main_t *im = &ip4_main;
3107 vnet_main_t *vnm = vnet_get_main ();
3108 u32 sw_if_index = ~0;
3110 p = hash_get (im->fib_index_by_table_id, ntohl (mp->encap_vrf_id));
3113 rv = VNET_API_ERROR_NO_SUCH_FIB;
3116 encap_fib_index = p[0];
3117 memset (a, 0, sizeof (*a));
3119 a->is_add = mp->is_add;
3120 a->is_ip6 = mp->is_ipv6;
3122 /* ip addresses sent in network byte order */
3123 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &a->dst);
3124 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &a->src);
3126 /* Check src & dst are different */
3127 if (ip46_address_cmp (&a->dst, &a->src) == 0)
3129 rv = VNET_API_ERROR_SAME_SRC_DST;
3132 a->mcast_sw_if_index = ntohl (mp->mcast_sw_if_index);
3133 if (ip46_address_is_multicast (&a->dst) &&
3134 pool_is_free_index (vnm->interface_main.sw_interfaces,
3135 a->mcast_sw_if_index))
3137 rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
3140 a->encap_fib_index = encap_fib_index;
3141 a->decap_next_index = ntohl (mp->decap_next_index);
3142 a->vni = ntohl (mp->vni);
3143 rv = vnet_vxlan_add_del_tunnel (a, &sw_if_index);
3147 REPLY_MACRO2(VL_API_VXLAN_ADD_DEL_TUNNEL_REPLY,
3149 rmp->sw_if_index = ntohl (sw_if_index);
3154 static void send_vxlan_tunnel_details
3155 (vxlan_tunnel_t * t, unix_shared_memory_queue_t * q, u32 context)
3157 vl_api_vxlan_tunnel_details_t *rmp;
3158 ip4_main_t *im4 = &ip4_main;
3159 ip6_main_t *im6 = &ip6_main;
3160 u8 is_ipv6 = !ip46_address_is_ip4 (&t->dst);
3162 rmp = vl_msg_api_alloc (sizeof (*rmp));
3163 memset (rmp, 0, sizeof (*rmp));
3164 rmp->_vl_msg_id = ntohs (VL_API_VXLAN_TUNNEL_DETAILS);
3167 memcpy (rmp->src_address, t->src.ip6.as_u8, 16);
3168 memcpy (rmp->dst_address, t->dst.ip6.as_u8, 16);
3169 rmp->encap_vrf_id = htonl (im6->fibs[t->encap_fib_index].ft_table_id);
3173 memcpy (rmp->src_address, t->src.ip4.as_u8, 4);
3174 memcpy (rmp->dst_address, t->dst.ip4.as_u8, 4);
3175 rmp->encap_vrf_id = htonl (im4->fibs[t->encap_fib_index].ft_table_id);
3177 rmp->mcast_sw_if_index = htonl (t->mcast_sw_if_index);
3178 rmp->vni = htonl (t->vni);
3179 rmp->decap_next_index = htonl (t->decap_next_index);
3180 rmp->sw_if_index = htonl (t->sw_if_index);
3181 rmp->is_ipv6 = is_ipv6;
3182 rmp->context = context;
3184 vl_msg_api_send_shmem (q, (u8 *) & rmp);
3187 static void vl_api_vxlan_tunnel_dump_t_handler
3188 (vl_api_vxlan_tunnel_dump_t * mp)
3190 unix_shared_memory_queue_t *q;
3191 vxlan_main_t *vxm = &vxlan_main;
3195 q = vl_api_client_index_to_input_queue (mp->client_index);
3201 sw_if_index = ntohl (mp->sw_if_index);
3203 if (~0 == sw_if_index)
3206 pool_foreach (t, vxm->tunnels,
3208 send_vxlan_tunnel_details(t, q, mp->context);
3214 if ((sw_if_index >= vec_len (vxm->tunnel_index_by_sw_if_index)) ||
3215 (~0 == vxm->tunnel_index_by_sw_if_index[sw_if_index]))
3219 t = &vxm->tunnels[vxm->tunnel_index_by_sw_if_index[sw_if_index]];
3220 send_vxlan_tunnel_details (t, q, mp->context);
3224 static void vl_api_gre_add_del_tunnel_t_handler
3225 (vl_api_gre_add_del_tunnel_t * mp)
3227 vl_api_gre_add_del_tunnel_reply_t *rmp;
3229 vnet_gre_add_del_tunnel_args_t _a, *a = &_a;
3232 ip4_main_t *im = &ip4_main;
3233 u32 sw_if_index = ~0;
3235 p = hash_get (im->fib_index_by_table_id, ntohl (mp->outer_fib_id));
3238 rv = VNET_API_ERROR_NO_SUCH_FIB;
3241 outer_fib_id = p[0];
3243 /* Check src & dst are different */
3244 if ((mp->is_ipv6 && memcmp (mp->src_address, mp->dst_address, 16) == 0) ||
3245 (!mp->is_ipv6 && memcmp (mp->src_address, mp->dst_address, 4) == 0))
3247 rv = VNET_API_ERROR_SAME_SRC_DST;
3250 memset (a, 0, sizeof (*a));
3252 a->is_add = mp->is_add;
3255 /* ip addresses sent in network byte order */
3256 clib_memcpy (&(a->src), mp->src_address, 4);
3257 clib_memcpy (&(a->dst), mp->dst_address, 4);
3259 a->outer_fib_id = outer_fib_id;
3260 rv = vnet_gre_add_del_tunnel (a, &sw_if_index);
3264 REPLY_MACRO2(VL_API_GRE_ADD_DEL_TUNNEL_REPLY,
3266 rmp->sw_if_index = ntohl (sw_if_index);
3271 static void send_gre_tunnel_details
3272 (gre_tunnel_t * t, unix_shared_memory_queue_t * q, u32 context)
3274 vl_api_gre_tunnel_details_t *rmp;
3275 ip4_main_t *im = &ip4_main;
3277 rmp = vl_msg_api_alloc (sizeof (*rmp));
3278 memset (rmp, 0, sizeof (*rmp));
3279 rmp->_vl_msg_id = ntohs (VL_API_GRE_TUNNEL_DETAILS);
3280 clib_memcpy (rmp->src_address, &(t->tunnel_src), 4);
3281 clib_memcpy (rmp->dst_address, &(t->tunnel_dst), 4);
3282 rmp->outer_fib_id = htonl (im->fibs[t->outer_fib_index].ft_table_id);
3283 rmp->teb = (GRE_TUNNEL_TYPE_TEB == t->type);
3284 rmp->sw_if_index = htonl (t->sw_if_index);
3285 rmp->context = context;
3287 vl_msg_api_send_shmem (q, (u8 *) & rmp);
3291 vl_api_gre_tunnel_dump_t_handler (vl_api_gre_tunnel_dump_t * mp)
3293 unix_shared_memory_queue_t *q;
3294 gre_main_t *gm = &gre_main;
3298 q = vl_api_client_index_to_input_queue (mp->client_index);
3304 sw_if_index = ntohl (mp->sw_if_index);
3306 if (~0 == sw_if_index)
3309 pool_foreach (t, gm->tunnels,
3311 send_gre_tunnel_details(t, q, mp->context);
3317 if ((sw_if_index >= vec_len (gm->tunnel_index_by_sw_if_index)) ||
3318 (~0 == gm->tunnel_index_by_sw_if_index[sw_if_index]))
3322 t = &gm->tunnels[gm->tunnel_index_by_sw_if_index[sw_if_index]];
3323 send_gre_tunnel_details (t, q, mp->context);
3328 vl_api_l2_patch_add_del_t_handler (vl_api_l2_patch_add_del_t * mp)
3330 extern int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index,
3332 vl_api_l2_patch_add_del_reply_t *rmp;
3333 int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index,
3337 VALIDATE_RX_SW_IF_INDEX (mp);
3338 VALIDATE_TX_SW_IF_INDEX (mp);
3340 rv = vnet_l2_patch_add_del (ntohl (mp->rx_sw_if_index),
3341 ntohl (mp->tx_sw_if_index),
3342 (int) (mp->is_add != 0));
3344 BAD_RX_SW_IF_INDEX_LABEL;
3345 BAD_TX_SW_IF_INDEX_LABEL;
3347 REPLY_MACRO (VL_API_L2_PATCH_ADD_DEL_REPLY);
3351 vl_api_vxlan_gpe_add_del_tunnel_t_handler
3352 (vl_api_vxlan_gpe_add_del_tunnel_t * mp)
3354 vl_api_vxlan_gpe_add_del_tunnel_reply_t *rmp;
3356 vnet_vxlan_gpe_add_del_tunnel_args_t _a, *a = &_a;
3357 u32 encap_fib_index, decap_fib_index;
3360 ip4_main_t *im = &ip4_main;
3361 u32 sw_if_index = ~0;
3364 p = hash_get (im->fib_index_by_table_id, ntohl (mp->encap_vrf_id));
3367 rv = VNET_API_ERROR_NO_SUCH_FIB;
3370 encap_fib_index = p[0];
3372 protocol = mp->protocol;
3374 /* Interpret decap_vrf_id as an opaque if sending to other-than-ip4-input */
3375 if (protocol == VXLAN_GPE_INPUT_NEXT_IP4_INPUT)
3377 p = hash_get (im->fib_index_by_table_id, ntohl (mp->decap_vrf_id));
3380 rv = VNET_API_ERROR_NO_SUCH_INNER_FIB;
3383 decap_fib_index = p[0];
3387 decap_fib_index = ntohl (mp->decap_vrf_id);
3390 /* Check src & dst are different */
3391 if ((mp->is_ipv6 && memcmp (mp->local, mp->remote, 16) == 0) ||
3392 (!mp->is_ipv6 && memcmp (mp->local, mp->remote, 4) == 0))
3394 rv = VNET_API_ERROR_SAME_SRC_DST;
3397 memset (a, 0, sizeof (*a));
3399 a->is_add = mp->is_add;
3400 a->is_ip6 = mp->is_ipv6;
3401 /* ip addresses sent in network byte order */
3404 clib_memcpy (&(a->local.ip6), mp->local, 16);
3405 clib_memcpy (&(a->remote.ip6), mp->remote, 16);
3409 clib_memcpy (&(a->local.ip4), mp->local, 4);
3410 clib_memcpy (&(a->remote.ip4), mp->remote, 4);
3412 a->encap_fib_index = encap_fib_index;
3413 a->decap_fib_index = decap_fib_index;
3414 a->protocol = protocol;
3415 a->vni = ntohl (mp->vni);
3416 rv = vnet_vxlan_gpe_add_del_tunnel (a, &sw_if_index);
3420 REPLY_MACRO2(VL_API_VXLAN_GPE_ADD_DEL_TUNNEL_REPLY,
3422 rmp->sw_if_index = ntohl (sw_if_index);
3427 static void send_vxlan_gpe_tunnel_details
3428 (vxlan_gpe_tunnel_t * t, unix_shared_memory_queue_t * q, u32 context)
3430 vl_api_vxlan_gpe_tunnel_details_t *rmp;
3431 ip4_main_t *im4 = &ip4_main;
3432 ip6_main_t *im6 = &ip6_main;
3433 u8 is_ipv6 = !(t->flags & VXLAN_GPE_TUNNEL_IS_IPV4);
3435 rmp = vl_msg_api_alloc (sizeof (*rmp));
3436 memset (rmp, 0, sizeof (*rmp));
3437 rmp->_vl_msg_id = ntohs (VL_API_VXLAN_GPE_TUNNEL_DETAILS);
3440 memcpy (rmp->local, &(t->local.ip6), 16);
3441 memcpy (rmp->remote, &(t->remote.ip6), 16);
3442 rmp->encap_vrf_id = htonl (im6->fibs[t->encap_fib_index].ft_table_id);
3443 rmp->decap_vrf_id = htonl (im6->fibs[t->decap_fib_index].ft_table_id);
3447 memcpy (rmp->local, &(t->local.ip4), 4);
3448 memcpy (rmp->remote, &(t->remote.ip4), 4);
3449 rmp->encap_vrf_id = htonl (im4->fibs[t->encap_fib_index].ft_table_id);
3450 rmp->decap_vrf_id = htonl (im4->fibs[t->decap_fib_index].ft_table_id);
3452 rmp->vni = htonl (t->vni);
3453 rmp->protocol = t->protocol;
3454 rmp->sw_if_index = htonl (t->sw_if_index);
3455 rmp->is_ipv6 = is_ipv6;
3456 rmp->context = context;
3458 vl_msg_api_send_shmem (q, (u8 *) & rmp);
3461 static void vl_api_vxlan_gpe_tunnel_dump_t_handler
3462 (vl_api_vxlan_gpe_tunnel_dump_t * mp)
3464 unix_shared_memory_queue_t *q;
3465 vxlan_gpe_main_t *vgm = &vxlan_gpe_main;
3466 vxlan_gpe_tunnel_t *t;
3469 q = vl_api_client_index_to_input_queue (mp->client_index);
3475 sw_if_index = ntohl (mp->sw_if_index);
3477 if (~0 == sw_if_index)
3480 pool_foreach (t, vgm->tunnels,
3482 send_vxlan_gpe_tunnel_details(t, q, mp->context);
3488 if ((sw_if_index >= vec_len (vgm->tunnel_index_by_sw_if_index)) ||
3489 (~0 == vgm->tunnel_index_by_sw_if_index[sw_if_index]))
3493 t = &vgm->tunnels[vgm->tunnel_index_by_sw_if_index[sw_if_index]];
3494 send_vxlan_gpe_tunnel_details (t, q, mp->context);
3498 /** Used for transferring locators via VPP API */
3500 typedef CLIB_PACKED (struct {
3501 u32 sw_if_index; /**< locator sw_if_index */
3502 u8 priority; /**< locator priority */
3503 u8 weight; /**< locator weight */
3508 vl_api_lisp_add_del_locator_set_t_handler (vl_api_lisp_add_del_locator_set_t *
3511 vl_api_lisp_add_del_locator_set_reply_t *rmp;
3513 vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
3515 ls_locator_t *ls_loc;
3516 u32 ls_index = ~0, locator_num;
3517 u8 *locator_name = NULL;
3520 memset (a, 0, sizeof (a[0]));
3522 locator_name = format (0, "%s", mp->locator_set_name);
3524 a->name = locator_name;
3525 a->is_add = mp->is_add;
3527 locator_num = clib_net_to_host_u32 (mp->locator_num);
3529 memset (&locator, 0, sizeof (locator));
3530 for (i = 0; i < locator_num; i++)
3532 ls_loc = &((ls_locator_t *) mp->locators)[i];
3533 VALIDATE_SW_IF_INDEX (ls_loc);
3535 locator.sw_if_index = htonl (ls_loc->sw_if_index);
3536 locator.priority = ls_loc->priority;
3537 locator.weight = ls_loc->weight;
3539 vec_add1 (a->locators, locator);
3542 rv = vnet_lisp_add_del_locator_set (a, &ls_index);
3544 BAD_SW_IF_INDEX_LABEL;
3546 vec_free (locator_name);
3547 vec_free (a->locators);
3550 REPLY_MACRO2 (VL_API_LISP_ADD_DEL_LOCATOR_SET_REPLY,
3552 rmp->ls_index = clib_host_to_net_u32 (ls_index);
3558 vl_api_lisp_add_del_locator_t_handler (vl_api_lisp_add_del_locator_t * mp)
3560 vl_api_lisp_add_del_locator_reply_t *rmp;
3562 locator_t locator, *locators = NULL;
3563 vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
3565 u8 *locator_name = NULL;
3567 memset (&locator, 0, sizeof (locator));
3568 memset (a, 0, sizeof (a[0]));
3570 locator.sw_if_index = ntohl (mp->sw_if_index);
3571 locator.priority = mp->priority;
3572 locator.weight = mp->weight;
3574 vec_add1 (locators, locator);
3576 locator_name = format (0, "%s", mp->locator_set_name);
3578 a->name = locator_name;
3579 a->locators = locators;
3580 a->is_add = mp->is_add;
3583 rv = vnet_lisp_add_del_locator (a, NULL, &ls_index);
3585 vec_free (locators);
3586 vec_free (locator_name);
3588 REPLY_MACRO (VL_API_LISP_ADD_DEL_LOCATOR_REPLY);
3592 unformat_lisp_eid_api (gid_address_t * dst, u32 vni, u8 type, void *src,
3598 gid_address_type (dst) = GID_ADDR_IP_PREFIX;
3599 gid_address_ip_set (dst, src, IP4);
3600 gid_address_ippref_len (dst) = len;
3601 ip_prefix_normalize (&gid_address_ippref (dst));
3604 gid_address_type (dst) = GID_ADDR_IP_PREFIX;
3605 gid_address_ip_set (dst, src, IP6);
3606 gid_address_ippref_len (dst) = len;
3607 ip_prefix_normalize (&gid_address_ippref (dst));
3609 case 2: /* l2 mac */
3610 gid_address_type (dst) = GID_ADDR_MAC;
3611 clib_memcpy (&gid_address_mac (dst), src, 6);
3615 return VNET_API_ERROR_INVALID_VALUE;
3618 gid_address_vni (dst) = vni;
3624 vl_api_lisp_add_del_local_eid_t_handler (vl_api_lisp_add_del_local_eid_t * mp)
3626 vl_api_lisp_add_del_local_eid_reply_t *rmp;
3627 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
3629 gid_address_t _eid, *eid = &_eid;
3631 u32 locator_set_index = ~0, map_index = ~0;
3632 vnet_lisp_add_del_mapping_args_t _a, *a = &_a;
3633 u8 *name = NULL, *key = NULL;
3634 memset (a, 0, sizeof (a[0]));
3635 memset (eid, 0, sizeof (eid[0]));
3637 rv = unformat_lisp_eid_api (eid, clib_net_to_host_u32 (mp->vni),
3638 mp->eid_type, mp->eid, mp->prefix_len);
3642 name = format (0, "%s", mp->locator_set_name);
3643 p = hash_get_mem (lcm->locator_set_index_by_name, name);
3646 rv = VNET_API_ERROR_INVALID_VALUE;
3649 locator_set_index = p[0];
3652 key = format (0, "%s", mp->key);
3654 /* XXX treat batch configuration */
3655 a->is_add = mp->is_add;
3656 gid_address_copy (&a->eid, eid);
3657 a->locator_set_index = locator_set_index;
3660 a->key_id = clib_net_to_host_u16 (mp->key_id);
3662 rv = vnet_lisp_add_del_local_mapping (a, &map_index);
3667 gid_address_free (&a->eid);
3669 REPLY_MACRO (VL_API_LISP_ADD_DEL_LOCAL_EID_REPLY);
3673 vl_api_lisp_eid_table_add_del_map_t_handler
3674 (vl_api_lisp_eid_table_add_del_map_t * mp)
3676 vl_api_lisp_eid_table_add_del_map_reply_t *rmp;
3678 rv = vnet_lisp_eid_table_map (clib_net_to_host_u32 (mp->vni),
3679 clib_net_to_host_u32 (mp->dp_table),
3680 mp->is_l2, mp->is_add);
3681 REPLY_MACRO (VL_API_LISP_EID_TABLE_ADD_DEL_MAP_REPLY)}
3683 /** Used for transferring locators via VPP API */
3685 typedef CLIB_PACKED (struct {
3686 u8 is_ip4; /**< is locator an IPv4 address */
3687 u8 priority; /**< locator priority */
3688 u8 weight; /**< locator weight */
3689 u8 addr[16]; /**< IPv4/IPv6 address */
3693 static locator_pair_t *
3694 unformat_lisp_loc_pairs (void *lcl_locs, void *rmt_locs, u32 rloc_num)
3697 locator_pair_t *pairs = 0, pair;
3700 for (i = 0; i < rloc_num; i++)
3703 r = &((rloc_t *) lcl_locs)[i];
3704 memset (&pair.lcl_loc, 0, sizeof (pair.lcl_loc));
3705 ip_address_set (&pair.lcl_loc, &r->addr, r->is_ip4 ? IP4 : IP6);
3707 /* remote locators */
3708 r = &((rloc_t *) rmt_locs)[i];
3709 memset (&pair.rmt_loc, 0, sizeof (pair.rmt_loc));
3710 ip_address_set (&pair.rmt_loc, &r->addr, r->is_ip4 ? IP4 : IP6);
3712 pair.priority = r->priority;
3713 pair.weight = r->weight;
3715 vec_add1 (pairs, pair);
3721 unformat_lisp_locs (void *rmt_locs, u32 rloc_num)
3724 locator_t *locs = 0, loc;
3727 for (i = 0; i < rloc_num; i++)
3729 /* remote locators */
3730 r = &((rloc_t *) rmt_locs)[i];
3731 memset (&loc, 0, sizeof (loc));
3732 gid_address_ip_set (&loc.address, &r->addr, r->is_ip4 ? IP4 : IP6);
3734 loc.priority = r->priority;
3735 loc.weight = r->weight;
3737 vec_add1 (locs, loc);
3743 vl_api_lisp_gpe_add_del_fwd_entry_t_handler
3744 (vl_api_lisp_gpe_add_del_fwd_entry_t * mp)
3746 vl_api_lisp_gpe_add_del_fwd_entry_reply_t *rmp;
3747 vnet_lisp_gpe_add_del_fwd_entry_args_t _a, *a = &_a;
3748 locator_pair_t *pairs = 0;
3751 memset (a, 0, sizeof (a[0]));
3753 rv = unformat_lisp_eid_api (&a->rmt_eid, mp->vni, mp->eid_type,
3754 mp->rmt_eid, mp->rmt_len);
3755 rv |= unformat_lisp_eid_api (&a->lcl_eid, mp->vni, mp->eid_type,
3756 mp->lcl_eid, mp->lcl_len);
3758 pairs = unformat_lisp_loc_pairs (mp->lcl_locs, mp->rmt_locs, mp->loc_num);
3760 if (rv || 0 == pairs)
3763 a->is_add = mp->is_add;
3764 a->locator_pairs = pairs;
3765 a->dp_table = mp->dp_table;
3767 a->action = mp->action;
3769 rv = vnet_lisp_gpe_add_del_fwd_entry (a, 0);
3772 REPLY_MACRO (VL_API_LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY);
3776 vl_api_lisp_add_del_map_server_t_handler (vl_api_lisp_add_del_map_server_t
3779 vl_api_lisp_add_del_map_server_reply_t *rmp;
3783 memset (&addr, 0, sizeof (addr));
3785 ip_address_set (&addr, mp->ip_address, mp->is_ipv6 ? IP6 : IP4);
3786 rv = vnet_lisp_add_del_map_server (&addr, mp->is_add);
3788 REPLY_MACRO (VL_API_LISP_ADD_DEL_MAP_SERVER_REPLY);
3792 vl_api_lisp_add_del_map_resolver_t_handler (vl_api_lisp_add_del_map_resolver_t
3795 vl_api_lisp_add_del_map_resolver_reply_t *rmp;
3797 vnet_lisp_add_del_map_resolver_args_t _a, *a = &_a;
3799 memset (a, 0, sizeof (a[0]));
3801 a->is_add = mp->is_add;
3802 ip_address_set (&a->address, mp->ip_address, mp->is_ipv6 ? IP6 : IP4);
3804 rv = vnet_lisp_add_del_map_resolver (a);
3806 REPLY_MACRO (VL_API_LISP_ADD_DEL_MAP_RESOLVER_REPLY);
3810 vl_api_lisp_gpe_enable_disable_t_handler (vl_api_lisp_gpe_enable_disable_t *
3813 vl_api_lisp_gpe_enable_disable_reply_t *rmp;
3815 vnet_lisp_gpe_enable_disable_args_t _a, *a = &_a;
3817 a->is_en = mp->is_en;
3818 vnet_lisp_gpe_enable_disable (a);
3820 REPLY_MACRO (VL_API_LISP_GPE_ENABLE_DISABLE_REPLY);
3824 vl_api_lisp_map_register_enable_disable_t_handler
3825 (vl_api_lisp_map_register_enable_disable_t * mp)
3827 vl_api_lisp_map_register_enable_disable_reply_t *rmp;
3830 vnet_lisp_map_register_enable_disable (mp->is_enabled);
3831 REPLY_MACRO (VL_API_LISP_ENABLE_DISABLE_REPLY);
3835 vl_api_lisp_rloc_probe_enable_disable_t_handler
3836 (vl_api_lisp_rloc_probe_enable_disable_t * mp)
3838 vl_api_lisp_rloc_probe_enable_disable_reply_t *rmp;
3841 vnet_lisp_rloc_probe_enable_disable (mp->is_enabled);
3842 REPLY_MACRO (VL_API_LISP_ENABLE_DISABLE_REPLY);
3846 vl_api_lisp_enable_disable_t_handler (vl_api_lisp_enable_disable_t * mp)
3848 vl_api_lisp_enable_disable_reply_t *rmp;
3851 vnet_lisp_enable_disable (mp->is_en);
3852 REPLY_MACRO (VL_API_LISP_ENABLE_DISABLE_REPLY);
3856 vl_api_lisp_gpe_add_del_iface_t_handler (vl_api_lisp_gpe_add_del_iface_t * mp)
3858 vl_api_lisp_gpe_add_del_iface_reply_t *rmp;
3866 lisp_gpe_tenant_l2_iface_add_or_lock (mp->vni, mp->dp_table))
3870 lisp_gpe_tenant_l2_iface_unlock (mp->vni);
3877 lisp_gpe_tenant_l3_iface_add_or_lock (mp->vni, mp->dp_table))
3881 lisp_gpe_tenant_l3_iface_unlock (mp->vni);
3884 REPLY_MACRO (VL_API_LISP_GPE_ADD_DEL_IFACE_REPLY);
3888 vl_api_show_lisp_map_request_mode_t_handler
3889 (vl_api_show_lisp_map_request_mode_t * mp)
3892 vl_api_show_lisp_map_request_mode_reply_t *rmp;
3895 REPLY_MACRO2(VL_API_SHOW_LISP_MAP_REQUEST_MODE_REPLY,
3897 rmp->mode = vnet_lisp_get_map_request_mode ();
3903 vl_api_lisp_map_request_mode_t_handler (vl_api_lisp_map_request_mode_t * mp)
3905 vl_api_lisp_map_request_mode_reply_t *rmp;
3908 rv = vnet_lisp_set_map_request_mode (mp->mode);
3910 REPLY_MACRO (VL_API_LISP_MAP_REQUEST_MODE_REPLY);
3914 vl_api_lisp_pitr_set_locator_set_t_handler (vl_api_lisp_pitr_set_locator_set_t
3917 vl_api_lisp_pitr_set_locator_set_reply_t *rmp;
3921 ls_name = format (0, "%s", mp->ls_name);
3922 rv = vnet_lisp_pitr_set_locator_set (ls_name, mp->is_add);
3925 REPLY_MACRO (VL_API_LISP_PITR_SET_LOCATOR_SET_REPLY);
3929 vl_api_lisp_add_del_map_request_itr_rlocs_t_handler
3930 (vl_api_lisp_add_del_map_request_itr_rlocs_t * mp)
3932 vl_api_lisp_add_del_map_request_itr_rlocs_reply_t *rmp;
3934 u8 *locator_set_name = NULL;
3935 vnet_lisp_add_del_mreq_itr_rloc_args_t _a, *a = &_a;
3937 locator_set_name = format (0, "%s", mp->locator_set_name);
3939 a->is_add = mp->is_add;
3940 a->locator_set_name = locator_set_name;
3942 rv = vnet_lisp_add_del_mreq_itr_rlocs (a);
3944 vec_free (locator_set_name);
3946 REPLY_MACRO (VL_API_LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY);
3950 vl_api_lisp_add_del_remote_mapping_t_handler
3951 (vl_api_lisp_add_del_remote_mapping_t * mp)
3953 locator_t *rlocs = 0;
3954 vl_api_lisp_add_del_remote_mapping_reply_t *rmp;
3956 gid_address_t _eid, *eid = &_eid;
3957 u32 rloc_num = clib_net_to_host_u32 (mp->rloc_num);
3959 memset (eid, 0, sizeof (eid[0]));
3961 rv = unformat_lisp_eid_api (eid, clib_net_to_host_u32 (mp->vni),
3962 mp->eid_type, mp->eid, mp->eid_len);
3966 rlocs = unformat_lisp_locs (mp->rlocs, rloc_num);
3970 vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
3971 gid_address_copy (&a->reid, eid);
3973 rv = vnet_lisp_add_del_adjacency (a);
3980 /* NOTE: for now this works as a static remote mapping, i.e.,
3981 * not authoritative and ttl infinite. */
3982 rv = vnet_lisp_add_del_mapping (eid, rlocs, mp->action, 0, ~0,
3983 mp->is_add, 1 /* is_static */ , 0);
3986 vnet_lisp_clear_all_remote_adjacencies ();
3991 REPLY_MACRO (VL_API_LISP_ADD_DEL_REMOTE_MAPPING_REPLY);
3995 vl_api_lisp_add_del_adjacency_t_handler (vl_api_lisp_add_del_adjacency_t * mp)
3997 vl_api_lisp_add_del_adjacency_reply_t *rmp;
3998 vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
4001 memset (a, 0, sizeof (a[0]));
4003 rv = unformat_lisp_eid_api (&a->leid, clib_net_to_host_u32 (mp->vni),
4004 mp->eid_type, mp->leid, mp->leid_len);
4005 rv |= unformat_lisp_eid_api (&a->reid, clib_net_to_host_u32 (mp->vni),
4006 mp->eid_type, mp->reid, mp->reid_len);
4011 a->is_add = mp->is_add;
4012 rv = vnet_lisp_add_del_adjacency (a);
4015 REPLY_MACRO (VL_API_LISP_ADD_DEL_ADJACENCY_REPLY);
4019 send_lisp_locator_details (lisp_cp_main_t * lcm,
4021 unix_shared_memory_queue_t * q, u32 context)
4023 vl_api_lisp_locator_details_t *rmp;
4025 rmp = vl_msg_api_alloc (sizeof (*rmp));
4026 memset (rmp, 0, sizeof (*rmp));
4027 rmp->_vl_msg_id = ntohs (VL_API_LISP_LOCATOR_DETAILS);
4028 rmp->context = context;
4030 rmp->local = loc->local;
4033 rmp->sw_if_index = ntohl (loc->sw_if_index);
4037 rmp->is_ipv6 = gid_address_ip_version (&loc->address);
4038 ip_address_copy_addr (rmp->ip_address, &gid_address_ip (&loc->address));
4040 rmp->priority = loc->priority;
4041 rmp->weight = loc->weight;
4043 vl_msg_api_send_shmem (q, (u8 *) & rmp);
4047 vl_api_lisp_locator_dump_t_handler (vl_api_lisp_locator_dump_t * mp)
4050 unix_shared_memory_queue_t *q = 0;
4051 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
4052 locator_set_t *lsit = 0;
4054 u32 ls_index = ~0, *locit = 0;
4057 q = vl_api_client_index_to_input_queue (mp->client_index);
4063 if (mp->is_index_set)
4064 ls_index = htonl (mp->ls_index);
4067 /* make sure we get a proper C-string */
4068 mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
4069 ls_name = format (0, "%s", mp->ls_name);
4070 p = hash_get_mem (lcm->locator_set_index_by_name, ls_name);
4076 if (pool_is_free_index (lcm->locator_set_pool, ls_index))
4079 lsit = pool_elt_at_index (lcm->locator_set_pool, ls_index);
4081 vec_foreach (locit, lsit->locator_indices)
4083 loc = pool_elt_at_index (lcm->locator_pool, locit[0]);
4084 send_lisp_locator_details (lcm, loc, q, mp->context);
4091 send_lisp_locator_set_details (lisp_cp_main_t * lcm,
4092 locator_set_t * lsit,
4093 unix_shared_memory_queue_t * q,
4094 u32 context, u32 ls_index)
4096 vl_api_lisp_locator_set_details_t *rmp;
4099 rmp = vl_msg_api_alloc (sizeof (*rmp));
4100 memset (rmp, 0, sizeof (*rmp));
4101 rmp->_vl_msg_id = ntohs (VL_API_LISP_LOCATOR_SET_DETAILS);
4102 rmp->context = context;
4104 rmp->ls_index = htonl (ls_index);
4107 ASSERT (lsit->name != NULL);
4108 strncpy ((char *) rmp->ls_name, (char *) lsit->name,
4109 vec_len (lsit->name));
4113 str = format (0, "<remote-%d>", ls_index);
4114 strncpy ((char *) rmp->ls_name, (char *) str, vec_len (str));
4118 vl_msg_api_send_shmem (q, (u8 *) & rmp);
4122 vl_api_lisp_locator_set_dump_t_handler (vl_api_lisp_locator_set_dump_t * mp)
4124 unix_shared_memory_queue_t *q = NULL;
4125 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
4126 locator_set_t *lsit = NULL;
4129 q = vl_api_client_index_to_input_queue (mp->client_index);
4135 filter = mp->filter;
4137 pool_foreach (lsit, lcm->locator_set_pool,
4139 if (filter && !((1 == filter && lsit->local) ||
4140 (2 == filter && !lsit->local)))
4144 send_lisp_locator_set_details (lcm, lsit, q, mp->context,
4145 lsit - lcm->locator_set_pool);
4151 lisp_fid_put_api (u8 * dst, fid_address_t * src, u8 * prefix_length)
4153 ASSERT (prefix_length);
4154 ip_prefix_t *ippref = &fid_addr_ippref (src);
4156 switch (fid_addr_type (src))
4158 case FID_ADDR_IP_PREF:
4159 if (ip_prefix_version (ippref) == IP4)
4160 clib_memcpy (dst, &ip_prefix_v4 (ippref), 4);
4162 clib_memcpy (dst, &ip_prefix_v6 (ippref), 16);
4163 prefix_length[0] = ip_prefix_len (ippref);
4167 prefix_length[0] = 0;
4168 clib_memcpy (dst, fid_addr_mac (src), 6);
4172 clib_warning ("Unknown FID type %d!", fid_addr_type (src));
4178 fid_type_to_api_type (fid_address_t * fid)
4180 ip_prefix_t *ippref;
4182 switch (fid_addr_type (fid))
4184 case FID_ADDR_IP_PREF:
4185 ippref = &fid_addr_ippref (fid);
4186 if (ip_prefix_version (ippref) == IP4)
4188 else if (ip_prefix_version (ippref) == IP6)
4201 send_lisp_eid_table_details (mapping_t * mapit,
4202 unix_shared_memory_queue_t * q,
4203 u32 context, u8 filter)
4206 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
4207 locator_set_t *ls = 0;
4208 vl_api_lisp_eid_table_details_t *rmp = NULL;
4209 gid_address_t *gid = NULL;
4211 ip_prefix_t *ip_prefix = NULL;
4215 case 0: /* all mappings */
4218 case 1: /* local only */
4222 case 2: /* remote only */
4227 clib_warning ("Filter error, unknown filter: %d", filter);
4232 ip_prefix = &gid_address_ippref (gid);
4233 mac = gid_address_mac (gid);
4235 rmp = vl_msg_api_alloc (sizeof (*rmp));
4236 memset (rmp, 0, sizeof (*rmp));
4237 rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_DETAILS);
4239 ls = pool_elt_at_index (lcm->locator_set_pool, mapit->locator_set_index);
4240 if (vec_len (ls->locator_indices) == 0)
4241 rmp->locator_set_index = ~0;
4243 rmp->locator_set_index = clib_host_to_net_u32 (mapit->locator_set_index);
4245 rmp->is_local = mapit->local;
4246 rmp->ttl = clib_host_to_net_u32 (mapit->ttl);
4247 rmp->action = mapit->action;
4248 rmp->authoritative = mapit->authoritative;
4250 switch (gid_address_type (gid))
4252 case GID_ADDR_SRC_DST:
4253 rmp->is_src_dst = 1;
4254 fid = &gid_address_sd_src (gid);
4255 rmp->eid_type = fid_type_to_api_type (fid);
4256 lisp_fid_put_api (rmp->seid, &gid_address_sd_src (gid),
4257 &rmp->seid_prefix_len);
4258 lisp_fid_put_api (rmp->eid, &gid_address_sd_dst (gid),
4259 &rmp->eid_prefix_len);
4261 case GID_ADDR_IP_PREFIX:
4262 rmp->eid_prefix_len = ip_prefix_len (ip_prefix);
4263 if (ip_prefix_version (ip_prefix) == IP4)
4265 rmp->eid_type = 0; /* ipv4 type */
4266 clib_memcpy (rmp->eid, &ip_prefix_v4 (ip_prefix),
4267 sizeof (ip_prefix_v4 (ip_prefix)));
4271 rmp->eid_type = 1; /* ipv6 type */
4272 clib_memcpy (rmp->eid, &ip_prefix_v6 (ip_prefix),
4273 sizeof (ip_prefix_v6 (ip_prefix)));
4277 rmp->eid_type = 2; /* l2 mac type */
4278 clib_memcpy (rmp->eid, mac, 6);
4283 rmp->context = context;
4284 rmp->vni = clib_host_to_net_u32 (gid_address_vni (gid));
4285 rmp->key_id = clib_host_to_net_u16 (mapit->key_id);
4286 memcpy (rmp->key, mapit->key, vec_len (mapit->key));
4287 vl_msg_api_send_shmem (q, (u8 *) & rmp);
4291 vl_api_lisp_eid_table_dump_t_handler (vl_api_lisp_eid_table_dump_t * mp)
4294 unix_shared_memory_queue_t *q = NULL;
4295 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
4296 mapping_t *mapit = NULL;
4297 gid_address_t _eid, *eid = &_eid;
4299 q = vl_api_client_index_to_input_queue (mp->client_index);
4307 memset (eid, 0, sizeof (*eid));
4309 unformat_lisp_eid_api (eid, clib_net_to_host_u32 (mp->vni),
4310 mp->eid_type, mp->eid, mp->prefix_length);
4312 mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, eid);
4313 if ((u32) ~ 0 == mi)
4316 mapit = pool_elt_at_index (lcm->mapping_pool, mi);
4317 send_lisp_eid_table_details (mapit, q, mp->context,
4318 0 /* ignore filter */ );
4323 pool_foreach (mapit, lcm->mapping_pool,
4325 send_lisp_eid_table_details(mapit, q, mp->context,
4333 send_lisp_gpe_fwd_entry_details (lisp_gpe_fwd_entry_t * lfe,
4334 unix_shared_memory_queue_t * q, u32 context)
4336 vl_api_lisp_gpe_tunnel_details_t *rmp;
4337 lisp_gpe_main_t *lgm = &lisp_gpe_main;
4339 rmp = vl_msg_api_alloc (sizeof (*rmp));
4340 memset (rmp, 0, sizeof (*rmp));
4341 rmp->_vl_msg_id = ntohs (VL_API_LISP_GPE_TUNNEL_DETAILS);
4343 rmp->tunnels = lfe - lgm->lisp_fwd_entry_pool;
4345 rmp->is_ipv6 = ip_prefix_version (&(lfe->key->rmt.ippref)) == IP6 ? 1 : 0;
4346 ip_address_copy_addr (rmp->source_ip,
4347 &ip_prefix_addr (&(lfe->key->rmt.ippref)));
4348 ip_address_copy_addr (rmp->destination_ip,
4349 &ip_prefix_addr (&(lfe->key->rmt.ippref)));
4351 rmp->encap_fib_id = htonl (0);
4352 rmp->decap_fib_id = htonl (lfe->eid_fib_index);
4353 rmp->iid = htonl (lfe->key->vni);
4354 rmp->context = context;
4356 vl_msg_api_send_shmem (q, (u8 *) & rmp);
4360 vl_api_lisp_gpe_tunnel_dump_t_handler (vl_api_lisp_gpe_tunnel_dump_t * mp)
4362 unix_shared_memory_queue_t *q = NULL;
4363 lisp_gpe_main_t *lgm = &lisp_gpe_main;
4364 lisp_gpe_fwd_entry_t *lfe = NULL;
4366 if (pool_elts (lgm->lisp_fwd_entry_pool) == 0)
4371 q = vl_api_client_index_to_input_queue (mp->client_index);
4378 pool_foreach(lfe, lgm->lisp_fwd_entry_pool,
4380 send_lisp_gpe_fwd_entry_details(lfe, q, mp->context);
4386 send_lisp_map_server_details (ip_address_t * ip,
4387 unix_shared_memory_queue_t * q, u32 context)
4389 vl_api_lisp_map_server_details_t *rmp = NULL;
4391 rmp = vl_msg_api_alloc (sizeof (*rmp));
4392 memset (rmp, 0, sizeof (*rmp));
4393 rmp->_vl_msg_id = ntohs (VL_API_LISP_MAP_SERVER_DETAILS);
4395 switch (ip_addr_version (ip))
4399 clib_memcpy (rmp->ip_address, &ip_addr_v4 (ip),
4400 sizeof (ip_addr_v4 (ip)));
4405 clib_memcpy (rmp->ip_address, &ip_addr_v6 (ip),
4406 sizeof (ip_addr_v6 (ip)));
4412 rmp->context = context;
4414 vl_msg_api_send_shmem (q, (u8 *) & rmp);
4418 vl_api_lisp_map_server_dump_t_handler (vl_api_lisp_map_server_dump_t * mp)
4420 unix_shared_memory_queue_t *q = NULL;
4421 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
4424 q = vl_api_client_index_to_input_queue (mp->client_index);
4430 vec_foreach (mr, lcm->map_servers)
4432 send_lisp_map_server_details (&mr->address, q, mp->context);
4437 send_lisp_map_resolver_details (ip_address_t * ip,
4438 unix_shared_memory_queue_t * q, u32 context)
4440 vl_api_lisp_map_resolver_details_t *rmp = NULL;
4442 rmp = vl_msg_api_alloc (sizeof (*rmp));
4443 memset (rmp, 0, sizeof (*rmp));
4444 rmp->_vl_msg_id = ntohs (VL_API_LISP_MAP_RESOLVER_DETAILS);
4446 switch (ip_addr_version (ip))
4450 clib_memcpy (rmp->ip_address, &ip_addr_v4 (ip),
4451 sizeof (ip_addr_v4 (ip)));
4456 clib_memcpy (rmp->ip_address, &ip_addr_v6 (ip),
4457 sizeof (ip_addr_v6 (ip)));
4463 rmp->context = context;
4465 vl_msg_api_send_shmem (q, (u8 *) & rmp);
4469 vl_api_lisp_map_resolver_dump_t_handler (vl_api_lisp_map_resolver_dump_t * mp)
4471 unix_shared_memory_queue_t *q = NULL;
4472 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
4475 q = vl_api_client_index_to_input_queue (mp->client_index);
4481 vec_foreach (mr, lcm->map_resolvers)
4483 send_lisp_map_resolver_details (&mr->address, q, mp->context);
4488 send_eid_table_map_pair (hash_pair_t * p,
4489 unix_shared_memory_queue_t * q, u32 context)
4491 vl_api_lisp_eid_table_map_details_t *rmp = NULL;
4493 rmp = vl_msg_api_alloc (sizeof (*rmp));
4494 memset (rmp, 0, sizeof (*rmp));
4495 rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_MAP_DETAILS);
4497 rmp->vni = clib_host_to_net_u32 (p->key);
4498 rmp->dp_table = clib_host_to_net_u32 (p->value[0]);
4499 rmp->context = context;
4500 vl_msg_api_send_shmem (q, (u8 *) & rmp);
4504 vl_api_lisp_eid_table_map_dump_t_handler (vl_api_lisp_eid_table_map_dump_t *
4507 unix_shared_memory_queue_t *q = NULL;
4508 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
4510 uword *vni_table = 0;
4512 q = vl_api_client_index_to_input_queue (mp->client_index);
4520 vni_table = lcm->bd_id_by_vni;
4524 vni_table = lcm->table_id_by_vni;
4528 hash_foreach_pair (p, vni_table,
4530 send_eid_table_map_pair (p, q, mp->context);
4536 send_eid_table_vni (u32 vni, unix_shared_memory_queue_t * q, u32 context)
4538 vl_api_lisp_eid_table_vni_details_t *rmp = 0;
4540 rmp = vl_msg_api_alloc (sizeof (*rmp));
4541 memset (rmp, 0, sizeof (*rmp));
4542 rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_VNI_DETAILS);
4543 rmp->context = context;
4544 rmp->vni = clib_host_to_net_u32 (vni);
4545 vl_msg_api_send_shmem (q, (u8 *) & rmp);
4549 lisp_adjacency_copy (vl_api_lisp_adjacency_t * dst, lisp_adjacency_t * adjs)
4551 lisp_adjacency_t *adj;
4552 vl_api_lisp_adjacency_t a;
4553 u32 i, n = vec_len (adjs);
4555 for (i = 0; i < n; i++)
4557 adj = vec_elt_at_index (adjs, i);
4558 memset (&a, 0, sizeof (a));
4560 switch (gid_address_type (&adj->reid))
4562 case GID_ADDR_IP_PREFIX:
4563 a.reid_prefix_len = gid_address_ippref_len (&adj->reid);
4564 a.leid_prefix_len = gid_address_ippref_len (&adj->leid);
4565 if (gid_address_ip_version (&adj->reid) == IP4)
4567 a.eid_type = 0; /* ipv4 type */
4568 clib_memcpy (a.reid, &gid_address_ip (&adj->reid), 4);
4569 clib_memcpy (a.leid, &gid_address_ip (&adj->leid), 4);
4573 a.eid_type = 1; /* ipv6 type */
4574 clib_memcpy (a.reid, &gid_address_ip (&adj->reid), 16);
4575 clib_memcpy (a.leid, &gid_address_ip (&adj->leid), 16);
4579 a.eid_type = 2; /* l2 mac type */
4580 mac_copy (a.reid, gid_address_mac (&adj->reid));
4581 mac_copy (a.leid, gid_address_mac (&adj->leid));
4591 vl_api_show_lisp_rloc_probe_state_t_handler
4592 (vl_api_show_lisp_rloc_probe_state_t * mp)
4594 vl_api_show_lisp_rloc_probe_state_reply_t *rmp = 0;
4598 REPLY_MACRO2 (VL_API_SHOW_LISP_RLOC_PROBE_STATE_REPLY,
4600 rmp->is_enabled = vnet_lisp_rloc_probe_state_get ();
4606 vl_api_show_lisp_map_register_state_t_handler
4607 (vl_api_show_lisp_map_register_state_t * mp)
4609 vl_api_show_lisp_map_register_state_reply_t *rmp = 0;
4613 REPLY_MACRO2 (VL_API_SHOW_LISP_MAP_REGISTER_STATE_REPLY,
4615 rmp->is_enabled = vnet_lisp_map_register_state_get ();
4621 vl_api_lisp_adjacencies_get_t_handler (vl_api_lisp_adjacencies_get_t * mp)
4623 vl_api_lisp_adjacencies_get_reply_t *rmp = 0;
4624 lisp_adjacency_t *adjs = 0;
4626 vl_api_lisp_adjacency_t a;
4628 u32 vni = clib_net_to_host_u32 (mp->vni);
4630 adjs = vnet_lisp_adjacencies_get_by_vni (vni);
4631 size = vec_len (adjs) * sizeof (a);
4634 REPLY_MACRO4 (VL_API_LISP_ADJACENCIES_GET_REPLY, size,
4636 rmp->count = clib_host_to_net_u32 (vec_len (adjs));
4637 lisp_adjacency_copy (rmp->adjacencies, adjs);
4645 vl_api_lisp_eid_table_vni_dump_t_handler (vl_api_lisp_eid_table_vni_dump_t *
4650 unix_shared_memory_queue_t *q = 0;
4651 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
4653 q = vl_api_client_index_to_input_queue (mp->client_index);
4660 hash_foreach_pair (p, lcm->table_id_by_vni,
4662 hash_set (vnis, p->key, 0);
4665 hash_foreach_pair (p, lcm->bd_id_by_vni,
4667 hash_set (vnis, p->key, 0);
4670 hash_foreach_pair (p, vnis,
4672 send_eid_table_vni (p->key, q, mp->context);
4680 vl_api_show_lisp_status_t_handler (vl_api_show_lisp_status_t * mp)
4682 unix_shared_memory_queue_t *q = NULL;
4683 vl_api_show_lisp_status_reply_t *rmp = NULL;
4686 q = vl_api_client_index_to_input_queue (mp->client_index);
4693 REPLY_MACRO2(VL_API_SHOW_LISP_STATUS_REPLY,
4695 rmp->gpe_status = vnet_lisp_gpe_enable_disable_status ();
4696 rmp->feature_status = vnet_lisp_enable_disable_status ();
4702 vl_api_lisp_get_map_request_itr_rlocs_t_handler
4703 (vl_api_lisp_get_map_request_itr_rlocs_t * mp)
4705 unix_shared_memory_queue_t *q = NULL;
4706 vl_api_lisp_get_map_request_itr_rlocs_reply_t *rmp = NULL;
4707 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
4708 locator_set_t *loc_set = 0;
4712 q = vl_api_client_index_to_input_queue (mp->client_index);
4718 if (~0 == lcm->mreq_itr_rlocs)
4720 tmp_str = format (0, " ");
4725 pool_elt_at_index (lcm->locator_set_pool, lcm->mreq_itr_rlocs);
4726 tmp_str = format (0, "%s", loc_set->name);
4730 REPLY_MACRO2(VL_API_LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY,
4732 strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
4733 ARRAY_LEN(rmp->locator_set_name) - 1);
4741 vl_api_show_lisp_pitr_t_handler (vl_api_show_lisp_pitr_t * mp)
4743 unix_shared_memory_queue_t *q = NULL;
4744 vl_api_show_lisp_pitr_reply_t *rmp = NULL;
4745 lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
4747 locator_set_t *ls = 0;
4751 q = vl_api_client_index_to_input_queue (mp->client_index);
4757 if (!lcm->lisp_pitr)
4759 tmp_str = format (0, "N/A");
4763 m = pool_elt_at_index (lcm->mapping_pool, lcm->pitr_map_index);
4764 if (~0 != m->locator_set_index)
4767 pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
4768 tmp_str = format (0, "%s", ls->name);
4772 tmp_str = format (0, "N/A");
4775 vec_add1 (tmp_str, 0);
4778 REPLY_MACRO2(VL_API_SHOW_LISP_PITR_REPLY,
4780 rmp->status = lcm->lisp_pitr;
4781 strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
4782 ARRAY_LEN(rmp->locator_set_name) - 1);
4788 vl_api_interface_name_renumber_t_handler (vl_api_interface_name_renumber_t *
4791 vl_api_interface_name_renumber_reply_t *rmp;
4794 VALIDATE_SW_IF_INDEX (mp);
4796 rv = vnet_interface_name_renumber
4797 (ntohl (mp->sw_if_index), ntohl (mp->new_show_dev_instance));
4799 BAD_SW_IF_INDEX_LABEL;
4801 REPLY_MACRO (VL_API_INTERFACE_NAME_RENUMBER_REPLY);
4805 arp_change_data_callback (u32 pool_index, u8 * new_mac,
4806 u32 sw_if_index, u32 address)
4808 vpe_api_main_t *am = &vpe_api_main;
4809 vlib_main_t *vm = am->vlib_main;
4810 vl_api_ip4_arp_event_t *event;
4811 static f64 arp_event_last_time;
4812 f64 now = vlib_time_now (vm);
4814 if (pool_is_free_index (am->arp_events, pool_index))
4817 event = pool_elt_at_index (am->arp_events, pool_index);
4819 if (memcmp (&event->new_mac, new_mac, sizeof (event->new_mac)))
4821 clib_memcpy (event->new_mac, new_mac, sizeof (event->new_mac));
4825 if (sw_if_index == event->sw_if_index &&
4827 /* for BD case, also check IP address with 10 sec timeout */
4828 (address == event->address &&
4829 (now - arp_event_last_time) < 10.0)))
4834 arp_event_last_time = now;
4835 event->sw_if_index = sw_if_index;
4837 event->address = address;
4842 nd_change_data_callback (u32 pool_index, u8 * new_mac,
4843 u32 sw_if_index, ip6_address_t * address)
4845 vpe_api_main_t *am = &vpe_api_main;
4846 vlib_main_t *vm = am->vlib_main;
4847 vl_api_ip6_nd_event_t *event;
4848 static f64 nd_event_last_time;
4849 f64 now = vlib_time_now (vm);
4851 if (pool_is_free_index (am->nd_events, pool_index))
4854 event = pool_elt_at_index (am->nd_events, pool_index);
4857 if (memcmp (&event->new_mac, new_mac, sizeof (event->new_mac)))
4859 clib_memcpy (event->new_mac, new_mac, sizeof (event->new_mac));
4863 if (sw_if_index == event->sw_if_index &&
4865 /* for BD case, also check IP address with 10 sec timeout */
4866 (ip6_address_is_equal (address,
4867 (ip6_address_t *) event->address) &&
4868 (now - nd_event_last_time) < 10.0)))
4873 nd_event_last_time = now;
4874 event->sw_if_index = sw_if_index;
4876 clib_memcpy (event->address, address, sizeof (event->address));
4881 arp_change_delete_callback (u32 pool_index, u8 * notused)
4883 vpe_api_main_t *am = &vpe_api_main;
4885 if (pool_is_free_index (am->arp_events, pool_index))
4888 pool_put_index (am->arp_events, pool_index);
4893 nd_change_delete_callback (u32 pool_index, u8 * notused)
4895 vpe_api_main_t *am = &vpe_api_main;
4897 if (pool_is_free_index (am->nd_events, pool_index))
4900 pool_put_index (am->nd_events, pool_index);
4905 vl_api_want_ip4_arp_events_t_handler (vl_api_want_ip4_arp_events_t * mp)
4907 vpe_api_main_t *am = &vpe_api_main;
4908 vnet_main_t *vnm = vnet_get_main ();
4909 vl_api_want_ip4_arp_events_reply_t *rmp;
4910 vl_api_ip4_arp_event_t *event;
4913 if (mp->enable_disable)
4915 pool_get (am->arp_events, event);
4916 memset (event, 0, sizeof (*event));
4918 event->_vl_msg_id = ntohs (VL_API_IP4_ARP_EVENT);
4919 event->client_index = mp->client_index;
4920 event->context = mp->context;
4921 event->address = mp->address;
4922 event->pid = mp->pid;
4923 if (mp->address == 0)
4926 rv = vnet_add_del_ip4_arp_change_event
4927 (vnm, arp_change_data_callback,
4928 mp->pid, &mp->address /* addr, in net byte order */ ,
4929 vpe_resolver_process_node.index,
4930 IP4_ARP_EVENT, event - am->arp_events, 1 /* is_add */ );
4934 rv = vnet_add_del_ip4_arp_change_event
4935 (vnm, arp_change_delete_callback,
4936 mp->pid, &mp->address /* addr, in net byte order */ ,
4937 vpe_resolver_process_node.index,
4938 IP4_ARP_EVENT, ~0 /* pool index */ , 0 /* is_add */ );
4940 REPLY_MACRO (VL_API_WANT_IP4_ARP_EVENTS_REPLY);
4944 vl_api_want_ip6_nd_events_t_handler (vl_api_want_ip6_nd_events_t * mp)
4946 vpe_api_main_t *am = &vpe_api_main;
4947 vnet_main_t *vnm = vnet_get_main ();
4948 vl_api_want_ip6_nd_events_reply_t *rmp;
4949 vl_api_ip6_nd_event_t *event;
4952 if (mp->enable_disable)
4954 pool_get (am->nd_events, event);
4955 memset (event, 0, sizeof (*event));
4957 event->_vl_msg_id = ntohs (VL_API_IP6_ND_EVENT);
4958 event->client_index = mp->client_index;
4959 event->context = mp->context;
4960 clib_memcpy (event->address, mp->address, 16);
4961 event->pid = mp->pid;
4962 if (ip6_address_is_zero ((ip6_address_t *) mp->address))
4965 rv = vnet_add_del_ip6_nd_change_event
4966 (vnm, nd_change_data_callback,
4967 mp->pid, mp->address /* addr, in net byte order */ ,
4968 vpe_resolver_process_node.index,
4969 IP6_ND_EVENT, event - am->nd_events, 1 /* is_add */ );
4973 rv = vnet_add_del_ip6_nd_change_event
4974 (vnm, nd_change_delete_callback,
4975 mp->pid, mp->address /* addr, in net byte order */ ,
4976 vpe_resolver_process_node.index,
4977 IP6_ND_EVENT, ~0 /* pool index */ , 0 /* is_add */ );
4979 REPLY_MACRO (VL_API_WANT_IP6_ND_EVENTS_REPLY);
4982 static void vl_api_input_acl_set_interface_t_handler
4983 (vl_api_input_acl_set_interface_t * mp)
4985 vlib_main_t *vm = vlib_get_main ();
4986 vl_api_input_acl_set_interface_reply_t *rmp;
4988 u32 sw_if_index, ip4_table_index, ip6_table_index, l2_table_index;
4990 ip4_table_index = ntohl (mp->ip4_table_index);
4991 ip6_table_index = ntohl (mp->ip6_table_index);
4992 l2_table_index = ntohl (mp->l2_table_index);
4993 sw_if_index = ntohl (mp->sw_if_index);
4995 VALIDATE_SW_IF_INDEX (mp);
4997 rv = vnet_set_input_acl_intfc (vm, sw_if_index, ip4_table_index,
4998 ip6_table_index, l2_table_index, mp->is_add);
5000 BAD_SW_IF_INDEX_LABEL;
5002 REPLY_MACRO (VL_API_INPUT_ACL_SET_INTERFACE_REPLY);
5005 static void vl_api_ipsec_spd_add_del_t_handler
5006 (vl_api_ipsec_spd_add_del_t * mp)
5009 clib_warning ("unimplemented");
5012 vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
5013 vl_api_ipsec_spd_add_del_reply_t *rmp;
5017 rv = ipsec_add_del_spd (vm, ntohl (mp->spd_id), mp->is_add);
5019 rv = VNET_API_ERROR_UNIMPLEMENTED;
5022 REPLY_MACRO (VL_API_IPSEC_SPD_ADD_DEL_REPLY);
5026 static void vl_api_ipsec_interface_add_del_spd_t_handler
5027 (vl_api_ipsec_interface_add_del_spd_t * mp)
5029 vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
5030 vl_api_ipsec_interface_add_del_spd_reply_t *rmp;
5032 u32 sw_if_index __attribute__ ((unused));
5033 u32 spd_id __attribute__ ((unused));
5035 sw_if_index = ntohl (mp->sw_if_index);
5036 spd_id = ntohl (mp->spd_id);
5038 VALIDATE_SW_IF_INDEX (mp);
5041 rv = ipsec_set_interface_spd (vm, sw_if_index, spd_id, mp->is_add);
5043 rv = VNET_API_ERROR_UNIMPLEMENTED;
5046 BAD_SW_IF_INDEX_LABEL;
5048 REPLY_MACRO (VL_API_IPSEC_INTERFACE_ADD_DEL_SPD_REPLY);
5051 static void vl_api_ipsec_spd_add_del_entry_t_handler
5052 (vl_api_ipsec_spd_add_del_entry_t * mp)
5054 vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
5055 vl_api_ipsec_spd_add_del_entry_reply_t *rmp;
5061 memset (&p, 0, sizeof (p));
5063 p.id = ntohl (mp->spd_id);
5064 p.priority = ntohl (mp->priority);
5065 p.is_outbound = mp->is_outbound;
5066 p.is_ipv6 = mp->is_ipv6;
5068 if (mp->is_ipv6 || mp->is_ip_any)
5070 clib_memcpy (&p.raddr.start, mp->remote_address_start, 16);
5071 clib_memcpy (&p.raddr.stop, mp->remote_address_stop, 16);
5072 clib_memcpy (&p.laddr.start, mp->local_address_start, 16);
5073 clib_memcpy (&p.laddr.stop, mp->local_address_stop, 16);
5077 clib_memcpy (&p.raddr.start.ip4.data, mp->remote_address_start, 4);
5078 clib_memcpy (&p.raddr.stop.ip4.data, mp->remote_address_stop, 4);
5079 clib_memcpy (&p.laddr.start.ip4.data, mp->local_address_start, 4);
5080 clib_memcpy (&p.laddr.stop.ip4.data, mp->local_address_stop, 4);
5082 p.protocol = mp->protocol;
5083 p.rport.start = ntohs (mp->remote_port_start);
5084 p.rport.stop = ntohs (mp->remote_port_stop);
5085 p.lport.start = ntohs (mp->local_port_start);
5086 p.lport.stop = ntohs (mp->local_port_stop);
5087 /* policy action resolve unsupported */
5088 if (mp->policy == IPSEC_POLICY_ACTION_RESOLVE)
5090 clib_warning ("unsupported action: 'resolve'");
5091 rv = VNET_API_ERROR_UNIMPLEMENTED;
5094 p.policy = mp->policy;
5095 p.sa_id = ntohl (mp->sa_id);
5097 rv = ipsec_add_del_policy (vm, &p, mp->is_add);
5104 rv = ipsec_add_del_policy (vm, &p, mp->is_add);
5107 rv = VNET_API_ERROR_UNIMPLEMENTED;
5112 REPLY_MACRO (VL_API_IPSEC_SPD_ADD_DEL_ENTRY_REPLY);
5115 static void vl_api_ipsec_sad_add_del_entry_t_handler
5116 (vl_api_ipsec_sad_add_del_entry_t * mp)
5118 vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
5119 vl_api_ipsec_sad_add_del_entry_reply_t *rmp;
5124 memset (&sa, 0, sizeof (sa));
5126 sa.id = ntohl (mp->sad_id);
5127 sa.spi = ntohl (mp->spi);
5128 /* security protocol AH unsupported */
5129 if (mp->protocol == IPSEC_PROTOCOL_AH)
5131 clib_warning ("unsupported security protocol 'AH'");
5132 rv = VNET_API_ERROR_UNIMPLEMENTED;
5135 sa.protocol = mp->protocol;
5136 /* check for unsupported crypto-alg */
5137 if (mp->crypto_algorithm < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
5138 mp->crypto_algorithm >= IPSEC_CRYPTO_N_ALG)
5140 clib_warning ("unsupported crypto-alg: '%U'", format_ipsec_crypto_alg,
5141 mp->crypto_algorithm);
5142 rv = VNET_API_ERROR_UNIMPLEMENTED;
5145 sa.crypto_alg = mp->crypto_algorithm;
5146 sa.crypto_key_len = mp->crypto_key_length;
5147 clib_memcpy (&sa.crypto_key, mp->crypto_key, sizeof (sa.crypto_key));
5148 /* check for unsupported integ-alg */
5150 if (mp->integrity_algorithm < IPSEC_INTEG_ALG_NONE ||
5152 if (mp->integrity_algorithm < IPSEC_INTEG_ALG_SHA1_96 ||
5154 mp->integrity_algorithm >= IPSEC_INTEG_N_ALG)
5156 clib_warning ("unsupported integ-alg: '%U'", format_ipsec_integ_alg,
5157 mp->integrity_algorithm);
5158 rv = VNET_API_ERROR_UNIMPLEMENTED;
5163 /*Special cases, aes-gcm-128 encryption */
5164 if (mp->crypto_algorithm == IPSEC_CRYPTO_ALG_AES_GCM_128)
5166 if (mp->integrity_algorithm != IPSEC_INTEG_ALG_NONE
5167 && mp->integrity_algorithm != IPSEC_INTEG_ALG_AES_GCM_128)
5170 ("unsupported: aes-gcm-128 crypto-alg needs none as integ-alg");
5171 rv = VNET_API_ERROR_UNIMPLEMENTED;
5174 else /*set integ-alg internally to aes-gcm-128 */
5175 mp->integrity_algorithm = IPSEC_INTEG_ALG_AES_GCM_128;
5177 else if (mp->integrity_algorithm == IPSEC_INTEG_ALG_AES_GCM_128)
5179 clib_warning ("unsupported integ-alg: aes-gcm-128");
5180 rv = VNET_API_ERROR_UNIMPLEMENTED;
5183 else if (mp->integrity_algorithm == IPSEC_INTEG_ALG_NONE)
5185 clib_warning ("unsupported integ-alg: none");
5186 rv = VNET_API_ERROR_UNIMPLEMENTED;
5191 sa.integ_alg = mp->integrity_algorithm;
5192 sa.integ_key_len = mp->integrity_key_length;
5193 clib_memcpy (&sa.integ_key, mp->integrity_key, sizeof (sa.integ_key));
5194 sa.use_esn = mp->use_extended_sequence_number;
5195 sa.is_tunnel = mp->is_tunnel;
5196 sa.is_tunnel_ip6 = mp->is_tunnel_ipv6;
5197 if (sa.is_tunnel_ip6)
5199 clib_memcpy (&sa.tunnel_src_addr, mp->tunnel_src_address, 16);
5200 clib_memcpy (&sa.tunnel_dst_addr, mp->tunnel_dst_address, 16);
5204 clib_memcpy (&sa.tunnel_src_addr.ip4.data, mp->tunnel_src_address, 4);
5205 clib_memcpy (&sa.tunnel_dst_addr.ip4.data, mp->tunnel_dst_address, 4);
5208 rv = ipsec_add_del_sa (vm, &sa, mp->is_add);
5210 rv = VNET_API_ERROR_UNIMPLEMENTED;
5215 REPLY_MACRO (VL_API_IPSEC_SAD_ADD_DEL_ENTRY_REPLY);
5219 vl_api_ikev2_profile_add_del_t_handler (vl_api_ikev2_profile_add_del_t * mp)
5221 vl_api_ikev2_profile_add_del_reply_t *rmp;
5225 vlib_main_t *vm = vlib_get_main ();
5226 clib_error_t *error;
5227 u8 *tmp = format (0, "%s", mp->name);
5228 error = ikev2_add_del_profile (vm, tmp, mp->is_add);
5231 rv = VNET_API_ERROR_UNSPECIFIED;
5233 rv = VNET_API_ERROR_UNIMPLEMENTED;
5236 REPLY_MACRO (VL_API_IKEV2_PROFILE_ADD_DEL_REPLY);
5240 vl_api_ikev2_profile_set_auth_t_handler
5241 (vl_api_ikev2_profile_set_auth_t * mp)
5243 vl_api_ikev2_profile_set_auth_reply_t *rmp;
5247 vlib_main_t *vm = vlib_get_main ();
5248 clib_error_t *error;
5249 u8 *tmp = format (0, "%s", mp->name);
5250 u8 *data = vec_new (u8, mp->data_len);
5251 clib_memcpy (data, mp->data, mp->data_len);
5252 error = ikev2_set_profile_auth (vm, tmp, mp->auth_method, data, mp->is_hex);
5256 rv = VNET_API_ERROR_UNSPECIFIED;
5258 rv = VNET_API_ERROR_UNIMPLEMENTED;
5261 REPLY_MACRO (VL_API_IKEV2_PROFILE_SET_AUTH_REPLY);
5265 vl_api_ikev2_profile_set_id_t_handler (vl_api_ikev2_profile_set_id_t * mp)
5267 vl_api_ikev2_profile_add_del_reply_t *rmp;
5271 vlib_main_t *vm = vlib_get_main ();
5272 clib_error_t *error;
5273 u8 *tmp = format (0, "%s", mp->name);
5274 u8 *data = vec_new (u8, mp->data_len);
5275 clib_memcpy (data, mp->data, mp->data_len);
5276 error = ikev2_set_profile_id (vm, tmp, mp->id_type, data, mp->is_local);
5280 rv = VNET_API_ERROR_UNSPECIFIED;
5282 rv = VNET_API_ERROR_UNIMPLEMENTED;
5285 REPLY_MACRO (VL_API_IKEV2_PROFILE_SET_ID_REPLY);
5289 vl_api_ikev2_profile_set_ts_t_handler (vl_api_ikev2_profile_set_ts_t * mp)
5291 vl_api_ikev2_profile_set_ts_reply_t *rmp;
5295 vlib_main_t *vm = vlib_get_main ();
5296 clib_error_t *error;
5297 u8 *tmp = format (0, "%s", mp->name);
5298 error = ikev2_set_profile_ts (vm, tmp, mp->proto, mp->start_port,
5299 mp->end_port, (ip4_address_t) mp->start_addr,
5300 (ip4_address_t) mp->end_addr, mp->is_local);
5303 rv = VNET_API_ERROR_UNSPECIFIED;
5305 rv = VNET_API_ERROR_UNIMPLEMENTED;
5308 REPLY_MACRO (VL_API_IKEV2_PROFILE_SET_TS_REPLY);
5312 vl_api_ikev2_set_local_key_t_handler (vl_api_ikev2_set_local_key_t * mp)
5314 vl_api_ikev2_profile_set_ts_reply_t *rmp;
5318 vlib_main_t *vm = vlib_get_main ();
5319 clib_error_t *error;
5321 error = ikev2_set_local_key (vm, mp->key_file);
5323 rv = VNET_API_ERROR_UNSPECIFIED;
5325 rv = VNET_API_ERROR_UNIMPLEMENTED;
5328 REPLY_MACRO (VL_API_IKEV2_SET_LOCAL_KEY_REPLY);
5332 vl_api_ipsec_sa_set_key_t_handler (vl_api_ipsec_sa_set_key_t * mp)
5334 vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
5335 vl_api_ipsec_sa_set_key_reply_t *rmp;
5339 sa.id = ntohl (mp->sa_id);
5340 sa.crypto_key_len = mp->crypto_key_length;
5341 clib_memcpy (&sa.crypto_key, mp->crypto_key, sizeof (sa.crypto_key));
5342 sa.integ_key_len = mp->integrity_key_length;
5343 clib_memcpy (&sa.integ_key, mp->integrity_key, sizeof (sa.integ_key));
5345 rv = ipsec_set_sa_key (vm, &sa);
5347 rv = VNET_API_ERROR_UNIMPLEMENTED;
5350 REPLY_MACRO (VL_API_IPSEC_SA_SET_KEY_REPLY);
5353 static void vl_api_cop_interface_enable_disable_t_handler
5354 (vl_api_cop_interface_enable_disable_t * mp)
5356 vl_api_cop_interface_enable_disable_reply_t *rmp;
5358 u32 sw_if_index = ntohl (mp->sw_if_index);
5361 VALIDATE_SW_IF_INDEX (mp);
5363 enable_disable = (int) mp->enable_disable;
5365 rv = cop_interface_enable_disable (sw_if_index, enable_disable);
5367 BAD_SW_IF_INDEX_LABEL;
5369 REPLY_MACRO (VL_API_COP_INTERFACE_ENABLE_DISABLE_REPLY);
5372 static void vl_api_cop_whitelist_enable_disable_t_handler
5373 (vl_api_cop_whitelist_enable_disable_t * mp)
5375 vl_api_cop_whitelist_enable_disable_reply_t *rmp;
5376 cop_whitelist_enable_disable_args_t _a, *a = &_a;
5377 u32 sw_if_index = ntohl (mp->sw_if_index);
5380 VALIDATE_SW_IF_INDEX (mp);
5382 a->sw_if_index = sw_if_index;
5385 a->default_cop = mp->default_cop;
5386 a->fib_id = ntohl (mp->fib_id);
5388 rv = cop_whitelist_enable_disable (a);
5390 BAD_SW_IF_INDEX_LABEL;
5392 REPLY_MACRO (VL_API_COP_WHITELIST_ENABLE_DISABLE_REPLY);
5396 vl_api_get_node_graph_t_handler (vl_api_get_node_graph_t * mp)
5400 api_main_t *am = &api_main;
5401 vlib_main_t *vm = vlib_get_main ();
5403 vl_api_get_node_graph_reply_t *rmp;
5405 pthread_mutex_lock (&am->vlib_rp->mutex);
5406 oldheap = svm_push_data_heap (am->vlib_rp);
5409 * Keep the number of memcpy ops to a minimum (e.g. 1).
5411 vec_validate (vector, 16384);
5412 vec_reset_length (vector);
5415 vector = vlib_node_serialize (&vm->node_main, vector,
5416 (u32) ~ 0 /* all threads */ ,
5417 1 /* include nexts */ ,
5418 1 /* include stats */ );
5420 svm_pop_heap (oldheap);
5421 pthread_mutex_unlock (&am->vlib_rp->mutex);
5424 REPLY_MACRO2(VL_API_GET_NODE_GRAPH_REPLY,
5426 rmp->reply_in_shmem = (uword) vector;
5432 vl_api_ioam_enable_t_handler (vl_api_ioam_enable_t * mp)
5435 vl_api_ioam_enable_reply_t *rmp;
5436 clib_error_t *error;
5438 /* Ignoring the profile id as currently a single profile
5440 error = ip6_ioam_enable (mp->trace_enable, mp->pot_enable,
5441 mp->seqno, mp->analyse);
5444 clib_error_report (error);
5445 rv = clib_error_get_code (error);
5448 REPLY_MACRO (VL_API_IOAM_ENABLE_REPLY);
5452 vl_api_ioam_disable_t_handler (vl_api_ioam_disable_t * mp)
5455 vl_api_ioam_disable_reply_t *rmp;
5456 clib_error_t *error;
5458 error = clear_ioam_rewrite_fn ();
5461 clib_error_report (error);
5462 rv = clib_error_get_code (error);
5465 REPLY_MACRO (VL_API_IOAM_DISABLE_REPLY);
5469 vl_api_af_packet_create_t_handler (vl_api_af_packet_create_t * mp)
5471 vlib_main_t *vm = vlib_get_main ();
5472 vl_api_af_packet_create_reply_t *rmp;
5474 u8 *host_if_name = NULL;
5477 host_if_name = format (0, "%s", mp->host_if_name);
5478 vec_add1 (host_if_name, 0);
5480 rv = af_packet_create_if (vm, host_if_name,
5481 mp->use_random_hw_addr ? 0 : mp->hw_addr,
5484 vec_free (host_if_name);
5487 REPLY_MACRO2(VL_API_AF_PACKET_CREATE_REPLY,
5489 rmp->sw_if_index = clib_host_to_net_u32(sw_if_index);
5495 vl_api_af_packet_delete_t_handler (vl_api_af_packet_delete_t * mp)
5497 vlib_main_t *vm = vlib_get_main ();
5498 vl_api_af_packet_delete_reply_t *rmp;
5500 u8 *host_if_name = NULL;
5502 host_if_name = format (0, "%s", mp->host_if_name);
5503 vec_add1 (host_if_name, 0);
5505 rv = af_packet_delete_if (vm, host_if_name);
5507 vec_free (host_if_name);
5509 REPLY_MACRO (VL_API_AF_PACKET_DELETE_REPLY);
5513 vl_api_policer_add_del_t_handler (vl_api_policer_add_del_t * mp)
5515 vlib_main_t *vm = vlib_get_main ();
5516 vl_api_policer_add_del_reply_t *rmp;
5519 sse2_qos_pol_cfg_params_st cfg;
5520 clib_error_t *error;
5523 name = format (0, "%s", mp->name);
5525 memset (&cfg, 0, sizeof (cfg));
5527 cfg.rnd_type = mp->round_type;
5528 cfg.rate_type = mp->rate_type;
5529 cfg.rb.kbps.cir_kbps = mp->cir;
5530 cfg.rb.kbps.eir_kbps = mp->eir;
5531 cfg.rb.kbps.cb_bytes = mp->cb;
5532 cfg.rb.kbps.eb_bytes = mp->eb;
5533 cfg.conform_action.action_type = mp->conform_action_type;
5534 cfg.conform_action.dscp = mp->conform_dscp;
5535 cfg.exceed_action.action_type = mp->exceed_action_type;
5536 cfg.exceed_action.dscp = mp->exceed_dscp;
5537 cfg.violate_action.action_type = mp->violate_action_type;
5538 cfg.violate_action.dscp = mp->violate_dscp;
5539 cfg.color_aware = mp->color_aware;
5541 error = policer_add_del (vm, name, &cfg, &policer_index, mp->is_add);
5544 rv = VNET_API_ERROR_UNSPECIFIED;
5547 REPLY_MACRO2(VL_API_POLICER_ADD_DEL_REPLY,
5549 if (rv == 0 && mp->is_add)
5550 rmp->policer_index = ntohl(policer_index);
5552 rmp->policer_index = ~0;
5558 send_policer_details (u8 * name,
5559 sse2_qos_pol_cfg_params_st * config,
5560 policer_read_response_type_st * templ,
5561 unix_shared_memory_queue_t * q, u32 context)
5563 vl_api_policer_details_t *mp;
5565 mp = vl_msg_api_alloc (sizeof (*mp));
5566 memset (mp, 0, sizeof (*mp));
5567 mp->_vl_msg_id = ntohs (VL_API_POLICER_DETAILS);
5568 mp->context = context;
5569 mp->cir = htonl (config->rb.kbps.cir_kbps);
5570 mp->eir = htonl (config->rb.kbps.eir_kbps);
5571 mp->cb = htonl (config->rb.kbps.cb_bytes);
5572 mp->eb = htonl (config->rb.kbps.eb_bytes);
5573 mp->rate_type = config->rate_type;
5574 mp->round_type = config->rnd_type;
5575 mp->type = config->rfc;
5576 mp->conform_action_type = config->conform_action.action_type;
5577 mp->conform_dscp = config->conform_action.dscp;
5578 mp->exceed_action_type = config->exceed_action.action_type;
5579 mp->exceed_dscp = config->exceed_action.dscp;
5580 mp->violate_action_type = config->violate_action.action_type;
5581 mp->violate_dscp = config->violate_action.dscp;
5582 mp->single_rate = templ->single_rate ? 1 : 0;
5583 mp->color_aware = templ->color_aware ? 1 : 0;
5584 mp->scale = htonl (templ->scale);
5585 mp->cir_tokens_per_period = htonl (templ->cir_tokens_per_period);
5586 mp->pir_tokens_per_period = htonl (templ->pir_tokens_per_period);
5587 mp->current_limit = htonl (templ->current_limit);
5588 mp->current_bucket = htonl (templ->current_bucket);
5589 mp->extended_limit = htonl (templ->extended_limit);
5590 mp->extended_bucket = htonl (templ->extended_bucket);
5591 mp->last_update_time = clib_host_to_net_u64 (templ->last_update_time);
5593 strncpy ((char *) mp->name, (char *) name, ARRAY_LEN (mp->name) - 1);
5595 vl_msg_api_send_shmem (q, (u8 *) & mp);
5599 vl_api_policer_dump_t_handler (vl_api_policer_dump_t * mp)
5601 unix_shared_memory_queue_t *q;
5602 vnet_policer_main_t *pm = &vnet_policer_main;
5608 sse2_qos_pol_cfg_params_st *config;
5609 policer_read_response_type_st *templ;
5611 q = vl_api_client_index_to_input_queue (mp->client_index);
5615 if (mp->match_name_valid)
5617 match_name = format (0, "%s%c", mp->match_name, 0);
5620 if (mp->match_name_valid)
5622 p = hash_get_mem (pm->policer_config_by_name, match_name);
5626 config = pool_elt_at_index (pm->configs, pool_index);
5627 templ = pool_elt_at_index (pm->policer_templates, pool_index);
5628 send_policer_details (match_name, config, templ, q, mp->context);
5634 hash_foreach_pair (hp, pm->policer_config_by_name,
5636 name = (u8 *) hp->key;
5637 pool_index = hp->value[0];
5638 config = pool_elt_at_index (pm->configs, pool_index);
5639 templ = pool_elt_at_index (pm->policer_templates, pool_index);
5640 send_policer_details(name, config, templ, q, mp->context);
5647 vl_api_policer_classify_set_interface_t_handler
5648 (vl_api_policer_classify_set_interface_t * mp)
5650 vlib_main_t *vm = vlib_get_main ();
5651 vl_api_policer_classify_set_interface_reply_t *rmp;
5653 u32 sw_if_index, ip4_table_index, ip6_table_index, l2_table_index;
5655 ip4_table_index = ntohl (mp->ip4_table_index);
5656 ip6_table_index = ntohl (mp->ip6_table_index);
5657 l2_table_index = ntohl (mp->l2_table_index);
5658 sw_if_index = ntohl (mp->sw_if_index);
5660 VALIDATE_SW_IF_INDEX (mp);
5662 rv = vnet_set_policer_classify_intfc (vm, sw_if_index, ip4_table_index,
5663 ip6_table_index, l2_table_index,
5666 BAD_SW_IF_INDEX_LABEL;
5668 REPLY_MACRO (VL_API_POLICER_CLASSIFY_SET_INTERFACE_REPLY);
5672 send_policer_classify_details (u32 sw_if_index,
5674 unix_shared_memory_queue_t * q, u32 context)
5676 vl_api_policer_classify_details_t *mp;
5678 mp = vl_msg_api_alloc (sizeof (*mp));
5679 memset (mp, 0, sizeof (*mp));
5680 mp->_vl_msg_id = ntohs (VL_API_POLICER_CLASSIFY_DETAILS);
5681 mp->context = context;
5682 mp->sw_if_index = htonl (sw_if_index);
5683 mp->table_index = htonl (table_index);
5685 vl_msg_api_send_shmem (q, (u8 *) & mp);
5689 vl_api_policer_classify_dump_t_handler (vl_api_policer_classify_dump_t * mp)
5691 unix_shared_memory_queue_t *q;
5692 policer_classify_main_t *pcm = &policer_classify_main;
5696 q = vl_api_client_index_to_input_queue (mp->client_index);
5700 vec_tbl = pcm->classify_table_index_by_sw_if_index[mp->type];
5702 if (vec_len (vec_tbl))
5704 for (i = 0; i < vec_len (vec_tbl); i++)
5706 if (vec_elt (vec_tbl, i) == ~0)
5709 send_policer_classify_details (i, vec_elt (vec_tbl, i), q,
5716 vl_api_netmap_create_t_handler (vl_api_netmap_create_t * mp)
5718 vlib_main_t *vm = vlib_get_main ();
5719 vl_api_netmap_create_reply_t *rmp;
5723 if_name = format (0, "%s", mp->netmap_if_name);
5724 vec_add1 (if_name, 0);
5727 netmap_create_if (vm, if_name, mp->use_random_hw_addr ? 0 : mp->hw_addr,
5728 mp->is_pipe, mp->is_master, 0);
5732 REPLY_MACRO (VL_API_NETMAP_CREATE_REPLY);
5736 vl_api_netmap_delete_t_handler (vl_api_netmap_delete_t * mp)
5738 vlib_main_t *vm = vlib_get_main ();
5739 vl_api_netmap_delete_reply_t *rmp;
5743 if_name = format (0, "%s", mp->netmap_if_name);
5744 vec_add1 (if_name, 0);
5746 rv = netmap_delete_if (vm, if_name);
5750 REPLY_MACRO (VL_API_NETMAP_DELETE_REPLY);
5754 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_fib_details_t * mp)
5756 clib_warning ("BUG");
5759 typedef struct mpls_tunnel_send_walk_ctx_t_
5761 unix_shared_memory_queue_t *q;
5764 } mpls_tunnel_send_walk_ctx_t;
5767 send_mpls_tunnel_entry (u32 mti, void *arg)
5769 mpls_tunnel_send_walk_ctx_t *ctx;
5770 vl_api_mpls_tunnel_details_t *mp;
5771 const mpls_tunnel_t *mt;
5776 if (~0 != ctx->index && mti != ctx->index)
5779 mt = mpls_tunnel_get (mti);
5780 nlabels = vec_len (mt->mt_label_stack);
5782 mp = vl_msg_api_alloc (sizeof (*mp) + nlabels * sizeof (u32));
5783 memset (mp, 0, sizeof (*mp));
5784 mp->_vl_msg_id = ntohs (VL_API_MPLS_TUNNEL_DETAILS);
5785 mp->context = ctx->context;
5787 mp->tunnel_index = ntohl (mti);
5788 memcpy (mp->mt_next_hop_out_labels,
5789 mt->mt_label_stack, nlabels * sizeof (u32));
5793 vl_msg_api_send_shmem (ctx->q, (u8 *) & mp);
5797 vl_api_mpls_tunnel_dump_t_handler (vl_api_mpls_tunnel_dump_t * mp)
5799 unix_shared_memory_queue_t *q;
5801 q = vl_api_client_index_to_input_queue (mp->client_index);
5805 mpls_tunnel_send_walk_ctx_t ctx = {
5807 .index = ntohl (mp->tunnel_index),
5808 .context = mp->context,
5810 mpls_tunnel_walk (send_mpls_tunnel_entry, &ctx);
5814 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
5816 clib_warning ("BUG");
5820 vl_api_mpls_fib_details_t_endian (vl_api_mpls_fib_details_t * mp)
5822 clib_warning ("BUG");
5826 vl_api_mpls_fib_details_t_print (vl_api_mpls_fib_details_t * mp)
5828 clib_warning ("BUG");
5832 send_mpls_fib_details (vpe_api_main_t * am,
5833 unix_shared_memory_queue_t * q,
5834 u32 table_id, u32 label, u32 eos,
5835 fib_route_path_encode_t * api_rpaths, u32 context)
5837 vl_api_mpls_fib_details_t *mp;
5838 fib_route_path_encode_t *api_rpath;
5839 vl_api_fib_path2_t *fp;
5842 path_count = vec_len (api_rpaths);
5843 mp = vl_msg_api_alloc (sizeof (*mp) + path_count * sizeof (*fp));
5846 memset (mp, 0, sizeof (*mp));
5847 mp->_vl_msg_id = ntohs (VL_API_MPLS_FIB_DETAILS);
5848 mp->context = context;
5850 mp->table_id = htonl (table_id);
5852 mp->label = htonl (label);
5854 mp->count = htonl (path_count);
5856 vec_foreach (api_rpath, api_rpaths)
5858 memset (fp, 0, sizeof (*fp));
5859 fp->weight = htonl (api_rpath->rpath.frp_weight);
5860 fp->sw_if_index = htonl (api_rpath->rpath.frp_sw_if_index);
5861 copy_fib_next_hop (api_rpath, fp);
5865 vl_msg_api_send_shmem (q, (u8 *) & mp);
5869 vl_api_mpls_fib_dump_t_handler (vl_api_mpls_fib_dump_t * mp)
5871 vpe_api_main_t *am = &vpe_api_main;
5872 unix_shared_memory_queue_t *q;
5873 mpls_main_t *mm = &mpls_main;
5874 fib_table_t *fib_table;
5875 fib_node_index_t lfei, *lfeip, *lfeis = NULL;
5879 fib_route_path_encode_t *api_rpaths;
5881 q = vl_api_client_index_to_input_queue (mp->client_index);
5886 pool_foreach (fib_table, mm->fibs,
5888 hash_foreach(key, lfei, fib_table->mpls.mf_entries,
5890 vec_add1(lfeis, lfei);
5893 vec_sort_with_function(lfeis, fib_entry_cmp_for_sort);
5895 vec_foreach(lfeip, lfeis)
5897 fib_entry_get_prefix(*lfeip, &pfx);
5898 fib_index = fib_entry_get_fib_index(*lfeip);
5899 fib_table = fib_table_get(fib_index, pfx.fp_proto);
5901 fib_entry_encode(*lfeip, &api_rpaths);
5902 send_mpls_fib_details (am, q,
5903 fib_table->ft_table_id,
5908 vec_free(api_rpaths);
5915 vl_api_classify_table_ids_t_handler (vl_api_classify_table_ids_t * mp)
5917 unix_shared_memory_queue_t *q;
5919 q = vl_api_client_index_to_input_queue (mp->client_index);
5923 vnet_classify_main_t *cm = &vnet_classify_main;
5924 vnet_classify_table_t *t;
5929 pool_foreach (t, cm->tables,
5931 vec_add1 (table_ids, ntohl(t - cm->tables));
5934 count = vec_len (table_ids);
5936 vl_api_classify_table_ids_reply_t *rmp;
5937 rmp = vl_msg_api_alloc_as_if_client (sizeof (*rmp) + count * sizeof (u32));
5938 rmp->_vl_msg_id = ntohs (VL_API_CLASSIFY_TABLE_IDS_REPLY);
5939 rmp->context = mp->context;
5940 rmp->count = ntohl (count);
5941 clib_memcpy (rmp->ids, table_ids, count * sizeof (u32));
5944 vl_msg_api_send_shmem (q, (u8 *) & rmp);
5946 vec_free (table_ids);
5950 vl_api_classify_table_by_interface_t_handler
5951 (vl_api_classify_table_by_interface_t * mp)
5953 vl_api_classify_table_by_interface_reply_t *rmp;
5956 u32 sw_if_index = ntohl (mp->sw_if_index);
5959 vec_validate (acl, INPUT_ACL_N_TABLES - 1);
5962 VALIDATE_SW_IF_INDEX (mp);
5964 input_acl_main_t *am = &input_acl_main;
5969 for (type = 0; type < INPUT_ACL_N_TABLES; type++)
5971 u32 *vec_tbl = am->classify_table_index_by_sw_if_index[type];
5972 if (vec_len (vec_tbl))
5974 for (if_idx = 0; if_idx < vec_len (vec_tbl); if_idx++)
5976 if (vec_elt (vec_tbl, if_idx) == ~0 || sw_if_index != if_idx)
5980 acl[type] = vec_elt (vec_tbl, if_idx);
5985 BAD_SW_IF_INDEX_LABEL;
5988 REPLY_MACRO2(VL_API_CLASSIFY_TABLE_BY_INTERFACE_REPLY,
5990 rmp->sw_if_index = ntohl(sw_if_index);
5991 rmp->l2_table_id = ntohl(acl[INPUT_ACL_TABLE_L2]);
5992 rmp->ip4_table_id = ntohl(acl[INPUT_ACL_TABLE_IP4]);
5993 rmp->ip6_table_id = ntohl(acl[INPUT_ACL_TABLE_IP6]);
6000 vl_api_classify_table_info_t_handler (vl_api_classify_table_info_t * mp)
6002 unix_shared_memory_queue_t *q;
6004 q = vl_api_client_index_to_input_queue (mp->client_index);
6008 vl_api_classify_table_info_reply_t *rmp = 0;
6010 vnet_classify_main_t *cm = &vnet_classify_main;
6011 u32 table_id = ntohl (mp->table_id);
6012 vnet_classify_table_t *t;
6015 pool_foreach (t, cm->tables,
6017 if (table_id == t - cm->tables)
6019 rmp = vl_msg_api_alloc_as_if_client
6020 (sizeof (*rmp) + t->match_n_vectors * sizeof (u32x4));
6021 rmp->_vl_msg_id = ntohs (VL_API_CLASSIFY_TABLE_INFO_REPLY);
6022 rmp->context = mp->context;
6023 rmp->table_id = ntohl(table_id);
6024 rmp->nbuckets = ntohl(t->nbuckets);
6025 rmp->match_n_vectors = ntohl(t->match_n_vectors);
6026 rmp->skip_n_vectors = ntohl(t->skip_n_vectors);
6027 rmp->active_sessions = ntohl(t->active_elements);
6028 rmp->next_table_index = ntohl(t->next_table_index);
6029 rmp->miss_next_index = ntohl(t->miss_next_index);
6030 rmp->mask_length = ntohl(t->match_n_vectors * sizeof (u32x4));
6031 clib_memcpy(rmp->mask, t->mask, t->match_n_vectors * sizeof(u32x4));
6040 rmp = vl_msg_api_alloc (sizeof (*rmp));
6041 rmp->_vl_msg_id = ntohs ((VL_API_CLASSIFY_TABLE_INFO_REPLY));
6042 rmp->context = mp->context;
6043 rmp->retval = ntohl (VNET_API_ERROR_CLASSIFY_TABLE_NOT_FOUND);
6046 vl_msg_api_send_shmem (q, (u8 *) & rmp);
6050 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
6053 clib_warning ("BUG");
6057 send_classify_session_details (unix_shared_memory_queue_t * q,
6060 vnet_classify_entry_t * e, u32 context)
6062 vl_api_classify_session_details_t *rmp;
6064 rmp = vl_msg_api_alloc (sizeof (*rmp));
6065 memset (rmp, 0, sizeof (*rmp));
6066 rmp->_vl_msg_id = ntohs (VL_API_CLASSIFY_SESSION_DETAILS);
6067 rmp->context = context;
6068 rmp->table_id = ntohl (table_id);
6069 rmp->hit_next_index = ntohl (e->next_index);
6070 rmp->advance = ntohl (e->advance);
6071 rmp->opaque_index = ntohl (e->opaque_index);
6072 rmp->match_length = ntohl (match_length);
6073 clib_memcpy (rmp->match, e->key, match_length);
6075 vl_msg_api_send_shmem (q, (u8 *) & rmp);
6079 vl_api_classify_session_dump_t_handler (vl_api_classify_session_dump_t * mp)
6081 vnet_classify_main_t *cm = &vnet_classify_main;
6082 unix_shared_memory_queue_t *q;
6084 u32 table_id = ntohl (mp->table_id);
6085 vnet_classify_table_t *t;
6087 q = vl_api_client_index_to_input_queue (mp->client_index);
6092 pool_foreach (t, cm->tables,
6094 if (table_id == t - cm->tables)
6096 vnet_classify_bucket_t * b;
6097 vnet_classify_entry_t * v, * save_v;
6100 for (i = 0; i < t->nbuckets; i++)
6102 b = &t->buckets [i];
6106 save_v = vnet_classify_get_entry (t, b->offset);
6107 for (j = 0; j < (1<<b->log2_pages); j++)
6109 for (k = 0; k < t->entries_per_page; k++)
6111 v = vnet_classify_entry_at_index
6112 (t, save_v, j*t->entries_per_page + k);
6113 if (vnet_classify_entry_is_free (v))
6116 send_classify_session_details
6117 (q, table_id, t->match_n_vectors * sizeof (u32x4),
6129 vl_api_set_ipfix_exporter_t_handler (vl_api_set_ipfix_exporter_t * mp)
6131 vlib_main_t *vm = vlib_get_main ();
6132 flow_report_main_t *frm = &flow_report_main;
6133 vl_api_set_ipfix_exporter_reply_t *rmp;
6134 ip4_address_t collector, src;
6135 u16 collector_port = UDP_DST_PORT_ipfix;
6137 u32 template_interval;
6143 memcpy (collector.data, mp->collector_address, sizeof (collector.data));
6144 collector_port = ntohs (mp->collector_port);
6145 if (collector_port == (u16) ~ 0)
6146 collector_port = UDP_DST_PORT_ipfix;
6147 memcpy (src.data, mp->src_address, sizeof (src.data));
6148 fib_id = ntohl (mp->vrf_id);
6150 ip4_main_t *im = &ip4_main;
6157 uword *p = hash_get (im->fib_index_by_table_id, fib_id);
6160 rv = VNET_API_ERROR_NO_SUCH_FIB;
6166 path_mtu = ntohl (mp->path_mtu);
6168 path_mtu = 512; // RFC 7011 section 10.3.3.
6169 template_interval = ntohl (mp->template_interval);
6170 if (template_interval == ~0)
6171 template_interval = 20;
6172 udp_checksum = mp->udp_checksum;
6174 if (collector.as_u32 == 0)
6176 rv = VNET_API_ERROR_INVALID_VALUE;
6180 if (src.as_u32 == 0)
6182 rv = VNET_API_ERROR_INVALID_VALUE;
6186 if (path_mtu > 1450 /* vpp does not support fragmentation */ )
6188 rv = VNET_API_ERROR_INVALID_VALUE;
6194 rv = VNET_API_ERROR_INVALID_VALUE;
6198 /* Reset report streams if we are reconfiguring IP addresses */
6199 if (frm->ipfix_collector.as_u32 != collector.as_u32 ||
6200 frm->src_address.as_u32 != src.as_u32 ||
6201 frm->collector_port != collector_port)
6202 vnet_flow_reports_reset (frm);
6204 frm->ipfix_collector.as_u32 = collector.as_u32;
6205 frm->collector_port = collector_port;
6206 frm->src_address.as_u32 = src.as_u32;
6207 frm->fib_index = fib_index;
6208 frm->path_mtu = path_mtu;
6209 frm->template_interval = template_interval;
6210 frm->udp_checksum = udp_checksum;
6212 /* Turn on the flow reporting process */
6213 vlib_process_signal_event (vm, flow_report_process_node.index, 1, 0);
6216 REPLY_MACRO (VL_API_SET_IPFIX_EXPORTER_REPLY);
6220 vl_api_ipfix_exporter_dump_t_handler (vl_api_ipfix_exporter_dump_t * mp)
6222 flow_report_main_t *frm = &flow_report_main;
6223 unix_shared_memory_queue_t *q;
6224 vl_api_ipfix_exporter_details_t *rmp;
6225 ip4_main_t *im = &ip4_main;
6228 q = vl_api_client_index_to_input_queue (mp->client_index);
6232 rmp = vl_msg_api_alloc (sizeof (*rmp));
6233 memset (rmp, 0, sizeof (*rmp));
6234 rmp->_vl_msg_id = ntohs (VL_API_IPFIX_EXPORTER_DETAILS);
6235 rmp->context = mp->context;
6236 memcpy (rmp->collector_address, frm->ipfix_collector.data,
6237 sizeof (frm->ipfix_collector.data));
6238 rmp->collector_port = htons (frm->collector_port);
6239 memcpy (rmp->src_address, frm->src_address.data,
6240 sizeof (frm->src_address.data));
6241 if (frm->fib_index == ~0)
6244 vrf_id = im->fibs[frm->fib_index].ft_table_id;
6245 rmp->vrf_id = htonl (vrf_id);
6246 rmp->path_mtu = htonl (frm->path_mtu);
6247 rmp->template_interval = htonl (frm->template_interval);
6248 rmp->udp_checksum = (frm->udp_checksum != 0);
6250 vl_msg_api_send_shmem (q, (u8 *) & rmp);
6254 vl_api_set_ipfix_classify_stream_t_handler
6255 (vl_api_set_ipfix_classify_stream_t * mp)
6257 vl_api_set_ipfix_classify_stream_reply_t *rmp;
6258 flow_report_classify_main_t *fcm = &flow_report_classify_main;
6259 flow_report_main_t *frm = &flow_report_main;
6261 u32 src_port = UDP_DST_PORT_ipfix;
6264 domain_id = ntohl (mp->domain_id);
6265 src_port = ntohs (mp->src_port);
6267 if (fcm->src_port != 0 &&
6268 (fcm->domain_id != domain_id || fcm->src_port != (u16) src_port))
6270 int rv = vnet_stream_change (frm, fcm->domain_id, fcm->src_port,
6271 domain_id, (u16) src_port);
6275 fcm->domain_id = domain_id;
6276 fcm->src_port = (u16) src_port;
6278 REPLY_MACRO (VL_API_SET_IPFIX_CLASSIFY_STREAM_REPLY);
6282 vl_api_ipfix_classify_stream_dump_t_handler
6283 (vl_api_ipfix_classify_stream_dump_t * mp)
6285 flow_report_classify_main_t *fcm = &flow_report_classify_main;
6286 unix_shared_memory_queue_t *q;
6287 vl_api_ipfix_classify_stream_details_t *rmp;
6289 q = vl_api_client_index_to_input_queue (mp->client_index);
6293 rmp = vl_msg_api_alloc (sizeof (*rmp));
6294 memset (rmp, 0, sizeof (*rmp));
6295 rmp->_vl_msg_id = ntohs (VL_API_IPFIX_CLASSIFY_STREAM_DETAILS);
6296 rmp->context = mp->context;
6297 rmp->domain_id = htonl (fcm->domain_id);
6298 rmp->src_port = htons (fcm->src_port);
6300 vl_msg_api_send_shmem (q, (u8 *) & rmp);
6304 vl_api_ipfix_classify_table_add_del_t_handler
6305 (vl_api_ipfix_classify_table_add_del_t * mp)
6307 vl_api_ipfix_classify_table_add_del_reply_t *rmp;
6308 flow_report_classify_main_t *fcm = &flow_report_classify_main;
6309 flow_report_main_t *frm = &flow_report_main;
6310 vnet_flow_report_add_del_args_t args;
6311 ipfix_classify_table_t *table;
6313 u32 classify_table_index;
6315 u8 transport_protocol;
6318 classify_table_index = ntohl (mp->table_id);
6319 ip_version = mp->ip_version;
6320 transport_protocol = mp->transport_protocol;
6321 is_add = mp->is_add;
6323 if (fcm->src_port == 0)
6325 /* call set_ipfix_classify_stream first */
6326 rv = VNET_API_ERROR_UNSPECIFIED;
6330 memset (&args, 0, sizeof (args));
6334 for (i = 0; i < vec_len (fcm->tables); i++)
6335 if (ipfix_classify_table_index_valid (i))
6336 if (fcm->tables[i].classify_table_index == classify_table_index)
6338 table = &fcm->tables[i];
6346 rv = VNET_API_ERROR_VALUE_EXIST;
6349 table = ipfix_classify_add_table ();
6350 table->classify_table_index = classify_table_index;
6356 rv = VNET_API_ERROR_NO_SUCH_ENTRY;
6361 table->ip_version = ip_version;
6362 table->transport_protocol = transport_protocol;
6364 args.opaque.as_uword = table - fcm->tables;
6365 args.rewrite_callback = ipfix_classify_template_rewrite;
6366 args.flow_data_callback = ipfix_classify_send_flows;
6367 args.is_add = is_add;
6368 args.domain_id = fcm->domain_id;
6369 args.src_port = fcm->src_port;
6371 rv = vnet_flow_report_add_del (frm, &args);
6373 /* If deleting, or add failed */
6374 if (is_add == 0 || (rv && is_add))
6375 ipfix_classify_delete_table (table - fcm->tables);
6378 REPLY_MACRO (VL_API_SET_IPFIX_CLASSIFY_STREAM_REPLY);
6382 send_ipfix_classify_table_details (u32 table_index,
6383 unix_shared_memory_queue_t * q,
6386 flow_report_classify_main_t *fcm = &flow_report_classify_main;
6387 vl_api_ipfix_classify_table_details_t *mp;
6389 ipfix_classify_table_t *table = &fcm->tables[table_index];
6391 mp = vl_msg_api_alloc (sizeof (*mp));
6392 memset (mp, 0, sizeof (*mp));
6393 mp->_vl_msg_id = ntohs (VL_API_IPFIX_CLASSIFY_TABLE_DETAILS);
6394 mp->context = context;
6395 mp->table_id = htonl (table->classify_table_index);
6396 mp->ip_version = table->ip_version;
6397 mp->transport_protocol = table->transport_protocol;
6399 vl_msg_api_send_shmem (q, (u8 *) & mp);
6403 vl_api_ipfix_classify_table_dump_t_handler
6404 (vl_api_ipfix_classify_table_dump_t * mp)
6406 flow_report_classify_main_t *fcm = &flow_report_classify_main;
6407 unix_shared_memory_queue_t *q;
6410 q = vl_api_client_index_to_input_queue (mp->client_index);
6414 for (i = 0; i < vec_len (fcm->tables); i++)
6415 if (ipfix_classify_table_index_valid (i))
6416 send_ipfix_classify_table_details (i, q, mp->context);
6420 vl_api_pg_create_interface_t_handler (vl_api_pg_create_interface_t * mp)
6422 vl_api_pg_create_interface_reply_t *rmp;
6425 pg_main_t *pg = &pg_main;
6426 u32 pg_if_id = pg_interface_add_or_get (pg, ntohl (mp->interface_id));
6427 pg_interface_t *pi = pool_elt_at_index (pg->interfaces, pg_if_id);
6430 REPLY_MACRO2(VL_API_PG_CREATE_INTERFACE_REPLY,
6432 rmp->sw_if_index = ntohl(pi->sw_if_index);
6438 vl_api_pg_capture_t_handler (vl_api_pg_capture_t * mp)
6440 vl_api_pg_capture_reply_t *rmp;
6443 vnet_main_t *vnm = vnet_get_main ();
6444 vnet_interface_main_t *im = &vnm->interface_main;
6445 vnet_hw_interface_t *hi = 0;
6447 u8 *intf_name = format (0, "pg%d", ntohl (mp->interface_id), 0);
6448 u32 hw_if_index = ~0;
6449 uword *p = hash_get_mem (im->hw_interface_by_name, intf_name);
6452 vec_free (intf_name);
6454 if (hw_if_index != ~0)
6456 pg_capture_args_t _a, *a = &_a;
6458 u32 len = ntohl (mp->pcap_name_length);
6459 u8 *pcap_file_name = vec_new (u8, len);
6460 clib_memcpy (pcap_file_name, mp->pcap_file_name, len);
6462 hi = vnet_get_sup_hw_interface (vnm, hw_if_index);
6463 a->hw_if_index = hw_if_index;
6464 a->dev_instance = hi->dev_instance;
6465 a->is_enabled = mp->is_enabled;
6466 a->pcap_file_name = pcap_file_name;
6467 a->count = ntohl (mp->count);
6469 clib_error_t *e = pg_capture (a);
6472 clib_error_report (e);
6473 rv = VNET_API_ERROR_CANNOT_CREATE_PCAP_FILE;
6476 vec_free (pcap_file_name);
6478 REPLY_MACRO (VL_API_PG_CAPTURE_REPLY);
6482 vl_api_pg_enable_disable_t_handler (vl_api_pg_enable_disable_t * mp)
6484 vl_api_pg_enable_disable_reply_t *rmp;
6487 pg_main_t *pg = &pg_main;
6488 u32 stream_index = ~0;
6490 int is_enable = mp->is_enabled != 0;
6491 u32 len = ntohl (mp->stream_name_length) - 1;
6495 u8 *stream_name = vec_new (u8, len);
6496 clib_memcpy (stream_name, mp->stream_name, len);
6497 uword *p = hash_get_mem (pg->stream_index_by_name, stream_name);
6500 vec_free (stream_name);
6503 pg_enable_disable (stream_index, is_enable);
6505 REPLY_MACRO (VL_API_PG_ENABLE_DISABLE_REPLY);
6509 vl_api_ip_source_and_port_range_check_add_del_t_handler
6510 (vl_api_ip_source_and_port_range_check_add_del_t * mp)
6512 vl_api_ip_source_and_port_range_check_add_del_reply_t *rmp;
6515 u8 is_ipv6 = mp->is_ipv6;
6516 u8 is_add = mp->is_add;
6517 u8 mask_length = mp->mask_length;
6518 ip4_address_t ip4_addr;
6519 ip6_address_t ip6_addr;
6521 u16 *high_ports = 0;
6523 u16 tmp_low, tmp_high;
6527 // Validate port range
6528 num_ranges = mp->number_of_ranges;
6529 if (num_ranges > 32)
6530 { // This is size of array in VPE.API
6531 rv = VNET_API_ERROR_EXCEEDED_NUMBER_OF_RANGES_CAPACITY;
6535 vec_reset_length (low_ports);
6536 vec_reset_length (high_ports);
6538 for (i = 0; i < num_ranges; i++)
6540 tmp_low = mp->low_ports[i];
6541 tmp_high = mp->high_ports[i];
6542 // If tmp_low <= tmp_high then only need to check tmp_low = 0
6543 // If tmp_low <= tmp_high then only need to check tmp_high > 65535
6544 if (tmp_low > tmp_high || tmp_low == 0 || tmp_high > 65535)
6546 rv = VNET_API_ERROR_INVALID_VALUE;
6549 vec_add1 (low_ports, tmp_low);
6550 vec_add1 (high_ports, tmp_high + 1);
6553 // Validate mask_length
6554 if ((is_ipv6 && mask_length > 128) || (!is_ipv6 && mask_length > 32))
6556 rv = VNET_API_ERROR_ADDRESS_LENGTH_MISMATCH;
6560 vrf_id = ntohl (mp->vrf_id);
6564 rv = VNET_API_ERROR_INVALID_VALUE;
6571 clib_memcpy (ip6_addr.as_u8, mp->address, sizeof (ip6_addr.as_u8));
6572 rv = ip6_source_and_port_range_check_add_del (&ip6_addr,
6576 high_ports, is_add);
6580 clib_memcpy (ip4_addr.data, mp->address, sizeof (ip4_addr));
6581 rv = ip4_source_and_port_range_check_add_del (&ip4_addr,
6585 high_ports, is_add);
6589 vec_free (low_ports);
6590 vec_free (high_ports);
6591 REPLY_MACRO (VL_API_IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY);
6595 vl_api_ip_source_and_port_range_check_interface_add_del_t_handler
6596 (vl_api_ip_source_and_port_range_check_interface_add_del_t * mp)
6598 vlib_main_t *vm = vlib_get_main ();
6599 vl_api_ip_source_and_port_range_check_interface_add_del_reply_t *rmp;
6600 ip4_main_t *im = &ip4_main;
6603 u32 fib_index[IP_SOURCE_AND_PORT_RANGE_CHECK_N_PROTOCOLS];
6604 u32 vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_N_PROTOCOLS];
6608 vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_PROTOCOL_TCP_OUT] =
6609 ntohl (mp->tcp_out_vrf_id);
6610 vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_PROTOCOL_UDP_OUT] =
6611 ntohl (mp->udp_out_vrf_id);
6612 vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_PROTOCOL_TCP_IN] =
6613 ntohl (mp->tcp_in_vrf_id);
6614 vrf_id[IP_SOURCE_AND_PORT_RANGE_CHECK_PROTOCOL_UDP_IN] =
6615 ntohl (mp->udp_in_vrf_id);
6618 for (i = 0; i < IP_SOURCE_AND_PORT_RANGE_CHECK_N_PROTOCOLS; i++)
6620 if (vrf_id[i] != 0 && vrf_id[i] != ~0)
6622 p = hash_get (im->fib_index_by_table_id, vrf_id[i]);
6626 rv = VNET_API_ERROR_INVALID_VALUE;
6630 fib_index[i] = p[0];
6635 sw_if_index = ntohl (mp->sw_if_index);
6637 VALIDATE_SW_IF_INDEX (mp);
6640 set_ip_source_and_port_range_check (vm, fib_index, sw_if_index,
6643 BAD_SW_IF_INDEX_LABEL;
6646 REPLY_MACRO (VL_API_IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY);
6650 vl_api_ipsec_gre_add_del_tunnel_t_handler (vl_api_ipsec_gre_add_del_tunnel_t *
6653 vl_api_ipsec_gre_add_del_tunnel_reply_t *rmp;
6655 vnet_ipsec_gre_add_del_tunnel_args_t _a, *a = &_a;
6656 u32 sw_if_index = ~0;
6658 /* Check src & dst are different */
6659 if (memcmp (mp->src_address, mp->dst_address, 4) == 0)
6661 rv = VNET_API_ERROR_SAME_SRC_DST;
6665 memset (a, 0, sizeof (*a));
6667 /* ip addresses sent in network byte order */
6668 clib_memcpy (&(a->src), mp->src_address, 4);
6669 clib_memcpy (&(a->dst), mp->dst_address, 4);
6670 a->is_add = mp->is_add;
6671 a->lsa = ntohl (mp->local_sa_id);
6672 a->rsa = ntohl (mp->remote_sa_id);
6674 rv = vnet_ipsec_gre_add_del_tunnel (a, &sw_if_index);
6678 REPLY_MACRO2(VL_API_GRE_ADD_DEL_TUNNEL_REPLY,
6680 rmp->sw_if_index = ntohl (sw_if_index);
6685 static void send_ipsec_gre_tunnel_details
6686 (ipsec_gre_tunnel_t * t, unix_shared_memory_queue_t * q, u32 context)
6688 vl_api_ipsec_gre_tunnel_details_t *rmp;
6690 rmp = vl_msg_api_alloc (sizeof (*rmp));
6691 memset (rmp, 0, sizeof (*rmp));
6692 rmp->_vl_msg_id = ntohs (VL_API_IPSEC_GRE_TUNNEL_DETAILS);
6693 clib_memcpy (rmp->src_address, &(t->tunnel_src), 4);
6694 clib_memcpy (rmp->dst_address, &(t->tunnel_dst), 4);
6695 rmp->sw_if_index = htonl (t->sw_if_index);
6696 rmp->local_sa_id = htonl (t->local_sa_id);
6697 rmp->remote_sa_id = htonl (t->remote_sa_id);
6698 rmp->context = context;
6700 vl_msg_api_send_shmem (q, (u8 *) & rmp);
6703 static void vl_api_ipsec_gre_tunnel_dump_t_handler
6704 (vl_api_ipsec_gre_tunnel_dump_t * mp)
6706 unix_shared_memory_queue_t *q;
6707 ipsec_gre_main_t *igm = &ipsec_gre_main;
6708 ipsec_gre_tunnel_t *t;
6711 q = vl_api_client_index_to_input_queue (mp->client_index);
6717 sw_if_index = ntohl (mp->sw_if_index);
6719 if (~0 == sw_if_index)
6722 pool_foreach (t, igm->tunnels,
6724 send_ipsec_gre_tunnel_details(t, q, mp->context);
6730 if ((sw_if_index >= vec_len (igm->tunnel_index_by_sw_if_index)) ||
6731 (~0 == igm->tunnel_index_by_sw_if_index[sw_if_index]))
6735 t = &igm->tunnels[igm->tunnel_index_by_sw_if_index[sw_if_index]];
6736 send_ipsec_gre_tunnel_details (t, q, mp->context);
6741 vl_api_delete_subif_t_handler (vl_api_delete_subif_t * mp)
6743 vl_api_delete_subif_reply_t *rmp;
6746 rv = vnet_delete_sub_interface (ntohl (mp->sw_if_index));
6748 REPLY_MACRO (VL_API_DELETE_SUBIF_REPLY);
6752 vl_api_l2_interface_pbb_tag_rewrite_t_handler
6753 (vl_api_l2_interface_pbb_tag_rewrite_t * mp)
6755 vl_api_l2_interface_pbb_tag_rewrite_reply_t *rmp;
6756 vnet_main_t *vnm = vnet_get_main ();
6757 vlib_main_t *vm = vlib_get_main ();
6761 VALIDATE_SW_IF_INDEX (mp);
6763 vtr_op = ntohl (mp->vtr_op);
6767 case L2_VTR_DISABLED:
6770 case L2_VTR_TRANSLATE_2_1:
6774 rv = VNET_API_ERROR_INVALID_VALUE;
6775 goto bad_sw_if_index;
6778 rv = l2pbb_configure (vm, vnm, ntohl (mp->sw_if_index), vtr_op,
6779 mp->b_dmac, mp->b_smac, ntohs (mp->b_vlanid),
6780 ntohl (mp->i_sid), ntohs (mp->outer_tag));
6782 BAD_SW_IF_INDEX_LABEL;
6784 REPLY_MACRO (VL_API_L2_INTERFACE_PBB_TAG_REWRITE_REPLY);
6789 vl_api_bfd_udp_add_t_handler (vl_api_bfd_udp_add_t * mp)
6791 vl_api_bfd_udp_add_reply_t *rmp;
6794 VALIDATE_SW_IF_INDEX (mp);
6796 ip46_address_t local_addr;
6797 memset (&local_addr, 0, sizeof (local_addr));
6798 ip46_address_t peer_addr;
6799 memset (&peer_addr, 0, sizeof (peer_addr));
6802 clib_memcpy (&local_addr.ip6, mp->local_addr, sizeof (local_addr.ip6));
6803 clib_memcpy (&peer_addr.ip6, mp->peer_addr, sizeof (peer_addr.ip6));
6807 clib_memcpy (&local_addr.ip4, mp->local_addr, sizeof (local_addr.ip4));
6808 clib_memcpy (&peer_addr.ip4, mp->peer_addr, sizeof (peer_addr.ip4));
6811 rv = bfd_udp_add_session (clib_net_to_host_u32 (mp->sw_if_index),
6812 clib_net_to_host_u32 (mp->desired_min_tx),
6813 clib_net_to_host_u32 (mp->required_min_rx),
6814 mp->detect_mult, &local_addr, &peer_addr);
6816 BAD_SW_IF_INDEX_LABEL;
6817 REPLY_MACRO (VL_API_BFD_UDP_ADD_REPLY);
6821 vl_api_bfd_udp_del_t_handler (vl_api_bfd_udp_del_t * mp)
6823 vl_api_bfd_udp_del_reply_t *rmp;
6826 VALIDATE_SW_IF_INDEX (mp);
6828 ip46_address_t local_addr;
6829 memset (&local_addr, 0, sizeof (local_addr));
6830 ip46_address_t peer_addr;
6831 memset (&peer_addr, 0, sizeof (peer_addr));
6834 clib_memcpy (&local_addr.ip6, mp->local_addr, sizeof (local_addr.ip6));
6835 clib_memcpy (&peer_addr.ip6, mp->peer_addr, sizeof (peer_addr.ip6));
6839 clib_memcpy (&local_addr.ip4, mp->local_addr, sizeof (local_addr.ip4));
6840 clib_memcpy (&peer_addr.ip4, mp->peer_addr, sizeof (peer_addr.ip4));
6844 bfd_udp_del_session (clib_net_to_host_u32 (mp->sw_if_index), &local_addr,
6847 BAD_SW_IF_INDEX_LABEL;
6848 REPLY_MACRO (VL_API_BFD_UDP_DEL_REPLY);
6852 send_bfd_udp_session_details (unix_shared_memory_queue_t * q, u32 context,
6855 if (bs->transport != BFD_TRANSPORT_UDP4 &&
6856 bs->transport != BFD_TRANSPORT_UDP6)
6861 vl_api_bfd_udp_session_details_t *mp = vl_msg_api_alloc (sizeof (*mp));
6862 memset (mp, 0, sizeof (*mp));
6863 mp->_vl_msg_id = ntohs (VL_API_BFD_UDP_SESSION_DETAILS);
6864 mp->context = context;
6865 mp->bs_index = clib_host_to_net_u32 (bs->bs_idx);
6866 mp->state = bs->local_state;
6867 bfd_udp_session_t *bus = &bs->udp;
6868 bfd_udp_key_t *key = &bus->key;
6869 mp->sw_if_index = clib_host_to_net_u32 (key->sw_if_index);
6870 mp->is_ipv6 = !(ip46_address_is_ip4 (&key->local_addr));
6873 clib_memcpy (mp->local_addr, &key->local_addr,
6874 sizeof (key->local_addr));
6875 clib_memcpy (mp->peer_addr, &key->peer_addr, sizeof (key->peer_addr));
6879 clib_memcpy (mp->local_addr, &key->local_addr.ip4.data,
6880 sizeof (&key->local_addr.ip4.data));
6881 clib_memcpy (mp->peer_addr, &key->peer_addr.ip4.data,
6882 sizeof (&key->peer_addr.ip4.data));
6885 vl_msg_api_send_shmem (q, (u8 *) & mp);
6889 bfd_event (bfd_main_t * bm, bfd_session_t * bs)
6891 vpe_api_main_t *vam = &vpe_api_main;
6892 vpe_client_registration_t *reg;
6893 unix_shared_memory_queue_t *q;
6895 pool_foreach (reg, vam->bfd_events_registrations, ({
6896 q = vl_api_client_index_to_input_queue (reg->client_index);
6899 switch (bs->transport)
6901 case BFD_TRANSPORT_UDP4:
6903 case BFD_TRANSPORT_UDP6:
6904 send_bfd_udp_session_details (q, 0, bs);
6912 vl_api_bfd_udp_session_dump_t_handler (vl_api_bfd_udp_session_dump_t * mp)
6914 unix_shared_memory_queue_t *q;
6916 q = vl_api_client_index_to_input_queue (mp->client_index);
6921 bfd_session_t *bs = NULL;
6923 pool_foreach (bs, bfd_main.sessions, ({
6924 if (bs->transport == BFD_TRANSPORT_UDP4 ||
6925 bs->transport == BFD_TRANSPORT_UDP6)
6926 send_bfd_udp_session_details (q, mp->context, bs);
6932 vl_api_bfd_session_set_flags_t_handler (vl_api_bfd_session_set_flags_t * mp)
6934 vl_api_bfd_session_set_flags_reply_t *rmp;
6938 bfd_session_set_flags (clib_net_to_host_u32 (mp->bs_index),
6941 REPLY_MACRO (VL_API_BFD_SESSION_SET_FLAGS_REPLY);
6945 vl_api_punt_t_handler (vl_api_punt_t * mp)
6947 vl_api_punt_reply_t *rmp;
6948 vlib_main_t *vm = vlib_get_main ();
6950 clib_error_t *error;
6952 error = vnet_punt_add_del (vm, mp->ipv, mp->l4_protocol,
6953 ntohs (mp->l4_port), mp->is_add);
6957 clib_error_report (error);
6960 REPLY_MACRO (VL_API_PUNT_REPLY);
6964 vl_api_flow_classify_set_interface_t_handler
6965 (vl_api_flow_classify_set_interface_t * mp)
6967 vlib_main_t *vm = vlib_get_main ();
6968 vl_api_flow_classify_set_interface_reply_t *rmp;
6970 u32 sw_if_index, ip4_table_index, ip6_table_index;
6972 ip4_table_index = ntohl (mp->ip4_table_index);
6973 ip6_table_index = ntohl (mp->ip6_table_index);
6974 sw_if_index = ntohl (mp->sw_if_index);
6976 VALIDATE_SW_IF_INDEX (mp);
6978 rv = vnet_set_flow_classify_intfc (vm, sw_if_index, ip4_table_index,
6979 ip6_table_index, mp->is_add);
6981 BAD_SW_IF_INDEX_LABEL;
6983 REPLY_MACRO (VL_API_FLOW_CLASSIFY_SET_INTERFACE_REPLY);
6987 send_flow_classify_details (u32 sw_if_index,
6989 unix_shared_memory_queue_t * q, u32 context)
6991 vl_api_flow_classify_details_t *mp;
6993 mp = vl_msg_api_alloc (sizeof (*mp));
6994 memset (mp, 0, sizeof (*mp));
6995 mp->_vl_msg_id = ntohs (VL_API_FLOW_CLASSIFY_DETAILS);
6996 mp->context = context;
6997 mp->sw_if_index = htonl (sw_if_index);
6998 mp->table_index = htonl (table_index);
7000 vl_msg_api_send_shmem (q, (u8 *) & mp);
7004 vl_api_flow_classify_dump_t_handler (vl_api_flow_classify_dump_t * mp)
7006 unix_shared_memory_queue_t *q;
7007 flow_classify_main_t *pcm = &flow_classify_main;
7011 q = vl_api_client_index_to_input_queue (mp->client_index);
7015 vec_tbl = pcm->classify_table_index_by_sw_if_index[mp->type];
7017 if (vec_len (vec_tbl))
7019 for (i = 0; i < vec_len (vec_tbl); i++)
7021 if (vec_elt (vec_tbl, i) == ~0)
7024 send_flow_classify_details (i, vec_elt (vec_tbl, i), q,
7031 send_ipsec_spd_details (ipsec_policy_t * p, unix_shared_memory_queue_t * q,
7034 vl_api_ipsec_spd_details_t *mp;
7036 mp = vl_msg_api_alloc (sizeof (*mp));
7037 memset (mp, 0, sizeof (*mp));
7038 mp->_vl_msg_id = ntohs (VL_API_IPSEC_SPD_DETAILS);
7039 mp->context = context;
7041 mp->spd_id = htonl (p->id);
7042 mp->priority = htonl (p->priority);
7043 mp->is_outbound = p->is_outbound;
7044 mp->is_ipv6 = p->is_ipv6;
7047 memcpy (mp->local_start_addr, &p->laddr.start.ip6, 16);
7048 memcpy (mp->local_stop_addr, &p->laddr.stop.ip6, 16);
7049 memcpy (mp->remote_start_addr, &p->raddr.start.ip6, 16);
7050 memcpy (mp->remote_stop_addr, &p->raddr.stop.ip6, 16);
7054 memcpy (mp->local_start_addr, &p->laddr.start.ip4, 4);
7055 memcpy (mp->local_stop_addr, &p->laddr.stop.ip4, 4);
7056 memcpy (mp->remote_start_addr, &p->raddr.start.ip4, 4);
7057 memcpy (mp->remote_stop_addr, &p->raddr.stop.ip4, 4);
7059 mp->local_start_port = htons (p->lport.start);
7060 mp->local_stop_port = htons (p->lport.stop);
7061 mp->remote_start_port = htons (p->rport.start);
7062 mp->remote_stop_port = htons (p->rport.stop);
7063 mp->protocol = p->protocol;
7064 mp->policy = p->policy;
7065 mp->sa_id = htonl (p->sa_id);
7066 mp->bytes = clib_host_to_net_u64 (p->counter.bytes);
7067 mp->packets = clib_host_to_net_u64 (p->counter.packets);
7069 vl_msg_api_send_shmem (q, (u8 *) & mp);
7073 vl_api_ipsec_spd_dump_t_handler (vl_api_ipsec_spd_dump_t * mp)
7075 unix_shared_memory_queue_t *q;
7076 ipsec_main_t *im = &ipsec_main;
7077 ipsec_policy_t *policy;
7082 q = vl_api_client_index_to_input_queue (mp->client_index);
7086 p = hash_get (im->spd_index_by_spd_id, ntohl (mp->spd_id));
7091 spd = pool_elt_at_index (im->spds, spd_index);
7094 pool_foreach (policy, spd->policies,
7096 if (mp->sa_id == ~(0) || ntohl (mp->sa_id) == policy->sa_id)
7097 send_ipsec_spd_details (policy, q,
7102 clib_warning ("unimplemented");
7107 vl_api_feature_enable_disable_t_handler (vl_api_feature_enable_disable_t * mp)
7109 vl_api_feature_enable_disable_reply_t *rmp;
7111 u8 *arc_name, *feature_name;
7113 VALIDATE_SW_IF_INDEX (mp);
7115 arc_name = format (0, "%s%c", mp->arc_name, 0);
7116 feature_name = format (0, "%s%c", mp->feature_name, 0);
7118 vnet_feature_registration_t *reg;
7120 vnet_get_feature_reg ((const char *) arc_name,
7121 (const char *) feature_name);
7123 rv = VNET_API_ERROR_INVALID_VALUE;
7127 clib_error_t *error = 0;
7129 sw_if_index = ntohl (mp->sw_if_index);
7130 if (reg->enable_disable_cb)
7131 error = reg->enable_disable_cb (sw_if_index, mp->enable);
7133 vnet_feature_enable_disable ((const char *) arc_name,
7134 (const char *) feature_name,
7135 sw_if_index, mp->enable, 0, 0);
7138 clib_error_report (error);
7139 rv = VNET_API_ERROR_CANNOT_ENABLE_DISABLE_FEATURE;
7143 vec_free (feature_name);
7144 vec_free (arc_name);
7146 BAD_SW_IF_INDEX_LABEL;
7148 REPLY_MACRO (VL_API_FEATURE_ENABLE_DISABLE_REPLY);
7151 #define BOUNCE_HANDLER(nn) \
7152 static void vl_api_##nn##_t_handler ( \
7153 vl_api_##nn##_t *mp) \
7155 vpe_client_registration_t *reg; \
7156 vpe_api_main_t * vam = &vpe_api_main; \
7157 unix_shared_memory_queue_t * q; \
7159 /* One registration only... */ \
7160 pool_foreach(reg, vam->nn##_registrations, \
7162 q = vl_api_client_index_to_input_queue (reg->client_index); \
7165 * If the queue is stuffed, turf the msg and complain \
7166 * It's unlikely that the intended recipient is \
7167 * alive; avoid deadlock at all costs. \
7169 if (q->cursize == q->maxsize) { \
7170 clib_warning ("ERROR: receiver queue full, drop msg"); \
7171 vl_msg_api_free (mp); \
7174 vl_msg_api_send_shmem (q, (u8 *)&mp); \
7178 vl_msg_api_free (mp); \
7181 static void setup_message_id_table (api_main_t * am);
7185 * Add vpe's API message handlers to the table.
7186 * vlib has alread mapped shared memory and
7187 * added the client registration handlers.
7188 * See .../open-repo/vlib/memclnt_vlib.c:memclnt_process()
7190 static clib_error_t *
7191 vpe_api_hookup (vlib_main_t * vm)
7193 api_main_t *am = &api_main;
7196 vl_msg_api_set_handlers(VL_API_##N, #n, \
7197 vl_api_##n##_t_handler, \
7199 vl_api_##n##_t_endian, \
7200 vl_api_##n##_t_print, \
7201 sizeof(vl_api_##n##_t), 1);
7202 foreach_vpe_api_msg;
7206 * Manually register the sr tunnel add del msg, so we trace
7207 * enough bytes to capture a typical segment list
7209 vl_msg_api_set_handlers (VL_API_SR_TUNNEL_ADD_DEL,
7210 "sr_tunnel_add_del",
7211 vl_api_sr_tunnel_add_del_t_handler,
7213 vl_api_sr_tunnel_add_del_t_endian,
7214 vl_api_sr_tunnel_add_del_t_print, 256, 1);
7218 * Manually register the sr policy add del msg, so we trace
7219 * enough bytes to capture a typical tunnel name list
7221 vl_msg_api_set_handlers (VL_API_SR_POLICY_ADD_DEL,
7222 "sr_policy_add_del",
7223 vl_api_sr_policy_add_del_t_handler,
7225 vl_api_sr_policy_add_del_t_endian,
7226 vl_api_sr_policy_add_del_t_print, 256, 1);
7229 * Trace space for 8 MPLS encap labels, classifier mask+match
7231 am->api_trace_cfg[VL_API_MPLS_TUNNEL_ADD_DEL].size += 8 * sizeof (u32);
7232 am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_TABLE].size += 5 * sizeof (u32x4);
7233 am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_SESSION].size
7234 += 5 * sizeof (u32x4);
7235 am->api_trace_cfg[VL_API_VXLAN_ADD_DEL_TUNNEL].size += 16 * sizeof (u32);
7238 * Thread-safe API messages
7240 am->is_mp_safe[VL_API_IP_ADD_DEL_ROUTE] = 1;
7241 am->is_mp_safe[VL_API_GET_NODE_GRAPH] = 1;
7244 * Set up the (msg_name, crc, message-id) table
7246 setup_message_id_table (am);
7251 VLIB_API_INIT_FUNCTION (vpe_api_hookup);
7253 static clib_error_t *
7254 vpe_api_init (vlib_main_t * vm)
7256 vpe_api_main_t *am = &vpe_api_main;
7259 am->vnet_main = vnet_get_main ();
7260 am->interface_events_registration_hash = hash_create (0, sizeof (uword));
7261 am->to_netconf_server_registration_hash = hash_create (0, sizeof (uword));
7262 am->from_netconf_server_registration_hash = hash_create (0, sizeof (uword));
7263 am->to_netconf_client_registration_hash = hash_create (0, sizeof (uword));
7264 am->from_netconf_client_registration_hash = hash_create (0, sizeof (uword));
7265 am->oam_events_registration_hash = hash_create (0, sizeof (uword));
7266 am->bfd_events_registration_hash = hash_create (0, sizeof (uword));
7269 vl_set_memory_region_name ("/vpe-api");
7270 vl_enable_disable_memory_api (vm, 1 /* enable it */ );
7275 VLIB_INIT_FUNCTION (vpe_api_init);
7278 static clib_error_t *
7279 api_segment_config (vlib_main_t * vm, unformat_input_t * input)
7282 u64 baseva, size, pvt_heap_size;
7284 const int max_buf_size = 4096;
7286 struct passwd _pw, *pw;
7287 struct group _grp, *grp;
7289 buf = vec_new (char, 128);
7290 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7292 if (unformat (input, "prefix %s", &chroot_path))
7294 vec_add1 (chroot_path, 0);
7295 vl_set_memory_root_path ((char *) chroot_path);
7297 else if (unformat (input, "uid %d", &uid))
7298 vl_set_memory_uid (uid);
7299 else if (unformat (input, "gid %d", &gid))
7300 vl_set_memory_gid (gid);
7301 else if (unformat (input, "baseva %llx", &baseva))
7302 vl_set_global_memory_baseva (baseva);
7303 else if (unformat (input, "global-size %lldM", &size))
7304 vl_set_global_memory_size (size * (1ULL << 20));
7305 else if (unformat (input, "global-size %lldG", &size))
7306 vl_set_global_memory_size (size * (1ULL << 30));
7307 else if (unformat (input, "global-size %lld", &size))
7308 vl_set_global_memory_size (size);
7309 else if (unformat (input, "global-pvt-heap-size %lldM", &pvt_heap_size))
7310 vl_set_global_pvt_heap_size (pvt_heap_size * (1ULL << 20));
7311 else if (unformat (input, "global-pvt-heap-size size %lld",
7313 vl_set_global_pvt_heap_size (pvt_heap_size);
7314 else if (unformat (input, "api-pvt-heap-size %lldM", &pvt_heap_size))
7315 vl_set_api_pvt_heap_size (pvt_heap_size * (1ULL << 20));
7316 else if (unformat (input, "api-pvt-heap-size size %lld",
7318 vl_set_api_pvt_heap_size (pvt_heap_size);
7319 else if (unformat (input, "api-size %lldM", &size))
7320 vl_set_api_memory_size (size * (1ULL << 20));
7321 else if (unformat (input, "api-size %lldG", &size))
7322 vl_set_api_memory_size (size * (1ULL << 30));
7323 else if (unformat (input, "api-size %lld", &size))
7324 vl_set_api_memory_size (size);
7325 else if (unformat (input, "uid %s", &s))
7327 /* lookup the username */
7330 getpwnam_r (s, &_pw, buf, vec_len (buf), &pw)) == ERANGE)
7331 && (vec_len (buf) <= max_buf_size))
7333 vec_resize (buf, vec_len (buf) * 2);
7337 e = clib_error_return_code (0, rv,
7338 CLIB_ERROR_ERRNO_VALID |
7340 "cannot fetch username %s", s);
7348 clib_error_return_fatal (0, "username %s does not exist", s);
7354 vl_set_memory_uid (pw->pw_uid);
7356 else if (unformat (input, "gid %s", &s))
7358 /* lookup the group name */
7361 getgrnam_r (s, &_grp, buf, vec_len (buf), &grp)) == ERANGE)
7362 && (vec_len (buf) <= max_buf_size))
7364 vec_resize (buf, vec_len (buf) * 2);
7368 e = clib_error_return_code (0, rv,
7369 CLIB_ERROR_ERRNO_VALID |
7371 "cannot fetch group %s", s);
7378 e = clib_error_return_fatal (0, "group %s does not exist", s);
7385 vl_set_memory_gid (grp->gr_gid);
7388 return clib_error_return (0, "unknown input `%U'",
7389 format_unformat_error, input);
7394 VLIB_EARLY_CONFIG_FUNCTION (api_segment_config, "api-segment");
7397 get_unformat_vnet_sw_interface (void)
7399 return (void *) &unformat_vnet_sw_interface;
7403 format_arp_event (u8 * s, va_list * args)
7405 vl_api_ip4_arp_event_t *event = va_arg (*args, vl_api_ip4_arp_event_t *);
7407 s = format (s, "pid %d: ", event->pid);
7409 s = format (s, "bd mac/ip4 binding events");
7411 s = format (s, "resolution for %U", format_ip4_address, &event->address);
7416 format_nd_event (u8 * s, va_list * args)
7418 vl_api_ip6_nd_event_t *event = va_arg (*args, vl_api_ip6_nd_event_t *);
7420 s = format (s, "pid %d: ", event->pid);
7422 s = format (s, "bd mac/ip6 binding events");
7424 s = format (s, "resolution for %U", format_ip6_address, event->address);
7428 static clib_error_t *
7429 show_ip_arp_nd_events_fn (vlib_main_t * vm,
7430 unformat_input_t * input, vlib_cli_command_t * cmd)
7432 vpe_api_main_t *am = &vpe_api_main;
7433 vl_api_ip4_arp_event_t *arp_event;
7434 vl_api_ip6_nd_event_t *nd_event;
7436 if ((pool_elts (am->arp_events) == 0) && (pool_elts (am->nd_events) == 0))
7438 vlib_cli_output (vm, "No active arp or nd event registrations");
7443 pool_foreach (arp_event, am->arp_events,
7445 vlib_cli_output (vm, "%U", format_arp_event, arp_event);
7448 pool_foreach (nd_event, am->nd_events,
7450 vlib_cli_output (vm, "%U", format_nd_event, nd_event);
7458 VLIB_CLI_COMMAND (show_ip_arp_nd_events, static) = {
7459 .path = "show arp-nd-event registrations",
7460 .function = show_ip_arp_nd_events_fn,
7461 .short_help = "Show ip4 arp and ip6 nd event registrations",
7465 #define vl_msg_name_crc_list
7466 #include <vpp-api/vpe_all_api_h.h>
7467 #undef vl_msg_name_crc_list
7470 setup_message_id_table (api_main_t * am)
7472 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
7473 foreach_vl_msg_name_crc_memclnt;
7474 foreach_vl_msg_name_crc_vpe;
7480 * fd.io coding-style-patch-verification: ON
7483 * eval: (c-set-style "gnu")