FD.io VPP  v16.12-rc0-308-g931be3a
Vector Packet Processing
api.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * api.c - message handler registration
4  *
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:
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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  *------------------------------------------------------------------
18  */
19 
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <sys/types.h>
24 #include <sys/mman.h>
25 #include <sys/stat.h>
26 #include <netinet/in.h>
27 #include <signal.h>
28 #include <pthread.h>
29 #include <unistd.h>
30 #include <time.h>
31 #include <fcntl.h>
32 #include <string.h>
33 #include <pwd.h>
34 #include <grp.h>
35 
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>
47 
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/unix/tuntap.h>
56 #include <vnet/unix/tapcli.h>
57 #include <vnet/mpls/mpls.h>
58 #include <vnet/dhcp/proxy.h>
59 #include <vnet/dhcp/client.h>
60 #if IPV6SR > 0
61 #include <vnet/sr/sr.h>
62 #endif
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>
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>
77 #include <vnet/lisp-gpe/lisp_gpe.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>
86 #include <vnet/policer/policer.h>
88 #include <vnet/flow/flow_report.h>
91 #include <vnet/ip/punt.h>
92 
93 #undef BIHASH_TYPE
94 #undef __included_bihash_template_h__
95 #include <vnet/l2/l2_fib.h>
96 
97 #if IPSEC > 0
98 #include <vnet/ipsec/ipsec.h>
99 #include <vnet/ipsec/ikev2.h>
100 #endif /* IPSEC */
102 
103 #include <stats/stats.h>
104 #include <oam/oam.h>
105 
106 #include <vnet/ethernet/ethernet.h>
108 #include <vnet/interface.h>
109 
110 #include <vnet/l2/l2_fib.h>
111 #include <vnet/l2/l2_bd.h>
112 #include <vpp-api/vpe_msg_enum.h>
113 
114 #include <vnet/fib/ip6_fib.h>
115 #include <vnet/fib/ip4_fib.h>
116 #include <vnet/dpo/drop_dpo.h>
117 #include <vnet/dpo/receive_dpo.h>
118 #include <vnet/dpo/lookup_dpo.h>
119 #include <vnet/dpo/classify_dpo.h>
120 #include <vnet/dpo/ip_null_dpo.h>
121 
122 #define f64_endian(a)
123 #define f64_print(a,b)
124 
125 #define vl_typedefs /* define message structures */
126 #include <vpp-api/vpe_all_api_h.h>
127 #undef vl_typedefs
128 
129 #define vl_endianfun /* define message structures */
130 #include <vpp-api/vpe_all_api_h.h>
131 #undef vl_endianfun
132 
133 /* instantiate all the print functions we know about */
134 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
135 #define vl_printfun
136 #include <vpp-api/vpe_all_api_h.h>
137 #undef vl_printfun
138 
139 #define REPLY_MACRO(t) \
140 do { \
141  unix_shared_memory_queue_t * q; \
142  rv = vl_msg_api_pd_handler (mp, rv); \
143  q = vl_api_client_index_to_input_queue (mp->client_index); \
144  if (!q) \
145  return; \
146  \
147  rmp = vl_msg_api_alloc (sizeof (*rmp)); \
148  rmp->_vl_msg_id = ntohs((t)); \
149  rmp->context = mp->context; \
150  rmp->retval = ntohl(rv); \
151  \
152  vl_msg_api_send_shmem (q, (u8 *)&rmp); \
153 } while(0);
154 
155 #define REPLY_MACRO2(t, body) \
156 do { \
157  unix_shared_memory_queue_t * q; \
158  rv = vl_msg_api_pd_handler (mp, rv); \
159  q = vl_api_client_index_to_input_queue (mp->client_index); \
160  if (!q) \
161  return; \
162  \
163  rmp = vl_msg_api_alloc (sizeof (*rmp)); \
164  rmp->_vl_msg_id = ntohs((t)); \
165  rmp->context = mp->context; \
166  rmp->retval = ntohl(rv); \
167  do {body;} while (0); \
168  vl_msg_api_send_shmem (q, (u8 *)&rmp); \
169 } while(0);
170 
171 #define REPLY_MACRO3(t, n, body) \
172 do { \
173  unix_shared_memory_queue_t * q; \
174  rv = vl_msg_api_pd_handler (mp, rv); \
175  q = vl_api_client_index_to_input_queue (mp->client_index); \
176  if (!q) \
177  return; \
178  \
179  rmp = vl_msg_api_alloc (sizeof (*rmp) + n); \
180  rmp->_vl_msg_id = ntohs((t)); \
181  rmp->context = mp->context; \
182  rmp->retval = ntohl(rv); \
183  do {body;} while (0); \
184  vl_msg_api_send_shmem (q, (u8 *)&rmp); \
185 } while(0);
186 
187 #define REPLY_MACRO4(t, n, body) \
188 do { \
189  unix_shared_memory_queue_t * q; \
190  u8 is_error = 0; \
191  rv = vl_msg_api_pd_handler (mp, rv); \
192  q = vl_api_client_index_to_input_queue (mp->client_index); \
193  if (!q) \
194  return; \
195  \
196  rmp = vl_msg_api_alloc_or_null (sizeof (*rmp) + n); \
197  if (!rmp) \
198  { \
199  /* if there isn't enough memory, try to allocate */ \
200  /* some at least for returning an error */ \
201  rmp = vl_msg_api_alloc (sizeof (*rmp)); \
202  if (!rmp) \
203  return; \
204  \
205  memset (rmp, 0, sizeof (*rmp)); \
206  rv = VNET_API_ERROR_TABLE_TOO_BIG; \
207  is_error = 1; \
208  } \
209  rmp->_vl_msg_id = ntohs((t)); \
210  rmp->context = mp->context; \
211  rmp->retval = ntohl(rv); \
212  if (!is_error) \
213  do {body;} while (0); \
214  vl_msg_api_send_shmem (q, (u8 *)&rmp); \
215 } while(0);
216 
217 #if (1 || CLIB_DEBUG > 0) /* "trust, but verify" */
218 
219 #define VALIDATE_SW_IF_INDEX(mp) \
220  do { u32 __sw_if_index = ntohl(mp->sw_if_index); \
221  vnet_main_t *__vnm = vnet_get_main(); \
222  if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \
223  __sw_if_index)) { \
224  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \
225  goto bad_sw_if_index; \
226  } \
227 } while(0);
228 
229 #define BAD_SW_IF_INDEX_LABEL \
230 do { \
231 bad_sw_if_index: \
232  ; \
233 } while (0);
234 
235 #define VALIDATE_RX_SW_IF_INDEX(mp) \
236  do { u32 __rx_sw_if_index = ntohl(mp->rx_sw_if_index); \
237  vnet_main_t *__vnm = vnet_get_main(); \
238  if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \
239  __rx_sw_if_index)) { \
240  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \
241  goto bad_rx_sw_if_index; \
242  } \
243 } while(0);
244 
245 #define BAD_RX_SW_IF_INDEX_LABEL \
246 do { \
247 bad_rx_sw_if_index: \
248  ; \
249 } while (0);
250 
251 #define VALIDATE_TX_SW_IF_INDEX(mp) \
252  do { u32 __tx_sw_if_index = ntohl(mp->tx_sw_if_index); \
253  vnet_main_t *__vnm = vnet_get_main(); \
254  if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \
255  __tx_sw_if_index)) { \
256  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \
257  goto bad_tx_sw_if_index; \
258  } \
259 } while(0);
260 
261 #define BAD_TX_SW_IF_INDEX_LABEL \
262 do { \
263 bad_tx_sw_if_index: \
264  ; \
265 } while (0);
266 
267 #else
268 
269 #define VALIDATE_SW_IF_INDEX(mp)
270 #define BAD_SW_IF_INDEX_LABEL
271 #define VALIDATE_RX_SW_IF_INDEX(mp)
272 #define BAD_RX_SW_IF_INDEX_LABEL
273 #define VALIDATE_TX_SW_IF_INDEX(mp)
274 #define BAD_TX_SW_IF_INDEX_LABEL
275 
276 #endif /* CLIB_DEBUG > 0 */
277 
278 #define foreach_vpe_api_msg \
279 _(WANT_INTERFACE_EVENTS, want_interface_events) \
280 _(WANT_OAM_EVENTS, want_oam_events) \
281 _(OAM_ADD_DEL, oam_add_del) \
282 _(SW_INTERFACE_DUMP, sw_interface_dump) \
283 _(SW_INTERFACE_DETAILS, sw_interface_details) \
284 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
285 _(IP_ADD_DEL_ROUTE, ip_add_del_route) \
286 _(MPLS_ROUTE_ADD_DEL, mpls_route_add_del) \
287 _(MPLS_IP_BIND_UNBIND, mpls_ip_bind_unbind) \
288 _(IS_ADDRESS_REACHABLE, is_address_reachable) \
289 _(SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address) \
290 _(SW_INTERFACE_SET_TABLE, sw_interface_set_table) \
291 _(SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable) \
292 _(SW_INTERFACE_SET_VPATH, sw_interface_set_vpath) \
293 _(SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect) \
294 _(SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge) \
295 _(SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe) \
296 _(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport) \
297 _(SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl) \
298 _(BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del) \
299 _(BRIDGE_DOMAIN_DUMP, bridge_domain_dump) \
300 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
301 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
302 _(L2FIB_ADD_DEL, l2fib_add_del) \
303 _(L2_FLAGS, l2_flags) \
304 _(BRIDGE_FLAGS, bridge_flags) \
305 _(TAP_CONNECT, tap_connect) \
306 _(TAP_MODIFY, tap_modify) \
307 _(TAP_DELETE, tap_delete) \
308 _(SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump) \
309 _(CREATE_VLAN_SUBIF, create_vlan_subif) \
310 _(CREATE_SUBIF, create_subif) \
311 _(MPLS_ETHERNET_ADD_DEL_TUNNEL, mpls_ethernet_add_del_tunnel) \
312 _(MPLS_ETHERNET_ADD_DEL_TUNNEL_2, mpls_ethernet_add_del_tunnel_2) \
313 _(MPLS_ADD_DEL_ENCAP, mpls_add_del_encap) \
314 _(PROXY_ARP_ADD_DEL, proxy_arp_add_del) \
315 _(PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable) \
316 _(IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del) \
317 _(VNET_GET_SUMMARY_STATS, vnet_get_summary_stats) \
318 _(RESET_FIB, reset_fib) \
319 _(DHCP_PROXY_CONFIG,dhcp_proxy_config) \
320 _(DHCP_PROXY_CONFIG_2,dhcp_proxy_config_2) \
321 _(DHCP_PROXY_SET_VSS,dhcp_proxy_set_vss) \
322 _(DHCP_CLIENT_CONFIG, dhcp_client_config) \
323 _(SET_IP_FLOW_HASH,set_ip_flow_hash) \
324 _(SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config) \
325 _(SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix) \
326 _(SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable ) \
327 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, \
328  sw_interface_ip6_set_link_local_address) \
329 _(SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered) \
330 _(CREATE_LOOPBACK, create_loopback) \
331 _(CONTROL_PING, control_ping) \
332 _(CLI_REQUEST, cli_request) \
333 _(CLI_INBAND, cli_inband) \
334 _(SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit) \
335 _(L2_PATCH_ADD_DEL, l2_patch_add_del) \
336 _(CLASSIFY_ADD_DEL_TABLE, classify_add_del_table) \
337 _(CLASSIFY_ADD_DEL_SESSION, classify_add_del_session) \
338 _(CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table) \
339 _(CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables) \
340 _(GET_NODE_INDEX, get_node_index) \
341 _(ADD_NODE_NEXT, add_node_next) \
342 _(L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel) \
343 _(L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies) \
344 _(L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable) \
345 _(L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key) \
346 _(SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump) \
347 _(VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel) \
348 _(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump) \
349 _(GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel) \
350 _(GRE_TUNNEL_DUMP, gre_tunnel_dump) \
351 _(L2_FIB_CLEAR_TABLE, l2_fib_clear_table) \
352 _(L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter) \
353 _(L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite) \
354 _(CREATE_VHOST_USER_IF, create_vhost_user_if) \
355 _(MODIFY_VHOST_USER_IF, modify_vhost_user_if) \
356 _(DELETE_VHOST_USER_IF, delete_vhost_user_if) \
357 _(SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump) \
358 _(IP_ADDRESS_DUMP, ip_address_dump) \
359 _(IP_DUMP, ip_dump) \
360 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
361 _(SHOW_VERSION, show_version) \
362 _(L2_FIB_TABLE_DUMP, l2_fib_table_dump) \
363 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
364 _(VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel) \
365 _(VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump) \
366 _(INTERFACE_NAME_RENUMBER, interface_name_renumber) \
367 _(WANT_IP4_ARP_EVENTS, want_ip4_arp_events) \
368 _(WANT_IP6_ND_EVENTS, want_ip6_nd_events) \
369 _(INPUT_ACL_SET_INTERFACE, input_acl_set_interface) \
370 _(IPSEC_SPD_ADD_DEL, ipsec_spd_add_del) \
371 _(IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd) \
372 _(IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry) \
373 _(IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry) \
374 _(IPSEC_SA_SET_KEY, ipsec_sa_set_key) \
375 _(IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del) \
376 _(IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth) \
377 _(IKEV2_PROFILE_SET_ID, ikev2_profile_set_id) \
378 _(IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts) \
379 _(IKEV2_SET_LOCAL_KEY, ikev2_set_local_key) \
380 _(DELETE_LOOPBACK, delete_loopback) \
381 _(BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del) \
382 _(MAP_ADD_DOMAIN, map_add_domain) \
383 _(MAP_DEL_DOMAIN, map_del_domain) \
384 _(MAP_ADD_DEL_RULE, map_add_del_rule) \
385 _(MAP_DOMAIN_DUMP, map_domain_dump) \
386 _(MAP_RULE_DUMP, map_rule_dump) \
387 _(MAP_SUMMARY_STATS, map_summary_stats) \
388 _(COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable) \
389 _(COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable) \
390 _(GET_NODE_GRAPH, get_node_graph) \
391 _(SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats) \
392 _(IOAM_ENABLE, ioam_enable) \
393 _(IOAM_DISABLE, ioam_disable) \
394 _(LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set) \
395 _(LISP_ADD_DEL_LOCATOR, lisp_add_del_locator) \
396 _(LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid) \
397 _(LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry) \
398 _(LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver) \
399 _(LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable) \
400 _(LISP_ENABLE_DISABLE, lisp_enable_disable) \
401 _(LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface) \
402 _(LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping) \
403 _(LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency) \
404 _(LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set) \
405 _(LISP_MAP_REQUEST_MODE, lisp_map_request_mode) \
406 _(LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map) \
407 _(LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump) \
408 _(LISP_LOCATOR_DUMP, lisp_locator_dump) \
409 _(LISP_EID_TABLE_DUMP, lisp_eid_table_dump) \
410 _(LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump) \
411 _(LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump) \
412 _(LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump) \
413 _(LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump) \
414 _(LISP_ADJACENCIES_GET, lisp_adjacencies_get) \
415 _(SHOW_LISP_STATUS, show_lisp_status) \
416 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, \
417  lisp_add_del_map_request_itr_rlocs) \
418 _(LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs) \
419 _(SHOW_LISP_PITR, show_lisp_pitr) \
420 _(SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode) \
421 _(SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del) \
422 _(AF_PACKET_CREATE, af_packet_create) \
423 _(AF_PACKET_DELETE, af_packet_delete) \
424 _(POLICER_ADD_DEL, policer_add_del) \
425 _(POLICER_DUMP, policer_dump) \
426 _(POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface) \
427 _(POLICER_CLASSIFY_DUMP, policer_classify_dump) \
428 _(NETMAP_CREATE, netmap_create) \
429 _(NETMAP_DELETE, netmap_delete) \
430 _(MPLS_ETH_TUNNEL_DUMP, mpls_eth_tunnel_dump) \
431 _(MPLS_ETH_TUNNEL_DETAILS, mpls_eth_tunnel_details) \
432 _(MPLS_FIB_ENCAP_DUMP, mpls_fib_encap_dump) \
433 _(MPLS_FIB_ENCAP_DETAILS, mpls_fib_encap_details) \
434 _(MPLS_FIB_DUMP, mpls_fib_dump) \
435 _(MPLS_FIB_DETAILS, mpls_fib_details) \
436 _(CLASSIFY_TABLE_IDS,classify_table_ids) \
437 _(CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface) \
438 _(CLASSIFY_TABLE_INFO,classify_table_info) \
439 _(CLASSIFY_SESSION_DUMP,classify_session_dump) \
440 _(CLASSIFY_SESSION_DETAILS,classify_session_details) \
441 _(SET_IPFIX_EXPORTER, set_ipfix_exporter) \
442 _(IPFIX_EXPORTER_DUMP, ipfix_exporter_dump) \
443 _(SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream) \
444 _(IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump) \
445 _(IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del) \
446 _(IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump) \
447 _(GET_NEXT_INDEX, get_next_index) \
448 _(PG_CREATE_INTERFACE, pg_create_interface) \
449 _(PG_CAPTURE, pg_capture) \
450 _(PG_ENABLE_DISABLE, pg_enable_disable) \
451 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, \
452  ip_source_and_port_range_check_add_del) \
453 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, \
454  ip_source_and_port_range_check_interface_add_del) \
455 _(IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel) \
456 _(IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump) \
457 _(DELETE_SUBIF, delete_subif) \
458 _(L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite) \
459 _(PUNT, punt) \
460 _(FLOW_CLASSIFY_SET_INTERFACE, flow_classify_set_interface) \
461 _(FLOW_CLASSIFY_DUMP, flow_classify_dump)
462 
463 #define QUOTE_(x) #x
464 #define QUOTE(x) QUOTE_(x)
465 
466 #define foreach_registration_hash \
467 _(interface_events) \
468 _(to_netconf_server) \
469 _(from_netconf_server) \
470 _(to_netconf_client) \
471 _(from_netconf_client) \
472 _(oam_events)
473 
474 typedef enum
475 {
479 } resolve_t;
480 
481 typedef struct
482 {
484  union
485  {
488  };
490 
491 typedef struct
492 {
493 
494 #define _(a) uword *a##_registration_hash; \
495  vpe_client_registration_t * a##_registrations;
497 #undef _
498  /* notifications happen really early in the game */
500 
501  /* ip4 and ip6 pending route adds */
503 
504  /* ip4 arp event registration pool */
506 
507  /* ip6 nd event registration pool */
509 
510  /* convenience */
514 
517 
518 static void send_sw_interface_flags (vpe_api_main_t * am,
520  vnet_sw_interface_t * swif);
523  u32 sw_if_index);
524 
525 static int arp_change_delete_callback (u32 pool_index, u8 * notused);
526 static int nd_change_delete_callback (u32 pool_index, u8 * notused);
527 
528 
529 /* Clean up all registrations belonging to the indicated client */
530 int
532 {
535  uword *p;
536  int stats_memclnt_delete_callback (u32 client_index);
537 
538  stats_memclnt_delete_callback (client_index);
539 
540 #define _(a) \
541  p = hash_get (vam->a##_registration_hash, client_index); \
542  if (p) { \
543  rp = pool_elt_at_index (vam->a##_registrations, p[0]); \
544  pool_put (vam->a##_registrations, rp); \
545  hash_unset (vam->a##_registration_hash, client_index); \
546  }
548 #undef _
549  return 0;
550 }
551 
552 #define API_LINK_STATE_EVENT 1
553 #define API_ADMIN_UP_DOWN_EVENT 2
554 
555 static int
556 event_data_cmp (void *a1, void *a2)
557 {
558  uword *e1 = a1;
559  uword *e2 = a2;
560 
561  return (word) e1[0] - (word) e2[0];
562 }
563 
564 static uword
567 {
569  vnet_main_t *vnm = vam->vnet_main;
570  vnet_sw_interface_t *swif;
571  uword *event_data = 0;
573  int i;
574  u32 prev_sw_if_index;
576 
577  vam->link_state_process_up = 1;
578 
579  while (1)
580  {
582 
583  /* Unified list of changed link or admin state sw_if_indices */
585  (vm, &event_data, API_LINK_STATE_EVENT);
587  (vm, &event_data, API_ADMIN_UP_DOWN_EVENT);
588 
589  /* Sort, so we can eliminate duplicates */
591 
592  prev_sw_if_index = ~0;
593 
594  for (i = 0; i < vec_len (event_data); i++)
595  {
596  /* Only one message per swif */
597  if (prev_sw_if_index == event_data[i])
598  continue;
599  prev_sw_if_index = event_data[i];
600 
601  /* *INDENT-OFF* */
602  pool_foreach(reg, vam->interface_events_registrations,
603  ({
604  q = vl_api_client_index_to_input_queue (reg->client_index);
605  if (q)
606  {
607  /* sw_interface may be deleted already */
608  if (!pool_is_free_index (vnm->interface_main.sw_interfaces,
609  event_data[i]))
610  {
611  swif = vnet_get_sw_interface (vnm, event_data[i]);
612  send_sw_interface_flags (vam, q, swif);
613  }
614  }
615  }));
616  /* *INDENT-ON* */
617  }
618  vec_reset_length (event_data);
619  }
620 
621  return 0;
622 }
623 
624 static clib_error_t *link_up_down_function (vnet_main_t * vm, u32 hw_if_index,
625  u32 flags);
627  u32 hw_if_index, u32 flags);
628 
629 /* *INDENT-OFF* */
631  .function = link_state_process,
632  .type = VLIB_NODE_TYPE_PROCESS,
633  .name = "vpe-link-state-process",
634 };
635 /* *INDENT-ON* */
636 
637 VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION (admin_up_down_function);
638 VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION (link_up_down_function);
639 
640 static clib_error_t *
641 link_up_down_function (vnet_main_t * vm, u32 hw_if_index, u32 flags)
642 {
644  vnet_hw_interface_t *hi = vnet_get_hw_interface (vm, hw_if_index);
645 
646  if (vam->link_state_process_up)
650  return 0;
651 }
652 
653 static clib_error_t *
654 admin_up_down_function (vnet_main_t * vm, u32 sw_if_index, u32 flags)
655 {
657 
658  /*
659  * Note: it's perfectly fair to set a subif admin up / admin down.
660  * Note the subtle distinction between this routine and the previous
661  * routine.
662  */
663  if (vam->link_state_process_up)
666  API_ADMIN_UP_DOWN_EVENT, sw_if_index);
667  return 0;
668 }
669 
670 #define pub_sub_handler(lca,UCA) \
671 static void vl_api_want_##lca##_t_handler ( \
672  vl_api_want_##lca##_t *mp) \
673 { \
674  vpe_api_main_t *vam = &vpe_api_main; \
675  vpe_client_registration_t *rp; \
676  vl_api_want_##lca##_reply_t *rmp; \
677  uword *p; \
678  i32 rv = 0; \
679  \
680  p = hash_get (vam->lca##_registration_hash, mp->client_index); \
681  if (p) { \
682  if (mp->enable_disable) { \
683  clib_warning ("pid %d: already enabled...", mp->pid); \
684  rv = VNET_API_ERROR_INVALID_REGISTRATION; \
685  goto reply; \
686  } else { \
687  rp = pool_elt_at_index (vam->lca##_registrations, p[0]); \
688  pool_put (vam->lca##_registrations, rp); \
689  hash_unset (vam->lca##_registration_hash, \
690  mp->client_index); \
691  goto reply; \
692  } \
693  } \
694  if (mp->enable_disable == 0) { \
695  clib_warning ("pid %d: already disabled...", mp->pid); \
696  rv = VNET_API_ERROR_INVALID_REGISTRATION; \
697  goto reply; \
698  } \
699  pool_get (vam->lca##_registrations, rp); \
700  rp->client_index = mp->client_index; \
701  rp->client_pid = mp->pid; \
702  hash_set (vam->lca##_registration_hash, rp->client_index, \
703  rp - vam->lca##_registrations); \
704  \
705 reply: \
706  REPLY_MACRO (VL_API_WANT_##UCA##_REPLY); \
707 }
708 
709 /* *INDENT-OFF* */
710 pub_sub_handler (interface_events, INTERFACE_EVENTS)
711 pub_sub_handler (oam_events, OAM_EVENTS)
712 /* *INDENT-ON* */
713 
714 #define RESOLUTION_EVENT 1
715 #define RESOLUTION_PENDING_EVENT 2
716 #define IP4_ARP_EVENT 3
717 #define IP6_ND_EVENT 4
718 
720 
722 
725 
726 void
727 handle_ip4_arp_event (u32 pool_index)
728 {
730  vnet_main_t *vnm = vam->vnet_main;
731  vlib_main_t *vm = vam->vlib_main;
732  vl_api_ip4_arp_event_t *event;
735 
736  /* Client can cancel, die, etc. */
737  if (pool_is_free_index (vam->arp_events, pool_index))
738  return;
739 
740  event = pool_elt_at_index (vam->arp_events, pool_index);
741 
743  if (!q)
744  {
747  event->pid, &event->address,
748  vpe_resolver_process_node.index, IP4_ARP_EVENT,
749  ~0 /* pool index, notused */ , 0 /* is_add */ );
750  return;
751  }
752 
753  if (q->cursize < q->maxsize)
754  {
755  mp = vl_msg_api_alloc (sizeof (*mp));
756  clib_memcpy (mp, event, sizeof (*mp));
757  vl_msg_api_send_shmem (q, (u8 *) & mp);
758  }
759  else
760  {
761  static f64 last_time;
762  /*
763  * Throttle syslog msgs.
764  * It's pretty tempting to just revoke the registration...
765  */
766  if (vlib_time_now (vm) > last_time + 10.0)
767  {
768  clib_warning ("arp event for %U to pid %d: queue stuffed!",
769  format_ip4_address, &event->address, event->pid);
770  last_time = vlib_time_now (vm);
771  }
772  }
773 }
774 
775 void
777 {
779  vnet_main_t *vnm = vam->vnet_main;
780  vlib_main_t *vm = vam->vlib_main;
781  vl_api_ip6_nd_event_t *event;
784 
785  /* Client can cancel, die, etc. */
786  if (pool_is_free_index (vam->nd_events, pool_index))
787  return;
788 
789  event = pool_elt_at_index (vam->nd_events, pool_index);
790 
792  if (!q)
793  {
796  event->pid, &event->address,
797  vpe_resolver_process_node.index, IP6_ND_EVENT,
798  ~0 /* pool index, notused */ , 0 /* is_add */ );
799  return;
800  }
801 
802  if (q->cursize < q->maxsize)
803  {
804  mp = vl_msg_api_alloc (sizeof (*mp));
805  clib_memcpy (mp, event, sizeof (*mp));
806  vl_msg_api_send_shmem (q, (u8 *) & mp);
807  }
808  else
809  {
810  static f64 last_time;
811  /*
812  * Throttle syslog msgs.
813  * It's pretty tempting to just revoke the registration...
814  */
815  if (vlib_time_now (vm) > last_time + 10.0)
816  {
817  clib_warning ("ip6 nd event for %U to pid %d: queue stuffed!",
818  format_ip6_address, &event->address, event->pid);
819  last_time = vlib_time_now (vm);
820  }
821  }
822 }
823 
824 static uword
827 {
828  uword event_type;
829  uword *event_data = 0;
830  f64 timeout = 100.0;
832  pending_route_t *pr;
835  u32 *resolution_failures = 0;
836  int i, rv;
837  clib_error_t *e;
838 
839  while (1)
840  {
842 
843  event_type = vlib_process_get_events (vm, &event_data);
844 
845  switch (event_type)
846  {
848  timeout = 1.0;
849  break;
850 
851  case RESOLUTION_EVENT:
852  for (i = 0; i < vec_len (event_data); i++)
853  {
854  /*
855  * Resolution events can occur long after the
856  * original request has timed out. $$$ add a cancel
857  * mechanism..
858  */
859  if (pool_is_free_index (vam->pending_routes, event_data[i]))
860  continue;
861 
862  pr = pool_elt_at_index (vam->pending_routes, event_data[i]);
863  adr = &pr->r;
864  pme = &pr->t;
865 
866  switch (pr->resolve_type)
867  {
869  rv = ip4_add_del_route_t_handler (adr);
870  clib_warning ("resolver: add %U/%d via %U %s",
872  (ip4_address_t *) & (adr->dst_address),
873  adr->dst_address_length,
875  (ip4_address_t *) & (adr->next_hop_address),
876  (rv >= 0) ? "succeeded" : "failed");
877  break;
878 
880  rv = ip6_add_del_route_t_handler (adr);
881  clib_warning ("resolver: add %U/%d via %U %s",
883  (ip6_address_t *) & (adr->dst_address),
884  adr->dst_address_length,
886  (ip6_address_t *) & (adr->next_hop_address),
887  (rv >= 0) ? "succeeded" : "failed");
888  break;
889 
892  clib_warning ("resolver: add mpls-o-e via %U %s",
894  (ip4_address_t *) &
896  (rv >= 0) ? "succeeded" : "failed");
897  break;
898 
899  default:
900  clib_warning ("resolver: BOGUS TYPE %d", pr->resolve_type);
901  }
902  pool_put (vam->pending_routes, pr);
903  }
904  break;
905 
906  case IP4_ARP_EVENT:
907  for (i = 0; i < vec_len (event_data); i++)
908  handle_ip4_arp_event (event_data[i]);
909  break;
910 
911  case IP6_ND_EVENT:
912  for (i = 0; i < vec_len (event_data); i++)
913  handle_ip6_nd_event (event_data[i]);
914  break;
915 
916  case ~0: /* timeout, retry pending resolutions */
917  /* *INDENT-OFF* */
918  pool_foreach (pr, vam->pending_routes,
919  ({
920  int is_adr = 1;
921  adr = &pr->r;
922  pme = &pr->t;
923 
924  /* May fail, e.g. due to interface down */
925  switch (pr->resolve_type)
926  {
927  case RESOLVE_IP4_ADD_DEL_ROUTE:
928  e = ip4_probe_neighbor
929  (vm, (ip4_address_t *)&(adr->next_hop_address),
930  ntohl(adr->next_hop_sw_if_index));
931  break;
932 
933  case RESOLVE_IP6_ADD_DEL_ROUTE:
934  e = ip6_probe_neighbor
935  (vm, (ip6_address_t *)&(adr->next_hop_address),
936  ntohl(adr->next_hop_sw_if_index));
937  break;
938 
939  case RESOLVE_MPLS_ETHERNET_ADD_DEL:
940  is_adr = 0;
941  e = ip4_probe_neighbor
942  (vm,
943  (ip4_address_t *)&(pme->next_hop_ip4_address_in_outer_vrf),
944  pme->resolve_opaque);
945  break;
946 
947  default:
948  e = clib_error_return (0, "resolver: BOGUS TYPE %d",
949  pr->resolve_type);
950  }
951  if (e)
952  {
953  clib_error_report (e);
954  if (is_adr)
955  adr->resolve_attempts = 1;
956  else
957  pme->resolve_attempts = 1;
958  }
959  if (is_adr)
960  {
961  adr->resolve_attempts -= 1;
962  if (adr->resolve_attempts == 0)
963  vec_add1 (resolution_failures,
964  pr - vam->pending_routes);
965  }
966  else
967  {
968  pme->resolve_attempts -= 1;
969  if (pme->resolve_attempts == 0)
970  vec_add1 (resolution_failures,
971  pr - vam->pending_routes);
972  }
973  }));
974  /* *INDENT-ON* */
975  for (i = 0; i < vec_len (resolution_failures); i++)
976  {
978  resolution_failures[i]);
979  adr = &pr->r;
980  pme = &pr->t;
981 
982  switch (pr->resolve_type)
983  {
985  clib_warning ("resolver: add %U/%d via %U retry failure",
987  (ip4_address_t *) & (adr->dst_address),
988  adr->dst_address_length,
990  (ip4_address_t *) & (adr->next_hop_address));
991  break;
992 
994  clib_warning ("resolver: add %U/%d via %U retry failure",
996  (ip6_address_t *) & (adr->dst_address),
997  adr->dst_address_length,
999  (ip6_address_t *) & (adr->next_hop_address));
1000  break;
1001 
1003  clib_warning ("resolver: add mpls-o-e via %U retry failure",
1005  (ip4_address_t *) &
1007  break;
1008 
1009  default:
1010  clib_warning ("BUG");
1011  }
1012  pool_put (vam->pending_routes, pr);
1013  }
1014  vec_reset_length (resolution_failures);
1015  break;
1016  }
1017  if (pool_elts (vam->pending_routes) == 0)
1018  timeout = 100.0;
1019  vec_reset_length (event_data);
1020  }
1021  return 0; /* or not */
1022 }
1023 
1024 /* *INDENT-OFF* */
1025 VLIB_REGISTER_NODE (vpe_resolver_process_node,static) = {
1026  .function = resolver_process,
1027  .type = VLIB_NODE_TYPE_PROCESS,
1028  .name = "vpe-route-resolver-process",
1029 };
1030 /* *INDENT-ON* */
1031 
1032 static int
1034  u8 is_add,
1035  u8 is_drop,
1036  u8 is_unreach,
1037  u8 is_prohibit,
1038  u8 is_local,
1039  u8 is_classify,
1040  u32 classify_table_index,
1041  u8 is_resolve_host,
1042  u8 is_resolve_attached,
1043  u32 fib_index,
1044  const fib_prefix_t * prefix,
1045  u8 next_hop_proto_is_ip4,
1046  const ip46_address_t * next_hop,
1047  u32 next_hop_sw_if_index,
1048  u8 next_hop_fib_index,
1049  u32 next_hop_weight, u32 next_hop_out_label)
1050 {
1052  stats_main_t *sm = &stats_main;
1053 
1054  if (is_multipath)
1055  {
1057 
1058  dslock (sm, 1 /* release hint */ , 10 /* tag */ );
1059 
1060  if (is_resolve_host)
1061  path_flags |= FIB_ROUTE_PATH_RESOLVE_VIA_HOST;
1062  if (is_resolve_attached)
1064 
1065  if (is_add)
1066  fib_table_entry_path_add (fib_index,
1067  prefix,
1070  (next_hop_proto_is_ip4 ?
1073  next_hop,
1074  next_hop_sw_if_index,
1075  next_hop_fib_index,
1076  next_hop_weight,
1077  next_hop_out_label, path_flags);
1078  else
1079  fib_table_entry_path_remove (fib_index,
1080  prefix,
1082  (next_hop_proto_is_ip4 ?
1084  FIB_PROTOCOL_IP6),
1085  next_hop,
1086  next_hop_sw_if_index,
1087  next_hop_fib_index,
1088  next_hop_weight, path_flags);
1089 
1090  dsunlock (sm);
1091  return 0;
1092  }
1093 
1094  dslock (sm, 1 /* release hint */ , 2 /* tag */ );
1095 
1096  if (is_drop || is_local || is_classify || is_unreach || is_prohibit)
1097  {
1098  /*
1099  * special route types that link directly to the adj
1100  */
1101  if (is_add)
1102  {
1103  dpo_id_t dpo = DPO_INVALID;
1104  dpo_proto_t dproto;
1105 
1106  dproto = fib_proto_to_dpo (prefix->fp_proto);
1107 
1108  if (is_drop)
1110  else if (is_local)
1111  receive_dpo_add_or_lock (dproto, ~0, NULL, &dpo);
1112  else if (is_unreach)
1113  ip_null_dpo_add_and_lock (dproto,
1115  else if (is_prohibit)
1116  ip_null_dpo_add_and_lock (dproto,
1118  &dpo);
1119  else if (is_classify)
1120  {
1121  if (pool_is_free_index (cm->tables,
1122  ntohl (classify_table_index)))
1123  {
1124  dsunlock (sm);
1125  return VNET_API_ERROR_NO_SUCH_TABLE;
1126  }
1127 
1128  dpo_set (&dpo, DPO_CLASSIFY, dproto,
1129  classify_dpo_create (dproto,
1130  ntohl (classify_table_index)));
1131  }
1132  else
1133  {
1134  dsunlock (sm);
1135  return VNET_API_ERROR_NO_SUCH_TABLE;
1136  }
1137 
1139  prefix,
1141  FIB_ENTRY_FLAG_EXCLUSIVE, &dpo);
1142  dpo_reset (&dpo);
1143  }
1144  else
1145  {
1146  fib_table_entry_special_remove (fib_index, prefix, FIB_SOURCE_API);
1147  }
1148  }
1149  else
1150  {
1151  if (is_add)
1152  {
1154 
1155  if (is_resolve_host)
1156  path_flags |= FIB_ROUTE_PATH_RESOLVE_VIA_HOST;
1157  if (is_resolve_attached)
1159 
1161  prefix,
1164  (next_hop_proto_is_ip4 ?
1167  next_hop,
1168  next_hop_sw_if_index,
1169  next_hop_fib_index,
1170  next_hop_weight,
1171  next_hop_out_label, path_flags);
1172  }
1173  else
1174  {
1175  fib_table_entry_delete (fib_index, prefix, FIB_SOURCE_API);
1176  }
1177  }
1178 
1179  dsunlock (sm);
1180  return (0);
1181 }
1182 
1183 static int
1185  u32 table_id,
1186  u32 next_hop_sw_if_index,
1187  fib_protocol_t next_hop_table_proto,
1188  u32 next_hop_table_id,
1189  u8 create_missing_tables,
1190  u32 * fib_index, u32 * next_hop_fib_index)
1191 {
1192  vnet_main_t *vnm = vnet_get_main ();
1193 
1194  *fib_index = fib_table_find (table_proto, ntohl (table_id));
1195  if (~0 == *fib_index)
1196  {
1197  if (create_missing_tables)
1198  {
1199  *fib_index = fib_table_find_or_create_and_lock (table_proto,
1200  ntohl (table_id));
1201  }
1202  else
1203  {
1204  /* No such VRF, and we weren't asked to create one */
1205  return VNET_API_ERROR_NO_SUCH_FIB;
1206  }
1207  }
1208 
1209  if (~0 != ntohl (next_hop_sw_if_index))
1210  {
1212  ntohl (next_hop_sw_if_index)))
1213  {
1214  return VNET_API_ERROR_NO_MATCHING_INTERFACE;
1215  }
1216  }
1217  else
1218  {
1219  *next_hop_fib_index = fib_table_find (next_hop_table_proto,
1220  ntohl (next_hop_table_id));
1221 
1222  if (~0 == *next_hop_fib_index)
1223  {
1224  if (create_missing_tables)
1225  {
1226  *next_hop_fib_index =
1227  fib_table_find_or_create_and_lock (next_hop_table_proto,
1228  ntohl (next_hop_table_id));
1229  }
1230  else
1231  {
1232  /* No such VRF, and we weren't asked to create one */
1233  return VNET_API_ERROR_NO_SUCH_FIB;
1234  }
1235  }
1236  }
1237 
1238  return (0);
1239 }
1240 
1241 static int
1243 {
1244  u32 fib_index, next_hop_fib_index;
1245  int rv;
1246 
1248  mp->table_id,
1251  mp->next_hop_table_id,
1253  &fib_index, &next_hop_fib_index);
1254 
1255  if (0 != rv)
1256  return (rv);
1257 
1258  fib_prefix_t pfx = {
1259  .fp_len = mp->dst_address_length,
1260  .fp_proto = FIB_PROTOCOL_IP4,
1261  };
1262  clib_memcpy (&pfx.fp_addr.ip4, mp->dst_address, sizeof (pfx.fp_addr.ip4));
1263 
1264  ip46_address_t nh;
1265  memset (&nh, 0, sizeof (nh));
1266  memcpy (&nh.ip4, mp->next_hop_address, sizeof (nh.ip4));
1267 
1269  mp->is_add,
1270  mp->is_drop,
1271  mp->is_unreach,
1272  mp->is_prohibit,
1273  mp->is_local,
1274  mp->is_classify,
1276  mp->is_resolve_host,
1277  mp->is_resolve_attached,
1278  fib_index, &pfx, 1,
1279  &nh,
1280  ntohl (mp->next_hop_sw_if_index),
1281  next_hop_fib_index,
1282  mp->next_hop_weight,
1283  ntohl (mp->next_hop_out_label)));
1284 }
1285 
1286 static int
1288 {
1289  u32 fib_index, next_hop_fib_index;
1290  int rv;
1291 
1293  mp->table_id,
1296  mp->next_hop_table_id,
1298  &fib_index, &next_hop_fib_index);
1299 
1300  if (0 != rv)
1301  return (rv);
1302 
1303  fib_prefix_t pfx = {
1304  .fp_len = mp->dst_address_length,
1305  .fp_proto = FIB_PROTOCOL_IP6,
1306  };
1307  clib_memcpy (&pfx.fp_addr.ip6, mp->dst_address, sizeof (pfx.fp_addr.ip6));
1308 
1309  ip46_address_t nh;
1310  memset (&nh, 0, sizeof (nh));
1311  memcpy (&nh.ip6, mp->next_hop_address, sizeof (nh.ip6));
1312 
1314  mp->is_add,
1315  mp->is_drop,
1316  mp->is_unreach,
1317  mp->is_prohibit,
1318  mp->is_local,
1319  mp->is_classify,
1321  mp->is_resolve_host,
1322  mp->is_resolve_attached,
1323  fib_index, &pfx, 0,
1324  &nh, ntohl (mp->next_hop_sw_if_index),
1325  next_hop_fib_index,
1326  mp->next_hop_weight,
1327  ntohl (mp->next_hop_out_label)));
1328 }
1329 
1330 static int
1333 {
1334  u32 fib_index, next_hop_fib_index;
1335 
1336  int rv;
1337 
1338  fib_prefix_t pfx = {
1339  .fp_len = 21,
1340  .fp_proto = FIB_PROTOCOL_MPLS,
1341  .fp_eos = mp->mr_eos,
1342  .fp_label = ntohl (mp->mr_label),
1343  };
1344  if (pfx.fp_eos)
1345  {
1346  if (mp->mr_next_hop_proto_is_ip4)
1347  {
1349  }
1350  else
1351  {
1353  }
1354  }
1355  else
1356  {
1358  }
1359 
1361  mp->mr_table_id,
1366  &fib_index, &next_hop_fib_index);
1367 
1368  if (0 != rv)
1369  return (rv);
1370 
1371  ip46_address_t nh;
1372  memset (&nh, 0, sizeof (nh));
1373 
1374  if (mp->mr_next_hop_proto_is_ip4)
1375  memcpy (&nh.ip4, mp->mr_next_hop, sizeof (nh.ip4));
1376  else
1377  memcpy (&nh.ip6, mp->mr_next_hop, sizeof (nh.ip6));
1378 
1379  return (add_del_route_t_handler (mp->mr_is_multipath, mp->mr_is_add, 0, // mp->is_drop,
1380  0, // mp->is_unreach,
1381  0, // mp->is_prohibit,
1382  0, // mp->is_local,
1383  mp->mr_is_classify,
1385  mp->mr_is_resolve_host,
1387  fib_index, &pfx,
1389  &nh, ntohl (mp->mr_next_hop_sw_if_index),
1390  next_hop_fib_index,
1391  mp->mr_next_hop_weight,
1392  ntohl (mp->mr_next_hop_out_label)));
1393 }
1394 
1395 void
1397 {
1399  int rv;
1400  vnet_main_t *vnm = vnet_get_main ();
1401 
1402  vnm->api_errno = 0;
1403 
1404  if (mp->is_ipv6)
1405  rv = ip6_add_del_route_t_handler (mp);
1406  else
1407  rv = ip4_add_del_route_t_handler (mp);
1408 
1409  rv = (rv == 0) ? vnm->api_errno : rv;
1410 
1411  REPLY_MACRO (VL_API_IP_ADD_DEL_ROUTE_REPLY);
1412 }
1413 
1414 void
1416 {
1418  vnet_main_t *vnm;
1419  int rv;
1420 
1421  vnm = vnet_get_main ();
1422  vnm->api_errno = 0;
1423 
1424  rv = mpls_route_add_del_t_handler (vnm, mp);
1425 
1426  rv = (rv == 0) ? vnm->api_errno : rv;
1427 
1428  REPLY_MACRO (VL_API_MPLS_ROUTE_ADD_DEL_REPLY);
1429 }
1430 
1431 static int
1434 {
1435  u32 mpls_fib_index, ip_fib_index;
1436 
1437  mpls_fib_index =
1439 
1440  if (~0 == mpls_fib_index)
1441  {
1442  if (mp->mb_create_table_if_needed)
1443  {
1444  mpls_fib_index =
1446  ntohl (mp->mb_mpls_table_id));
1447  }
1448  else
1449  return VNET_API_ERROR_NO_SUCH_FIB;
1450  }
1451 
1452  ip_fib_index = fib_table_find ((mp->mb_is_ip4 ?
1455  ntohl (mp->mb_ip_table_id));
1456  if (~0 == ip_fib_index)
1457  return VNET_API_ERROR_NO_SUCH_FIB;
1458 
1459  fib_prefix_t pfx = {
1460  .fp_len = mp->mb_address_length,
1461  };
1462 
1463  if (mp->mb_is_ip4)
1464  {
1465  pfx.fp_proto = FIB_PROTOCOL_IP4;
1466  clib_memcpy (&pfx.fp_addr.ip4, mp->mb_address,
1467  sizeof (pfx.fp_addr.ip4));
1468  }
1469  else
1470  {
1471  pfx.fp_proto = FIB_PROTOCOL_IP6;
1472  clib_memcpy (&pfx.fp_addr.ip6, mp->mb_address,
1473  sizeof (pfx.fp_addr.ip6));
1474  }
1475 
1476  if (mp->mb_is_bind)
1477  fib_table_entry_local_label_add (ip_fib_index, &pfx,
1478  ntohl (mp->mb_label));
1479  else
1480  fib_table_entry_local_label_remove (ip_fib_index, &pfx,
1481  ntohl (mp->mb_label));
1482 
1483  return (0);
1484 }
1485 
1486 void
1488 {
1490  vnet_main_t *vnm;
1491  int rv;
1492 
1493  vnm = vnet_get_main ();
1494  vnm->api_errno = 0;
1495 
1496  rv = mpls_ip_bind_unbind_handler (vnm, mp);
1497 
1498  rv = (rv == 0) ? vnm->api_errno : rv;
1499 
1500  REPLY_MACRO (VL_API_MPLS_ROUTE_ADD_DEL_REPLY);
1501 }
1502 
1503 static void
1506 {
1507  vlib_main_t *vm = vlib_get_main ();
1509  int rv = 0;
1510  u32 is_del;
1511 
1512  VALIDATE_SW_IF_INDEX (mp);
1513 
1514  is_del = mp->is_add == 0;
1515 
1516  if (mp->del_all)
1517  ip_del_all_interface_addresses (vm, ntohl (mp->sw_if_index));
1518  else if (mp->is_ipv6)
1519  ip6_add_del_interface_address (vm, ntohl (mp->sw_if_index),
1520  (void *) mp->address,
1521  mp->address_length, is_del);
1522  else
1523  ip4_add_del_interface_address (vm, ntohl (mp->sw_if_index),
1524  (void *) mp->address,
1525  mp->address_length, is_del);
1526 
1528 
1529  REPLY_MACRO (VL_API_SW_INTERFACE_ADD_DEL_ADDRESS_REPLY);
1530 }
1531 
1532 static void
1534 {
1535  int rv = 0;
1536  u32 table_id = ntohl (mp->vrf_id);
1537  u32 sw_if_index = ntohl (mp->sw_if_index);
1539  stats_main_t *sm = &stats_main;
1540  u32 fib_index;
1541 
1542  VALIDATE_SW_IF_INDEX (mp);
1543 
1544  dslock (sm, 1 /* release hint */ , 4 /* tag */ );
1545 
1546  if (mp->is_ipv6)
1547  {
1549  table_id);
1550 
1552  ip6_main.fib_index_by_sw_if_index[sw_if_index] = fib_index;
1553  }
1554  else
1555  {
1556 
1558  table_id);
1559 
1561  ip4_main.fib_index_by_sw_if_index[sw_if_index] = fib_index;
1562  }
1563  dsunlock (sm);
1564 
1566 
1567  REPLY_MACRO (VL_API_SW_INTERFACE_SET_TABLE_REPLY);
1568 }
1569 
1570 static void
1572 {
1573  vlib_main_t *vm = vlib_get_main ();
1574  ip4_main_t *im4 = &ip4_main;
1575  ip6_main_t *im6 = &ip6_main;
1577  int rv = 0;
1578  u32 ci;
1579  u32 sw_if_index = ntohl (mp->sw_if_index);
1580  ip4_main_t *ip4m = &ip4_main;
1581  ip6_main_t *ip6m = &ip6_main;
1582  ip_lookup_main_t *ip4lm = &ip4m->lookup_main;
1583  ip_lookup_main_t *ip6lm = &ip6m->lookup_main;
1584  vnet_feature_config_main_t *rx_cm4u =
1586  vnet_feature_config_main_t *rx_cm4m =
1588  vnet_feature_config_main_t *rx_cm6u =
1590  vnet_feature_config_main_t *rx_cm6m =
1592 
1593  VALIDATE_SW_IF_INDEX (mp);
1594 
1595  l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_VPATH, mp->enable);
1596  if (mp->enable)
1597  {
1598  ci = rx_cm4u->config_index_by_sw_if_index[sw_if_index]; //IP4 unicast
1599  ci = vnet_config_add_feature (vm, &rx_cm4u->config_main,
1600  ci,
1601  im4->ip4_unicast_rx_feature_vpath, 0, 0);
1602  rx_cm4u->config_index_by_sw_if_index[sw_if_index] = ci;
1603  ci = rx_cm4m->config_index_by_sw_if_index[sw_if_index]; //IP4 mcast
1604  ci = vnet_config_add_feature (vm, &rx_cm4m->config_main,
1605  ci,
1607  0, 0);
1608  rx_cm4m->config_index_by_sw_if_index[sw_if_index] = ci;
1609  ci = rx_cm6u->config_index_by_sw_if_index[sw_if_index]; //IP6 unicast
1610  ci = vnet_config_add_feature (vm, &rx_cm6u->config_main,
1611  ci,
1612  im6->ip6_unicast_rx_feature_vpath, 0, 0);
1613  rx_cm6u->config_index_by_sw_if_index[sw_if_index] = ci;
1614  ci = rx_cm6m->config_index_by_sw_if_index[sw_if_index]; //IP6 mcast
1615  ci = vnet_config_add_feature (vm, &rx_cm6m->config_main,
1616  ci,
1618  0, 0);
1619  rx_cm6m->config_index_by_sw_if_index[sw_if_index] = ci;
1620  }
1621  else
1622  {
1623  ci = rx_cm4u->config_index_by_sw_if_index[sw_if_index]; //IP4 unicast
1624  ci = vnet_config_del_feature (vm, &rx_cm4u->config_main,
1625  ci,
1626  im4->ip4_unicast_rx_feature_vpath, 0, 0);
1627  rx_cm4u->config_index_by_sw_if_index[sw_if_index] = ci;
1628  ci = rx_cm4m->config_index_by_sw_if_index[sw_if_index]; //IP4 mcast
1629  ci = vnet_config_del_feature (vm, &rx_cm4m->config_main,
1630  ci,
1632  0, 0);
1633  rx_cm4m->config_index_by_sw_if_index[sw_if_index] = ci;
1634  ci = rx_cm6u->config_index_by_sw_if_index[sw_if_index]; //IP6 unicast
1635  ci = vnet_config_del_feature (vm, &rx_cm6u->config_main,
1636  ci,
1637  im6->ip6_unicast_rx_feature_vpath, 0, 0);
1638  rx_cm6u->config_index_by_sw_if_index[sw_if_index] = ci;
1639  ci = rx_cm6m->config_index_by_sw_if_index[sw_if_index]; //IP6 mcast
1640  ci = vnet_config_del_feature (vm, &rx_cm6m->config_main,
1641  ci,
1643  0, 0);
1644  rx_cm6m->config_index_by_sw_if_index[sw_if_index] = ci;
1645  }
1646 
1648 
1649  REPLY_MACRO (VL_API_SW_INTERFACE_SET_VPATH_REPLY);
1650 }
1651 
1652 static void
1655 {
1657  int rv = 0;
1658  u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index);
1659  u32 tx_sw_if_index = ntohl (mp->tx_sw_if_index);
1660  vlib_main_t *vm = vlib_get_main ();
1661  vnet_main_t *vnm = vnet_get_main ();
1662 
1664 
1665  if (mp->enable)
1666  {
1668  rv = set_int_l2_mode (vm, vnm, MODE_L2_XC,
1669  rx_sw_if_index, 0, 0, 0, tx_sw_if_index);
1670  }
1671  else
1672  {
1673  rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, 0, 0, 0);
1674  }
1675 
1678 
1679  REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_XCONNECT_REPLY);
1680 }
1681 
1682 static void
1685 {
1686  bd_main_t *bdm = &bd_main;
1688  int rv = 0;
1689  u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index);
1690  u32 bd_id = ntohl (mp->bd_id);
1691  u32 bd_index;
1692  u32 bvi = mp->bvi;
1693  u8 shg = mp->shg;
1694  vlib_main_t *vm = vlib_get_main ();
1695  vnet_main_t *vnm = vnet_get_main ();
1696 
1698 
1699  bd_index = bd_find_or_add_bd_index (bdm, bd_id);
1700 
1701  if (mp->enable)
1702  {
1703  //VALIDATE_TX_SW_IF_INDEX(mp);
1704  rv = set_int_l2_mode (vm, vnm, MODE_L2_BRIDGE,
1705  rx_sw_if_index, bd_index, bvi, shg, 0);
1706  }
1707  else
1708  {
1709  rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, 0, 0, 0);
1710  }
1711 
1713 
1714  REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_BRIDGE_REPLY);
1715 }
1716 
1717 static void
1720 {
1722  int rv = 0;
1723 
1724 #if DPDK > 0
1725  dpdk_main_t *dm = &dpdk_main;
1726  dpdk_device_t *xd;
1727 
1728  u32 sw_if_index = ntohl (mp->sw_if_index);
1729  u32 subport = ntohl (mp->subport);
1730  u32 pipe = ntohl (mp->pipe);
1731  u32 profile = ntohl (mp->profile);
1732  vnet_hw_interface_t *hw;
1733 
1734  VALIDATE_SW_IF_INDEX (mp);
1735 
1736  /* hw_if & dpdk device */
1737  hw = vnet_get_sup_hw_interface (dm->vnet_main, sw_if_index);
1738 
1739  xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1740 
1741  rv = rte_sched_pipe_config (xd->hqos_ht->hqos, subport, pipe, profile);
1742 
1744 #else
1745  clib_warning ("setting HQoS pipe parameters without DPDK not implemented");
1746  rv = VNET_API_ERROR_UNIMPLEMENTED;
1747 #endif /* DPDK */
1748 
1749  REPLY_MACRO (VL_API_SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY);
1750 }
1751 
1752 static void
1755 {
1757  int rv = 0;
1758 
1759 #if DPDK > 0
1760  dpdk_main_t *dm = &dpdk_main;
1761  dpdk_device_t *xd;
1762  struct rte_sched_subport_params p;
1763 
1764  u32 sw_if_index = ntohl (mp->sw_if_index);
1765  u32 subport = ntohl (mp->subport);
1766  p.tb_rate = ntohl (mp->tb_rate);
1767  p.tb_size = ntohl (mp->tb_size);
1768  p.tc_rate[0] = ntohl (mp->tc_rate[0]);
1769  p.tc_rate[1] = ntohl (mp->tc_rate[1]);
1770  p.tc_rate[2] = ntohl (mp->tc_rate[2]);
1771  p.tc_rate[3] = ntohl (mp->tc_rate[3]);
1772  p.tc_period = ntohl (mp->tc_period);
1773 
1774  vnet_hw_interface_t *hw;
1775 
1776  VALIDATE_SW_IF_INDEX (mp);
1777 
1778  /* hw_if & dpdk device */
1779  hw = vnet_get_sup_hw_interface (dm->vnet_main, sw_if_index);
1780 
1781  xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1782 
1783  rv = rte_sched_subport_config (xd->hqos_ht->hqos, subport, &p);
1784 
1786 #else
1787  clib_warning
1788  ("setting HQoS subport parameters without DPDK not implemented");
1789  rv = VNET_API_ERROR_UNIMPLEMENTED;
1790 #endif /* DPDK */
1791 
1792  REPLY_MACRO (VL_API_SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY);
1793 }
1794 
1795 static void
1798 {
1800  int rv = 0;
1801 
1802 #if DPDK > 0
1803  dpdk_main_t *dm = &dpdk_main;
1805  dpdk_device_t *xd;
1806 
1807  u32 sw_if_index = ntohl (mp->sw_if_index);
1808  u32 entry = ntohl (mp->entry);
1809  u32 tc = ntohl (mp->tc);
1810  u32 queue = ntohl (mp->queue);
1811  u32 val, i;
1812 
1813  vnet_hw_interface_t *hw;
1814 
1815  VALIDATE_SW_IF_INDEX (mp);
1816 
1817  /* hw_if & dpdk device */
1818  hw = vnet_get_sup_hw_interface (dm->vnet_main, sw_if_index);
1819 
1820  xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1821 
1822  if (tc >= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE)
1823  {
1824  clib_warning ("invalid traffic class !!");
1825  rv = VNET_API_ERROR_INVALID_VALUE;
1826  goto done;
1827  }
1828  if (queue >= RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS)
1829  {
1830  clib_warning ("invalid queue !!");
1831  rv = VNET_API_ERROR_INVALID_VALUE;
1832  goto done;
1833  }
1834 
1835  /* Detect the set of worker threads */
1836  uword *p = hash_get_mem (tm->thread_registrations_by_name, "workers");
1837 
1838  if (p == 0)
1839  {
1840  clib_warning ("worker thread registration AWOL !!");
1841  rv = VNET_API_ERROR_INVALID_VALUE_2;
1842  goto done;
1843  }
1844 
1846  int worker_thread_first = tr->first_index;
1847  int worker_thread_count = tr->count;
1848 
1849  val = tc * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS + queue;
1850  for (i = 0; i < worker_thread_count; i++)
1851  xd->hqos_wt[worker_thread_first + i].hqos_tc_table[entry] = val;
1852 
1854 done:
1855 #else
1856  clib_warning ("setting HQoS DSCP table entry without DPDK not implemented");
1857  rv = VNET_API_ERROR_UNIMPLEMENTED;
1858 #endif /* DPDK */
1859 
1860  REPLY_MACRO (VL_API_SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY);
1861 }
1862 
1863 static void
1865 {
1866  vlib_main_t *vm = vlib_get_main ();
1867  bd_main_t *bdm = &bd_main;
1869  int rv = 0;
1870  u32 enable_flags = 0, disable_flags = 0;
1871  u32 bd_id = ntohl (mp->bd_id);
1872  u32 bd_index;
1873 
1874  if (mp->is_add)
1875  {
1876  bd_index = bd_find_or_add_bd_index (bdm, bd_id);
1877 
1878  if (mp->flood)
1879  enable_flags |= L2_FLOOD;
1880  else
1881  disable_flags |= L2_FLOOD;
1882 
1883  if (mp->uu_flood)
1884  enable_flags |= L2_UU_FLOOD;
1885  else
1886  disable_flags |= L2_UU_FLOOD;
1887 
1888  if (mp->forward)
1889  enable_flags |= L2_FWD;
1890  else
1891  disable_flags |= L2_FWD;
1892 
1893  if (mp->arp_term)
1894  enable_flags |= L2_ARP_TERM;
1895  else
1896  disable_flags |= L2_ARP_TERM;
1897 
1898  if (mp->learn)
1899  enable_flags |= L2_LEARN;
1900  else
1901  disable_flags |= L2_LEARN;
1902 
1903  if (enable_flags)
1904  bd_set_flags (vm, bd_index, enable_flags, 1 /* enable */ );
1905 
1906  if (disable_flags)
1907  bd_set_flags (vm, bd_index, disable_flags, 0 /* disable */ );
1908 
1909  }
1910  else
1911  rv = bd_delete_bd_index (bdm, bd_id);
1912 
1913  REPLY_MACRO (VL_API_BRIDGE_DOMAIN_ADD_DEL_REPLY);
1914 }
1915 
1916 static void
1918 {
1919  clib_warning ("BUG");
1920 }
1921 
1922 static void
1925 {
1926  clib_warning ("BUG");
1927 }
1928 
1929 static void
1931  l2_bridge_domain_t * bd_config,
1932  u32 n_sw_ifs, u32 context)
1933 {
1935 
1936  mp = vl_msg_api_alloc (sizeof (*mp));
1937  memset (mp, 0, sizeof (*mp));
1938  mp->_vl_msg_id = ntohs (VL_API_BRIDGE_DOMAIN_DETAILS);
1939  mp->bd_id = ntohl (bd_config->bd_id);
1940  mp->flood = bd_feature_flood (bd_config);
1941  mp->uu_flood = bd_feature_uu_flood (bd_config);
1942  mp->forward = bd_feature_forward (bd_config);
1943  mp->learn = bd_feature_learn (bd_config);
1944  mp->arp_term = bd_feature_arp_term (bd_config);
1945  mp->bvi_sw_if_index = ntohl (bd_config->bvi_sw_if_index);
1946  mp->n_sw_ifs = ntohl (n_sw_ifs);
1947  mp->context = context;
1948 
1949  vl_msg_api_send_shmem (q, (u8 *) & mp);
1950 }
1951 
1952 static void
1955  l2_flood_member_t * member, u32 bd_id, u32 context)
1956 {
1958  l2_input_config_t *input_cfg;
1959 
1960  mp = vl_msg_api_alloc (sizeof (*mp));
1961  memset (mp, 0, sizeof (*mp));
1962  mp->_vl_msg_id = ntohs (VL_API_BRIDGE_DOMAIN_SW_IF_DETAILS);
1963  mp->bd_id = ntohl (bd_id);
1964  mp->sw_if_index = ntohl (member->sw_if_index);
1965  input_cfg = vec_elt_at_index (l2im->configs, member->sw_if_index);
1966  mp->shg = input_cfg->shg;
1967  mp->context = context;
1968 
1969  vl_msg_api_send_shmem (q, (u8 *) & mp);
1970 }
1971 
1972 static void
1974 {
1975  bd_main_t *bdm = &bd_main;
1976  l2input_main_t *l2im = &l2input_main;
1978  l2_bridge_domain_t *bd_config;
1979  u32 bd_id, bd_index;
1980  u32 end;
1981 
1983 
1984  if (q == 0)
1985  return;
1986 
1987  bd_id = ntohl (mp->bd_id);
1988 
1989  bd_index = (bd_id == ~0) ? 0 : bd_find_or_add_bd_index (bdm, bd_id);
1990  end = (bd_id == ~0) ? vec_len (l2im->bd_configs) : bd_index + 1;
1991  for (; bd_index < end; bd_index++)
1992  {
1993  bd_config = l2input_bd_config_from_index (l2im, bd_index);
1994  /* skip dummy bd_id 0 */
1995  if (bd_config && (bd_config->bd_id > 0))
1996  {
1997  u32 n_sw_ifs;
1998  l2_flood_member_t *m;
1999 
2000  n_sw_ifs = vec_len (bd_config->members);
2001  send_bridge_domain_details (q, bd_config, n_sw_ifs, mp->context);
2002 
2003  vec_foreach (m, bd_config->members)
2004  {
2005  send_bd_sw_if_details (l2im, q, m, bd_config->bd_id, mp->context);
2006  }
2007  }
2008  }
2009 }
2010 
2011 static void
2013 {
2014  bd_main_t *bdm = &bd_main;
2015  l2input_main_t *l2im = &l2input_main;
2017  int rv = 0;
2018  u64 mac = 0;
2019  u32 sw_if_index = ntohl (mp->sw_if_index);
2020  u32 bd_id = ntohl (mp->bd_id);
2021  u32 bd_index;
2022  u32 static_mac;
2023  u32 filter_mac;
2024  u32 bvi_mac;
2025  uword *p;
2026 
2027  mac = mp->mac;
2028 
2029  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
2030  if (!p)
2031  {
2032  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
2033  goto bad_sw_if_index;
2034  }
2035  bd_index = p[0];
2036 
2037  if (mp->is_add)
2038  {
2039  VALIDATE_SW_IF_INDEX (mp);
2040  if (vec_len (l2im->configs) <= sw_if_index)
2041  {
2042  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
2043  goto bad_sw_if_index;
2044  }
2045  else
2046  {
2047  l2_input_config_t *config;
2048  config = vec_elt_at_index (l2im->configs, sw_if_index);
2049  if (config->bridge == 0)
2050  {
2051  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
2052  goto bad_sw_if_index;
2053  }
2054  }
2055  static_mac = mp->static_mac ? 1 : 0;
2056  filter_mac = mp->filter_mac ? 1 : 0;
2057  bvi_mac = mp->bvi_mac ? 1 : 0;
2058  l2fib_add_entry (mac, bd_index, sw_if_index, static_mac, filter_mac,
2059  bvi_mac);
2060  }
2061  else
2062  {
2063  l2fib_del_entry (mac, bd_index);
2064  }
2065 
2067 
2068  REPLY_MACRO (VL_API_L2FIB_ADD_DEL_REPLY);
2069 }
2070 
2071 static void
2073 {
2075  int rv = 0;
2076  u32 sw_if_index = ntohl (mp->sw_if_index);
2077  u32 flags = ntohl (mp->feature_bitmap);
2078  u32 rbm = 0;
2079 
2080  VALIDATE_SW_IF_INDEX (mp);
2081 
2082 #define _(a,b) \
2083  if (flags & L2INPUT_FEAT_ ## a) \
2084  rbm = l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_ ## a, mp->is_set);
2086 #undef _
2087 
2089 
2090  /* *INDENT-OFF* */
2091  REPLY_MACRO2(VL_API_L2_FLAGS_REPLY,
2092  ({
2093  rmp->resulting_feature_bitmap = ntohl(rbm);
2094  }));
2095  /* *INDENT-ON* */
2096 }
2097 
2098 static void
2100 {
2101  vlib_main_t *vm = vlib_get_main ();
2102  bd_main_t *bdm = &bd_main;
2104  int rv = 0;
2105  u32 bd_id = ntohl (mp->bd_id);
2106  u32 bd_index;
2107  u32 flags = ntohl (mp->feature_bitmap);
2108  uword *p;
2109 
2110  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
2111  if (p == 0)
2112  {
2113  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
2114  goto out;
2115  }
2116 
2117  bd_index = p[0];
2118 
2119  bd_set_flags (vm, bd_index, flags, mp->is_set);
2120 
2121 out:
2122  /* *INDENT-OFF* */
2123  REPLY_MACRO2(VL_API_BRIDGE_FLAGS_REPLY,
2124  ({
2125  rmp->resulting_feature_bitmap = ntohl(flags);
2126  }));
2127  /* *INDENT-ON* */
2128 }
2129 
2130 static void
2132 {
2133  bd_main_t *bdm = &bd_main;
2135  int rv = 0;
2136  u32 bd_id = ntohl (mp->bd_id);
2137  u32 bd_index;
2138  uword *p;
2139 
2140  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
2141  if (p == 0)
2142  {
2143  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
2144  goto out;
2145  }
2146 
2147  bd_index = p[0];
2148  if (bd_add_del_ip_mac (bd_index, mp->ip_address,
2149  mp->mac_address, mp->is_ipv6, mp->is_add))
2150  rv = VNET_API_ERROR_UNSPECIFIED;
2151 
2152 out:
2153  REPLY_MACRO (VL_API_BD_IP_MAC_ADD_DEL_REPLY);
2154 }
2155 
2156 static void
2158 {
2159  int rv;
2162  u32 sw_if_index = (u32) ~ 0;
2163 
2164  rv = vnet_tap_connect_renumber (vm, mp->tap_name,
2165  mp->use_random_mac ? 0 : mp->mac_address,
2166  &sw_if_index, mp->renumber,
2167  ntohl (mp->custom_dev_instance));
2168 
2170  if (!q)
2171  return;
2172 
2173  rmp = vl_msg_api_alloc (sizeof (*rmp));
2174  rmp->_vl_msg_id = ntohs (VL_API_TAP_CONNECT_REPLY);
2175  rmp->context = mp->context;
2176  rmp->retval = ntohl (rv);
2177  rmp->sw_if_index = ntohl (sw_if_index);
2178 
2179  vl_msg_api_send_shmem (q, (u8 *) & rmp);
2180 }
2181 
2182 static void
2184 {
2185  int rv;
2188  u32 sw_if_index = (u32) ~ 0;
2189 
2190  rv = vnet_tap_modify (vm, ntohl (mp->sw_if_index), mp->tap_name,
2191  mp->use_random_mac ? 0 : mp->mac_address,
2192  &sw_if_index, mp->renumber,
2193  ntohl (mp->custom_dev_instance));
2194 
2196  if (!q)
2197  return;
2198 
2199  rmp = vl_msg_api_alloc (sizeof (*rmp));
2200  rmp->_vl_msg_id = ntohs (VL_API_TAP_MODIFY_REPLY);
2201  rmp->context = mp->context;
2202  rmp->retval = ntohl (rv);
2203  rmp->sw_if_index = ntohl (sw_if_index);
2204 
2205  vl_msg_api_send_shmem (q, (u8 *) & rmp);
2206 }
2207 
2208 static void
2210 {
2211  int rv;
2212  vpe_api_main_t *vam = &vpe_api_main;
2215  u32 sw_if_index = ntohl (mp->sw_if_index);
2216 
2217  rv = vnet_tap_delete (vm, sw_if_index);
2218 
2220  if (!q)
2221  return;
2222 
2223  rmp = vl_msg_api_alloc (sizeof (*rmp));
2224  rmp->_vl_msg_id = ntohs (VL_API_TAP_DELETE_REPLY);
2225  rmp->context = mp->context;
2226  rmp->retval = ntohl (rv);
2227 
2228  vl_msg_api_send_shmem (q, (u8 *) & rmp);
2229 
2230  if (!rv)
2231  send_sw_interface_flags_deleted (vam, q, sw_if_index);
2232 }
2233 
2234 static void
2236 {
2238  vnet_main_t *vnm = vnet_get_main ();
2239  u32 hw_if_index, sw_if_index = (u32) ~ 0;
2241  int rv = 0;
2242  u32 id;
2243  vnet_sw_interface_t template;
2244  uword *p;
2246  u64 sup_and_sub_key;
2247  u64 *kp;
2249  clib_error_t *error;
2250 
2251  VALIDATE_SW_IF_INDEX (mp);
2252 
2253  hw_if_index = ntohl (mp->sw_if_index);
2254  hi = vnet_get_hw_interface (vnm, hw_if_index);
2255 
2256  id = ntohl (mp->vlan_id);
2257  if (id == 0 || id > 4095)
2258  {
2259  rv = VNET_API_ERROR_INVALID_VLAN;
2260  goto out;
2261  }
2262 
2263  sup_and_sub_key = ((u64) (hi->sw_if_index) << 32) | (u64) id;
2264 
2265  p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
2266  if (p)
2267  {
2268  rv = VNET_API_ERROR_VLAN_ALREADY_EXISTS;
2269  goto out;
2270  }
2271 
2272  kp = clib_mem_alloc (sizeof (*kp));
2273  *kp = sup_and_sub_key;
2274 
2275  memset (&template, 0, sizeof (template));
2276  template.type = VNET_SW_INTERFACE_TYPE_SUB;
2277  template.sup_sw_if_index = hi->sw_if_index;
2278  template.sub.id = id;
2279  template.sub.eth.raw_flags = 0;
2280  template.sub.eth.flags.one_tag = 1;
2281  template.sub.eth.outer_vlan_id = id;
2282  template.sub.eth.flags.exact_match = 1;
2283 
2284  error = vnet_create_sw_interface (vnm, &template, &sw_if_index);
2285  if (error)
2286  {
2287  clib_error_report (error);
2288  rv = VNET_API_ERROR_INVALID_REGISTRATION;
2289  goto out;
2290  }
2291  hash_set (hi->sub_interface_sw_if_index_by_id, id, sw_if_index);
2292  hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index);
2293 
2295 
2296 out:
2298  if (!q)
2299  return;
2300 
2301  rmp = vl_msg_api_alloc (sizeof (*rmp));
2302  rmp->_vl_msg_id = ntohs (VL_API_CREATE_VLAN_SUBIF_REPLY);
2303  rmp->context = mp->context;
2304  rmp->retval = ntohl (rv);
2305  rmp->sw_if_index = ntohl (sw_if_index);
2306  vl_msg_api_send_shmem (q, (u8 *) & rmp);
2307 }
2308 
2309 static void
2311 {
2313  vnet_main_t *vnm = vnet_get_main ();
2314  u32 sw_if_index = ~0;
2315  int rv = 0;
2316  u32 sub_id;
2317  vnet_sw_interface_t *si;
2319  vnet_sw_interface_t template;
2320  uword *p;
2322  u64 sup_and_sub_key;
2323  u64 *kp;
2324  clib_error_t *error;
2325 
2326  VALIDATE_SW_IF_INDEX (mp);
2327 
2328  si = vnet_get_sup_sw_interface (vnm, ntohl (mp->sw_if_index));
2329  hi = vnet_get_sup_hw_interface (vnm, ntohl (mp->sw_if_index));
2330 
2332  {
2333  rv = VNET_API_ERROR_BOND_SLAVE_NOT_ALLOWED;
2334  goto out;
2335  }
2336 
2337  sw_if_index = si->sw_if_index;
2338  sub_id = ntohl (mp->sub_id);
2339 
2340  sup_and_sub_key = ((u64) (sw_if_index) << 32) | (u64) sub_id;
2341 
2342  p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
2343  if (p)
2344  {
2345  if (CLIB_DEBUG > 0)
2346  clib_warning ("sup sw_if_index %d, sub id %d already exists\n",
2347  sw_if_index, sub_id);
2348  rv = VNET_API_ERROR_SUBIF_ALREADY_EXISTS;
2349  goto out;
2350  }
2351 
2352  kp = clib_mem_alloc (sizeof (*kp));
2353  *kp = sup_and_sub_key;
2354 
2355  memset (&template, 0, sizeof (template));
2356  template.type = VNET_SW_INTERFACE_TYPE_SUB;
2357  template.sup_sw_if_index = sw_if_index;
2358  template.sub.id = sub_id;
2359  template.sub.eth.flags.no_tags = mp->no_tags;
2360  template.sub.eth.flags.one_tag = mp->one_tag;
2361  template.sub.eth.flags.two_tags = mp->two_tags;
2362  template.sub.eth.flags.dot1ad = mp->dot1ad;
2363  template.sub.eth.flags.exact_match = mp->exact_match;
2364  template.sub.eth.flags.default_sub = mp->default_sub;
2365  template.sub.eth.flags.outer_vlan_id_any = mp->outer_vlan_id_any;
2366  template.sub.eth.flags.inner_vlan_id_any = mp->inner_vlan_id_any;
2367  template.sub.eth.outer_vlan_id = ntohs (mp->outer_vlan_id);
2368  template.sub.eth.inner_vlan_id = ntohs (mp->inner_vlan_id);
2369 
2370  error = vnet_create_sw_interface (vnm, &template, &sw_if_index);
2371  if (error)
2372  {
2373  clib_error_report (error);
2374  rv = VNET_API_ERROR_SUBIF_CREATE_FAILED;
2375  goto out;
2376  }
2377 
2378  hash_set (hi->sub_interface_sw_if_index_by_id, sub_id, sw_if_index);
2379  hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index);
2380 
2382 
2383 out:
2384 
2385  /* *INDENT-OFF* */
2386  REPLY_MACRO2(VL_API_CREATE_SUBIF_REPLY,
2387  ({
2388  rmp->sw_if_index = ntohl(sw_if_index);
2389  }));
2390  /* *INDENT-ON* */
2391 }
2392 
2393 static void
2396 {
2398  int rv = 0;
2399  stats_main_t *sm = &stats_main;
2400  u32 tunnel_sw_if_index;
2401 
2402  dslock (sm, 1 /* release hint */ , 5 /* tag */ );
2403 
2405  (mp->dst_mac_address, (ip4_address_t *) (mp->adj_address),
2406  (u32) (mp->adj_address_length), ntohl (mp->vrf_id),
2407  ntohl (mp->tx_sw_if_index),
2408  &tunnel_sw_if_index, mp->l2_only, mp->is_add);
2409 
2410  dsunlock (sm);
2411 
2412  /* *INDENT-OFF* */
2413  REPLY_MACRO2(VL_API_MPLS_ETHERNET_ADD_DEL_TUNNEL_REPLY,
2414  ({
2415  rmp->tunnel_sw_if_index = ntohl(tunnel_sw_if_index);
2416  }));
2417  /* *INDENT-ON* */
2418 }
2419 
2420 /*
2421  * This piece of misery brought to you because the control-plane
2422  * can't figure out the tx interface + dst-mac address all by itself
2423  */
2426 {
2427  pending_route_t *pr;
2429  vnet_main_t *vnm = vnet_get_main ();
2430  vlib_main_t *vm = vlib_get_main ();
2431  stats_main_t *sm = &stats_main;
2432  vpe_api_main_t *vam = &vpe_api_main;
2433  u32 inner_fib_index, outer_fib_index;
2434  ip4_main_t *im = &ip4_main;
2435  ip_lookup_main_t *lm = &im->lookup_main;
2436  ip_adjacency_t *adj = 0;
2437  u32 lookup_result;
2438  u32 tx_sw_if_index;
2439  u8 *dst_mac_address;
2440  clib_error_t *e;
2441  uword *p;
2442  int rv;
2443  u32 tunnel_sw_if_index;
2444 
2445  p = hash_get (im->fib_index_by_table_id, ntohl (mp->outer_vrf_id));
2446  if (!p)
2447  return VNET_API_ERROR_NO_SUCH_FIB;
2448  else
2449  outer_fib_index = p[0];
2450 
2451 
2452  p = hash_get (im->fib_index_by_table_id, ntohl (mp->inner_vrf_id));
2453  if (!p)
2454  return VNET_API_ERROR_NO_SUCH_INNER_FIB;
2455  else
2456  inner_fib_index = p[0];
2457 
2458  if (inner_fib_index == outer_fib_index)
2459  return VNET_API_ERROR_INVALID_VALUE;
2460 
2461  // FIXME not an ADJ
2462  lookup_result = ip4_fib_table_lookup_lb (ip4_fib_get (outer_fib_index),
2463  (ip4_address_t *)
2465 
2466  adj = ip_get_adjacency (lm, lookup_result);
2467  tx_sw_if_index = adj->rewrite_header.sw_if_index;
2468 
2469  if (mp->is_add && mp->resolve_if_needed)
2470  {
2472  {
2473  pool_get (vam->pending_routes, pr);
2475  pme = &pr->t;
2476  clib_memcpy (pme, mp, sizeof (*pme));
2477  /* recursion block, "just in case" */
2478  pme->resolve_if_needed = 0;
2479  pme->resolve_attempts = ntohl (mp->resolve_attempts);
2480  pme->resolve_opaque = tx_sw_if_index;
2482  (vnm,
2484  vpe_resolver_process_node.index,
2485  RESOLUTION_EVENT, pr - vam->pending_routes);
2486 
2488  (vm, vpe_resolver_process_node.index,
2489  RESOLUTION_PENDING_EVENT, 0 /* data */ );
2490 
2491  /* The interface may be down, etc. */
2492  e = ip4_probe_neighbor
2494  tx_sw_if_index);
2495 
2496  if (e)
2497  clib_error_report (e);
2498 
2499  return VNET_API_ERROR_IN_PROGRESS;
2500  }
2501  }
2502 
2504  return VNET_API_ERROR_NEXT_HOP_NOT_IN_FIB;
2505 
2506  dst_mac_address =
2508  (&adj->rewrite_header, sizeof (adj->rewrite_data));
2509 
2510  dslock (sm, 1 /* release hint */ , 10 /* tag */ );
2511 
2513  (dst_mac_address, (ip4_address_t *) (mp->adj_address),
2514  (u32) (mp->adj_address_length), ntohl (mp->inner_vrf_id),
2515  tx_sw_if_index, &tunnel_sw_if_index, mp->l2_only, mp->is_add);
2516 
2517  dsunlock (sm);
2518 
2519  return rv;
2520 }
2521 
2522 static void
2525 {
2527  int rv = 0;
2528 
2530 
2531  REPLY_MACRO (VL_API_MPLS_ETHERNET_ADD_DEL_TUNNEL_2_REPLY);
2532 }
2533 
2534 
2535 static void
2537 {
2539  int rv;
2540  static u32 *labels;
2541  int i;
2542 
2543  vec_reset_length (labels);
2544 
2545  for (i = 0; i < mp->nlabels; i++)
2546  vec_add1 (labels, ntohl (mp->labels[i]));
2547 
2548  /* $$$$ fixme */
2550  ntohl (mp->vrf_id), labels,
2551  ~0 /* policy_tunnel_index */ ,
2552  0 /* no_dst_hash */ ,
2553  0 /* indexp */ ,
2554  mp->is_add);
2555 
2556  REPLY_MACRO (VL_API_MPLS_ADD_DEL_ENCAP_REPLY);
2557 }
2558 
2559 static void
2561 {
2563  u32 fib_index;
2564  int rv;
2565  ip4_main_t *im = &ip4_main;
2566  stats_main_t *sm = &stats_main;
2567  int vnet_proxy_arp_add_del (ip4_address_t * lo_addr,
2568  ip4_address_t * hi_addr,
2569  u32 fib_index, int is_del);
2570  uword *p;
2571 
2572  dslock (sm, 1 /* release hint */ , 6 /* tag */ );
2573 
2574  p = hash_get (im->fib_index_by_table_id, ntohl (mp->vrf_id));
2575 
2576  if (!p)
2577  {
2578  rv = VNET_API_ERROR_NO_SUCH_FIB;
2579  goto out;
2580  }
2581 
2582  fib_index = p[0];
2583 
2585  (ip4_address_t *) mp->hi_address,
2586  fib_index, mp->is_add == 0);
2587 
2588 out:
2589  dsunlock (sm);
2590  REPLY_MACRO (VL_API_PROXY_ARP_ADD_DEL_REPLY);
2591 }
2592 
2593 static void
2596 {
2597  int rv = 0;
2598  vnet_main_t *vnm = vnet_get_main ();
2600  vnet_sw_interface_t *si;
2601  u32 sw_if_index;
2602 
2603  VALIDATE_SW_IF_INDEX (mp);
2604 
2605  sw_if_index = ntohl (mp->sw_if_index);
2606 
2607  if (pool_is_free_index (vnm->interface_main.sw_interfaces, sw_if_index))
2608  {
2609  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
2610  goto out;
2611  }
2612 
2613  si = vnet_get_sw_interface (vnm, sw_if_index);
2614 
2615  ASSERT (si);
2616 
2617  if (mp->enable_disable)
2619  else
2621 
2623 
2624 out:
2625  REPLY_MACRO (VL_API_PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY);
2626 }
2627 
2628 static void
2630  vlib_main_t * vm)
2631 {
2633  vnet_main_t *vnm = vnet_get_main ();
2634  stats_main_t *sm = &stats_main;
2635  int rv = 0;
2636 
2637  VALIDATE_SW_IF_INDEX (mp);
2638 
2639  dslock (sm, 1 /* release hint */ , 7 /* tag */ );
2640 
2641  /*
2642  * there's no validation here of the ND/ARP entry being added.
2643  * The expectation is that the FIB will ensure that nothing bad
2644  * will come of adding bogus entries.
2645  */
2646  if (mp->is_ipv6)
2647  {
2648  if (mp->is_add)
2650  (vm, ntohl (mp->sw_if_index),
2651  (ip6_address_t *) (mp->dst_address),
2652  mp->mac_address, sizeof (mp->mac_address), mp->is_static);
2653  else
2655  (vm, ntohl (mp->sw_if_index),
2656  (ip6_address_t *) (mp->dst_address),
2657  mp->mac_address, sizeof (mp->mac_address));
2658  }
2659  else
2660  {
2661  ethernet_arp_ip4_over_ethernet_address_t a;
2662 
2663  clib_memcpy (&a.ethernet, mp->mac_address, 6);
2664  clib_memcpy (&a.ip4, mp->dst_address, 4);
2665 
2666  if (mp->is_add)
2667  rv = vnet_arp_set_ip4_over_ethernet (vnm, ntohl (mp->sw_if_index),
2668  &a, mp->is_static);
2669  else
2670  rv =
2671  vnet_arp_unset_ip4_over_ethernet (vnm, ntohl (mp->sw_if_index), &a);
2672  }
2673 
2675 
2676  dsunlock (sm);
2677  REPLY_MACRO (VL_API_IP_NEIGHBOR_ADD_DEL_REPLY);
2678 }
2679 
2680 static void
2682 {
2683 #if 0
2684  vpe_main_t *rm = &vpe_main;
2685  ip4_main_t *im4 = &ip4_main;
2686  ip6_main_t *im6 = &ip6_main;
2687  ip_lookup_main_t *lm;
2688  union
2689  {
2690  ip4_address_t ip4;
2691  ip6_address_t ip6;
2692  } addr;
2693  u32 adj_index, sw_if_index;
2695  ip_adjacency_t *adj;
2697 
2699  if (!q)
2700  {
2701  increment_missing_api_client_counter (rm->vlib_main);
2702  return;
2703  }
2704 
2705  rmp = vl_msg_api_alloc (sizeof (*rmp));
2706  clib_memcpy (rmp, mp, sizeof (*rmp));
2707 
2708  sw_if_index = mp->next_hop_sw_if_index;
2709  clib_memcpy (&addr, mp->address, sizeof (addr));
2710  if (mp->is_ipv6)
2711  {
2712  lm = &im6->lookup_main;
2713  adj_index = ip6_fib_lookup (im6, sw_if_index, &addr.ip6);
2714  }
2715  else
2716  {
2717  lm = &im4->lookup_main;
2718  // FIXME NOT an ADJ
2719  adj_index = ip4_fib_lookup (im4, sw_if_index, &addr.ip4);
2720  }
2721  if (adj_index == ~0)
2722  {
2723  rmp->is_error = 1;
2724  goto send;
2725  }
2726  adj = ip_get_adjacency (lm, adj_index);
2727 
2729  && adj->rewrite_header.sw_if_index == sw_if_index)
2730  {
2731  rmp->is_known = 1;
2732  }
2733  else
2734  {
2736  && adj->rewrite_header.sw_if_index == sw_if_index)
2737  {
2738  if (mp->is_ipv6)
2739  ip6_probe_neighbor (rm->vlib_main, &addr.ip6, sw_if_index);
2740  else
2741  ip4_probe_neighbor (rm->vlib_main, &addr.ip4, sw_if_index);
2742  }
2743  else if (adj->lookup_next_index == IP_LOOKUP_NEXT_DROP)
2744  {
2745  rmp->is_known = 1;
2746  goto send;
2747  }
2748  rmp->is_known = 0;
2749  }
2750 
2751 send:
2752  vl_msg_api_send_shmem (q, (u8 *) & rmp);
2753 #endif
2754 }
2755 
2756 static void
2758 {
2759  clib_warning ("BUG");
2760 }
2761 
2762 static void
2764 {
2766  vnet_main_t *vnm = vnet_get_main ();
2767  int rv = 0;
2768  clib_error_t *error;
2769  u16 flags;
2770 
2771  VALIDATE_SW_IF_INDEX (mp);
2772 
2774 
2775  error = vnet_sw_interface_set_flags (vnm, ntohl (mp->sw_if_index), flags);
2776  if (error)
2777  {
2778  rv = -1;
2779  clib_error_report (error);
2780  }
2781 
2783  REPLY_MACRO (VL_API_SW_INTERFACE_SET_FLAGS_REPLY);
2784 }
2785 
2786 static void
2789 {
2791  int rv = 0;
2792 
2793  VALIDATE_SW_IF_INDEX (mp);
2794 
2796  ntohl (mp->sw_if_index), mp->enable);
2797 
2799  REPLY_MACRO (VL_API_SW_INTERFACE_SET_MPLS_ENABLE_REPLY);
2800 }
2801 
2802 static void
2804  mp)
2805 {
2807 
2808  vnet_main_t *vnm = vnet_get_main ();
2812  static vnet_main_t **my_vnet_mains;
2813  int i, j, n_counters;
2814  int rv = 0;
2815 
2816  if (mp->sw_if_index != ~0)
2817  VALIDATE_SW_IF_INDEX (mp);
2818 
2819  vec_reset_length (my_vnet_mains);
2820 
2821  for (i = 0; i < vec_len (vnet_mains); i++)
2822  {
2823  if (vnet_mains[i])
2824  vec_add1 (my_vnet_mains, vnet_mains[i]);
2825  }
2826 
2827  if (vec_len (vnet_mains) == 0)
2828  vec_add1 (my_vnet_mains, vnm);
2829 
2830  n_counters = vec_len (im->combined_sw_if_counters);
2831 
2832  for (j = 0; j < n_counters; j++)
2833  {
2834  for (i = 0; i < vec_len (my_vnet_mains); i++)
2835  {
2836  im = &my_vnet_mains[i]->interface_main;
2837  cm = im->combined_sw_if_counters + j;
2838  if (mp->sw_if_index == (u32) ~ 0)
2840  else
2841  vlib_zero_combined_counter (cm, ntohl (mp->sw_if_index));
2842  }
2843  }
2844 
2845  n_counters = vec_len (im->sw_if_counters);
2846 
2847  for (j = 0; j < n_counters; j++)
2848  {
2849  for (i = 0; i < vec_len (my_vnet_mains); i++)
2850  {
2851  im = &my_vnet_mains[i]->interface_main;
2852  sm = im->sw_if_counters + j;
2853  if (mp->sw_if_index == (u32) ~ 0)
2855  else
2856  vlib_zero_simple_counter (sm, ntohl (mp->sw_if_index));
2857  }
2858  }
2859 
2861 
2862  REPLY_MACRO (VL_API_SW_INTERFACE_CLEAR_STATS_REPLY);
2863 }
2864 
2865 static void
2868  vnet_sw_interface_t * swif,
2869  u8 * interface_name, u32 context)
2870 {
2873 
2875 
2876  mp = vl_msg_api_alloc (sizeof (*mp));
2877  memset (mp, 0, sizeof (*mp));
2878  mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_DETAILS);
2879  mp->sw_if_index = ntohl (swif->sw_if_index);
2880  mp->sup_sw_if_index = ntohl (swif->sup_sw_if_index);
2881  mp->admin_up_down = (swif->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? 1 : 0;
2882  mp->link_up_down = (hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP) ? 1 : 0;
2887  mp->link_mtu = ntohs (hi->max_packet_bytes);
2888  mp->context = context;
2889 
2890  strncpy ((char *) mp->interface_name,
2891  (char *) interface_name, ARRAY_LEN (mp->interface_name) - 1);
2892 
2893  /* Send the L2 address for ethernet physical intfcs */
2894  if (swif->sup_sw_if_index == swif->sw_if_index
2896  {
2899 
2900  ei = pool_elt_at_index (em->interfaces, hi->hw_instance);
2901  ASSERT (sizeof (mp->l2_address) >= sizeof (ei->address));
2902  clib_memcpy (mp->l2_address, ei->address, sizeof (ei->address));
2903  mp->l2_address_length = ntohl (sizeof (ei->address));
2904  }
2905  else if (swif->sup_sw_if_index != swif->sw_if_index)
2906  {
2907  vnet_sub_interface_t *sub = &swif->sub;
2908  mp->sub_id = ntohl (sub->id);
2909  mp->sub_dot1ad = sub->eth.flags.dot1ad;
2910  mp->sub_number_of_tags =
2911  sub->eth.flags.one_tag + sub->eth.flags.two_tags * 2;
2912  mp->sub_outer_vlan_id = ntohs (sub->eth.outer_vlan_id);
2913  mp->sub_inner_vlan_id = ntohs (sub->eth.inner_vlan_id);
2914  mp->sub_exact_match = sub->eth.flags.exact_match;
2915  mp->sub_default = sub->eth.flags.default_sub;
2916  mp->sub_outer_vlan_id_any = sub->eth.flags.outer_vlan_id_any;
2917  mp->sub_inner_vlan_id_any = sub->eth.flags.inner_vlan_id_any;
2918 
2919  /* vlan tag rewrite data */
2920  u32 vtr_op = L2_VTR_DISABLED;
2921  u32 vtr_push_dot1q = 0, vtr_tag1 = 0, vtr_tag2 = 0;
2922 
2923  if (l2vtr_get (am->vlib_main, am->vnet_main, swif->sw_if_index,
2924  &vtr_op, &vtr_push_dot1q, &vtr_tag1, &vtr_tag2) != 0)
2925  {
2926  // error - default to disabled
2927  mp->vtr_op = ntohl (L2_VTR_DISABLED);
2928  clib_warning ("cannot get vlan tag rewrite for sw_if_index %d",
2929  swif->sw_if_index);
2930  }
2931  else
2932  {
2933  mp->vtr_op = ntohl (vtr_op);
2934  mp->vtr_push_dot1q = ntohl (vtr_push_dot1q);
2935  mp->vtr_tag1 = ntohl (vtr_tag1);
2936  mp->vtr_tag2 = ntohl (vtr_tag2);
2937  }
2938  }
2939 
2940  vl_msg_api_send_shmem (q, (u8 *) & mp);
2941 }
2942 
2943 static void
2946  vnet_sw_interface_t * swif)
2947 {
2949  vnet_main_t *vnm = am->vnet_main;
2950 
2952  swif->sw_if_index);
2953  mp = vl_msg_api_alloc (sizeof (*mp));
2954  memset (mp, 0, sizeof (*mp));
2955  mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_SET_FLAGS);
2956  mp->sw_if_index = ntohl (swif->sw_if_index);
2957 
2958  mp->admin_up_down = (swif->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? 1 : 0;
2959  mp->link_up_down = (hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP) ? 1 : 0;
2960  vl_msg_api_send_shmem (q, (u8 *) & mp);
2961 }
2962 
2965  u32 sw_if_index)
2966  __attribute__ ((unused));
2967 
2968 static void
2971  u32 sw_if_index)
2972 {
2974 
2975  mp = vl_msg_api_alloc (sizeof (*mp));
2976  memset (mp, 0, sizeof (*mp));
2977  mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_SET_FLAGS);
2978  mp->sw_if_index = ntohl (sw_if_index);
2979 
2980  mp->admin_up_down = 0;
2981  mp->link_up_down = 0;
2982  mp->deleted = 1;
2983  vl_msg_api_send_shmem (q, (u8 *) & mp);
2984 }
2985 
2986 static void
2988 {
2990  vnet_sw_interface_t *swif;
2992  u8 *filter_string = 0, *name_string = 0;
2994  char *strcasestr (char *, char *); /* lnx hdr file botch */
2995 
2997 
2998  if (q == 0)
2999  return;
3000 
3001  if (mp->name_filter_valid)
3002  {
3003  mp->name_filter[ARRAY_LEN (mp->name_filter) - 1] = 0;
3004  filter_string = format (0, "%s%c", mp->name_filter, 0);
3005  }
3006 
3007  /* *INDENT-OFF* */
3008  pool_foreach (swif, im->sw_interfaces,
3009  ({
3010  name_string = format (name_string, "%U%c",
3011  format_vnet_sw_interface_name,
3012  am->vnet_main, swif, 0);
3013 
3014  if (mp->name_filter_valid == 0 ||
3015  strcasestr((char *) name_string, (char *) filter_string)) {
3016 
3017  send_sw_interface_details (am, q, swif, name_string, mp->context);
3018  }
3019  _vec_len (name_string) = 0;
3020  }));
3021  /* *INDENT-ON* */
3022 
3023  vec_free (name_string);
3024  vec_free (filter_string);
3025 }
3026 
3027 void
3029 {
3030  vpe_api_main_t *vam = &vpe_api_main;
3033  vl_api_oam_event_t *mp;
3034 
3035  /* *INDENT-OFF* */
3036  pool_foreach(reg, vam->oam_events_registrations,
3037  ({
3038  q = vl_api_client_index_to_input_queue (reg->client_index);
3039  if (q)
3040  {
3041  mp = vl_msg_api_alloc (sizeof (*mp));
3042  mp->_vl_msg_id = ntohs (VL_API_OAM_EVENT);
3043  clib_memcpy (mp->dst_address, &t->dst_address,
3044  sizeof (mp->dst_address));
3045  mp->state = t->state;
3046  vl_msg_api_send_shmem (q, (u8 *)&mp);
3047  }
3048  }));
3049  /* *INDENT-ON* */
3050 }
3051 
3052 static void
3054 {
3056  int rv;
3057 
3059  (ip4_address_t *) mp->dst_address,
3060  ntohl (mp->vrf_id), (int) (mp->is_add));
3061 
3062  REPLY_MACRO (VL_API_OAM_ADD_DEL_REPLY);
3063 }
3064 
3065 static void
3067 {
3068  stats_main_t *sm = &stats_main;
3072  vlib_counter_t v;
3073  int i, which;
3074  u64 total_pkts[VLIB_N_RX_TX];
3075  u64 total_bytes[VLIB_N_RX_TX];
3076 
3079 
3080  if (!q)
3081  return;
3082 
3083  rmp = vl_msg_api_alloc (sizeof (*rmp));
3084  rmp->_vl_msg_id = ntohs (VL_API_VNET_SUMMARY_STATS_REPLY);
3085  rmp->context = mp->context;
3086  rmp->retval = 0;
3087 
3088  memset (total_pkts, 0, sizeof (total_pkts));
3089  memset (total_bytes, 0, sizeof (total_bytes));
3090 
3092 
3094  {
3095  which = cm - im->combined_sw_if_counters;
3096 
3097  for (i = 0; i < vec_len (cm->maxi); i++)
3098  {
3099  vlib_get_combined_counter (cm, i, &v);
3100  total_pkts[which] += v.packets;
3101  total_bytes[which] += v.bytes;
3102  }
3103  }
3105 
3106  rmp->total_pkts[VLIB_RX] = clib_host_to_net_u64 (total_pkts[VLIB_RX]);
3107  rmp->total_bytes[VLIB_RX] = clib_host_to_net_u64 (total_bytes[VLIB_RX]);
3108  rmp->total_pkts[VLIB_TX] = clib_host_to_net_u64 (total_pkts[VLIB_TX]);
3109  rmp->total_bytes[VLIB_TX] = clib_host_to_net_u64 (total_bytes[VLIB_TX]);
3110  rmp->vector_rate =
3111  clib_host_to_net_u64 (vlib_last_vector_length_per_node (sm->vlib_main));
3112 
3113  vl_msg_api_send_shmem (q, (u8 *) & rmp);
3114 }
3115 
3116 /* *INDENT-OFF* */
3117 typedef CLIB_PACKED (struct {
3118  ip4_address_t address;
3119  u32 address_length: 6;
3120  u32 index:26;
3121 }) ip4_route_t;
3122 /* *INDENT-ON* */
3123 
3124 static int
3125 ip4_reset_fib_t_handler (vl_api_reset_fib_t * mp)
3126 {
3127  vnet_main_t *vnm = vnet_get_main ();
3129  ip4_main_t *im4 = &ip4_main;
3130  static u32 *sw_if_indices_to_shut;
3131  stats_main_t *sm = &stats_main;
3132  fib_table_t *fib_table;
3133  ip4_fib_t *fib;
3134  u32 sw_if_index;
3135  int i;
3136  int rv = VNET_API_ERROR_NO_SUCH_FIB;
3137  u32 target_fib_id = ntohl (mp->vrf_id);
3138 
3139  dslock (sm, 1 /* release hint */ , 8 /* tag */ );
3140 
3141  /* *INDENT-OFF* */
3142  pool_foreach (fib_table, im4->fibs,
3143  ({
3144  fib = &fib_table->v4;
3145  vnet_sw_interface_t * si;
3146 
3147  if (fib->table_id != target_fib_id)
3148  continue;
3149 
3150  /* remove any mpls encap/decap labels */
3151  mpls_fib_reset_labels (fib->table_id);
3152 
3153  /* remove any proxy arps in this fib */
3154  vnet_proxy_arp_fib_reset (fib->table_id);
3155 
3156  /* Set the flow hash for this fib to the default */
3157  vnet_set_ip4_flow_hash (fib->table_id, IP_FLOW_HASH_DEFAULT);
3158 
3159  vec_reset_length (sw_if_indices_to_shut);
3160 
3161  /* Shut down interfaces in this FIB / clean out intfc routes */
3162  pool_foreach (si, im->sw_interfaces,
3163  ({
3164  u32 sw_if_index = si->sw_if_index;
3165 
3166  if (sw_if_index < vec_len (im4->fib_index_by_sw_if_index)
3167  && (im4->fib_index_by_sw_if_index[si->sw_if_index] ==
3168  fib->index))
3169  vec_add1 (sw_if_indices_to_shut, si->sw_if_index);
3170  }));
3171 
3172  for (i = 0; i < vec_len (sw_if_indices_to_shut); i++) {
3173  sw_if_index = sw_if_indices_to_shut[i];
3174  // vec_foreach (sw_if_index, sw_if_indices_to_shut) {
3175 
3176  u32 flags = vnet_sw_interface_get_flags (vnm, sw_if_index);
3177  flags &= ~(VNET_SW_INTERFACE_FLAG_ADMIN_UP);
3178  vnet_sw_interface_set_flags (vnm, sw_if_index, flags);
3179  }
3180 
3183 
3184  rv = 0;
3185  break;
3186  })); /* pool_foreach (fib) */
3187  /* *INDENT-ON* */
3188 
3189  dsunlock (sm);
3190  return rv;
3191 }
3192 
3193 static int
3195 {
3196  vnet_main_t *vnm = vnet_get_main ();
3198  ip6_main_t *im6 = &ip6_main;
3199  stats_main_t *sm = &stats_main;
3200  static u32 *sw_if_indices_to_shut;
3201  fib_table_t *fib_table;
3202  ip6_fib_t *fib;
3203  u32 sw_if_index;
3204  int i;
3205  int rv = VNET_API_ERROR_NO_SUCH_FIB;
3206  u32 target_fib_id = ntohl (mp->vrf_id);
3207 
3208  dslock (sm, 1 /* release hint */ , 9 /* tag */ );
3209 
3210  /* *INDENT-OFF* */
3211  pool_foreach (fib_table, im6->fibs,
3212  ({
3213  vnet_sw_interface_t * si;
3214  fib = &(fib_table->v6);
3215 
3216  if (fib->table_id != target_fib_id)
3217  continue;
3218 
3219  vec_reset_length (sw_if_indices_to_shut);
3220 
3221  /* Shut down interfaces in this FIB / clean out intfc routes */
3222  pool_foreach (si, im->sw_interfaces,
3223  ({
3224  if (im6->fib_index_by_sw_if_index[si->sw_if_index] ==
3225  fib->index)
3226  vec_add1 (sw_if_indices_to_shut, si->sw_if_index);
3227  }));
3228 
3229  for (i = 0; i < vec_len (sw_if_indices_to_shut); i++) {
3230  sw_if_index = sw_if_indices_to_shut[i];
3231  // vec_foreach (sw_if_index, sw_if_indices_to_shut) {
3232 
3233  u32 flags = vnet_sw_interface_get_flags (vnm, sw_if_index);
3234  flags &= ~(VNET_SW_INTERFACE_FLAG_ADMIN_UP);
3235  vnet_sw_interface_set_flags (vnm, sw_if_index, flags);
3236  }
3237 
3240 
3241  rv = 0;
3242  break;
3243  })); /* pool_foreach (fib) */
3244  /* *INDENT-ON* */
3245 
3246  dsunlock (sm);
3247  return rv;
3248 }
3249 
3250 static void
3252 {
3253  int rv;
3255 
3256  if (mp->is_ipv6)
3257  rv = ip6_reset_fib_t_handler (mp);
3258  else
3259  rv = ip4_reset_fib_t_handler (mp);
3260 
3261  REPLY_MACRO (VL_API_RESET_FIB_REPLY);
3262 }
3263 
3264 
3265 static void
3267 {
3269  int rv;
3270 
3272  (ip4_address_t *) (&mp->dhcp_src_address),
3273  (u32) ntohl (mp->vrf_id),
3274  (int) mp->insert_circuit_id,
3275  (int) (mp->is_add == 0));
3276 
3277  REPLY_MACRO (VL_API_DHCP_PROXY_CONFIG_REPLY);
3278 }
3279 
3280 
3281 static void
3283 {
3285  int rv = -1;
3286 
3288  (ip6_address_t *) (&mp->dhcp_src_address),
3289  (u32) ntohl (mp->vrf_id),
3290  (int) mp->insert_circuit_id,
3291  (int) (mp->is_add == 0));
3292 
3293  REPLY_MACRO (VL_API_DHCP_PROXY_CONFIG_REPLY);
3294 }
3295 
3296 static void
3298 {
3300  int rv;
3301 
3303  (ip4_address_t *) (&mp->dhcp_src_address),
3304  (u32) ntohl (mp->rx_vrf_id),
3305  (u32) ntohl (mp->server_vrf_id),
3306  (int) mp->insert_circuit_id,
3307  (int) (mp->is_add == 0));
3308 
3309  REPLY_MACRO (VL_API_DHCP_PROXY_CONFIG_2_REPLY);
3310 }
3311 
3312 
3313 static void
3315 {
3317  int rv = -1;
3318 
3319 #if 0 // $$$$ FIXME
3320  rv = dhcpv6_proxy_set_server_2 ((ip6_address_t *) (&mp->dhcp_server),
3321  (ip6_address_t *) (&mp->dhcp_src_address),
3322  (u32) ntohl (mp->rx_vrf_id),
3323  (u32) ntohl (mp->server_vrf_id),
3324  (int) mp->insert_circuit_id,
3325  (int) (mp->is_add == 0));
3326 #else
3327  rv = VNET_API_ERROR_UNIMPLEMENTED;
3328 #endif
3329 
3330  REPLY_MACRO (VL_API_DHCP_PROXY_CONFIG_2_REPLY);
3331 }
3332 
3333 
3334 static void
3336 {
3338  int rv;
3339  if (!mp->is_ipv6)
3340  rv = dhcp_proxy_set_option82_vss (ntohl (mp->tbl_id),
3341  ntohl (mp->oui),
3342  ntohl (mp->fib_id),
3343  (int) mp->is_add == 0);
3344  else
3345  rv = dhcpv6_proxy_set_vss (ntohl (mp->tbl_id),
3346  ntohl (mp->oui),
3347  ntohl (mp->fib_id), (int) mp->is_add == 0);
3348 
3349  REPLY_MACRO (VL_API_DHCP_PROXY_SET_VSS_REPLY);
3350 }
3351 
3352 
3355 {
3356  if (mp->is_ipv6 == 0)
3357  dhcpv4_proxy_config (mp);
3358  else
3359  dhcpv6_proxy_config (mp);
3360 }
3361 
3364 {
3365  if (mp->is_ipv6 == 0)
3366  dhcpv4_proxy_config_2 (mp);
3367  else
3368  dhcpv6_proxy_config_2 (mp);
3369 }
3370 
3371 void
3372 dhcp_compl_event_callback (u32 client_index, u32 pid, u8 * hostname,
3373  u8 is_ipv6, u8 * host_address, u8 * router_address,
3374  u8 * host_mac)
3375 {
3378 
3379  q = vl_api_client_index_to_input_queue (client_index);
3380  if (!q)
3381  return;
3382 
3383  mp = vl_msg_api_alloc (sizeof (*mp));
3384  mp->client_index = client_index;
3385  mp->pid = pid;
3386  mp->is_ipv6 = is_ipv6;
3387  clib_memcpy (&mp->hostname, hostname, vec_len (hostname));
3388  mp->hostname[vec_len (hostname) + 1] = '\n';
3389  clib_memcpy (&mp->host_address[0], host_address, 16);
3390  clib_memcpy (&mp->router_address[0], router_address, 16);
3391 
3392  if (NULL != host_mac)
3393  clib_memcpy (&mp->host_mac[0], host_mac, 6);
3394 
3395  mp->_vl_msg_id = ntohs (VL_API_DHCP_COMPL_EVENT);
3396 
3397  vl_msg_api_send_shmem (q, (u8 *) & mp);
3398 }
3399 
3402 {
3403  vlib_main_t *vm = vlib_get_main ();
3405  int rv = 0;
3406 
3407  VALIDATE_SW_IF_INDEX (mp);
3408 
3409  rv = dhcp_client_config (vm, ntohl (mp->sw_if_index),
3410  mp->hostname, mp->is_add, mp->client_index,
3412  NULL, mp->pid);
3413 
3415 
3416  REPLY_MACRO (VL_API_DHCP_CLIENT_CONFIG_REPLY);
3417 }
3418 
3419 static void
3422 {
3424  int rv = 0;
3425  u8 is_no, suppress, managed, other, ll_option, send_unicast, cease,
3426  default_router;
3427 
3428  is_no = mp->is_no == 1;
3429  suppress = mp->suppress == 1;
3430  managed = mp->managed == 1;
3431  other = mp->other == 1;
3432  ll_option = mp->ll_option == 1;
3433  send_unicast = mp->send_unicast == 1;
3434  cease = mp->cease == 1;
3435  default_router = mp->default_router == 1;
3436 
3437  VALIDATE_SW_IF_INDEX (mp);
3438 
3439  rv = ip6_neighbor_ra_config (vm, ntohl (mp->sw_if_index),
3440  suppress, managed, other,
3441  ll_option, send_unicast, cease,
3442  default_router, ntohl (mp->lifetime),
3443  ntohl (mp->initial_count),
3444  ntohl (mp->initial_interval),
3445  ntohl (mp->max_interval),
3446  ntohl (mp->min_interval), is_no);
3447 
3449 
3450  REPLY_MACRO (VL_API_SW_INTERFACE_IP6ND_RA_CONFIG_REPLY);
3451 }
3452 
3453 static void
3456 {
3458  int rv = 0;
3459  u8 is_no, use_default, no_advertise, off_link, no_autoconfig, no_onlink;
3460 
3461  VALIDATE_SW_IF_INDEX (mp);
3462 
3463  is_no = mp->is_no == 1;
3464  use_default = mp->use_default == 1;
3465  no_advertise = mp->no_advertise == 1;
3466  off_link = mp->off_link == 1;
3467  no_autoconfig = mp->no_autoconfig == 1;
3468  no_onlink = mp->no_onlink == 1;
3469 
3470  rv = ip6_neighbor_ra_prefix (vm, ntohl (mp->sw_if_index),
3471  (ip6_address_t *) mp->address,
3472  mp->address_length, use_default,
3473  ntohl (mp->val_lifetime),
3474  ntohl (mp->pref_lifetime), no_advertise,
3475  off_link, no_autoconfig, no_onlink, is_no);
3476 
3478  REPLY_MACRO (VL_API_SW_INTERFACE_IP6ND_RA_PREFIX_REPLY);
3479 }
3480 
3481 static void
3484 {
3486  vnet_main_t *vnm = vnet_get_main ();
3487  int rv = 0;
3488  clib_error_t *error;
3489 
3490  vnm->api_errno = 0;
3491 
3492  VALIDATE_SW_IF_INDEX (mp);
3493 
3494  error =
3495  (mp->enable == 1) ? enable_ip6_interface (vm,
3496  ntohl (mp->sw_if_index)) :
3497  disable_ip6_interface (vm, ntohl (mp->sw_if_index));
3498 
3499  if (error)
3500  {
3501  clib_error_report (error);
3502  rv = VNET_API_ERROR_UNSPECIFIED;
3503  }
3504  else
3505  {
3506  rv = vnm->api_errno;
3507  }
3508 
3510 
3511  REPLY_MACRO (VL_API_SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY);
3512 }
3513 
3514 static void
3517 {
3519  int rv = 0;
3520  clib_error_t *error;
3521  vnet_main_t *vnm = vnet_get_main ();
3522 
3523  vnm->api_errno = 0;
3524 
3525  VALIDATE_SW_IF_INDEX (mp);
3526 
3527  error = set_ip6_link_local_address (vm,
3528  ntohl (mp->sw_if_index),
3529  (ip6_address_t *) mp->address,
3530  mp->address_length);
3531  if (error)
3532  {
3533  clib_error_report (error);
3534  rv = VNET_API_ERROR_UNSPECIFIED;
3535  }
3536  else
3537  {
3538  rv = vnm->api_errno;
3539  }
3540 
3542 
3543  REPLY_MACRO (VL_API_SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY);
3544 }
3545 
3546 static void
3548 {
3550  int rv = VNET_API_ERROR_UNIMPLEMENTED;
3551 
3552  clib_warning ("unimplemented...");
3553 
3554  REPLY_MACRO (VL_API_SET_IP_FLOW_HASH_REPLY);
3555 }
3556 
3557 static void
3559 {
3561  int rv;
3562  u32 table_id;
3563  flow_hash_config_t flow_hash_config = 0;
3564 
3565  table_id = ntohl (mp->vrf_id);
3566 
3567 #define _(a,b) if (mp->a) flow_hash_config |= b;
3569 #undef _
3570 
3571  rv = vnet_set_ip4_flow_hash (table_id, flow_hash_config);
3572 
3573  REPLY_MACRO (VL_API_SET_IP_FLOW_HASH_REPLY);
3574 }
3575 
3576 
3577 static void
3579 {
3580  if (mp->is_ipv6 == 0)
3581  set_ip4_flow_hash (mp);
3582  else
3583  set_ip6_flow_hash (mp);
3584 }
3585 
3588 {
3590  int rv = 0;
3591  vnet_sw_interface_t *si;
3592  vnet_main_t *vnm = vnet_get_main ();
3593  u32 sw_if_index, unnumbered_sw_if_index;
3594 
3595  sw_if_index = ntohl (mp->sw_if_index);
3596  unnumbered_sw_if_index = ntohl (mp->unnumbered_sw_if_index);
3597 
3598  /*
3599  * The API message field names are backwards from
3600  * the underlying data structure names.
3601  * It's not worth changing them now.
3602  */
3604  unnumbered_sw_if_index))
3605  {
3606  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
3607  goto done;
3608  }
3609 
3610  /* Only check the "use loop0" field when setting the binding */
3611  if (mp->is_add &&
3612  pool_is_free_index (vnm->interface_main.sw_interfaces, sw_if_index))
3613  {
3614  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX_2;
3615  goto done;
3616  }
3617 
3618  si = vnet_get_sw_interface (vnm, unnumbered_sw_if_index);
3619 
3620  if (mp->is_add)
3621  {
3623  si->unnumbered_sw_if_index = sw_if_index;
3624  ip4_sw_interface_enable_disable (unnumbered_sw_if_index, 1);
3625  ip6_sw_interface_enable_disable (unnumbered_sw_if_index, 1);
3626  }
3627  else
3628  {
3630  si->unnumbered_sw_if_index = (u32) ~ 0;
3631  ip4_sw_interface_enable_disable (unnumbered_sw_if_index, 0);
3632  ip6_sw_interface_enable_disable (unnumbered_sw_if_index, 0);
3633  }
3634 
3635 done:
3636  REPLY_MACRO (VL_API_SW_INTERFACE_SET_UNNUMBERED_REPLY);
3637 }
3638 
3639 static void
3641 {
3643  u32 sw_if_index;
3644  int rv;
3645 
3646  rv = vnet_create_loopback_interface (&sw_if_index, mp->mac_address);
3647 
3648  /* *INDENT-OFF* */
3649  REPLY_MACRO2(VL_API_CREATE_LOOPBACK_REPLY,
3650  ({
3651  rmp->sw_if_index = ntohl (sw_if_index);
3652  }));
3653  /* *INDENT-ON* */
3654 }
3655 
3656 static void
3658 {
3660  u32 sw_if_index;
3661  int rv;
3662 
3663  sw_if_index = ntohl (mp->sw_if_index);
3664  rv = vnet_delete_loopback_interface (sw_if_index);
3665 
3666  REPLY_MACRO (VL_API_DELETE_LOOPBACK_REPLY);
3667 }
3668 
3669 static void
3671 {
3673  int rv = 0;
3674 
3675  /* *INDENT-OFF* */
3676  REPLY_MACRO2(VL_API_CONTROL_PING_REPLY,
3677  ({
3678  rmp->vpe_pid = ntohl (getpid());
3679  }));
3680  /* *INDENT-ON* */
3681 }
3682 
3683 static void
3684 shmem_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
3685 {
3686  u8 **shmem_vecp = (u8 **) arg;
3687  u8 *shmem_vec;
3688  void *oldheap;
3689  api_main_t *am = &api_main;
3690  u32 offset;
3691 
3692  shmem_vec = *shmem_vecp;
3693 
3694  offset = vec_len (shmem_vec);
3695 
3696  pthread_mutex_lock (&am->vlib_rp->mutex);
3697  oldheap = svm_push_data_heap (am->vlib_rp);
3698 
3699  vec_validate (shmem_vec, offset + buffer_bytes - 1);
3700 
3701  clib_memcpy (shmem_vec + offset, buffer, buffer_bytes);
3702 
3703  svm_pop_heap (oldheap);
3704  pthread_mutex_unlock (&am->vlib_rp->mutex);
3705 
3706  *shmem_vecp = shmem_vec;
3707 }
3708 
3709 
3710 static void
3712 {
3713  vl_api_cli_reply_t *rp;
3715  vlib_main_t *vm = vlib_get_main ();
3716  api_main_t *am = &api_main;
3717  unformat_input_t input;
3718  u8 *shmem_vec = 0;
3719  void *oldheap;
3720 
3722  if (!q)
3723  return;
3724 
3725  rp = vl_msg_api_alloc (sizeof (*rp));
3726  rp->_vl_msg_id = ntohs (VL_API_CLI_REPLY);
3727  rp->context = mp->context;
3728 
3729  unformat_init_vector (&input, (u8 *) (uword) mp->cmd_in_shmem);
3730 
3731  vlib_cli_input (vm, &input, shmem_cli_output, (uword) & shmem_vec);
3732 
3733  pthread_mutex_lock (&am->vlib_rp->mutex);
3734  oldheap = svm_push_data_heap (am->vlib_rp);
3735 
3736  vec_add1 (shmem_vec, 0);
3737 
3738  svm_pop_heap (oldheap);
3739  pthread_mutex_unlock (&am->vlib_rp->mutex);
3740 
3741  rp->reply_in_shmem = (uword) shmem_vec;
3742 
3743  vl_msg_api_send_shmem (q, (u8 *) & rp);
3744 }
3745 
3746 static void
3747 inband_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
3748 {
3749  u8 **mem_vecp = (u8 **) arg;
3750  u8 *mem_vec = *mem_vecp;
3751  u32 offset = vec_len (mem_vec);
3752 
3753  vec_validate (mem_vec, offset + buffer_bytes - 1);
3754  clib_memcpy (mem_vec + offset, buffer, buffer_bytes);
3755  *mem_vecp = mem_vec;
3756 }
3757 
3758 static void
3760 {
3762  int rv = 0;
3764  vlib_main_t *vm = vlib_get_main ();
3765  unformat_input_t input;
3766  u8 *out_vec = 0;
3767 
3769  if (!q)
3770  return;
3771 
3772  unformat_init_string (&input, (char *) mp->cmd, ntohl (mp->length));
3773  vlib_cli_input (vm, &input, inband_cli_output, (uword) & out_vec);
3774 
3775  u32 len = vec_len (out_vec);
3776  /* *INDENT-OFF* */
3777  REPLY_MACRO3(VL_API_CLI_INBAND_REPLY, len,
3778  ({
3779  rmp->length = htonl (len);
3780  clib_memcpy (rmp->reply, out_vec, len);
3781  }));
3782  /* *INDENT-ON* */
3783  vec_free (out_vec);
3784 }
3785 
3786 static void
3788 {
3789  int rv;
3791  vnet_main_t *vnm = vnet_get_main ();
3792  clib_error_t *error;
3793 
3794  vnm->api_errno = 0;
3795 
3796  if (mp->is_ipv6)
3797  error = ip6_set_neighbor_limit (ntohl (mp->arp_neighbor_limit));
3798  else
3799  error = ip4_set_arp_limit (ntohl (mp->arp_neighbor_limit));
3800 
3801  if (error)
3802  {
3803  clib_error_report (error);
3804  rv = VNET_API_ERROR_UNSPECIFIED;
3805  }
3806  else
3807  {
3808  rv = vnm->api_errno;
3809  }
3810 
3811  REPLY_MACRO (VL_API_SET_ARP_NEIGHBOR_LIMIT_REPLY);
3812 }
3813 
3816 {
3817 #if IP6SR == 0
3818  clib_warning ("unimplemented");
3819 #else
3820  ip6_sr_add_del_tunnel_args_t _a, *a = &_a;
3821  int rv = 0;
3823  ip6_address_t *segments = 0, *seg;
3824  ip6_address_t *tags = 0, *tag;
3825  ip6_address_t *this_address;
3826  int i;
3827 
3828  if (mp->n_segments == 0)
3829  {
3830  rv = -11;
3831  goto out;
3832  }
3833 
3834  memset (a, 0, sizeof (*a));
3835  a->src_address = (ip6_address_t *) & mp->src_address;
3836  a->dst_address = (ip6_address_t *) & mp->dst_address;
3837  a->dst_mask_width = mp->dst_mask_width;
3839  a->is_del = (mp->is_add == 0);
3840  a->rx_table_id = ntohl (mp->outer_vrf_id);
3841  a->tx_table_id = ntohl (mp->inner_vrf_id);
3842 
3843  a->name = format (0, "%s", mp->name);
3844  if (!(vec_len (a->name)))
3845  a->name = 0;
3846 
3847  a->policy_name = format (0, "%s", mp->policy_name);
3848  if (!(vec_len (a->policy_name)))
3849  a->policy_name = 0;
3850 
3851  /* Yank segments and tags out of the API message */
3852  this_address = (ip6_address_t *) mp->segs_and_tags;
3853  for (i = 0; i < mp->n_segments; i++)
3854  {
3855  vec_add2 (segments, seg, 1);
3856  clib_memcpy (seg->as_u8, this_address->as_u8, sizeof (*this_address));
3857  this_address++;
3858  }
3859  for (i = 0; i < mp->n_tags; i++)
3860  {
3861  vec_add2 (tags, tag, 1);
3862  clib_memcpy (tag->as_u8, this_address->as_u8, sizeof (*this_address));
3863  this_address++;
3864  }
3865 
3866  a->segments = segments;
3867  a->tags = tags;
3868 
3869  rv = ip6_sr_add_del_tunnel (a);
3870 
3871 out:
3872 
3873  REPLY_MACRO (VL_API_SR_TUNNEL_ADD_DEL_REPLY);
3874 #endif
3875 }
3876 
3879 {
3880 #if IP6SR == 0
3881  clib_warning ("unimplemented");
3882 #else
3883  ip6_sr_add_del_policy_args_t _a, *a = &_a;
3884  int rv = 0;
3886  int i;
3887 
3888  memset (a, 0, sizeof (*a));
3889  a->is_del = (mp->is_add == 0);
3890 
3891  a->name = format (0, "%s", mp->name);
3892  if (!(vec_len (a->name)))
3893  {
3894  rv = VNET_API_ERROR_NO_SUCH_NODE2;
3895  goto out;
3896  }
3897 
3898  if (!(mp->tunnel_names[0]))
3899  {
3900  rv = VNET_API_ERROR_NO_SUCH_NODE2;
3901  goto out;
3902  }
3903 
3904  // start deserializing tunnel_names
3905  int num_tunnels = mp->tunnel_names[0]; //number of tunnels
3906  u8 *deser_tun_names = mp->tunnel_names;
3907  deser_tun_names += 1; //moving along
3908 
3909  u8 *tun_name = 0;
3910  int tun_name_len = 0;
3911 
3912  for (i = 0; i < num_tunnels; i++)
3913  {
3914  tun_name_len = *deser_tun_names;
3915  deser_tun_names += 1;
3916  vec_resize (tun_name, tun_name_len);
3917  memcpy (tun_name, deser_tun_names, tun_name_len);
3918  vec_add1 (a->tunnel_names, tun_name);
3919  deser_tun_names += tun_name_len;
3920  tun_name = 0;
3921  }
3922 
3923  rv = ip6_sr_add_del_policy (a);
3924 
3925 out:
3926 
3927  REPLY_MACRO (VL_API_SR_POLICY_ADD_DEL_REPLY);
3928 #endif
3929 }
3930 
3933 {
3934 #if IP6SR == 0
3935  clib_warning ("unimplemented");
3936 #else
3938  int rv = 0;
3940 
3941  memset (a, 0, sizeof (*a));
3942  a->is_del = (mp->is_add == 0);
3943 
3945  a->policy_name = format (0, "%s", mp->policy_name);
3946 
3947  if (a->multicast_address == 0)
3948  {
3949  rv = -1;
3950  goto out;
3951  }
3952 
3953  if (!(a->policy_name))
3954  {
3955  rv = -2;
3956  goto out;
3957  }
3958 
3959 #if DPDK > 0 /* Cannot call replicate without DPDK */
3960  rv = ip6_sr_add_del_multicastmap (a);
3961 #else
3962  clib_warning ("multicast replication without DPDK not implemented");
3963  rv = VNET_API_ERROR_UNIMPLEMENTED;
3964 #endif /* DPDK */
3965 
3966 out:
3967 
3968  REPLY_MACRO (VL_API_SR_MULTICAST_MAP_ADD_DEL_REPLY);
3969 #endif
3970 }
3971 
3972 #define foreach_classify_add_del_table_field \
3973 _(table_index) \
3974 _(nbuckets) \
3975 _(memory_size) \
3976 _(skip_n_vectors) \
3977 _(match_n_vectors) \
3978 _(next_table_index) \
3979 _(miss_next_index)
3980 
3983 {
3987  int rv;
3988 
3989 #define _(a) u32 a;
3991 #undef _
3992 
3993 #define _(a) a = ntohl(mp->a);
3995 #undef _
3996 
3997  /* The underlying API fails silently, on purpose, so check here */
3998  if (mp->is_add == 0)
3999  if (pool_is_free_index (cm->tables, table_index))
4000  {
4001  rv = VNET_API_ERROR_NO_SUCH_TABLE;
4002  goto out;
4003  }
4004 
4006  (cm, mp->mask, nbuckets, memory_size,
4007  skip_n_vectors, match_n_vectors,
4008  next_table_index, miss_next_index, &table_index, mp->is_add);
4009 
4010 out:
4011  /* *INDENT-OFF* */
4012  REPLY_MACRO2(VL_API_CLASSIFY_ADD_DEL_TABLE_REPLY,
4013  ({
4014  if (rv == 0 && mp->is_add)
4015  {
4016  t = pool_elt_at_index (cm->tables, table_index);
4017  rmp->skip_n_vectors = ntohl(t->skip_n_vectors);
4018  rmp->match_n_vectors = ntohl(t->match_n_vectors);
4019  rmp->new_table_index = ntohl(table_index);
4020  }
4021  else
4022  {
4023  rmp->skip_n_vectors = ~0;
4024  rmp->match_n_vectors = ~0;
4025  rmp->new_table_index = ~0;
4026  }
4027  }));
4028  /* *INDENT-ON* */
4029 }
4030 
4033 {
4036  int rv;
4037  u32 table_index, hit_next_index, opaque_index;
4038  i32 advance;
4039 
4040  table_index = ntohl (mp->table_index);
4041  hit_next_index = ntohl (mp->hit_next_index);
4042  opaque_index = ntohl (mp->opaque_index);
4043  advance = ntohl (mp->advance);
4044 
4046  (cm, table_index, mp->match, hit_next_index, opaque_index,
4047  advance, mp->is_add);
4048 
4049  REPLY_MACRO (VL_API_CLASSIFY_ADD_DEL_SESSION_REPLY);
4050 }
4051 
4054 {
4055  vlib_main_t *vm = vlib_get_main ();
4057  int rv;
4058  u32 table_index, sw_if_index;
4059 
4060  table_index = ntohl (mp->table_index);
4061  sw_if_index = ntohl (mp->sw_if_index);
4062 
4063  VALIDATE_SW_IF_INDEX (mp);
4064 
4065  if (mp->is_ipv6)
4066  rv = vnet_set_ip6_classify_intfc (vm, sw_if_index, table_index);
4067  else
4068  rv = vnet_set_ip4_classify_intfc (vm, sw_if_index, table_index);
4069 
4071 
4072  REPLY_MACRO (VL_API_CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY);
4073 }
4074 
4077 {
4079  int rv;
4080  u32 sw_if_index, ip4_table_index, ip6_table_index, other_table_index;
4081  int enable;
4082 
4083  ip4_table_index = ntohl (mp->ip4_table_index);
4084  ip6_table_index = ntohl (mp->ip6_table_index);
4085  other_table_index = ntohl (mp->other_table_index);
4086  sw_if_index = ntohl (mp->sw_if_index);
4087 
4088  VALIDATE_SW_IF_INDEX (mp);
4089 
4090  if (mp->is_input)
4091  rv = vnet_l2_input_classify_set_tables (sw_if_index, ip4_table_index,
4092  ip6_table_index,
4093  other_table_index);
4094  else
4095  rv = vnet_l2_output_classify_set_tables (sw_if_index, ip4_table_index,
4096  ip6_table_index,
4097  other_table_index);
4098 
4099  if (rv == 0)
4100  {
4101  if (ip4_table_index != ~0 || ip6_table_index != ~0
4102  || other_table_index != ~0)
4103  enable = 1;
4104  else
4105  enable = 0;
4106 
4107  if (mp->is_input)
4108  vnet_l2_input_classify_enable_disable (sw_if_index, enable);
4109  else
4110  vnet_l2_output_classify_enable_disable (sw_if_index, enable);
4111  }
4112 
4114 
4115  REPLY_MACRO (VL_API_CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY);
4116 }
4117 
4118 static void
4120 {
4121  int rv = 0;
4123 
4124  /* DAW-FIXME: This API should only clear non-static l2fib entries, but
4125  * that is not currently implemented. When that TODO is fixed
4126  * this call should be changed to pass 1 instead of 0.
4127  */
4128  l2fib_clear_table (0);
4129 
4130  REPLY_MACRO (VL_API_L2_FIB_CLEAR_TABLE_REPLY);
4131 }
4132 
4133 extern void l2_efp_filter_configure (vnet_main_t * vnet_main,
4134  u32 sw_if_index, u32 enable);
4135 
4136 static void
4138  mp)
4139 {
4140  int rv;
4142  vnet_main_t *vnm = vnet_get_main ();
4143 
4144  // enable/disable the feature
4146  rv = vnm->api_errno;
4147 
4148  REPLY_MACRO (VL_API_L2_INTERFACE_EFP_FILTER_REPLY);
4149 }
4150 
4151 static void
4154 {
4155  int rv = 0;
4157  vnet_main_t *vnm = vnet_get_main ();
4158  vlib_main_t *vm = vlib_get_main ();
4159  u32 vtr_op;
4160 
4161  VALIDATE_SW_IF_INDEX (mp);
4162 
4163  vtr_op = ntohl (mp->vtr_op);
4164 
4165  /* The L2 code is unsuspicious */
4166  switch (vtr_op)
4167  {
4168  case L2_VTR_DISABLED:
4169  case L2_VTR_PUSH_1:
4170  case L2_VTR_PUSH_2:
4171  case L2_VTR_POP_1:
4172  case L2_VTR_POP_2:
4173  case L2_VTR_TRANSLATE_1_1:
4174  case L2_VTR_TRANSLATE_1_2:
4175  case L2_VTR_TRANSLATE_2_1:
4176  case L2_VTR_TRANSLATE_2_2:
4177  break;
4178 
4179  default:
4180  rv = VNET_API_ERROR_INVALID_VALUE;
4181  goto bad_sw_if_index;
4182  }
4183 
4184  rv = l2vtr_configure (vm, vnm, ntohl (mp->sw_if_index), vtr_op,
4185  ntohl (mp->push_dot1q), ntohl (mp->tag1),
4186  ntohl (mp->tag2));
4187 
4189 
4190  REPLY_MACRO (VL_API_L2_INTERFACE_VLAN_TAG_REWRITE_REPLY);
4191 }
4192 
4193 static void
4195 {
4196  int rv = 0;
4198  u32 sw_if_index = (u32) ~ 0;
4199 
4200  vnet_main_t *vnm = vnet_get_main ();
4201  vlib_main_t *vm = vlib_get_main ();
4202 
4203  rv = vhost_user_create_if (vnm, vm, (char *) mp->sock_filename,
4204  mp->is_server, &sw_if_index, (u64) ~ 0,
4205  mp->renumber, ntohl (mp->custom_dev_instance),
4206  (mp->use_custom_mac) ? mp->mac_address : NULL);
4207 
4208  /* *INDENT-OFF* */
4209  REPLY_MACRO2(VL_API_CREATE_VHOST_USER_IF_REPLY,
4210  ({
4211  rmp->sw_if_index = ntohl (sw_if_index);
4212  }));
4213  /* *INDENT-ON* */
4214 }
4215 
4216 static void
4218 {
4219  int rv = 0;
4221  u32 sw_if_index = ntohl (mp->sw_if_index);
4222 
4223  vnet_main_t *vnm = vnet_get_main ();
4224  vlib_main_t *vm = vlib_get_main ();
4225 
4226  rv = vhost_user_modify_if (vnm, vm, (char *) mp->sock_filename,
4227  mp->is_server, sw_if_index, (u64) ~ 0,
4228  mp->renumber, ntohl (mp->custom_dev_instance));
4229  REPLY_MACRO (VL_API_MODIFY_VHOST_USER_IF_REPLY);
4230 }
4231 
4232 static void
4234 {
4235  int rv = 0;
4237  vpe_api_main_t *vam = &vpe_api_main;
4238  u32 sw_if_index = ntohl (mp->sw_if_index);
4239 
4240  vnet_main_t *vnm = vnet_get_main ();
4241  vlib_main_t *vm = vlib_get_main ();
4242 
4243  rv = vhost_user_delete_if (vnm, vm, sw_if_index);
4244 
4245  REPLY_MACRO (VL_API_DELETE_VHOST_USER_IF_REPLY);
4246  if (!rv)
4247  {
4250  if (!q)
4251  return;
4252 
4253  send_sw_interface_flags_deleted (vam, q, sw_if_index);
4254  }
4255 }
4256 
4257 static void
4260 {
4261  clib_warning ("BUG");
4262 }
4263 
4264 static void
4268  u32 context)
4269 {
4271 
4272  mp = vl_msg_api_alloc (sizeof (*mp));
4273  memset (mp, 0, sizeof (*mp));
4274  mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_VHOST_USER_DETAILS);
4275  mp->sw_if_index = ntohl (vui->sw_if_index);
4276  mp->virtio_net_hdr_sz = ntohl (vui->virtio_net_hdr_sz);
4277  mp->features = clib_net_to_host_u64 (vui->features);
4278  mp->is_server = vui->is_server;
4279  mp->num_regions = ntohl (vui->num_regions);
4280  mp->sock_errno = ntohl (vui->sock_errno);
4281  mp->context = context;
4282 
4283  strncpy ((char *) mp->sock_filename,
4284  (char *) vui->sock_filename, ARRAY_LEN (mp->sock_filename) - 1);
4285  strncpy ((char *) mp->interface_name,
4286  (char *) vui->if_name, ARRAY_LEN (mp->interface_name) - 1);
4287 
4288  vl_msg_api_send_shmem (q, (u8 *) & mp);
4289 }
4290 
4291 static void
4294 {
4295  int rv = 0;
4297  vnet_main_t *vnm = vnet_get_main ();
4298  vlib_main_t *vm = vlib_get_main ();
4299  vhost_user_intf_details_t *ifaces = NULL;
4302 
4304  if (q == 0)
4305  return;
4306 
4307  rv = vhost_user_dump_ifs (vnm, vm, &ifaces);
4308  if (rv)
4309  return;
4310 
4311  vec_foreach (vuid, ifaces)
4312  {
4313  send_sw_interface_vhost_user_details (am, q, vuid, mp->context);
4314  }
4315  vec_free (ifaces);
4316 }
4317 
4318 static void
4321  l2t_session_t * s,
4322  l2t_main_t * lm, u32 context)
4323 {
4325  u8 *if_name = NULL;
4326  vnet_sw_interface_t *si = NULL;
4327 
4329 
4330  if_name = format (if_name, "%U",
4332 
4333  mp = vl_msg_api_alloc (sizeof (*mp));
4334  memset (mp, 0, sizeof (*mp));
4335  mp->_vl_msg_id = ntohs (VL_API_SW_IF_L2TPV3_TUNNEL_DETAILS);
4336  strncpy ((char *) mp->interface_name,
4337  (char *) if_name, ARRAY_LEN (mp->interface_name) - 1);
4338  mp->sw_if_index = ntohl (si->sw_if_index);
4341  mp->local_cookie[0] = s->local_cookie[0];
4342  mp->local_cookie[1] = s->local_cookie[1];
4343  mp->remote_cookie = s->remote_cookie;
4345  sizeof (s->client_address));
4346  clib_memcpy (mp->our_address, &s->our_address, sizeof (s->our_address));
4348  mp->context = context;
4349 
4350  vl_msg_api_send_shmem (q, (u8 *) & mp);
4351 }
4352 
4353 static void
4356  u8 * ip, u16 prefix_length, u8 is_ipv6, u32 context)
4357 {
4359 
4360  mp = vl_msg_api_alloc (sizeof (*mp));
4361  memset (mp, 0, sizeof (*mp));
4362  mp->_vl_msg_id = ntohs (VL_API_IP_ADDRESS_DETAILS);
4363 
4364  if (is_ipv6)
4365  {
4366  clib_memcpy (&mp->ip, ip, sizeof (mp->ip));
4367  }
4368  else
4369  {
4370  u32 *tp = (u32 *) mp->ip;
4371  *tp = ntohl (*(u32 *) ip);
4372  }
4373  mp->prefix_length = prefix_length;
4374  mp->context = context;
4375 
4376  vl_msg_api_send_shmem (q, (u8 *) & mp);
4377 }
4378 
4379 static void
4381 {
4384  ip6_address_t *r6;
4385  ip4_address_t *r4;
4386  ip6_main_t *im6 = &ip6_main;
4387  ip4_main_t *im4 = &ip4_main;
4388  ip_lookup_main_t *lm6 = &im6->lookup_main;
4389  ip_lookup_main_t *lm4 = &im4->lookup_main;
4390  ip_interface_address_t *ia = 0;
4391  u32 sw_if_index = ~0;
4392  int rv __attribute__ ((unused)) = 0;
4393 
4394  VALIDATE_SW_IF_INDEX (mp);
4395 
4396  sw_if_index = ntohl (mp->sw_if_index);
4397 
4399  if (q == 0)
4400  {
4401  return;
4402  }
4403 
4404  if (mp->is_ipv6)
4405  {
4406  /* *INDENT-OFF* */
4407  foreach_ip_interface_address (lm6, ia, sw_if_index,
4408  1 /* honor unnumbered */,
4409  ({
4410  r6 = ip_interface_address_get_address (lm6, ia);
4411  u16 prefix_length = ia->address_length;
4412  send_ip_address_details(am, q, (u8*)r6, prefix_length, 1, mp->context);
4413  }));
4414  /* *INDENT-ON* */
4415  }
4416  else
4417  {
4418  /* *INDENT-OFF* */
4419  foreach_ip_interface_address (lm4, ia, sw_if_index,
4420  1 /* honor unnumbered */,
4421  ({
4422  r4 = ip_interface_address_get_address (lm4, ia);
4423  u16 prefix_length = ia->address_length;
4424  send_ip_address_details(am, q, (u8*)r4, prefix_length, 0, mp->context);
4425  }));
4426  /* *INDENT-ON* */
4427  }
4429 }
4430 
4431 static void
4433  unix_shared_memory_queue_t * q, u32 sw_if_index, u32 context)
4434 {
4435  vl_api_ip_details_t *mp;
4436 
4437  mp = vl_msg_api_alloc (sizeof (*mp));
4438  memset (mp, 0, sizeof (*mp));
4439  mp->_vl_msg_id = ntohs (VL_API_IP_DETAILS);
4440 
4441  mp->sw_if_index = ntohl (sw_if_index);
4442  mp->context = context;
4443 
4444  vl_msg_api_send_shmem (q, (u8 *) & mp);
4445 }
4446 
4447 static void
4449  mp)
4450 {
4452  l2t_main_t *lm = &l2t_main;
4454  l2t_session_t *session;
4455 
4457  if (q == 0)
4458  return;
4459 
4460  /* *INDENT-OFF* */
4461  pool_foreach (session, lm->sessions,
4462  ({
4463  send_sw_if_l2tpv3_tunnel_details (am, q, session, lm, mp->context);
4464  }));
4465  /* *INDENT-ON* */
4466 }
4467 
4468 
4469 static void
4472  tapcli_interface_details_t * tap_if,
4473  u32 context)
4474 {
4476  mp = vl_msg_api_alloc (sizeof (*mp));
4477  memset (mp, 0, sizeof (*mp));
4478  mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_TAP_DETAILS);
4479  mp->sw_if_index = ntohl (tap_if->sw_if_index);
4480  strncpy ((char *) mp->dev_name,
4481  (char *) tap_if->dev_name, ARRAY_LEN (mp->dev_name) - 1);
4482  mp->context = context;
4483 
4484  vl_msg_api_send_shmem (q, (u8 *) & mp);
4485 }
4486 
4487 static void
4489 {
4490  int rv = 0;
4493  tapcli_interface_details_t *tapifs = NULL;
4494  tapcli_interface_details_t *tap_if = NULL;
4495 
4497  if (q == 0)
4498  return;
4499 
4500  rv = vnet_tap_dump_ifs (&tapifs);
4501  if (rv)
4502  return;
4503 
4504  vec_foreach (tap_if, tapifs)
4505  {
4506  send_sw_interface_tap_details (am, q, tap_if, mp->context);
4507  }
4508 
4509  vec_free (tapifs);
4510 }
4511 
4512 static void
4514 {
4516  vnet_main_t *vnm = vnet_get_main ();
4517  vlib_main_t *vm = vlib_get_main ();
4520  vnet_sw_interface_t *si, *sorted_sis;
4521  u32 sw_if_index = ~0;
4522 
4524  if (q == 0)
4525  {
4526  return;
4527  }
4528 
4529  /* Gather interfaces. */
4530  sorted_sis = vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
4531  _vec_len (sorted_sis) = 0;
4532  /* *INDENT-OFF* */
4533  pool_foreach (si, im->sw_interfaces,
4534  ({
4535  vec_add1 (sorted_sis, si[0]);
4536  }));
4537  /* *INDENT-ON* */
4538 
4539  vec_foreach (si, sorted_sis)
4540  {
4542  {
4543  if (mp->is_ipv6 && !ip6_interface_enabled (vm, si->sw_if_index))
4544  {
4545  continue;
4546  }
4547  sw_if_index = si->sw_if_index;
4548  send_ip_details (am, q, sw_if_index, mp->context);
4549  }
4550  }
4551 }
4552 
4553 static void
4555 {
4556  clib_warning ("BUG");
4557 }
4558 
4559 static void
4562  l2fib_entry_key_t * l2fe_key,
4563  l2fib_entry_result_t * l2fe_res, u32 context)
4564 {
4566 
4567  mp = vl_msg_api_alloc (sizeof (*mp));
4568  memset (mp, 0, sizeof (*mp));
4569  mp->_vl_msg_id = ntohs (VL_API_L2_FIB_TABLE_ENTRY);
4570 
4571  mp->bd_id =
4572  ntohl (l2input_main.bd_configs[l2fe_key->fields.bd_index].bd_id);
4573 
4574  mp->mac = l2fib_make_key (l2fe_key->fields.mac, 0);
4575  mp->sw_if_index = ntohl (l2fe_res->fields.sw_if_index);
4576  mp->static_mac = l2fe_res->fields.static_mac;
4577  mp->filter_mac = l2fe_res->fields.filter;
4578  mp->bvi_mac = l2fe_res->fields.bvi;
4579  mp->context = context;
4580 
4581  vl_msg_api_send_shmem (q, (u8 *) & mp);
4582 }
4583 
4584 static void
4586 {
4588  bd_main_t *bdm = &bd_main;
4589  l2fib_entry_key_t *l2fe_key = NULL;
4590  l2fib_entry_result_t *l2fe_res = NULL;
4591  u32 ni, bd_id = ntohl (mp->bd_id);
4592  u32 bd_index;
4594  uword *p;
4595 
4597  if (q == 0)
4598  return;
4599 
4600  /* see l2fib_table_dump: ~0 means "any" */
4601  if (bd_id == ~0)
4602  bd_index = ~0;
4603  else
4604  {
4605  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
4606  if (p == 0)
4607  return;
4608 
4609  bd_index = p[0];
4610  }
4611 
4612  l2fib_table_dump (bd_index, &l2fe_key, &l2fe_res);
4613 
4614  vec_foreach_index (ni, l2fe_key)
4615  {
4616  send_l2fib_table_entry (am, q, vec_elt_at_index (l2fe_key, ni),
4617  vec_elt_at_index (l2fe_res, ni), mp->context);
4618  }
4619  vec_free (l2fe_key);
4620  vec_free (l2fe_res);
4621 }
4622 
4623 static void
4625 {
4627  int rv = 0;
4628  char *vpe_api_get_build_directory (void);
4629  char *vpe_api_get_version (void);
4630  char *vpe_api_get_build_date (void);
4631 
4634 
4635  if (!q)
4636  return;
4637 
4638  /* *INDENT-OFF* */
4639  REPLY_MACRO2(VL_API_SHOW_VERSION_REPLY,
4640  ({
4641  strncpy ((char *) rmp->program, "vpe", ARRAY_LEN(rmp->program)-1);
4642  strncpy ((char *) rmp->build_directory, vpe_api_get_build_directory(),
4643  ARRAY_LEN(rmp->build_directory)-1);
4644  strncpy ((char *) rmp->version, vpe_api_get_version(),
4645  ARRAY_LEN(rmp->version)-1);
4646  strncpy ((char *) rmp->build_date, vpe_api_get_build_date(),
4647  ARRAY_LEN(rmp->build_date)-1);
4648  }));
4649  /* *INDENT-ON* */
4650 }
4651 
4652 static void
4654 {
4655  vlib_main_t *vm = vlib_get_main ();
4657  vlib_node_t *n;
4658  int rv = 0;
4659  u32 node_index = ~0;
4660 
4661  n = vlib_get_node_by_name (vm, mp->node_name);
4662 
4663  if (n == 0)
4664  rv = VNET_API_ERROR_NO_SUCH_NODE;
4665  else
4666  node_index = n->index;
4667 
4668  /* *INDENT-OFF* */
4669  REPLY_MACRO2(VL_API_GET_NODE_INDEX_REPLY,
4670  ({
4671  rmp->node_index = ntohl(node_index);
4672  }));
4673  /* *INDENT-ON* */
4674 }
4675 
4676 static void
4678 {
4679  vlib_main_t *vm = vlib_get_main ();
4681  vlib_node_t *node, *next_node;
4682  int rv = 0;
4683  u32 next_node_index = ~0, next_index = ~0;
4684  uword *p;
4685 
4686  node = vlib_get_node_by_name (vm, mp->node_name);
4687 
4688  if (node == 0)
4689  {
4690  rv = VNET_API_ERROR_NO_SUCH_NODE;
4691  goto out;
4692  }
4693 
4694  next_node = vlib_get_node_by_name (vm, mp->next_name);
4695 
4696  if (next_node == 0)
4697  {
4698  rv = VNET_API_ERROR_NO_SUCH_NODE2;
4699  goto out;
4700  }
4701  else
4702  next_node_index = next_node->index;
4703 
4704  p = hash_get (node->next_slot_by_node, next_node_index);
4705 
4706  if (p == 0)
4707  {
4708  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
4709  goto out;
4710  }
4711  else
4712  next_index = p[0];
4713 
4714 out:
4715  /* *INDENT-OFF* */
4716  REPLY_MACRO2(VL_API_GET_NEXT_INDEX_REPLY,
4717  ({
4718  rmp->next_index = ntohl(next_index);
4719  }));
4720  /* *INDENT-ON* */
4721 }
4722 
4723 static void
4725 {
4726  vlib_main_t *vm = vlib_get_main ();
4728  vlib_node_t *n, *next;
4729  int rv = 0;
4730  u32 next_index = ~0;
4731 
4732  n = vlib_get_node_by_name (vm, mp->node_name);
4733 
4734  if (n == 0)
4735  {
4736  rv = VNET_API_ERROR_NO_SUCH_NODE;
4737  goto out;
4738  }
4739 
4740  next = vlib_get_node_by_name (vm, mp->next_name);
4741 
4742  if (next == 0)
4743  rv = VNET_API_ERROR_NO_SUCH_NODE2;
4744  else
4745  next_index = vlib_node_add_next (vm, n->index, next->index);
4746 
4747 out:
4748  /* *INDENT-OFF* */
4749  REPLY_MACRO2(VL_API_GET_NODE_INDEX_REPLY,
4750  ({
4751  rmp->next_index = ntohl(next_index);
4752  }));
4753  /* *INDENT-ON* */
4754 }
4755 
4758 {
4760  l2t_main_t *lm = &l2t_main;
4761  u32 sw_if_index = (u32) ~ 0;
4762  int rv;
4763 
4764  if (mp->is_ipv6 != 1)
4765  {
4766  rv = VNET_API_ERROR_UNIMPLEMENTED;
4767  goto out;
4768  }
4769 
4770  u32 encap_fib_index;
4771 
4772  if (mp->encap_vrf_id != ~0)
4773  {
4774  uword *p;
4775  ip6_main_t *im = &ip6_main;
4776  if (!
4777  (p =
4778  hash_get (im->fib_index_by_table_id, ntohl (mp->encap_vrf_id))))
4779  {
4780  rv = VNET_API_ERROR_NO_SUCH_FIB;
4781  goto out;
4782  }
4783  encap_fib_index = p[0];
4784  }
4785  else
4786  {
4787  encap_fib_index = ~0;
4788  }
4789 
4790  rv = create_l2tpv3_ipv6_tunnel (lm,
4791  (ip6_address_t *) mp->client_address,
4792  (ip6_address_t *) mp->our_address,
4793  ntohl (mp->local_session_id),
4794  ntohl (mp->remote_session_id),
4795  clib_net_to_host_u64 (mp->local_cookie),
4796  clib_net_to_host_u64 (mp->remote_cookie),
4797  mp->l2_sublayer_present,
4798  encap_fib_index, &sw_if_index);
4799 
4800 out:
4801  /* *INDENT-OFF* */
4802  REPLY_MACRO2(VL_API_L2TPV3_CREATE_TUNNEL_REPLY,
4803  ({
4804  rmp->sw_if_index = ntohl (sw_if_index);
4805  }));
4806  /* *INDENT-ON* */
4807 }
4808 
4811 {
4813  l2t_main_t *lm = &l2t_main;
4814  int rv;
4815 
4816  VALIDATE_SW_IF_INDEX (mp);
4817 
4818  rv = l2tpv3_set_tunnel_cookies (lm, ntohl (mp->sw_if_index),
4819  clib_net_to_host_u64 (mp->new_local_cookie),
4820  clib_net_to_host_u64
4821  (mp->new_remote_cookie));
4822 
4824 
4825  REPLY_MACRO (VL_API_L2TPV3_SET_TUNNEL_COOKIES_REPLY);
4826 }
4827 
4830 {
4831  int rv;
4832  vnet_main_t *vnm = vnet_get_main ();
4834 
4835  VALIDATE_SW_IF_INDEX (mp);
4836 
4838  (vnm, ntohl (mp->sw_if_index), mp->enable_disable);
4839 
4841 
4842  REPLY_MACRO (VL_API_L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY);
4843 }
4844 
4847 {
4848  int rv = 0;
4849  l2t_main_t *lm = &l2t_main;
4851 
4852  if (mp->key > L2T_LOOKUP_SESSION_ID)
4853  {
4854  rv = VNET_API_ERROR_INVALID_VALUE;
4855  goto out;
4856  }
4857 
4858  lm->lookup_type = mp->key;
4859 
4860 out:
4861  REPLY_MACRO (VL_API_L2TPV3_SET_LOOKUP_KEY_REPLY);
4862 }
4863 
4866 {
4868  int rv = 0;
4870  u32 encap_fib_index;
4871  uword *p;
4872  ip4_main_t *im = &ip4_main;
4873  u32 sw_if_index = ~0;
4874 
4875  p = hash_get (im->fib_index_by_table_id, ntohl (mp->encap_vrf_id));
4876  if (!p)
4877  {
4878  rv = VNET_API_ERROR_NO_SUCH_FIB;
4879  goto out;
4880  }
4881  encap_fib_index = p[0];
4882 
4883  /* Check src & dst are different */
4884  if ((mp->is_ipv6 && memcmp (mp->src_address, mp->dst_address, 16) == 0) ||
4885  (!mp->is_ipv6 && memcmp (mp->src_address, mp->dst_address, 4) == 0))
4886  {
4887  rv = VNET_API_ERROR_SAME_SRC_DST;
4888  goto out;
4889  }
4890  memset (a, 0, sizeof (*a));
4891 
4892  a->is_add = mp->is_add;
4893  a->is_ip6 = mp->is_ipv6;
4894 
4895  /* ip addresses sent in network byte order */
4896  if (a->is_ip6)
4897  {
4898  memcpy (&(a->src.ip6), mp->src_address, 16);
4899  memcpy (&(a->dst.ip6), mp->dst_address, 16);
4900  }
4901  else
4902  {
4903  memcpy (&(a->src.ip4), mp->src_address, 4);
4904  memcpy (&(a->dst.ip4), mp->dst_address, 4);
4905  }
4906 
4907  a->encap_fib_index = encap_fib_index;
4908  a->decap_next_index = ntohl (mp->decap_next_index);
4909  a->vni = ntohl (mp->vni);
4910  rv = vnet_vxlan_add_del_tunnel (a, &sw_if_index);
4911 
4912 out:
4913  /* *INDENT-OFF* */
4914  REPLY_MACRO2(VL_API_VXLAN_ADD_DEL_TUNNEL_REPLY,
4915  ({
4916  rmp->sw_if_index = ntohl (sw_if_index);
4917  }));
4918  /* *INDENT-ON* */
4919 }
4920 
4921 static void send_vxlan_tunnel_details
4923 {
4925  ip4_main_t *im4 = &ip4_main;
4926  ip6_main_t *im6 = &ip6_main;
4927  u8 is_ipv6 = !(t->flags & VXLAN_TUNNEL_IS_IPV4);
4928 
4929  rmp = vl_msg_api_alloc (sizeof (*rmp));
4930  memset (rmp, 0, sizeof (*rmp));
4931  rmp->_vl_msg_id = ntohs (VL_API_VXLAN_TUNNEL_DETAILS);
4932  if (is_ipv6)
4933  {
4934  memcpy (rmp->src_address, &(t->src.ip6), 16);
4935  memcpy (rmp->dst_address, &(t->dst.ip6), 16);
4936  rmp->encap_vrf_id = htonl (im6->fibs[t->encap_fib_index].ft_table_id);
4937  }
4938  else
4939  {
4940  memcpy (rmp->src_address, &(t->src.ip4), 4);
4941  memcpy (rmp->dst_address, &(t->dst.ip4), 4);
4942  rmp->encap_vrf_id = htonl (im4->fibs[t->encap_fib_index].ft_table_id);
4943  }
4944  rmp->vni = htonl (t->vni);
4945  rmp->decap_next_index = htonl (t->decap_next_index);
4946  rmp->sw_if_index = htonl (t->sw_if_index);
4947  rmp->is_ipv6 = is_ipv6;
4948  rmp->context = context;
4949 
4950  vl_msg_api_send_shmem (q, (u8 *) & rmp);
4951 }
4952 
4955 {
4957  vxlan_main_t *vxm = &vxlan_main;
4958  vxlan_tunnel_t *t;
4959  u32 sw_if_index;
4960 
4962  if (q == 0)
4963  {
4964  return;
4965  }
4966 
4967  sw_if_index = ntohl (mp->sw_if_index);
4968 
4969  if (~0 == sw_if_index)
4970  {
4971  /* *INDENT-OFF* */
4972  pool_foreach (t, vxm->tunnels,
4973  ({
4974  send_vxlan_tunnel_details(t, q, mp->context);
4975  }));
4976  /* *INDENT-ON* */
4977  }
4978  else
4979  {
4980  if ((sw_if_index >= vec_len (vxm->tunnel_index_by_sw_if_index)) ||
4981  (~0 == vxm->tunnel_index_by_sw_if_index[sw_if_index]))
4982  {
4983  return;
4984  }
4985  t = &vxm->tunnels[vxm->tunnel_index_by_sw_if_index[sw_if_index]];
4986  send_vxlan_tunnel_details (t, q, mp->context);
4987  }
4988 }
4989 
4992 {
4994  int rv = 0;
4995  vnet_gre_add_del_tunnel_args_t _a, *a = &_a;
4996  u32 outer_fib_id;
4997  uword *p;
4998  ip4_main_t *im = &ip4_main;
4999  u32 sw_if_index = ~0;
5000 
5001  p = hash_get (im->fib_index_by_table_id, ntohl (mp->outer_fib_id));
5002  if (!p)
5003  {
5004  rv = VNET_API_ERROR_NO_SUCH_FIB;
5005  goto out;
5006  }
5007  outer_fib_id = p[0];
5008 
5009  /* Check src & dst are different */
5010  if ((mp->is_ipv6 && memcmp (mp->src_address, mp->dst_address, 16) == 0) ||
5011  (!mp->is_ipv6 && memcmp (mp->src_address, mp->dst_address, 4) == 0))
5012  {
5013  rv = VNET_API_ERROR_SAME_SRC_DST;
5014  goto out;
5015  }
5016  memset (a, 0, sizeof (*a));
5017 
5018  a->is_add = mp->is_add;
5019  a->teb = mp->teb;
5020 
5021  /* ip addresses sent in network byte order */
5022  clib_memcpy (&(a->src), mp->src_address, 4);
5023  clib_memcpy (&(a->dst), mp->dst_address, 4);
5024 
5025  a->outer_fib_id = outer_fib_id;
5026  rv = vnet_gre_add_del_tunnel (a, &sw_if_index);
5027 
5028 out:
5029  /* *INDENT-OFF* */
5030  REPLY_MACRO2(VL_API_GRE_ADD_DEL_TUNNEL_REPLY,
5031  ({
5032  rmp->sw_if_index = ntohl (sw_if_index);
5033  }));
5034  /* *INDENT-ON* */
5035 }
5036 
5037 static void send_gre_tunnel_details
5039 {
5041  ip4_main_t *im = &ip4_main;
5042 
5043  rmp = vl_msg_api_alloc (sizeof (*rmp));
5044  memset (rmp, 0, sizeof (*rmp));
5045  rmp->_vl_msg_id = ntohs (VL_API_GRE_TUNNEL_DETAILS);
5046  clib_memcpy (rmp->src_address, &(t->tunnel_src), 4);
5047  clib_memcpy (rmp->dst_address, &(t->tunnel_dst), 4);
5048  rmp->outer_fib_id = htonl (im->fibs[t->outer_fib_index].ft_table_id);
5049  rmp->teb = t->teb;
5050  rmp->sw_if_index = htonl (t->sw_if_index);
5051  rmp->context = context;
5052 
5053  vl_msg_api_send_shmem (q, (u8 *) & rmp);
5054 }
5055 
5056 static void
5058 {
5060  gre_main_t *gm = &gre_main;
5061  gre_tunnel_t *t;
5062  u32 sw_if_index;
5063 
5065  if (q == 0)
5066  {
5067  return;
5068  }
5069 
5070  sw_if_index = ntohl (mp->sw_if_index);
5071 
5072  if (~0 == sw_if_index)
5073  {
5074  /* *INDENT-OFF* */
5075  pool_foreach (t, gm->tunnels,
5076  ({
5077  send_gre_tunnel_details(t, q, mp->context);
5078  }));
5079  /* *INDENT-ON* */
5080  }
5081  else
5082  {
5083  if ((sw_if_index >= vec_len (gm->tunnel_index_by_sw_if_index)) ||
5084  (~0 == gm->tunnel_index_by_sw_if_index[sw_if_index]))
5085  {
5086  return;
5087  }
5088  t = &gm->tunnels[gm->tunnel_index_by_sw_if_index[sw_if_index]];
5089  send_gre_tunnel_details (t, q, mp->context);
5090  }
5091 }
5092 
5093 static void
5095 {
5096  extern int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index,
5097  int is_add);
5099  int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index,
5100  int is_add);
5101  int rv = 0;
5102 
5105 
5106  rv = vnet_l2_patch_add_del (ntohl (mp->rx_sw_if_index),
5107  ntohl (mp->tx_sw_if_index),
5108  (int) (mp->is_add != 0));
5109 
5112 
5113  REPLY_MACRO (VL_API_L2_PATCH_ADD_DEL_REPLY);
5114 }
5115 
5116 static void
5119 {
5121  int rv = 0;
5123  u32 encap_fib_index, decap_fib_index;
5124  u8 protocol;
5125  uword *p;
5126  ip4_main_t *im = &ip4_main;
5127  u32 sw_if_index = ~0;
5128 
5129 
5130  p = hash_get (im->fib_index_by_table_id, ntohl (mp->encap_vrf_id));
5131  if (!p)
5132  {
5133  rv = VNET_API_ERROR_NO_SUCH_FIB;
5134  goto out;
5135  }
5136  encap_fib_index = p[0];
5137 
5138  protocol = mp->protocol;
5139 
5140  /* Interpret decap_vrf_id as an opaque if sending to other-than-ip4-input */
5141  if (protocol == VXLAN_GPE_INPUT_NEXT_IP4_INPUT)
5142  {
5143  p = hash_get (im->fib_index_by_table_id, ntohl (mp->decap_vrf_id));
5144  if (!p)
5145  {
5146  rv = VNET_API_ERROR_NO_SUCH_INNER_FIB;
5147  goto out;
5148  }
5149  decap_fib_index = p[0];
5150  }
5151  else
5152  {
5153  decap_fib_index = ntohl (mp->decap_vrf_id);
5154  }
5155 
5156  /* Check src & dst are different */
5157  if ((mp->is_ipv6 && memcmp (mp->local, mp->remote, 16) == 0) ||
5158  (!mp->is_ipv6 && memcmp (mp->local, mp->remote, 4) == 0))
5159  {
5160  rv = VNET_API_ERROR_SAME_SRC_DST;
5161  goto out;
5162  }
5163  memset (a, 0, sizeof (*a));
5164 
5165  a->is_add = mp->is_add;
5166  a->is_ip6 = mp->is_ipv6;
5167  /* ip addresses sent in network byte order */
5168  if (a->is_ip6)
5169  {
5170  clib_memcpy (&(a->local.ip6), mp->local, 16);
5171  clib_memcpy (&(a->remote.ip6), mp->remote, 16);
5172  }
5173  else
5174  {
5175  clib_memcpy (&(a->local.ip4), mp->local, 4);
5176  clib_memcpy (&(a->remote.ip4), mp->remote, 4);
5177  }
5178  a->encap_fib_index = encap_fib_index;
5179  a->decap_fib_index = decap_fib_index;
5180  a->protocol = protocol;
5181  a->vni = ntohl (mp->vni);
5182  rv = vnet_vxlan_gpe_add_del_tunnel (a, &sw_if_index);
5183 
5184 out:
5185  /* *INDENT-OFF* */
5186  REPLY_MACRO2(VL_API_VXLAN_GPE_ADD_DEL_TUNNEL_REPLY,
5187  ({
5188  rmp->sw_if_index = ntohl (sw_if_index);
5189  }));
5190  /* *INDENT-ON* */
5191 }
5192 
5195 {
5197  ip4_main_t *im4 = &ip4_main;
5198  ip6_main_t *im6 = &ip6_main;
5199  u8 is_ipv6 = !(t->flags & VXLAN_GPE_TUNNEL_IS_IPV4);
5200 
5201  rmp = vl_msg_api_alloc (sizeof (*rmp));
5202  memset (rmp, 0, sizeof (*rmp));
5203  rmp->_vl_msg_id = ntohs (VL_API_VXLAN_GPE_TUNNEL_DETAILS);
5204  if (is_ipv6)
5205  {
5206  memcpy (rmp->local, &(t->local.ip6), 16);
5207  memcpy (rmp->remote, &(t->remote.ip6), 16);
5208  rmp->encap_vrf_id = htonl (im6->fibs[t->encap_fib_index].ft_table_id);
5209  rmp->decap_vrf_id = htonl (im6->fibs[t->decap_fib_index].ft_table_id);
5210  }
5211  else
5212  {
5213  memcpy (rmp->local, &(t->local.ip4), 4);
5214  memcpy (rmp->remote, &(t->remote.ip4), 4);
5215  rmp->encap_vrf_id = htonl (im4->fibs[t->encap_fib_index].ft_table_id);
5216  rmp->decap_vrf_id = htonl (im4->fibs[t->decap_fib_index].ft_table_id);
5217  }
5218  rmp->vni = htonl (t->vni);
5219  rmp->protocol = t->protocol;
5220  rmp->sw_if_index = htonl (t->sw_if_index);
5221  rmp->is_ipv6 = is_ipv6;
5222  rmp->context = context;
5223 
5224  vl_msg_api_send_shmem (q, (u8 *) & rmp);
5225 }
5226 
5229 {
5232  vxlan_gpe_tunnel_t *t;
5233  u32 sw_if_index;
5234 
5236  if (q == 0)
5237  {
5238  return;
5239  }
5240 
5241  sw_if_index = ntohl (mp->sw_if_index);
5242 
5243  if (~0 == sw_if_index)
5244  {
5245  /* *INDENT-OFF* */
5246  pool_foreach (t, vgm->tunnels,
5247  ({
5248  send_vxlan_gpe_tunnel_details(t, q, mp->context);
5249  }));
5250  /* *INDENT-ON* */
5251  }
5252  else
5253  {
5254  if ((sw_if_index >= vec_len (vgm->tunnel_index_by_sw_if_index)) ||
5255  (~0 == vgm->tunnel_index_by_sw_if_index[sw_if_index]))
5256  {
5257  return;
5258  }
5259  t = &vgm->tunnels[vgm->tunnel_index_by_sw_if_index[sw_if_index]];
5261  }
5262 }
5263 
5264 /** Used for transferring locators via VPP API */
5265 /* *INDENT-OFF* */
5266 typedef CLIB_PACKED (struct {
5267  u32 sw_if_index; /**< locator sw_if_index */
5268  u8 priority; /**< locator priority */
5269  u8 weight; /**< locator weight */
5270 }) ls_locator_t;
5271 /* *INDENT-ON* */
5272 
5273 static void
5274 vl_api_lisp_add_del_locator_set_t_handler (vl_api_lisp_add_del_locator_set_t *
5275  mp)
5276 {
5278  int rv = 0;
5280  locator_t locator;
5281  ls_locator_t *ls_loc;
5282  u32 ls_index = ~0, locator_num;
5283  u8 *locator_name = NULL;
5284  int i;
5285 
5286  memset (a, 0, sizeof (a[0]));
5287 
5288  locator_name = format (0, "%s", mp->locator_set_name);
5289 
5290  a->name = locator_name;
5291  a->is_add = mp->is_add;
5292  a->local = 1;
5293  locator_num = clib_net_to_host_u32 (mp->locator_num);
5294 
5295  memset (&locator, 0, sizeof (locator));
5296  for (i = 0; i < locator_num; i++)
5297  {
5298  ls_loc = &((ls_locator_t *) mp->locators)[i];
5299  VALIDATE_SW_IF_INDEX (ls_loc);
5300 
5301  locator.sw_if_index = htonl (ls_loc->sw_if_index);
5302  locator.priority = ls_loc->priority;
5303  locator.weight = ls_loc->weight;
5304  locator.local = 1;
5305  vec_add1 (a->locators, locator);
5306  }
5307 
5308  rv = vnet_lisp_add_del_locator_set (a, &ls_index);
5309 
5311 
5312  vec_free (locator_name);
5313  vec_free (a->locators);
5314 
5315  /* *INDENT-OFF* */
5316  REPLY_MACRO2 (VL_API_LISP_ADD_DEL_LOCATOR_SET_REPLY,
5317  ({
5318  rmp->ls_index = clib_host_to_net_u32 (ls_index);
5319  }));
5320  /* *INDENT-ON* */
5321 }
5322 
5323 static void
5325 {
5327  int rv = 0;
5328  locator_t locator, *locators = NULL;
5330  u32 ls_index = ~0;
5331  u8 *locator_name = NULL;
5332 
5333  memset (&locator, 0, sizeof (locator));
5334  memset (a, 0, sizeof (a[0]));
5335 
5336  locator.sw_if_index = ntohl (mp->sw_if_index);
5337  locator.priority = mp->priority;
5338  locator.weight = mp->weight;
5339  locator.local = 1;
5340  vec_add1 (locators, locator);
5341 
5342  locator_name = format (0, "%s", mp->locator_set_name);
5343 
5344  a->name = locator_name;
5345  a->locators = locators;
5346  a->is_add = mp->is_add;
5347  a->local = 1;
5348 
5349  rv = vnet_lisp_add_del_locator (a, NULL, &ls_index);
5350 
5351  vec_free (locators);
5352  vec_free (locator_name);
5353 
5354  REPLY_MACRO (VL_API_LISP_ADD_DEL_LOCATOR_REPLY);
5355 }
5356 
5357 static int
5359  u8 len)
5360 {
5361  switch (type)
5362  {
5363  case 0: /* ipv4 */
5365  gid_address_ip_set (dst, src, IP4);
5366  gid_address_ippref_len (dst) = len;
5368  break;
5369  case 1: /* ipv6 */
5371  gid_address_ip_set (dst, src, IP6);
5372  gid_address_ippref_len (dst) = len;
5374  break;
5375  case 2: /* l2 mac */
5377  clib_memcpy (&gid_address_mac (dst), src, 6);
5378  break;
5379  default:
5380  /* unknown type */
5381  return VNET_API_ERROR_INVALID_VALUE;
5382  }
5383 
5384  gid_address_vni (dst) = vni;
5385 
5386  return 0;
5387 }
5388 
5389 static void
5391 {
5394  int rv = 0;
5395  gid_address_t _eid, *eid = &_eid;
5396  uword *p = NULL;
5397  u32 locator_set_index = ~0, map_index = ~0;
5399  u8 *name = NULL;
5400  memset (a, 0, sizeof (a[0]));
5401  memset (eid, 0, sizeof (eid[0]));
5402 
5403  rv = unformat_lisp_eid_api (eid, clib_net_to_host_u32 (mp->vni),
5404  mp->eid_type, mp->eid, mp->prefix_len);
5405  if (rv)
5406  goto out;
5407 
5408  name = format (0, "%s", mp->locator_set_name);
5409  p = hash_get_mem (lcm->locator_set_index_by_name, name);
5410  if (!p)
5411  {
5412  rv = VNET_API_ERROR_INVALID_VALUE;
5413  goto out;
5414  }
5415  locator_set_index = p[0];
5416 
5417  /* XXX treat batch configuration */
5418  a->is_add = mp->is_add;
5419  gid_address_copy (&a->eid, eid);
5420  a->locator_set_index = locator_set_index;
5421  a->local = 1;
5422  rv = vnet_lisp_add_del_local_mapping (a, &map_index);
5423 
5424 out:
5425  vec_free (name);
5426  gid_address_free (&a->eid);
5427 
5428  REPLY_MACRO (VL_API_LISP_ADD_DEL_LOCAL_EID_REPLY);
5429 }
5430 
5431 static void
5434 {
5436  int rv = 0;
5437  rv = vnet_lisp_eid_table_map (clib_net_to_host_u32 (mp->vni),
5438  clib_net_to_host_u32 (mp->dp_table),
5439  mp->is_l2, mp->is_add);
5440 REPLY_MACRO (VL_API_LISP_EID_TABLE_ADD_DEL_MAP_REPLY)}
5441 
5442 /** Used for transferring locators via VPP API */
5443 /* *INDENT-OFF* */
5444 typedef CLIB_PACKED (struct {
5445  u8 is_ip4; /**< is locator an IPv4 address */
5446  u8 priority; /**< locator priority */
5447  u8 weight; /**< locator weight */
5448  u8 addr[16]; /**< IPv4/IPv6 address */
5449 }) rloc_t;
5450 /* *INDENT-ON* */
5451 
5452 static locator_pair_t *
5453 unformat_lisp_loc_pairs (void *lcl_locs, void *rmt_locs, u32 rloc_num)
5454 {
5455  u32 i;
5456  locator_pair_t *pairs = 0, pair;
5457  rloc_t *r;
5458 
5459  for (i = 0; i < rloc_num; i++)
5460  {
5461  /* local locator */
5462  r = &((rloc_t *) lcl_locs)[i];
5463  memset (&pair.lcl_loc, 0, sizeof (pair.lcl_loc));
5464  ip_address_set (&pair.lcl_loc, &r->addr, r->is_ip4 ? IP4 : IP6);
5465 
5466  /* remote locators */
5467  r = &((rloc_t *) rmt_locs)[i];
5468  memset (&pair.rmt_loc, 0, sizeof (pair.rmt_loc));
5469  ip_address_set (&pair.rmt_loc, &r->addr, r->is_ip4 ? IP4 : IP6);
5470 
5471  pair.priority = r->priority;
5472  pair.weight = r->weight;
5473 
5474  vec_add1 (pairs, pair);
5475  }
5476  return pairs;
5477 }
5478 
5479 static locator_t *
5480 unformat_lisp_locs (void *rmt_locs, u32 rloc_num)
5481 {
5482  u32 i;
5483  locator_t *locs = 0, loc;
5484  rloc_t *r;
5485 
5486  for (i = 0; i < rloc_num; i++)
5487  {
5488  /* remote locators */
5489  r = &((rloc_t *) rmt_locs)[i];
5490  memset (&loc, 0, sizeof (loc));
5491  gid_address_ip_set (&loc.address, &r->addr, r->is_ip4 ? IP4 : IP6);
5492 
5493  loc.priority = r->priority;
5494  loc.weight = r->weight;
5495 
5496  vec_add1 (locs, loc);
5497  }
5498  return locs;
5499 }
5500 
5501 static void
5504 {
5507  locator_pair_t *pairs = 0;
5508  int rv = 0;
5509 
5510  memset (a, 0, sizeof (a[0]));
5511 
5512  rv = unformat_lisp_eid_api (&a->rmt_eid, mp->vni, mp->eid_type,
5513  mp->rmt_eid, mp->rmt_len);
5514  rv |= unformat_lisp_eid_api (&a->lcl_eid, mp->vni, mp->eid_type,
5515  mp->lcl_eid, mp->lcl_len);
5516 
5517  pairs = unformat_lisp_loc_pairs (mp->lcl_locs, mp->rmt_locs, mp->loc_num);
5518 
5519  if (rv || 0 == pairs)
5520  goto send_reply;
5521 
5522  a->is_add = mp->is_add;
5523  a->locator_pairs = pairs;
5524  a->dp_table = mp->dp_table;
5525  a->vni = mp->vni;
5526  a->action = mp->action;
5527 
5528  rv = vnet_lisp_gpe_add_del_fwd_entry (a, 0);
5529  vec_free (pairs);
5530 send_reply:
5531  REPLY_MACRO (VL_API_LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY);
5532 }
5533 
5534 static void
5536  * mp)
5537 {
5539  int rv = 0;
5541 
5542  memset (a, 0, sizeof (a[0]));
5543 
5544  a->is_add = mp->is_add;
5545  ip_address_set (&a->address, mp->ip_address, mp->is_ipv6 ? IP6 : IP4);
5546 
5548 
5549  REPLY_MACRO (VL_API_LISP_ADD_DEL_MAP_RESOLVER_REPLY);
5550 }
5551 
5552 static void
5554  mp)
5555 {
5557  int rv = 0;
5559 
5560  a->is_en = mp->is_en;
5562 
5563  REPLY_MACRO (VL_API_LISP_GPE_ENABLE_DISABLE_REPLY);
5564 }
5565 
5566 static void
5568 {
5570  int rv = 0;
5571 
5573  REPLY_MACRO (VL_API_LISP_ENABLE_DISABLE_REPLY);
5574 }
5575 
5576 static void
5578 {
5580  int rv = 0;
5581 
5582  if (mp->is_l2)
5583  {
5584  if (mp->is_add)
5585  {
5586  if (~0 ==
5588  rv = 1;
5589  }
5590  else
5592  }
5593  else
5594  {
5595  if (mp->is_add)
5596  {
5597  if (~0 ==
5599  rv = 1;
5600  }
5601  else
5603  }
5604 
5605  REPLY_MACRO (VL_API_LISP_GPE_ADD_DEL_IFACE_REPLY);
5606 }
5607 
5608 static void
5611 {
5612  int rv = 0;
5614 
5615  /* *INDENT-OFF* */
5616  REPLY_MACRO2(VL_API_SHOW_LISP_MAP_REQUEST_MODE_REPLY,
5617  ({
5619  }));
5620  /* *INDENT-ON* */
5621 }
5622 
5623 static void
5625 {
5627  int rv = 0;
5628 
5630 
5631  REPLY_MACRO (VL_API_LISP_MAP_REQUEST_MODE_REPLY);
5632 }
5633 
5634 static void
5636  * mp)
5637 {
5639  int rv = 0;
5640  u8 *ls_name = 0;
5641 
5642  ls_name = format (0, "%s", mp->ls_name);
5643  rv = vnet_lisp_pitr_set_locator_set (ls_name, mp->is_add);
5644  vec_free (ls_name);
5645 
5646  REPLY_MACRO (VL_API_LISP_PITR_SET_LOCATOR_SET_REPLY);
5647 }
5648 
5649 static void
5652 {
5654  int rv = 0;
5655  u8 *locator_set_name = NULL;
5657 
5658  locator_set_name = format (0, "%s", mp->locator_set_name);
5659 
5660  a->is_add = mp->is_add;
5661  a->locator_set_name = locator_set_name;
5662 
5664 
5665  vec_free (locator_set_name);
5666 
5667  REPLY_MACRO (VL_API_LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY);
5668 }
5669 
5670 static void
5673 {
5674  locator_t *rlocs = 0;
5676  int rv = 0;
5677  gid_address_t _eid, *eid = &_eid;
5678  u32 rloc_num = clib_net_to_host_u32 (mp->rloc_num);
5679 
5680  memset (eid, 0, sizeof (eid[0]));
5681 
5682  rv = unformat_lisp_eid_api (eid, clib_net_to_host_u32 (mp->vni),
5683  mp->eid_type, mp->eid, mp->eid_len);
5684  if (rv)
5685  goto send_reply;
5686 
5687  rlocs = unformat_lisp_locs (mp->rlocs, rloc_num);
5688 
5689  if (!mp->is_add)
5690  {
5692  gid_address_copy (&a->reid, eid);
5693  a->is_add = 0;
5694  rv = vnet_lisp_add_del_adjacency (a);
5695  if (rv)
5696  {
5697  goto out;
5698  }
5699  }
5700 
5701  /* NOTE: for now this works as a static remote mapping, i.e.,
5702  * not authoritative and ttl infinite. */
5703  rv = vnet_lisp_add_del_mapping (eid, rlocs, mp->action, 0, ~0,
5704  mp->is_add, 1 /* is_static */ , 0);
5705 
5706  if (mp->del_all)
5708 
5709 out:
5710  vec_free (rlocs);
5711 send_reply:
5712  REPLY_MACRO (VL_API_LISP_ADD_DEL_REMOTE_MAPPING_REPLY);
5713 }
5714 
5715 static void
5717 {
5720 
5721  int rv = 0;
5722  memset (a, 0, sizeof (a[0]));
5723 
5724  rv = unformat_lisp_eid_api (&a->leid, clib_net_to_host_u32 (mp->vni),
5725  mp->eid_type, mp->leid, mp->leid_len);
5726  rv |= unformat_lisp_eid_api (&a->reid, clib_net_to_host_u32 (mp->vni),
5727  mp->eid_type, mp->reid, mp->reid_len);
5728 
5729  if (rv)
5730  goto send_reply;
5731 
5732  a->is_add = mp->is_add;
5733  rv = vnet_lisp_add_del_adjacency (a);
5734 
5735 send_reply:
5736  REPLY_MACRO (VL_API_LISP_ADD_DEL_ADJACENCY_REPLY);
5737 }
5738 
5739 static void
5741  locator_t * loc,
5742  unix_shared_memory_queue_t * q, u32 context)
5743 {
5745 
5746  rmp = vl_msg_api_alloc (sizeof (*rmp));
5747  memset (rmp, 0, sizeof (*rmp));
5748  rmp->_vl_msg_id = ntohs (VL_API_LISP_LOCATOR_DETAILS);
5749  rmp->context = context;
5750 
5751  rmp->local = loc->local;
5752  if (loc->local)
5753  {
5754  rmp->sw_if_index = ntohl (loc->sw_if_index);
5755  }
5756  else
5757  {
5758  rmp->is_ipv6 = gid_address_ip_version (&loc->address);
5760  }
5761  rmp->priority = loc->priority;
5762  rmp->weight = loc->weight;
5763 
5764  vl_msg_api_send_shmem (q, (u8 *) & rmp);
5765 }
5766 
5767 static void
5769 {
5770  u8 *ls_name = 0;
5773  locator_set_t *lsit = 0;
5774  locator_t *loc = 0;
5775  u32 ls_index = ~0, *locit = 0;
5776  uword *p = 0;
5777 
5779  if (q == 0)
5780  {
5781  return;
5782  }
5783 
5784  if (mp->is_index_set)
5785  ls_index = htonl (mp->ls_index);
5786  else
5787  {
5788  /* make sure we get a proper C-string */
5789  mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
5790  ls_name = format (0, "%s", mp->ls_name);
5791  p = hash_get_mem (lcm->locator_set_index_by_name, ls_name);
5792  if (!p)
5793  goto out;
5794  ls_index = p[0];
5795  }
5796 
5797  if (pool_is_free_index (lcm->locator_set_pool, ls_index))
5798  return;
5799 
5800  lsit = pool_elt_at_index (lcm->locator_set_pool, ls_index);
5801 
5802  vec_foreach (locit, lsit->locator_indices)
5803  {
5804  loc = pool_elt_at_index (lcm->locator_pool, locit[0]);
5805  send_lisp_locator_details (lcm, loc, q, mp->context);
5806  };
5807 out:
5808  vec_free (ls_name);
5809 }
5810 
5811 static void
5813  locator_set_t * lsit,
5815  u32 context, u32 ls_index)
5816 {
5818  u8 *str = 0;
5819 
5820  rmp = vl_msg_api_alloc (sizeof (*rmp));
5821  memset (rmp, 0, sizeof (*rmp));
5822  rmp->_vl_msg_id = ntohs (VL_API_LISP_LOCATOR_SET_DETAILS);
5823  rmp->context = context;
5824 
5825  rmp->ls_index = htonl (ls_index);
5826  if (lsit->local)
5827  {
5828  ASSERT (lsit->name != NULL);
5829  strncpy ((char *) rmp->ls_name, (char *) lsit->name,
5830  vec_len (lsit->name));
5831  }
5832  else
5833  {
5834  str = format (0, "<remote-%d>", ls_index);
5835  strncpy ((char *) rmp->ls_name, (char *) str, vec_len (str));
5836  vec_free (str);
5837  }
5838 
5839  vl_msg_api_send_shmem (q, (u8 *) & rmp);
5840 }
5841 
5842 static void
5844 {
5847  locator_set_t *lsit = NULL;
5848  u8 filter;
5849 
5851  if (q == 0)
5852  {
5853  return;
5854  }
5855 
5856  filter = mp->filter;
5857  /* *INDENT-OFF* */
5858  pool_foreach (lsit, lcm->locator_set_pool,
5859  ({
5860  if (filter && !((1 == filter && lsit->local) ||
5861  (2 == filter && !lsit->local)))
5862  {
5863  continue;
5864  }
5865  send_lisp_locator_set_details (lcm, lsit, q, mp->context,
5866  lsit - lcm->locator_set_pool);
5867  }));
5868  /* *INDENT-ON* */
5869 }
5870 
5871 static void
5872 lisp_fid_put_api (u8 * dst, fid_address_t * src, u8 * prefix_length)
5873 {
5874  ASSERT (prefix_length);
5875  ip_prefix_t *ippref = &fid_addr_ippref (src);
5876 
5877  switch (fid_addr_type (src))
5878  {
5879  case FID_ADDR_IP_PREF:
5880  if (ip_prefix_version (ippref) == IP4)
5881  clib_memcpy (dst, &ip_prefix_v4 (ippref), 4);
5882  else
5883  clib_memcpy (dst, &ip_prefix_v6 (ippref), 16);
5884  prefix_length[0] = ip_prefix_len (ippref);
5885  break;
5886 
5887  case FID_ADDR_MAC:
5888  prefix_length[0] = 0;
5889  clib_memcpy (dst, fid_addr_mac (src), 6);
5890  break;
5891 
5892  default:
5893  clib_warning ("Unknown FID type %d!", fid_addr_type (src));
5894  break;
5895  }
5896 }
5897 
5898 static u8
5900 {
5901  ip_prefix_t *ippref;
5902 
5903  switch (fid_addr_type (fid))
5904  {
5905  case FID_ADDR_IP_PREF:
5906  ippref = &fid_addr_ippref (fid);
5907  if (ip_prefix_version (ippref) == IP4)
5908  return 0;
5909  else if (ip_prefix_version (ippref) == IP6)
5910  return 1;
5911  else
5912  return ~0;
5913 
5914  case FID_ADDR_MAC:
5915  return 2;
5916  }
5917 
5918  return ~0;
5919 }
5920 
5921 static void
5924  u32 context, u8 filter)
5925 {
5926  fid_address_t *fid;
5928  locator_set_t *ls = 0;
5930  gid_address_t *gid = NULL;
5931  u8 *mac = 0;
5932  ip_prefix_t *ip_prefix = NULL;
5933 
5934  switch (filter)
5935  {
5936  case 0: /* all mappings */
5937  break;
5938 
5939  case 1: /* local only */
5940  if (!mapit->local)
5941  return;
5942  break;
5943  case 2: /* remote only */
5944  if (mapit->local)
5945  return;
5946  break;
5947  default:
5948  clib_warning ("Filter error, unknown filter: %d", filter);
5949  return;
5950  }
5951 
5952  gid = &mapit->eid;
5953  ip_prefix = &gid_address_ippref (gid);
5954  mac = gid_address_mac (gid);
5955 
5956  rmp = vl_msg_api_alloc (sizeof (*rmp));
5957  memset (rmp, 0, sizeof (*rmp));
5958  rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_DETAILS);
5959 
5961  if (vec_len (ls->locator_indices) == 0)
5962  rmp->locator_set_index = ~0;
5963  else
5964  rmp->locator_set_index = clib_host_to_net_u32 (mapit->locator_set_index);
5965 
5966  rmp->is_local = mapit->local;
5967  rmp->ttl = clib_host_to_net_u32 (mapit->ttl);
5968  rmp->action = mapit->action;
5969  rmp->authoritative = mapit->authoritative;
5970 
5971  switch (gid_address_type (gid))
5972  {
5973  case GID_ADDR_SRC_DST:
5974  rmp->is_src_dst = 1;
5975  fid = &gid_address_sd_src (gid);
5976  rmp->eid_type = fid_type_to_api_type (fid);
5978  &rmp->seid_prefix_len);
5979  lisp_fid_put_api (rmp->eid, &gid_address_sd_dst (gid),
5980  &rmp->eid_prefix_len);
5981  break;
5982  case GID_ADDR_IP_PREFIX:
5983  rmp->eid_prefix_len = ip_prefix_len (ip_prefix);
5984  if (ip_prefix_version (ip_prefix) == IP4)
5985  {
5986  rmp->eid_type = 0; /* ipv4 type */
5987  clib_memcpy (rmp->eid, &ip_prefix_v4 (ip_prefix),
5988  sizeof (ip_prefix_v4 (ip_prefix)));
5989  }
5990  else
5991  {
5992  rmp->eid_type = 1; /* ipv6 type */
5993  clib_memcpy (rmp->eid, &ip_prefix_v6 (ip_prefix),
5994  sizeof (ip_prefix_v6 (ip_prefix)));
5995  }
5996  break;
5997  case GID_ADDR_MAC:
5998  rmp->eid_type = 2; /* l2 mac type */
5999  clib_memcpy (rmp->eid, mac, 6);
6000  break;
6001  default:
6002  ASSERT (0);
6003  }
6004  rmp->context = context;
6005  rmp->vni = clib_host_to_net_u32 (gid_address_vni (gid));
6006  vl_msg_api_send_shmem (q, (u8 *) & rmp);
6007 }
6008 
6009 static void
6011 {
6012  u32 mi;
6015  mapping_t *mapit = NULL;
6016  gid_address_t _eid, *eid = &_eid;
6017 
6019  if (q == 0)
6020  {
6021  return;
6022  }
6023 
6024  if (mp->eid_set)
6025  {
6026  memset (eid, 0, sizeof (*eid));
6027 
6028  unformat_lisp_eid_api (eid, clib_net_to_host_u32 (mp->vni),
6029  mp->eid_type, mp->eid, mp->prefix_length);
6030 
6031  mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, eid);
6032  if ((u32) ~ 0 == mi)
6033  return;
6034 
6035  mapit = pool_elt_at_index (lcm->mapping_pool, mi);
6036  send_lisp_eid_table_details (mapit, q, mp->context,
6037  0 /* ignore filter */ );
6038  }
6039  else
6040  {
6041  /* *INDENT-OFF* */
6042  pool_foreach (mapit, lcm->mapping_pool,
6043  ({
6044  send_lisp_eid_table_details(mapit, q, mp->context,
6045  mp->filter);
6046  }));
6047  /* *INDENT-ON* */
6048  }
6049 }
6050 
6051 static void
6053  unix_shared_memory_queue_t * q, u32 context)
6054 {
6057 
6058  rmp = vl_msg_api_alloc (sizeof (*rmp));
6059  memset (rmp, 0, sizeof (*rmp));
6060  rmp->_vl_msg_id = ntohs (VL_API_LISP_GPE_TUNNEL_DETAILS);
6061 
6062  rmp->tunnels = lfe - lgm->lisp_fwd_entry_pool;
6063 
6064  rmp->is_ipv6 = ip_prefix_version (&(lfe->key->rmt.ippref)) == IP6 ? 1 : 0;
6066  &ip_prefix_addr (&(lfe->key->rmt.ippref)));
6068  &ip_prefix_addr (&(lfe->key->rmt.ippref)));
6069 
6070  rmp->encap_fib_id = htonl (0);
6071  rmp->decap_fib_id = htonl (lfe->eid_fib_index);
6072  rmp->iid = htonl (lfe->key->vni);
6073  rmp->context = context;
6074 
6075  vl_msg_api_send_shmem (q, (u8 *) & rmp);
6076 }
6077 
6078 static void
6080 {
6083  lisp_gpe_fwd_entry_t *lfe = NULL;
6084 
6085  if (pool_elts (lgm->lisp_fwd_entry_pool) == 0)
6086  {
6087  return;
6088  }
6089 
6091  if (q == 0)
6092  {
6093  return;
6094  }
6095 
6096  /* *INDENT-OFF* */
6098  ({
6099  send_lisp_gpe_fwd_entry_details(lfe, q, mp->context);
6100  }));
6101  /* *INDENT-ON* */
6102 }
6103 
6104 static void
6106  unix_shared_memory_queue_t * q, u32 context)
6107 {
6109 
6110  rmp = vl_msg_api_alloc (sizeof (*rmp));
6111  memset (rmp, 0, sizeof (*rmp));
6112  rmp->_vl_msg_id = ntohs (VL_API_LISP_MAP_RESOLVER_DETAILS);
6113 
6114  switch (ip_addr_version (ip))
6115  {
6116  case IP4:
6117  rmp->is_ipv6 = 0;
6118  clib_memcpy (rmp->ip_address, &ip_addr_v4 (ip),
6119  sizeof (ip_addr_v4 (ip)));
6120  break;
6121 
6122  case IP6:
6123  rmp->is_ipv6 = 1;
6124  clib_memcpy (rmp->ip_address, &ip_addr_v6 (ip),
6125  sizeof (ip_addr_v6 (ip)));
6126  break;
6127 
6128  default:
6129  ASSERT (0);
6130  }
6131  rmp->context = context;
6132 
6133  vl_msg_api_send_shmem (q, (u8 *) & rmp);
6134 }
6135 
6136 static void
6138 {
6141  map_resolver_t *mr;
6142 
6144  if (q == 0)
6145  {
6146  return;
6147  }
6148 
6149  vec_foreach (mr, lcm->map_resolvers)
6150  {
6152  }
6153 }
6154 
6155 static void
6157  unix_shared_memory_queue_t * q, u32 context)
6158 {
6160 
6161  rmp = vl_msg_api_alloc (sizeof (*rmp));
6162  memset (rmp, 0, sizeof (*rmp));
6163  rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_MAP_DETAILS);
6164 
6165  rmp->vni = clib_host_to_net_u32 (p->key);
6166  rmp->dp_table = clib_host_to_net_u32 (p->value[0]);
6167  rmp->context = context;
6168  vl_msg_api_send_shmem (q, (u8 *) & rmp);
6169 }
6170 
6171 static void
6173  mp)
6174 {
6177  hash_pair_t *p;
6178  uword *vni_table = 0;
6179 
6181  if (q == 0)
6182  {
6183  return;
6184  }
6185 
6186  if (mp->is_l2)
6187  {
6188  vni_table = lcm->bd_id_by_vni;
6189  }
6190  else
6191  {
6192  vni_table = lcm->table_id_by_vni;
6193  }
6194 
6195  /* *INDENT-OFF* */
6196  hash_foreach_pair (p, vni_table,
6197  ({
6198  send_eid_table_map_pair (p, q, mp->context);
6199  }));
6200  /* *INDENT-ON* */
6201 }
6202 
6203 static void
6205 {
6207 
6208  rmp = vl_msg_api_alloc (sizeof (*rmp));
6209  memset (rmp, 0, sizeof (*rmp));
6210  rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_VNI_DETAILS);
6211  rmp->context = context;
6212  rmp->vni = clib_host_to_net_u32 (vni);
6213  vl_msg_api_send_shmem (q, (u8 *) & rmp);
6214 }
6215 
6216 static void
6218 {
6219  lisp_adjacency_t *adj;
6221  u32 i, n = vec_len (adjs);
6222 
6223  for (i = 0; i < n; i++)
6224  {
6225  adj = vec_elt_at_index (adjs, i);
6226  memset (&a, 0, sizeof (a));
6227 
6228  switch (gid_address_type (&adj->reid))
6229  {
6230  case GID_ADDR_IP_PREFIX:
6233  if (gid_address_ip_version (&adj->reid) == IP4)
6234  {
6235  a.eid_type = 0; /* ipv4 type */
6236  clib_memcpy (a.reid, &gid_address_ip (&adj->reid), 4);
6237  clib_memcpy (a.leid, &gid_address_ip (&adj->leid), 4);
6238  }
6239  else
6240  {
6241  a.eid_type = 1; /* ipv6 type */
6242  clib_memcpy (a.reid, &gid_address_ip (&adj->reid), 16);
6243  clib_memcpy (a.leid, &gid_address_ip (&adj->leid), 16);
6244  }
6245  break;
6246  case GID_ADDR_MAC:
6247  a.eid_type = 2; /* l2 mac type */
6248  mac_copy (a.reid, gid_address_mac (&adj->reid));
6249  mac_copy (a.leid, gid_address_mac (&adj->leid));
6250  break;
6251  default:
6252  ASSERT (0);
6253  }
6254  dst[i] = a;
6255  }
6256 }
6257 
6258 static void
6260 {
6262  lisp_adjacency_t *adjs = 0;
6263  int rv = 0;
6265  u32 size = ~0;
6266  u32 vni = clib_net_to_host_u32 (mp->vni);
6267 
6268  adjs = vnet_lisp_adjacencies_get_by_vni (vni);
6269  size = vec_len (adjs) * sizeof (a);
6270 
6271  /* *INDENT-OFF* */
6272  REPLY_MACRO4 (VL_API_LISP_ADJACENCIES_GET_REPLY, size,
6273  {
6274  rmp->count = clib_host_to_net_u32 (vec_len (adjs));
6275  lisp_adjacency_copy (rmp->adjacencies, adjs);
6276  });
6277  /* *INDENT-ON* */
6278 
6279  vec_free (adjs);
6280 }
6281 
6282 static void
6284  mp)
6285 {
6286  hash_pair_t *p;
6287  u32 *vnis = 0;
6290 
6292  if (q == 0)
6293  {
6294  return;
6295  }
6296 
6297  /* *INDENT-OFF* */
6299  ({
6300  hash_set (vnis, p->key, 0);
6301  }));
6302 
6304  ({
6305  hash_set (vnis, p->key, 0);
6306  }));
6307 
6308  hash_foreach_pair (p, vnis,
6309  ({
6310  send_eid_table_vni (p->key, q, mp->context);
6311  }));
6312  /* *INDENT-ON* */
6313 
6314  hash_free (vnis);
6315 }
6316 
6317 static void
6319 {
6322  int rv = 0;
6323 
6325  if (q == 0)
6326  {
6327  return;
6328  }
6329 
6330  /* *INDENT-OFF* */
6331  REPLY_MACRO2(VL_API_SHOW_LISP_STATUS_REPLY,
6332  ({
6335  }));
6336  /* *INDENT-ON* */
6337 }
6338 
6339 static void
6342 {
6346  locator_set_t *loc_set = 0;
6347  u8 *tmp_str = 0;
6348  int rv = 0;
6349 
6351  if (q == 0)
6352  {
6353  return;
6354  }
6355 
6356  if (~0 == lcm->mreq_itr_rlocs)
6357  {
6358  tmp_str = format (0, " ");
6359  }
6360  else
6361  {
6362  loc_set =
6364  tmp_str = format (0, "%s", loc_set->name);
6365  }
6366 
6367  /* *INDENT-OFF* */
6368  REPLY_MACRO2(VL_API_LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY,
6369  ({
6370  strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
6371  ARRAY_LEN(rmp->locator_set_name) - 1);
6372  }));
6373  /* *INDENT-ON* */
6374 
6375  vec_free (tmp_str);
6376 }
6377 
6378 static void
6380 {
6384  mapping_t *m;
6385  locator_set_t *ls = 0;
6386  u8 *tmp_str = 0;
6387  int rv = 0;
6388 
6390  if (q == 0)
6391  {
6392  return;
6393  }
6394 
6395  if (!lcm->lisp_pitr)
6396  {
6397  tmp_str = format (0, "N/A");
6398  }
6399  else
6400  {
6402  if (~0 != m->locator_set_index)
6403  {
6404  ls =
6406  tmp_str = format (0, "%s", ls->name);
6407  }
6408  else
6409  {
6410  tmp_str = format (0, "N/A");
6411  }
6412  }
6413  vec_add1 (tmp_str, 0);
6414 
6415  /* *INDENT-OFF* */
6416  REPLY_MACRO2(VL_API_SHOW_LISP_PITR_REPLY,
6417  ({
6418  rmp->status = lcm->lisp_pitr;
6419  strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
6420  ARRAY_LEN(rmp->locator_set_name) - 1);
6421  }));
6422  /* *INDENT-ON* */
6423 }
6424 
6425 static void
6427  mp)
6428 {
6430  int rv = 0;
6431 
6432  VALIDATE_SW_IF_INDEX (mp);
6433 
6435  (ntohl (mp->sw_if_index), ntohl (mp->new_show_dev_instance));
6436 
6438 
6439  REPLY_MACRO (VL_API_INTERFACE_NAME_RENUMBER_REPLY);
6440 }
6441 
6442 static int
6443 arp_change_data_callback (u32 pool_index, u8 * new_mac,
6444  u32 sw_if_index, u32 address)
6445 {
6447  vlib_main_t *vm = am->vlib_main;
6448  vl_api_ip4_arp_event_t *event;
6449  static f64 arp_event_last_time;
6450  f64 now = vlib_time_now (vm);
6451 
6452  if (pool_is_free_index (am->arp_events, pool_index))
6453  return 1;
6454 
6455  event = pool_elt_at_index (am->arp_events, pool_index);
6456  /* *INDENT-OFF* */
6457  if (memcmp (&event->new_mac, new_mac, sizeof (event->new_mac)))
6458  {
6459  clib_memcpy (event->new_mac, new_mac, sizeof (event->new_mac));
6460  }
6461  else
6462  { /* same mac */
6463  if (sw_if_index == event->sw_if_index &&
6464  (!event->mac_ip ||
6465  /* for BD case, also check IP address with 10 sec timeout */
6466  (address == event->address &&
6467  (now - arp_event_last_time) < 10.0)))
6468  return 1;
6469  }
6470  /* *INDENT-ON* */
6471 
6472  arp_event_last_time = now;
6473  event->sw_if_index = sw_if_index;
6474  if (event->mac_ip)
6475  event->address = address;
6476  return 0;
6477 }
6478 
6479 static int
6480 nd_change_data_callback (u32 pool_index, u8 * new_mac,
6481  u32 sw_if_index, ip6_address_t * address)
6482 {
6484  vlib_main_t *vm = am->vlib_main;
6485  vl_api_ip6_nd_event_t *event;
6486  static f64 nd_event_last_time;
6487  f64 now = vlib_time_now (vm);
6488 
6489  if (pool_is_free_index (am->nd_events, pool_index))
6490  return 1;
6491 
6492  event = pool_elt_at_index (am->nd_events, pool_index);
6493 
6494  /* *INDENT-OFF* */
6495  if (memcmp (&event->new_mac, new_mac, sizeof (event->new_mac)))
6496  {
6497  clib_memcpy (event->new_mac, new_mac, sizeof (event->new_mac));
6498  }
6499  else
6500  { /* same mac */
6501  if (sw_if_index == event->sw_if_index &&
6502  (!event->mac_ip ||
6503  /* for BD case, also check IP address with 10 sec timeout */
6504  (ip6_address_is_equal (address,
6505  (ip6_address_t *) event->address) &&
6506  (now - nd_event_last_time) < 10.0)))
6507  return 1;
6508  }
6509  /* *INDENT-ON* */
6510 
6511  nd_event_last_time = now;
6512  event->sw_if_index = sw_if_index;
6513  if (event->mac_ip)
6514  clib_memcpy (event->address, address, sizeof (event->address));
6515  return 0;
6516 }
6517 
6518 static int
6519 arp_change_delete_callback (u32 pool_index, u8 * notused)
6520 {
6522 
6523  if (pool_is_free_index (am->arp_events, pool_index))
6524  return 1;
6525 
6526  pool_put_index (am->arp_events, pool_index);
6527  return 0;
6528 }
6529 
6530 static int
6531 nd_change_delete_callback (u32 pool_index, u8 * notused)
6532 {
6534 
6535  if (pool_is_free_index (am->nd_events, pool_index))
6536  return 1;
6537 
6538  pool_put_index (am->nd_events, pool_index);
6539  return 0;
6540 }
6541 
6542 static void
6544 {
6546  vnet_main_t *vnm = vnet_get_main ();
6548  vl_api_ip4_arp_event_t *event;
6549  int rv;
6550 
6551  if (mp->enable_disable)
6552  {
6553  pool_get (am->arp_events, event);
6554  memset (event, 0, sizeof (*event));
6555 
6556  event->_vl_msg_id = ntohs (VL_API_IP4_ARP_EVENT);
6557  event->client_index = mp->client_index;
6558  event->context = mp->context;
6559  event->address = mp->address;
6560  event->pid = mp->pid;
6561  if (mp->address == 0)
6562  event->mac_ip = 1;
6563 
6566  mp->pid, &mp->address /* addr, in net byte order */ ,
6567  vpe_resolver_process_node.index,
6568  IP4_ARP_EVENT, event - am->arp_events, 1 /* is_add */ );
6569  }
6570  else
6571  {
6574  mp->pid, &mp->address /* addr, in net byte order */ ,
6575  vpe_resolver_process_node.index,
6576  IP4_ARP_EVENT, ~0 /* pool index */ , 0 /* is_add */ );
6577  }
6578  REPLY_MACRO (VL_API_WANT_IP4_ARP_EVENTS_REPLY);
6579 }
6580 
6581 static void
6583 {
6585  vnet_main_t *vnm = vnet_get_main ();
6587  vl_api_ip6_nd_event_t *event;
6588  int rv;
6589 
6590  if (mp->enable_disable)
6591  {
6592  pool_get (am->nd_events, event);
6593  memset (event, 0, sizeof (*event));
6594 
6595  event->_vl_msg_id = ntohs (VL_API_IP6_ND_EVENT);
6596  event->client_index = mp->client_index;
6597  event->context = mp->context;
6598  clib_memcpy (event->address, mp->address, 16);
6599  event->pid = mp->pid;
6601  event->mac_ip = 1;
6602 
6605  mp->pid, mp->address /* addr, in net byte order */ ,
6606  vpe_resolver_process_node.index,
6607  IP6_ND_EVENT, event - am->nd_events, 1 /* is_add */ );
6608  }
6609  else
6610  {
6613  mp->pid, mp->address /* addr, in net byte order */ ,
6614  vpe_resolver_process_node.index,
6615  IP6_ND_EVENT, ~0 /* pool index */ , 0 /* is_add */ );
6616  }
6617  REPLY_MACRO (VL_API_WANT_IP6_ND_EVENTS_REPLY);
6618 }
6619 
6622 {
6623  vlib_main_t *vm = vlib_get_main ();
6625  int rv;
6626  u32 sw_if_index, ip4_table_index, ip6_table_index, l2_table_index;
6627 
6628  ip4_table_index = ntohl (mp->ip4_table_index);
6629  ip6_table_index = ntohl (mp->ip6_table_index);
6630  l2_table_index = ntohl (mp->l2_table_index);
6631  sw_if_index = ntohl (mp->sw_if_index);
6632 
6633  VALIDATE_SW_IF_INDEX (mp);
6634 
6635  rv = vnet_set_input_acl_intfc (vm, sw_if_index, ip4_table_index,
6636  ip6_table_index, l2_table_index, mp->is_add);
6637 
6639 
6640  REPLY_MACRO (VL_API_INPUT_ACL_SET_INTERFACE_REPLY);
6641 }
6642 
6645 {
6646 #if IPSEC == 0
6647  clib_warning ("unimplemented");
6648 #else
6649 
6650  vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
6652  int rv;
6653 
6654 #if DPDK > 0
6655  rv = ipsec_add_del_spd (vm, ntohl (mp->spd_id), mp->is_add);
6656 #else
6657  rv = VNET_API_ERROR_UNIMPLEMENTED;
6658 #endif
6659 
6660  REPLY_MACRO (VL_API_IPSEC_SPD_ADD_DEL_REPLY);
6661 #endif
6662 }
6663 
6666 {
6667  vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
6669  int rv;
6670  u32 sw_if_index __attribute__ ((unused));
6671  u32 spd_id __attribute__ ((unused));
6672 
6673  sw_if_index = ntohl (mp->sw_if_index);
6674  spd_id = ntohl (mp->spd_id);
6675 
6676  VALIDATE_SW_IF_INDEX (mp);
6677 
6678 #if IPSEC > 0
6679  rv = ipsec_set_interface_spd (vm, sw_if_index, spd_id, mp->is_add);
6680 #else
6681  rv = VNET_API_ERROR_UNIMPLEMENTED;
6682 #endif
6683 
6685 
6686  REPLY_MACRO (VL_API_IPSEC_INTERFACE_ADD_DEL_SPD_REPLY);
6687 }
6688 
6691 {
6692  vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
6694  int rv;
6695 
6696 #if IPSEC > 0
6697  ipsec_policy_t p;
6698 
6699  memset (&p, 0, sizeof (p));
6700 
6701  p.id = ntohl (mp->spd_id);
6702  p.priority = ntohl (mp->priority);
6703  p.is_outbound = mp->is_outbound;
6704  p.is_ipv6 = mp->is_ipv6;
6705 
6706  if (mp->is_ipv6 || mp->is_ip_any)
6707  {
6709  clib_memcpy (&p.raddr.stop, mp->remote_address_stop, 16);
6711  clib_memcpy (&p.laddr.stop, mp->local_address_stop, 16);
6712  }
6713  else
6714  {
6715  clib_memcpy (&p.raddr.start.ip4.data, mp->remote_address_start, 4);
6716  clib_memcpy (&p.raddr.stop.ip4.data, mp->remote_address_stop, 4);
6717  clib_memcpy (&p.laddr.start.ip4.data, mp->local_address_start, 4);
6718  clib_memcpy (&p.laddr.stop.ip4.data, mp->local_address_stop, 4);
6719  }
6720  p.protocol = mp->protocol;
6721  p.rport.start = ntohs (mp->remote_port_start);
6722  p.rport.stop = ntohs (mp->remote_port_stop);
6723  p.lport.start = ntohs (mp->local_port_start);
6724  p.lport.stop = ntohs (mp->local_port_stop);
6725  /* policy action resolve unsupported */
6726  if (mp->policy == IPSEC_POLICY_ACTION_RESOLVE)
6727  {
6728  clib_warning ("unsupported action: 'resolve'");
6729  rv = VNET_API_ERROR_UNIMPLEMENTED;
6730  goto out;
6731  }
6732  p.policy = mp->policy;
6733  p.sa_id = ntohl (mp->sa_id);
6734 
6735  rv = ipsec_add_del_policy (vm, &p, mp->is_add);
6736  if (rv)
6737  goto out;
6738 
6739  if (mp->is_ip_any)
6740  {
6741  p.is_ipv6 = 1;
6742  rv = ipsec_add_del_policy (vm, &p, mp->is_add);
6743  }
6744 #else
6745  rv = VNET_API_ERROR_UNIMPLEMENTED;
6746  goto out;
6747 #endif
6748 
6749 out:
6750  REPLY_MACRO (VL_API_IPSEC_SPD_ADD_DEL_ENTRY_REPLY);
6751 }
6752 
6755 {
6756  vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
6758  int rv;
6759 #if IPSEC > 0
6760  ipsec_sa_t sa;
6761 
6762  memset (&sa, 0, sizeof (sa));
6763 
6764  sa.id = ntohl (mp->sad_id);
6765  sa.spi = ntohl (mp->spi);
6766  /* security protocol AH unsupported */
6767  if (mp->protocol == IPSEC_PROTOCOL_AH)
6768  {
6769  clib_warning ("unsupported security protocol 'AH'");
6770  rv = VNET_API_ERROR_UNIMPLEMENTED;
6771  goto out;
6772  }
6773  sa.protocol = mp->protocol;
6774  /* check for unsupported crypto-alg */
6775  if (mp->crypto_algorithm < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
6776  mp->crypto_algorithm > IPSEC_CRYPTO_ALG_AES_CBC_256)
6777  {
6778  clib_warning ("unsupported crypto-alg: '%U'", format_ipsec_crypto_alg,
6779  mp->crypto_algorithm);
6780  rv = VNET_API_ERROR_UNIMPLEMENTED;
6781  goto out;
6782  }
6783  sa.crypto_alg = mp->crypto_algorithm;
6785  clib_memcpy (&sa.crypto_key, mp->crypto_key, sizeof (sa.crypto_key));
6786  /* check for unsupported integ-alg */
6787  if (mp->integrity_algorithm < IPSEC_INTEG_ALG_SHA1_96 ||
6788  mp->integrity_algorithm > IPSEC_INTEG_ALG_SHA_512_256)
6789  {
6790  clib_warning ("unsupported integ-alg: '%U'", format_ipsec_integ_alg,
6791  mp->integrity_algorithm);
6792  rv = VNET_API_ERROR_UNIMPLEMENTED;
6793  goto out;
6794  }
6795  sa.integ_alg = mp->integrity_algorithm;
6797  clib_memcpy (&sa.integ_key, mp->integrity_key, sizeof (sa.integ_key));
6799  sa.is_tunnel = mp->is_tunnel;
6800  sa.is_tunnel_ip6 = mp->is_tunnel_ipv6;
6801  if (sa.is_tunnel_ip6)
6802  {
6805  }
6806  else
6807  {
6808  clib_memcpy (&sa.tunnel_src_addr.ip4.data, mp->tunnel_src_address, 4);
6809  clib_memcpy (&sa.tunnel_dst_addr.ip4.data, mp->tunnel_dst_address, 4);
6810  }
6811 
6812  rv = ipsec_add_del_sa (vm, &sa, mp->is_add);
6813 #else
6814  rv = VNET_API_ERROR_UNIMPLEMENTED;
6815  goto out;
6816 #endif
6817 
6818 out:
6819  REPLY_MACRO (VL_API_IPSEC_SAD_ADD_DEL_ENTRY_REPLY);
6820 }
6821 
6822 static void
6824 {
6826  int rv = 0;
6827 
6828 #if IPSEC > 0
6829  vlib_main_t *vm = vlib_get_main ();
6830  clib_error_t *error;
6831  u8 *tmp = format (0, "%s", mp->name);
6832  error = ikev2_add_del_profile (vm, tmp, mp->is_add);
6833  vec_free (tmp);
6834  if (error)
6835  rv = VNET_API_ERROR_UNSPECIFIED;
6836 #else
6837  rv = VNET_API_ERROR_UNIMPLEMENTED;
6838 #endif
6839 
6840  REPLY_MACRO (VL_API_IKEV2_PROFILE_ADD_DEL_REPLY);
6841 }
6842 
6843 static void
6846 {
6848  int rv = 0;
6849 
6850 #if IPSEC > 0
6851  vlib_main_t *vm = vlib_get_main ();
6852  clib_error_t *error;
6853  u8 *tmp = format (0, "%s", mp->name);
6854  u8 *data = vec_new (u8, mp->data_len);
6855  clib_memcpy (data, mp->data, mp->data_len);
6856  error = ikev2_set_profile_auth (vm, tmp, mp->auth_method, data, mp->is_hex);
6857  vec_free (tmp);
6858  vec_free (data);
6859  if (error)
6860  rv = VNET_API_ERROR_UNSPECIFIED;
6861 #else
6862  rv = VNET_API_ERROR_UNIMPLEMENTED;
6863 #endif
6864 
6865  REPLY_MACRO (VL_API_IKEV2_PROFILE_SET_AUTH_REPLY);
6866 }
6867 
6868 static void
6870 {
6872  int rv = 0;
6873 
6874 #if IPSEC > 0
6875  vlib_main_t *vm = vlib_get_main ();
6876  clib_error_t *error;
6877  u8 *tmp = format (0, "%s", mp->name);
6878  u8 *data = vec_new (u8, mp->data_len);
6879  clib_memcpy (data, mp->data, mp->data_len);
6880  error = ikev2_set_profile_id (vm, tmp, mp->id_type, data, mp->is_local);
6881  vec_free (tmp);
6882  vec_free (data);
6883  if (error)
6884  rv = VNET_API_ERROR_UNSPECIFIED;
6885 #else
6886  rv = VNET_API_ERROR_UNIMPLEMENTED;
6887 #endif
6888 
6889  REPLY_MACRO (VL_API_IKEV2_PROFILE_SET_ID_REPLY);
6890 }
6891 
6892 static void
6894 {
6896  int rv = 0;
6897 
6898 #if IPSEC > 0
6899  vlib_main_t *vm = vlib_get_main ();
6900  clib_error_t *error;
6901  u8 *tmp = format (0, "%s", mp->name);
6902  error = ikev2_set_profile_ts (vm, tmp, mp->proto, mp->start_port,
6903  mp->end_port, (ip4_address_t) mp->start_addr,
6904  (ip4_address_t) mp->end_addr, mp->is_local);
6905  vec_free (tmp);
6906  if (error)
6907  rv = VNET_API_ERROR_UNSPECIFIED;
6908 #else
6909  rv = VNET_API_ERROR_UNIMPLEMENTED;
6910 #endif
6911 
6912  REPLY_MACRO (VL_API_IKEV2_PROFILE_SET_TS_REPLY);
6913 }
6914 
6915 static void
6917 {
6919  int rv = 0;
6920 
6921 #if IPSEC > 0
6922  vlib_main_t *vm = vlib_get_main ();
6923  clib_error_t *error;
6924 
6925  error = ikev2_set_local_key (vm, mp->key_file);
6926  if (error)
6927  rv = VNET_API_ERROR_UNSPECIFIED;
6928 #else
6929  rv = VNET_API_ERROR_UNIMPLEMENTED;
6930 #endif
6931 
6932  REPLY_MACRO (VL_API_IKEV2_SET_LOCAL_KEY_REPLY);
6933 }
6934 
6935 static void
6937 {
6939  int rv = 0;
6940  u32 index;
6941  u8 flags = mp->is_translation ? MAP_DOMAIN_TRANSLATION : 0;
6942  rv =
6944  (ip6_address_t *) & mp->ip6_prefix, mp->ip6_prefix_len,
6945  (ip6_address_t *) & mp->ip6_src,
6947  mp->psid_offset, mp->psid_length, &index,
6948  ntohs (mp->mtu), flags);
6949 
6950  /* *INDENT-OFF* */
6951  REPLY_MACRO2(VL_API_MAP_ADD_DOMAIN_REPLY,
6952  ({
6953  rmp->index = ntohl(index);
6954  }));
6955  /* *INDENT-ON* */
6956 }
6957 
6958 static void
6960 {
6962  int rv = 0;
6963 
6964  rv = map_delete_domain (ntohl (mp->index));
6965 
6966  REPLY_MACRO (VL_API_MAP_DEL_DOMAIN_REPLY);
6967 }
6968 
6969 static void
6971 {
6973  int rv = 0;
6974 
6975  rv =
6976  map_add_del_psid (ntohl (mp->index), ntohs (mp->psid),
6977  (ip6_address_t *) mp->ip6_dst, mp->is_add);
6978 
6979  REPLY_MACRO (VL_API_MAP_ADD_DEL_RULE_REPLY);
6980 }
6981 
6982 static void
6984 {
6986  map_main_t *mm = &map_main;
6987  map_domain_t *d;
6989 
6990  if (pool_elts (mm->domains) == 0)
6991  return;
6992 
6994  if (q == 0)
6995  {
6996  return;
6997  }
6998 
6999  /* *INDENT-OFF* */
7000  pool_foreach(d, mm->domains,
7001  ({
7002  /* Make sure every field is initiated (or don't skip the memset()) */
7003  rmp = vl_msg_api_alloc (sizeof (*rmp));
7004  rmp->_vl_msg_id = ntohs(VL_API_MAP_DOMAIN_DETAILS);
7005  rmp->domain_index = htonl(d - mm->domains);
7006  rmp->ea_bits_len = d->ea_bits_len;
7007  rmp->psid_offset = d->psid_offset;
7008  rmp->psid_length = d->psid_length;
7009  clib_memcpy(rmp->ip4_prefix, &d->ip4_prefix, sizeof(rmp->ip4_prefix));
7010  rmp->ip4_prefix_len = d->ip4_prefix_len;
7011  clib_memcpy(rmp->ip6_prefix, &d->ip6_prefix, sizeof(rmp->ip6_prefix));
7012  rmp->ip6_prefix_len = d->ip6_prefix_len;
7013  clib_memcpy(rmp->ip6_src, &d->ip6_src, sizeof(rmp->ip6_src));
7014  rmp->ip6_src_len = d->ip6_src_len;
7015  rmp->mtu = htons(d->mtu);
7016  rmp->is_translation = (d->flags & MAP_DOMAIN_TRANSLATION);
7017  rmp->context = mp->context;
7018 
7019  vl_msg_api_send_shmem (q, (u8 *)&rmp);
7020  }));
7021  /* *INDENT-ON* */
7022 }
7023 
7024 static void
7026 {
7028  u16 i;
7029  ip6_address_t dst;
7031  map_main_t *mm = &map_main;
7032  u32 domain_index = ntohl (mp->domain_index);
7033  map_domain_t *d;
7034 
7035  if (pool_elts (mm->domains) == 0)
7036  return;
7037 
7038  d = pool_elt_at_index (mm->domains, domain_index);
7039  if (!d || !d->rules)
7040  {
7041  return;
7042  }
7043 
7045  if (q == 0)
7046  {
7047  return;
7048  }
7049 
7050  for (i = 0; i < (0x1 << d->psid_length); i++)
7051  {
7052  dst = d->rules[i];
7053  if (dst.as_u64[0] == 0 && dst.as_u64[1] == 0)
7054  {
7055  continue;
7056  }
7057  rmp = vl_msg_api_alloc (sizeof (*rmp));
7058  memset (rmp, 0, sizeof (*rmp));
7059  rmp->_vl_msg_id = ntohs (VL_API_MAP_RULE_DETAILS);
7060  rmp->psid = htons (i);
7061  clib_memcpy (rmp->ip6_dst, &dst, sizeof (rmp->ip6_dst));
7062  rmp->context = mp->context;
7063  vl_msg_api_send_shmem (q, (u8 *) & rmp);
7064  }
7065 }
7066 
7067 static void
7069 {
7072  vlib_counter_t v;
7073  int i, which;
7074  u64 total_pkts[VLIB_N_RX_TX];
7075  u64 total_bytes[VLIB_N_RX_TX];
7076  map_main_t *mm = &map_main;
7079 
7080  if (!q)
7081  return;
7082 
7083  rmp = vl_msg_api_alloc (sizeof (*rmp));
7084  rmp->_vl_msg_id = ntohs (VL_API_MAP_SUMMARY_STATS_REPLY);
7085  rmp->context = mp->context;
7086  rmp->retval = 0;
7087 
7088  memset (total_pkts, 0, sizeof (total_pkts));
7089  memset (total_bytes, 0, sizeof (total_bytes));
7090 
7092  vec_foreach (cm, mm->domain_counters)
7093  {
7094  which = cm - mm->domain_counters;
7095 
7096  for (i = 0; i < vec_len (cm->maxi); i++)
7097  {
7098  vlib_get_combined_counter (cm, i, &v);
7099  total_pkts[which] += v.packets;
7100  total_bytes[which] += v.bytes;
7101  }
7102  }
7103 
7105 
7106  /* Note: in network byte order! */
7108  clib_host_to_net_u64 (total_pkts[MAP_DOMAIN_COUNTER_RX]);
7110  clib_host_to_net_u64 (total_bytes[MAP_DOMAIN_COUNTER_RX]);
7112  clib_host_to_net_u64 (total_pkts[MAP_DOMAIN_COUNTER_TX]);
7114  clib_host_to_net_u64 (total_bytes[MAP_DOMAIN_COUNTER_TX]);
7115  rmp->total_bindings = clib_host_to_net_u64 (pool_elts (mm->domains));
7116  rmp->total_ip4_fragments = 0; // Not yet implemented. Should be a simple counter.
7118  clib_host_to_net_u64 (map_error_counter_get
7119  (ip4_map_node.index, MAP_ERROR_ENCAP_SEC_CHECK));
7121  clib_host_to_net_u64 (map_error_counter_get
7122  (ip4_map_node.index, MAP_ERROR_DECAP_SEC_CHECK));
7123 
7124  vl_msg_api_send_shmem (q, (u8 *) & rmp);
7125 }
7126 
7127 static void
7129 {
7130  vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
7132  int rv;
7133 #if IPSEC > 0
7134  ipsec_sa_t sa;
7135  sa.id = ntohl (mp->sa_id);
7137  clib_memcpy (&sa.crypto_key, mp->crypto_key, sizeof (sa.crypto_key));
7139  clib_memcpy (&sa.integ_key, mp->integrity_key, sizeof (sa.integ_key));
7140 
7141  rv = ipsec_set_sa_key (vm, &sa);
7142 #else
7143  rv = VNET_API_ERROR_UNIMPLEMENTED;
7144 #endif
7145 
7146  REPLY_MACRO (VL_API_IPSEC_SA_SET_KEY_REPLY);
7147 }
7148 
7151 {
7153  int rv;
7154  u32 sw_if_index = ntohl (mp->sw_if_index);
7155  int enable_disable;
7156 
7157  VALIDATE_SW_IF_INDEX (mp);
7158 
7159  enable_disable = (int) mp->enable_disable;
7160 
7161  rv = cop_interface_enable_disable (sw_if_index, enable_disable);
7162 
7164 
7165  REPLY_MACRO (VL_API_COP_INTERFACE_ENABLE_DISABLE_REPLY);
7166 }
7167 
7170 {
7173  u32 sw_if_index = ntohl (mp->sw_if_index);
7174  int rv;
7175 
7176  VALIDATE_SW_IF_INDEX (mp);
7177 
7178  a->sw_if_index = sw_if_index;
7179  a->ip4 = mp->ip4;
7180  a->ip6 = mp->ip6;
7181  a->default_cop = mp->default_cop;
7182  a->fib_id = ntohl (mp->fib_id);
7183 
7185 
7187 
7188  REPLY_MACRO (VL_API_COP_WHITELIST_ENABLE_DISABLE_REPLY);
7189 }
7190 
7191 static void
7193 {
7194  int rv = 0;
7195  u8 *vector = 0;
7196  api_main_t *am = &api_main;
7197  vlib_main_t *vm = vlib_get_main ();
7198  void *oldheap;
7200 
7201  pthread_mutex_lock (&am->vlib_rp->mutex);
7202  oldheap = svm_push_data_heap (am->vlib_rp);
7203 
7204  /*
7205  * Keep the number of memcpy ops to a minimum (e.g. 1).
7206  */
7207  vec_validate (vector, 16384);
7208  vec_reset_length (vector);
7209 
7210  /* $$$$ FIXME */
7211  vector = vlib_node_serialize (&vm->node_main, vector,
7212  (u32) ~ 0 /* all threads */ ,
7213  1 /* include nexts */ ,
7214  1 /* include stats */ );
7215 
7216  svm_pop_heap (oldheap);
7217  pthread_mutex_unlock (&am->vlib_rp->mutex);
7218 
7219  /* *INDENT-OFF* */
7220  REPLY_MACRO2(VL_API_GET_NODE_GRAPH_REPLY,
7221  ({
7222  rmp->reply_in_shmem = (uword) vector;
7223  }));
7224  /* *INDENT-ON* */
7225 }
7226 
7227 static void
7229 {
7230  int rv = 0;
7232  clib_error_t *error;
7233 
7234  /* Ignoring the profile id as currently a single profile
7235  * is supported */
7236  error = ip6_ioam_enable (mp->trace_enable, mp->pot_enable,
7237  mp->seqno, mp->analyse);
7238  if (error)
7239  {
7240  clib_error_report (error);
7241  rv = clib_error_get_code (error);
7242  }
7243 
7244  REPLY_MACRO (VL_API_IOAM_ENABLE_REPLY);
7245 }
7246 
7247 static void
7249 {
7250  int rv = 0;
7252  clib_error_t *error;
7253 
7254  error = clear_ioam_rewrite_fn ();
7255  if (error)
7256  {
7257  clib_error_report (error);
7258  rv = clib_error_get_code (error);
7259  }
7260 
7261  REPLY_MACRO (VL_API_IOAM_DISABLE_REPLY);
7262 }
7263 
7264 static void
7266 {
7267  vlib_main_t *vm = vlib_get_main ();
7269  int rv = 0;
7270  u8 *host_if_name = NULL;
7271  u32 sw_if_index;
7272 
7273  host_if_name = format (0, "%s", mp->host_if_name);
7274  vec_add1 (host_if_name, 0);
7275 
7276  rv = af_packet_create_if (vm, host_if_name,
7277  mp->use_random_hw_addr ? 0 : mp->hw_addr,
7278  &sw_if_index);
7279 
7280  vec_free (host_if_name);
7281 
7282  /* *INDENT-OFF* */
7283  REPLY_MACRO2(VL_API_AF_PACKET_CREATE_REPLY,
7284  ({
7285  rmp->sw_if_index = clib_host_to_net_u32(sw_if_index);
7286  }));
7287  /* *INDENT-ON* */
7288 }
7289 
7290 static void
7292 {
7293  vlib_main_t *vm = vlib_get_main ();
7295  int rv = 0;
7296  u8 *host_if_name = NULL;
7297 
7298  host_if_name = format (0, "%s", mp->host_if_name);
7299  vec_add1 (host_if_name, 0);
7300 
7301  rv = af_packet_delete_if (vm, host_if_name);
7302 
7303  vec_free (host_if_name);
7304 
7305  REPLY_MACRO (VL_API_AF_PACKET_DELETE_REPLY);
7306 }
7307 
7308 static void
7310 {
7311  vlib_main_t *vm = vlib_get_main ();
7313  int rv = 0;
7314  u8 *name = NULL;
7316  clib_error_t *error;
7317  u32 policer_index;
7318 
7319  name = format (0, "%s", mp->name);
7320 
7321  memset (&cfg, 0, sizeof (cfg));
7322  cfg.rfc = mp->type;
7323  cfg.rnd_type = mp->round_type;
7324  cfg.rate_type = mp->rate_type;
7325  cfg.rb.kbps.cir_kbps = mp->cir;
7326  cfg.rb.kbps.eir_kbps = mp->eir;
7327  cfg.rb.kbps.cb_bytes = mp->cb;
7328  cfg.rb.kbps.eb_bytes = mp->eb;
7330  cfg.conform_action.dscp = mp->conform_dscp;
7332  cfg.exceed_action.dscp = mp->exceed_dscp;
7334  cfg.violate_action.dscp = mp->violate_dscp;
7335  cfg.color_aware = mp->color_aware;
7336 
7337  error = policer_add_del (vm, name, &cfg, &policer_index, mp->is_add);
7338 
7339  if (error)
7340  rv = VNET_API_ERROR_UNSPECIFIED;
7341 
7342  /* *INDENT-OFF* */
7343  REPLY_MACRO2(VL_API_POLICER_ADD_DEL_REPLY,
7344  ({
7345  if (rv == 0 && mp->is_add)
7346  rmp->policer_index = ntohl(policer_index);
7347  else
7348  rmp->policer_index = ~0;
7349  }));
7350  /* *INDENT-ON* */
7351 }
7352 
7353 static void
7355  sse2_qos_pol_cfg_params_st * config,
7357  unix_shared_memory_queue_t * q, u32 context)
7358 {
7360 
7361  mp = vl_msg_api_alloc (sizeof (*mp));
7362  memset (mp, 0, sizeof (*mp));
7363  mp->_vl_msg_id = ntohs (VL_API_POLICER_DETAILS);
7364  mp->context = context;
7365  mp->cir = htonl (config->rb.kbps.cir_kbps);
7366  mp->eir = htonl (config->rb.kbps.eir_kbps);
7367  mp->cb = htonl (config->rb.kbps.cb_bytes);
7368  mp->eb = htonl (config->rb.kbps.eb_bytes);
7369  mp->rate_type = config->rate_type;
7370  mp->round_type = config->rnd_type;
7371  mp->type = config->rfc;
7373  mp->conform_dscp = config->conform_action.dscp;
7375  mp->exceed_dscp = config->exceed_action.dscp;
7377  mp->violate_dscp = config->violate_action.dscp;
7378  mp->single_rate = templ->single_rate ? 1 : 0;
7379  mp->color_aware = templ->color_aware ? 1 : 0;
7380  mp->scale = htonl (templ->scale);
7381  mp->cir_tokens_per_period = htonl (templ->cir_tokens_per_period);
7382  mp->pir_tokens_per_period = htonl (templ->pir_tokens_per_period);
7383  mp->current_limit = htonl (templ->current_limit);
7384  mp->current_bucket = htonl (templ->current_bucket);
7385  mp->extended_limit = htonl (templ->extended_limit);
7386  mp->extended_bucket = htonl (templ->extended_bucket);
7387  mp->last_update_time = clib_host_to_net_u64 (templ->last_update_time);
7388 
7389  strncpy ((char *) mp->name, (char *) name, ARRAY_LEN (mp->name) - 1);
7390 
7391  vl_msg_api_send_shmem (q, (u8 *) & mp);
7392 }
7393 
7394 static void
7396 {
7399  hash_pair_t *hp;
7400  uword *p;
7401  u32 pool_index;
7402  u8 *match_name = 0;
7403  u8 *name;
7406 
7408  if (q == 0)
7409  return;
7410 
7411  if (mp->match_name_valid)
7412  {
7413  match_name = format (0, "%s%c", mp->match_name, 0);
7414  }
7415 
7416  if (mp->match_name_valid)
7417  {
7418  p = hash_get_mem (pm->policer_config_by_name, match_name);
7419  if (p)
7420  {
7421  pool_index = p[0];
7422  config = pool_elt_at_index (pm->configs, pool_index);
7423  templ = pool_elt_at_index (pm->policer_templates, pool_index);
7424  send_policer_details (match_name, config, templ, q, mp->context);
7425  }
7426  }
7427  else
7428  {
7429  /* *INDENT-OFF* */
7431  ({
7432  name = (u8 *) hp->key;
7433  pool_index = hp->value[0];
7434  config = pool_elt_at_index (pm->configs, pool_index);
7435  templ = pool_elt_at_index (pm->policer_templates, pool_index);
7436  send_policer_details(name, config, templ, q, mp->context);
7437  }));
7438  /* *INDENT-ON* */
7439  }
7440 }
7441 
7442 static void
7445 {
7446  vlib_main_t *vm = vlib_get_main ();
7448  int rv;
7449  u32 sw_if_index, ip4_table_index, ip6_table_index, l2_table_index;
7450 
7451  ip4_table_index = ntohl (mp->ip4_table_index);
7452  ip6_table_index = ntohl (mp->ip6_table_index);
7453  l2_table_index = ntohl (mp->l2_table_index);
7454  sw_if_index = ntohl (mp->sw_if_index);
7455 
7456  VALIDATE_SW_IF_INDEX (mp);
7457 
7458  rv = vnet_set_policer_classify_intfc (vm, sw_if_index, ip4_table_index,
7459  ip6_table_index, l2_table_index,
7460  mp->is_add);
7461 
7463 
7464  REPLY_MACRO (VL_API_POLICER_CLASSIFY_SET_INTERFACE_REPLY);
7465 }
7466 
7467 static void
7469  u32 table_index,
7470  unix_shared_memory_queue_t * q, u32 context)
7471 {
7473 
7474  mp = vl_msg_api_alloc (sizeof (*mp));
7475  memset (mp, 0, sizeof (*mp));
7476  mp->_vl_msg_id = ntohs (VL_API_POLICER_CLASSIFY_DETAILS);
7477  mp->context = context;
7478  mp->sw_if_index = htonl (sw_if_index);
7479  mp->table_index = htonl (table_index);
7480 
7481  vl_msg_api_send_shmem (q, (u8 *) & mp);
7482 }
7483 
7484 static void
7486 {
7489  u32 *vec_tbl;
7490  int i;
7491 
7493  if (q == 0)
7494  return;
7495 
7496  vec_tbl = pcm->classify_table_index_by_sw_if_index[mp->type];
7497 
7498  if (vec_len (vec_tbl))
7499  {
7500  for (i = 0; i < vec_len (vec_tbl); i++)
7501  {
7502  if (vec_elt (vec_tbl, i) == ~0)
7503  continue;
7504 
7505  send_policer_classify_details (i, vec_elt (vec_tbl, i), q,
7506  mp->context);
7507  }
7508  }
7509 }
7510 
7511 static void
7513 {
7514  vlib_main_t *vm = vlib_get_main ();
7516  int rv = 0;
7517  u8 *if_name = NULL;
7518 
7519  if_name = format (0, "%s", mp->netmap_if_name);
7520  vec_add1 (if_name, 0);
7521 
7522  rv =
7523  netmap_create_if (vm, if_name, mp->use_random_hw_addr ? 0 : mp->hw_addr,
7524  mp->is_pipe, mp->is_master, 0);
7525 
7526  vec_free (if_name);
7527 
7528  REPLY_MACRO (VL_API_NETMAP_CREATE_REPLY);
7529 }
7530 
7531 static void
7533 {
7534  vlib_main_t *vm = vlib_get_main ();
7536  int rv = 0;
7537  u8 *if_name = NULL;
7538 
7539  if_name = format (0, "%s", mp->netmap_if_name);
7540  vec_add1 (if_name, 0);
7541 
7542  rv = netmap_delete_if (vm, if_name);
7543 
7544  vec_free (if_name);
7545 
7546  REPLY_MACRO (VL_API_NETMAP_DELETE_REPLY);
7547 }
7548 
7549 static void
7551  mp)
7552 {
7553  clib_warning ("BUG");
7554 }
7555 
7556 static void
7559  mpls_eth_tunnel_t * et, u32 index, u32 context)
7560 {
7561  mpls_main_t *mm = &mpls_main;
7562  mpls_encap_t *e;
7563  int i;
7564  u32 nlabels;
7566 
7567  e = pool_elt_at_index (mm->encaps, et->encap_index);
7568  nlabels = vec_len (e->labels);
7569 
7570  mp = vl_msg_api_alloc (sizeof (*mp) + nlabels * sizeof (u32));
7571  memset (mp, 0, sizeof (*mp));
7572  mp->_vl_msg_id = ntohs (VL_API_MPLS_ETH_TUNNEL_DETAILS);
7573  mp->context = context;
7574 
7575  mp->tunnel_index = htonl (index);
7576  memcpy (mp->tunnel_dst_mac, et->tunnel_dst, 6);
7578  mp->tx_sw_if_index = htonl (et->tx_sw_if_index);
7579  mp->inner_fib_index = htonl (et->inner_fib_index);
7580  mp->mask_width = htonl (et->mask_width);
7581  mp->encap_index = htonl (et->encap_index);
7582  mp->hw_if_index = htonl (et->hw_if_index);
7583  mp->l2_only = htonl (et->l2_only);
7584  mp->nlabels = htonl (nlabels);
7585 
7586  for (i = 0; i < nlabels; i++)
7587  {
7588  mp->labels[i] =
7589  htonl (vnet_mpls_uc_get_label
7590  (clib_host_to_net_u32 (e->labels[i].label_exp_s_ttl)));
7591  }
7592 
7593  vl_msg_api_send_shmem (q, (u8 *) & mp);
7594 }
7595 
7596 static void
7598 {
7601  mpls_main_t *mm = &mpls_main;
7602  mpls_eth_tunnel_t *et;
7603  u32 index = ntohl (mp->tunnel_index);
7604 
7606  if (q == 0)
7607  return;
7608 
7609  if (index != ~0)
7610  {
7611  if (!pool_is_free_index (mm->eth_tunnels, index))
7612  {
7613  et = pool_elt_at_index (mm->eth_tunnels, index);
7614  send_mpls_eth_tunnel_entry (am, q, et, et - mm->eth_tunnels,
7615  mp->context);
7616  }
7617  }
7618  else
7619  {
7620  /* *INDENT-OFF* */
7621  pool_foreach (et, mm->eth_tunnels,
7622  ({
7623  send_mpls_eth_tunnel_entry (am, q, et, et - mm->eth_tunnels,
7624  mp->context);
7625  }));
7626  /* *INDENT-ON* */
7627  }
7628 }
7629 
7630 static void
7632 {
7633  clib_warning ("BUG");
7634 }
7635 
7636 static void
7639  u32 table_id, u32 label, u32 eos, u32 context)
7640 {
7642 
7643  mp = vl_msg_api_alloc (sizeof (*mp));
7644  memset (mp, 0, sizeof (*mp));
7645  mp->_vl_msg_id = ntohs (VL_API_MPLS_FIB_DETAILS);
7646  mp->context = context;
7647 
7648  mp->table_id = htonl (table_id);
7649  mp->eos_bit = eos;
7650  mp->label = htonl (label);
7651 
7652  vl_msg_api_send_shmem (q, (u8 *) & mp);
7653 }
7654 
7655 static void
7657 {
7660  mpls_main_t *mm = &mpls_main;
7661  fib_table_t *fib_table;
7662  fib_node_index_t lfei, *lfeip, *lfeis = NULL;
7663  mpls_label_t key;
7664  fib_prefix_t pfx;
7665  u32 fib_index;
7666 
7668  if (q == 0)
7669  return;
7670 
7671  /* *INDENT-OFF* */
7672  pool_foreach (fib_table, mm->fibs,
7673  ({
7674  hash_foreach(key, lfei, fib_table->mpls.mf_entries,
7675  ({
7676  vec_add1(lfeis, lfei);
7677  }));
7678  }));
7680 
7681  vec_foreach(lfeip, lfeis)
7682  {
7683  fib_entry_get_prefix(*lfeip, &pfx);
7684  fib_index = fib_entry_get_fib_index(*lfeip);
7685 
7686  fib_table = fib_table_get(fib_index, pfx.fp_proto);
7687 
7688  send_mpls_fib_details (am, q,
7689  fib_table->ft_table_id,
7690  pfx.fp_label,
7691  pfx.fp_eos,
7692  mp->context);
7693  }
7694 
7695  vec_free (lfeis);
7696 }
7697 
7698 static void
7700 {
7701  clib_warning ("BUG");
7702 }
7703 
7704 static void
7707  show_mpls_fib_t * s, u32 context)
7708 {
7710  mpls_main_t *mm = &mpls_main;
7711  mpls_encap_t *e;
7712  int i;
7713  u32 nlabels;
7714 
7715  e = pool_elt_at_index (mm->encaps, s->entry_index);
7716  nlabels = vec_len (e->labels);
7717 
7718  mp = vl_msg_api_alloc (sizeof (*mp) + nlabels * sizeof (u32));
7719  memset (mp, 0, sizeof (*mp));
7720  mp->_vl_msg_id = ntohs (VL_API_MPLS_FIB_ENCAP_DETAILS);
7721  mp->context = context;
7722 
7723  mp->fib_index = htonl (s->fib_index);
7724  mp->entry_index = htonl (s->entry_index);
7725  mp->dest = s->dest;
7726  mp->s_bit = htonl (s->s_bit);
7727 
7728  mp->nlabels = htonl (nlabels);
7729 
7730  for (i = 0; i < nlabels; i++)
7731  {
7732  mp->labels[i] =
7733  htonl (vnet_mpls_uc_get_label
7734  (clib_host_to_net_u32 (e->labels[i].label_exp_s_ttl)));
7735  }
7736 
7737  vl_msg_api_send_shmem (q, (u8 *) & mp);
7738 }
7739 
7740 static void
7742 {
7746  u64 key;
7747  u32 value;
7748  show_mpls_fib_t *records = 0;
7749  show_mpls_fib_t *s;
7750  mpls_main_t *mm = &mpls_main;
7751  ip4_fib_t *rx_fib;
7752 
7754  if (q == 0)
7755  return;
7756 
7757  /* *INDENT-OFF* */
7758  hash_foreach (key, value, mm->mpls_encap_by_fib_and_dest,
7759  ({
7760  vec_add2 (records, s, 1);
7761  s->fib_index = (u32)(key>>32);
7762  s->dest = (u32)(key & 0xFFFFFFFF);
7763  s->entry_index = (u32) value;
7764  }));
7765  /* *INDENT-ON* */
7766 
7767  if (0 == vec_len (records))
7768  {
7769  vlib_cli_output (vm, "MPLS encap table empty");
7770  goto out;
7771  }
7772 
7773  /* sort output by dst address within fib */
7776  vlib_cli_output (vm, "MPLS encap table");
7777  vlib_cli_output (vm, "%=6s%=16s%=16s", "Table", "Dest address", "Labels");
7778  vec_foreach (s, records)
7779  {
7780  rx_fib = ip4_fib_get (s->fib_index);
7781  vlib_cli_output (vm, "%=6d%=16U%=16U", rx_fib->table_id,
7783  mm, s->entry_index);
7784  send_mpls_fib_encap_details (am, q, s, mp->context);
7785  }
7786 
7787 out:
7788  vec_free (records);
7789 }
7790 
7791 static void
7793 {
7795 
7797  if (q == 0)
7798  return;
7799 
7802  u32 *table_ids = 0;
7803  u32 count;
7804 
7805  /* *INDENT-OFF* */
7806  pool_foreach (t, cm->tables,
7807  ({
7808  vec_add1 (table_ids, ntohl(t - cm->tables));
7809  }));
7810  /* *INDENT-ON* */
7811  count = vec_len (table_ids);
7812 
7814  rmp = vl_msg_api_alloc_as_if_client (sizeof (*rmp) + count * sizeof (u32));
7815  rmp->_vl_msg_id = ntohs (VL_API_CLASSIFY_TABLE_IDS_REPLY);
7816  rmp->context = mp->context;
7817  rmp->count = ntohl (count);
7818  clib_memcpy (rmp->ids, table_ids, count * sizeof (u32));
7819  rmp->retval = 0;
7820 
7821  vl_msg_api_send_shmem (q, (u8 *) & rmp);
7822 
7823  vec_free (table_ids);
7824 }
7825 
7826 static void
7829 {
7831  int rv = 0;
7832 
7833  u32 sw_if_index = ntohl (mp->sw_if_index);
7834  u32 *acl = 0;
7835 
7836  vec_validate (acl, INPUT_ACL_N_TABLES - 1);
7837  vec_set (acl, ~0);
7838 
7839  VALIDATE_SW_IF_INDEX (mp);
7840 
7842 
7843  int if_idx;
7844  u32 type;
7845 
7846  for (type = 0; type < INPUT_ACL_N_TABLES; type++)
7847  {
7849  if (vec_len (vec_tbl))
7850  {
7851  for (if_idx = 0; if_idx < vec_len (vec_tbl); if_idx++)
7852  {
7853  if (vec_elt (vec_tbl, if_idx) == ~0 || sw_if_index != if_idx)
7854  {
7855  continue;
7856  }
7857  acl[type] = vec_elt (vec_tbl, if_idx);
7858  }
7859  }
7860  }
7861 
7863 
7864  /* *INDENT-OFF* */
7865  REPLY_MACRO2(VL_API_CLASSIFY_TABLE_BY_INTERFACE_REPLY,
7866  ({
7867  rmp->sw_if_index = ntohl(sw_if_index);
7868  rmp->l2_table_id = ntohl(acl[INPUT_ACL_TABLE_L2]);
7869  rmp->ip4_table_id = ntohl(acl[INPUT_ACL_TABLE_IP4]);
7870  rmp->ip6_table_id = ntohl(acl[INPUT_ACL_TABLE_IP6]);
7871  }));
7872  /* *INDENT-ON* */
7873  vec_free (acl);
7874 }
7875 
7876 static void
7878 {
7880 
7882  if (q == 0)
7883  return;
7884 
7886 
7888  u32 table_id = ntohl (mp->table_id);
7890 
7891  /* *INDENT-OFF* */
7892  pool_foreach (t, cm->tables,
7893  ({
7894  if (table_id == t - cm->tables)
7895  {
7896  rmp = vl_msg_api_alloc_as_if_client
7897  (sizeof (*rmp) + t->match_n_vectors * sizeof (u32x4));
7898  rmp->_vl_msg_id = ntohs (VL_API_CLASSIFY_TABLE_INFO_REPLY);
7899  rmp->context = mp->context;
7900  rmp->table_id = ntohl(table_id);
7901  rmp->nbuckets = ntohl(t->nbuckets);
7902  rmp->match_n_vectors = ntohl(t->match_n_vectors);
7903  rmp->skip_n_vectors = ntohl(t->skip_n_vectors);
7904  rmp->active_sessions = ntohl(t->active_elements);
7905  rmp->next_table_index = ntohl(t->next_table_index);
7906  rmp->miss_next_index = ntohl(t->miss_next_index);
7907  rmp->mask_length = ntohl(t->match_n_vectors * sizeof (u32x4));
7908  clib_memcpy(rmp->mask, t->mask, t->match_n_vectors * sizeof(u32x4));
7909  rmp->retval = 0;
7910  break;
7911  }
7912  }));
7913  /* *INDENT-ON* */
7914 
7915  if (rmp == 0)
7916  {
7917  rmp = vl_msg_api_alloc (sizeof (*rmp));
7918  rmp->_vl_msg_id = ntohs ((VL_API_CLASSIFY_TABLE_INFO_REPLY));
7919  rmp->context = mp->context;
7920  rmp->retval = ntohl (VNET_API_ERROR_CLASSIFY_TABLE_NOT_FOUND);
7921  }
7922 
7923  vl_msg_api_send_shmem (q, (u8 *) & rmp);
7924 }
7925 
7926 static void
7928  mp)
7929 {
7930  clib_warning ("BUG");
7931 }
7932 
7933 static void
7935  u32 table_id,
7936  u32 match_length,
7937  vnet_classify_entry_t * e, u32 context)
7938 {
7940 
7941  rmp = vl_msg_api_alloc (sizeof (*rmp));
7942  memset (rmp, 0, sizeof (*rmp));
7943  rmp->_vl_msg_id = ntohs (VL_API_CLASSIFY_SESSION_DETAILS);
7944  rmp->context = context;
7945  rmp->table_id = ntohl (table_id);
7946  rmp->hit_next_index = ntohl (e->next_index);
7947  rmp->advance = ntohl (e->advance);
7948  rmp->opaque_index = ntohl (e->opaque_index);
7949  rmp->match_length = ntohl (match_length);
7950  clib_memcpy (rmp->match, e->key, match_length);
7951 
7952  vl_msg_api_send_shmem (q, (u8 *) & rmp);
7953 }
7954 
7955 static void
7957 {
7960 
7961  u32 table_id = ntohl (mp->table_id);
7963 
7965  if (!q)
7966  return;
7967 
7968  /* *INDENT-OFF* */
7969  pool_foreach (t, cm->tables,
7970  ({
7971  if (table_id == t - cm->tables)
7972  {
7973  vnet_classify_bucket_t * b;
7974  vnet_classify_entry_t * v, * save_v;
7975  int i, j, k;
7976 
7977  for (i = 0; i < t->nbuckets; i++)
7978  {
7979  b = &t->buckets [i];
7980  if (b->offset == 0)
7981  continue;
7982 
7983  save_v = vnet_classify_get_entry (t, b->offset);
7984  for (j = 0; j < (1<<b->log2_pages); j++)
7985  {
7986  for (k = 0; k < t->entries_per_page; k++)
7987  {
7988  v = vnet_classify_entry_at_index
7989  (t, save_v, j*t->entries_per_page + k);
7990  if (vnet_classify_entry_is_free (v))
7991  continue;
7992 
7993  send_classify_session_details
7994  (q, table_id, t->match_n_vectors * sizeof (u32x4),
7995  v, mp->context);
7996  }
7997  }
7998  }
7999  break;
8000  }
8001  }));
8002  /* *INDENT-ON* */
8003 }
8004 
8005 static void
8007 {
8008  vlib_main_t *vm = vlib_get_main ();
8011  ip4_address_t collector, src;
8012  u16 collector_port = UDP_DST_PORT_ipfix;
8013  u32 path_mtu;
8014  u32 template_interval;
8015  u8 udp_checksum;
8016  u32 fib_id;
8017  u32 fib_index = ~0;
8018  int rv = 0;
8019 
8020  memcpy (collector.data, mp->collector_address, sizeof (collector.data));
8021  collector_port = ntohs (mp->collector_port);
8022  if (collector_port == (u16) ~ 0)
8023  collector_port = UDP_DST_PORT_ipfix;
8024  memcpy (src.data, mp->src_address, sizeof (src.data));
8025  fib_id = ntohl (mp->vrf_id);
8026 
8027  ip4_main_t *im = &ip4_main;
8028  if (fib_id == ~0)
8029  {
8030  fib_index = ~0;
8031  }
8032  else
8033  {
8034  uword *p = hash_get (im->fib_index_by_table_id, fib_id);
8035  if (!p)
8036  {
8037  rv = VNET_API_ERROR_NO_SUCH_FIB;
8038  goto out;
8039  }
8040  fib_index = p[0];
8041  }
8042 
8043  path_mtu = ntohl (mp->path_mtu);
8044  if (path_mtu == ~0)
8045  path_mtu = 512; // RFC 7011 section 10.3.3.
8046  template_interval = ntohl (mp->template_interval);
8047  if (template_interval == ~0)
8048  template_interval = 20;
8049  udp_checksum = mp->udp_checksum;
8050 
8051  if (collector.as_u32 == 0)
8052  {
8053  rv = VNET_API_ERROR_INVALID_VALUE;
8054  goto out;
8055  }
8056 
8057  if (src.as_u32 == 0)
8058  {
8059  rv = VNET_API_ERROR_INVALID_VALUE;
8060  goto out;
8061  }
8062 
8063  if (path_mtu > 1450 /* vpp does not support fragmentation */ )
8064  {
8065  rv = VNET_API_ERROR_INVALID_VALUE;
8066  goto out;
8067  }
8068 
8069  if (path_mtu < 68)
8070  {
8071  rv = VNET_API_ERROR_INVALID_VALUE;
8072  goto out;
8073  }
8074 
8075  /* Reset report streams if we are reconfiguring IP addresses */
8076  if (frm->ipfix_collector.as_u32 != collector.as_u32 ||
8077  frm->src_address.as_u32 != src.as_u32 ||
8078  frm->collector_port != collector_port)
8080 
8081  frm->ipfix_collector.as_u32 = collector.as_u32;
8082  frm->collector_port = collector_port;
8083  frm->src_address.as_u32 = src.as_u32;
8084  frm->fib_index = fib_index;
8085  frm->path_mtu = path_mtu;
8086  frm->template_interval = template_interval;
8087  frm->udp_checksum = udp_checksum;
8088 
8089  /* Turn on the flow reporting process */
8091 
8092 out:
8093  REPLY_MACRO (VL_API_SET_IPFIX_EXPORTER_REPLY);
8094 }
8095 
8096 static void
8098 {
8102  ip4_main_t *im = &ip4_main;
8103  u32 vrf_id;
8104 
8106  if (!q)
8107  return;
8108 
8109  rmp = vl_msg_api_alloc (sizeof (*rmp));
8110  memset (rmp, 0, sizeof (*rmp));
8111  rmp->_vl_msg_id = ntohs (VL_API_IPFIX_EXPORTER_DETAILS);
8112  rmp->context = mp->context;
8113  memcpy (rmp->collector_address, frm->ipfix_collector.data,
8114  sizeof (frm->ipfix_collector.data));
8115  rmp->collector_port = htons (frm->collector_port);
8116  memcpy (rmp->src_address, frm->src_address.data,
8117  sizeof (frm->src_address.data));
8118  if (frm->fib_index == ~0)
8119  vrf_id = ~0;
8120  else
8121  vrf_id = im->fibs[frm->fib_index].ft_table_id;
8122  rmp->vrf_id = htonl (vrf_id);
8123  rmp->path_mtu = htonl (frm->path_mtu);
8124  rmp->template_interval = htonl (frm->template_interval);
8125  rmp->udp_checksum = (frm->udp_checksum != 0);
8126 
8127  vl_msg_api_send_shmem (q, (u8 *) & rmp);
8128 }
8129 
8130 static void
8133 {
8137  u32 domain_id = 0;
8138  u32 src_port = UDP_DST_PORT_ipfix;
8139  int rv = 0;
8140 
8141  domain_id = ntohl (mp->domain_id);
8142  src_port = ntohs (mp->src_port);
8143 
8144  if (fcm->src_port != 0 &&
8145  (fcm->domain_id != domain_id || fcm->src_port != (u16) src_port))
8146  {
8147  int rv = vnet_stream_change (frm, fcm->domain_id, fcm->src_port,
8148  domain_id, (u16) src_port);
8149  ASSERT (rv == 0);
8150  }
8151 
8152  fcm->domain_id = domain_id;
8153  fcm->src_port = (u16) src_port;
8154 
8155  REPLY_MACRO (VL_API_SET_IPFIX_CLASSIFY_STREAM_REPLY);
8156 }
8157 
8158 static void
8161 {
8165 
8167  if (!q)
8168  return;
8169 
8170  rmp = vl_msg_api_alloc (sizeof (*rmp));
8171  memset (rmp, 0, sizeof (*rmp));
8172  rmp->_vl_msg_id = ntohs (VL_API_IPFIX_CLASSIFY_STREAM_DETAILS);
8173  rmp->context = mp->context;
8174  rmp->domain_id = htonl (fcm->domain_id);
8175  rmp->src_port = htons (fcm->src_port);
8176 
8177  vl_msg_api_send_shmem (q, (u8 *) & rmp);
8178 }
8179 
8180 static void
8183 {
8188  ipfix_classify_table_t *table;
8189  int is_add;
8190  u32 classify_table_index;
8191  u8 ip_version;
8192  u8 transport_protocol;
8193  int rv = 0;
8194 
8195  classify_table_index = ntohl (mp->table_id);
8196  ip_version = mp->ip_version;
8197  transport_protocol = mp->transport_protocol;
8198  is_add = mp->is_add;
8199 
8200  if (fcm->src_port == 0)
8201  {
8202  /* call set_ipfix_classify_stream first */
8203  rv = VNET_API_ERROR_UNSPECIFIED;
8204  goto out;
8205  }
8206 
8207  memset (&args, 0, sizeof (args));
8208 
8209  table = 0;
8210  int i;
8211  for (i = 0; i < vec_len (fcm->tables); i++)
8213  if (fcm->tables[i].classify_table_index == classify_table_index)
8214  {
8215  table = &fcm->tables[i];
8216  break;
8217  }
8218 
8219  if (is_add)
8220  {
8221  if (table)
8222  {
8223  rv = VNET_API_ERROR_VALUE_EXIST;
8224  goto out;
8225  }
8226  table = ipfix_classify_add_table ();
8227  table->classify_table_index = classify_table_index;
8228  }
8229  else
8230  {
8231  if (!table)
8232  {
8233  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
8234  goto out;
8235  }
8236  }
8237 
8238  table->ip_version = ip_version;
8239  table->transport_protocol = transport_protocol;
8240 
8241  args.opaque.as_uword = table - fcm->tables;
8244  args.is_add = is_add;
8245  args.domain_id = fcm->domain_id;
8246  args.src_port = fcm->src_port;
8247 
8248  rv = vnet_flow_report_add_del (frm, &args);
8249 
8250  /* If deleting, or add failed */
8251  if (is_add == 0 || (rv && is_add))
8252  ipfix_classify_delete_table (table - fcm->tables);
8253 
8254 out:
8255  REPLY_MACRO (VL_API_SET_IPFIX_CLASSIFY_STREAM_REPLY);
8256 }
8257 
8258 static void
8261  u32 context)
8262 {
8265 
8266  ipfix_classify_table_t *table = &fcm->tables[table_index];
8267 
8268  mp = vl_msg_api_alloc (sizeof (*mp));
8269  memset (mp, 0, sizeof (*mp));
8270  mp->_vl_msg_id = ntohs (VL_API_IPFIX_CLASSIFY_TABLE_DETAILS);
8271  mp->context = context;
8272  mp->table_id = htonl (table->classify_table_index);
8273  mp->ip_version = table->ip_version;
8275 
8276  vl_msg_api_send_shmem (q, (u8 *) & mp);
8277 }
8278 
8279 static void
8282 {
8285  u32 i;
8286 
8288  if (!q)
8289  return;
8290 
8291  for (i = 0; i < vec_len (fcm->tables); i++)
8294 }
8295 
8296 static void
8298 {
8300  int rv = 0;
8301 
8302  pg_main_t *pg = &pg_main;
8303  u32 pg_if_id = pg_interface_add_or_get (pg, ntohl (mp->interface_id));
8304  pg_interface_t *pi = pool_elt_at_index (pg->interfaces, pg_if_id);
8305 
8306  /* *INDENT-OFF* */
8307  REPLY_MACRO2(VL_API_PG_CREATE_INTERFACE_REPLY,
8308  ({
8309  rmp->sw_if_index = ntohl(pi->sw_if_index);
8310  }));
8311  /* *INDENT-ON* */
8312 }
8313 
8314 static void
8316 {
8318  int rv = 0;
8319 
8320  vnet_main_t *vnm = vnet_get_main ();
8322  vnet_hw_interface_t *hi = 0;
8323 
8324  u8 *intf_name = format (0, "pg%d", ntohl (mp->interface_id), 0);
8325  u32 hw_if_index = ~0;
8326  uword *p = hash_get_mem (im->hw_interface_by_name, intf_name);
8327  if (p)
8328  hw_if_index = *p;
8329  vec_free (intf_name);
8330 
8331  if (hw_if_index != ~0)
8332  {
8333  pg_capture_args_t _a, *a = &_a;
8334 
8335  u32 len = ntohl (mp->pcap_name_length);
8336  u8 *pcap_file_name = vec_new (u8, len);
8337  clib_memcpy (pcap_file_name, mp->pcap_file_name, len);
8338 
8339  hi = vnet_get_sup_hw_interface (vnm, hw_if_index);
8340  a->hw_if_index = hw_if_index;
8341  a->dev_instance = hi->dev_instance;
8342  a->is_enabled = mp->is_enabled;
8343  a->pcap_file_name = pcap_file_name;
8344  a->count = ntohl (mp->count);
8345 
8346  clib_error_t *e = pg_capture (a);
8347  if (e)
8348  {
8349  clib_error_report (e);
8350  rv = VNET_API_ERROR_CANNOT_CREATE_PCAP_FILE;
8351  }
8352 
8353  vec_free (pcap_file_name);
8354  }
8355  REPLY_MACRO (VL_API_PG_CAPTURE_REPLY);
8356 }
8357 
8358 static void
8360 {
8362  int rv = 0;
8363 
8364  pg_main_t *pg = &pg_main;
8365  u32 stream_index = ~0;
8366 
8367  int is_enable = mp->is_enabled != 0;
8368  u32 len = ntohl (mp->stream_name_length) - 1;
8369 
8370  if (len > 0)
8371  {
8372  u8 *stream_name = vec_new (u8, len);
8373  clib_memcpy (stream_name, mp->stream_name, len);
8374  uword *p = hash_get_mem (pg->stream_index_by_name, stream_name);
8375  if (p)
8376  stream_index = *p;
8377  vec_free (stream_name);
8378  }
8379 
8380  pg_enable_disable (stream_index, is_enable);
8381 
8382  REPLY_MACRO (VL_API_PG_ENABLE_DISABLE_REPLY);
8383 }
8384 
8385 static void
8388 {
8390  int rv = 0;
8391 
8392  u8 is_ipv6 = mp->is_ipv6;
8393  u8 is_add = mp->is_add;
8394  u8 mask_length = mp->mask_length;
8395  ip4_address_t ip4_addr;
8396  ip6_address_t ip6_addr;
8397  u16 *low_ports = 0;
8398  u16 *high_ports = 0;
8399  u32 vrf_id;
8400  u16 tmp_low, tmp_high;
8401  u8 num_ranges;
8402  int i;
8403 
8404  // Validate port range
8405  num_ranges = mp->number_of_ranges;
8406  if (num_ranges > 32)
8407  { // This is size of array in VPE.API
8408  rv = VNET_API_ERROR_EXCEEDED_NUMBER_OF_RANGES_CAPACITY;
8409  goto reply;
8410  }
8411 
8412  vec_reset_length (low_ports);
8413  vec_reset_length (high_ports);
8414 
8415  for (i = 0; i < num_ranges; i++)
8416  {
8417  tmp_low = mp->low_ports[i];
8418  tmp_high = mp->high_ports[i];
8419  // If tmp_low <= tmp_high then only need to check tmp_low = 0
8420  // If tmp_low <= tmp_high then only need to check tmp_high > 65535
8421  if (tmp_low > tmp_high || tmp_low == 0 || tmp_high > 65535)
8422  {
8423  rv = VNET_API_ERROR_INVALID_VALUE;
8424  goto reply;
8425  }
8426  vec_add1 (low_ports, tmp_low);
8427  vec_add1 (high_ports, tmp_high + 1);
8428  }
8429 
8430  // Validate mask_length
8431  if ((is_ipv6 && mask_length > 128) || (!is_ipv6 && mask_length > 32))
8432  {
8433  rv = VNET_API_ERROR_ADDRESS_LENGTH_MISMATCH;
8434  goto reply;
8435  }
8436 
8437  vrf_id = ntohl (mp->vrf_id);
8438 
8439  if (vrf_id < 1)
8440  {
8441  rv = VNET_API_ERROR_INVALID_VALUE;
8442  goto reply;
8443  }
8444 
8445 
8446  if (is_ipv6)
8447  {
8448  clib_memcpy (ip6_addr.as_u8, mp->address, sizeof (ip6_addr.as_u8));
8450  mask_length,
8451  vrf_id,
8452  low_ports,
8453  high_ports, is_add);
8454  }
8455  else
8456  {
8457  clib_memcpy (ip4_addr.data, mp->address, sizeof (ip4_addr));
8459  mask_length,
8460  vrf_id,
8461  low_ports,
8462  high_ports, is_add);
8463  }
8464 
8465 reply:
8466  vec_free (low_ports);
8467  vec_free (high_ports);
8468  REPLY_MACRO (VL_API_IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY);
8469 }
8470 
8471 static void
8474 {
8475  vlib_main_t *vm = vlib_get_main ();
8477  ip4_main_t *im = &ip4_main;
8478  int rv;
8479  u32 sw_if_index;
8482  uword *p = 0;
8483  int i;
8484 
8486  ntohl (mp->tcp_out_vrf_id);
8488  ntohl (mp->udp_out_vrf_id);
8490  ntohl (mp->tcp_in_vrf_id);
8492  ntohl (mp->udp_in_vrf_id);
8493 
8494 
8495  for (i = 0; i < IP_SOURCE_AND_PORT_RANGE_CHECK_N_PROTOCOLS; i++)
8496  {
8497  if (vrf_id[i] != 0 && vrf_id[i] != ~0)
8498  {
8499  p = hash_get (im->fib_index_by_table_id, vrf_id[i]);
8500 
8501  if (p == 0)
8502  {
8503  rv = VNET_API_ERROR_INVALID_VALUE;
8504  goto reply;
8505  }
8506 
8507  fib_index[i] = p[0];
8508  }
8509  else
8510  fib_index[i] = ~0;
8511  }
8512  sw_if_index = ntohl (mp->sw_if_index);
8513 
8514  VALIDATE_SW_IF_INDEX (mp);
8515 
8516  rv =
8517  set_ip_source_and_port_range_check (vm, fib_index, sw_if_index,
8518  mp->is_add);
8519 
8521 reply:
8522 
8523  REPLY_MACRO (VL_API_IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY);
8524 }
8525 
8526 static void
8528  mp)
8529 {
8531  int rv = 0;
8533  u32 sw_if_index = ~0;
8534 
8535  /* Check src & dst are different */
8536  if (memcmp (mp->src_address, mp->dst_address, 4) == 0)
8537  {
8538  rv = VNET_API_ERROR_SAME_SRC_DST;
8539  goto out;
8540  }
8541 
8542  memset (a, 0, sizeof (*a));
8543 
8544  /* ip addresses sent in network byte order */
8545  clib_memcpy (&(a->src), mp->src_address, 4);
8546  clib_memcpy (&(a->dst), mp->dst_address, 4);
8547  a->is_add = mp->is_add;
8548  a->lsa = ntohl (mp->local_sa_id);
8549  a->rsa = ntohl (mp->remote_sa_id);
8550 
8551  rv = vnet_ipsec_gre_add_del_tunnel (a, &sw_if_index);
8552 
8553 out:
8554  /* *INDENT-OFF* */
8555  REPLY_MACRO2(VL_API_GRE_ADD_DEL_TUNNEL_REPLY,
8556  ({
8557  rmp->sw_if_index = ntohl (sw_if_index);
8558  }));
8559  /* *INDENT-ON* */
8560 }
8561 
8564 {
8566 
8567  rmp = vl_msg_api_alloc (sizeof (*rmp));
8568  memset (rmp, 0, sizeof (*rmp));
8569  rmp->_vl_msg_id = ntohs (VL_API_IPSEC_GRE_TUNNEL_DETAILS);
8570  clib_memcpy (rmp->src_address, &(t->tunnel_src), 4);
8571  clib_memcpy (rmp->dst_address, &(t->tunnel_dst), 4);
8572  rmp->sw_if_index = htonl (t->sw_if_index);
8573  rmp->local_sa_id = htonl (t->local_sa_id);
8574  rmp->remote_sa_id = htonl (t->remote_sa_id);
8575  rmp->context = context;
8576 
8577  vl_msg_api_send_shmem (q, (u8 *) & rmp);
8578 }
8579 
8582 {
8585  ipsec_gre_tunnel_t *t;
8586  u32 sw_if_index;
8587 
8589  if (q == 0)
8590  {
8591  return;
8592  }
8593 
8594  sw_if_index = ntohl (mp->sw_if_index);
8595 
8596  if (~0 == sw_if_index)
8597  {
8598  /* *INDENT-OFF* */
8599  pool_foreach (t, igm->tunnels,
8600  ({
8601  send_ipsec_gre_tunnel_details(t, q, mp->context);
8602  }));
8603  /* *INDENT-ON* */
8604  }
8605  else
8606  {
8607  if ((sw_if_index >= vec_len (igm->tunnel_index_by_sw_if_index)) ||
8608  (~0 == igm->tunnel_index_by_sw_if_index[sw_if_index]))
8609  {
8610  return;
8611  }
8612  t = &igm->tunnels[igm->tunnel_index_by_sw_if_index[sw_if_index]];
8614  }
8615 }
8616 
8617 static void
8619 {
8621  int rv;
8622 
8623  rv = vnet_delete_sub_interface (ntohl (mp->sw_if_index));
8624 
8625  REPLY_MACRO (VL_API_DELETE_SUBIF_REPLY);
8626 }
8627 
8628 static void
8631 {
8633  vnet_main_t *vnm = vnet_get_main ();
8634  vlib_main_t *vm = vlib_get_main ();
8635  u32 vtr_op;
8636  int rv = 0;
8637 
8638  VALIDATE_SW_IF_INDEX (mp);
8639 
8640  vtr_op = ntohl (mp->vtr_op);
8641 
8642  switch (vtr_op)
8643  {
8644  case L2_VTR_DISABLED:
8645  case L2_VTR_PUSH_2:
8646  case L2_VTR_POP_2:
8647  case L2_VTR_TRANSLATE_2_1:
8648  break;
8649 
8650  default:
8651  rv = VNET_API_ERROR_INVALID_VALUE;
8652  goto bad_sw_if_index;
8653  }
8654 
8655  rv = l2pbb_configure (vm, vnm, ntohl (mp->sw_if_index), vtr_op,
8656  mp->b_dmac, mp->b_smac, ntohs (mp->b_vlanid),
8657  ntohl (mp->i_sid), ntohs (mp->outer_tag));
8658 
8660 
8661  REPLY_MACRO (VL_API_L2_INTERFACE_PBB_TAG_REWRITE_REPLY);
8662 }
8663 
8664 static void
8666 {
8667  vl_api_punt_reply_t *rmp;
8668  vlib_main_t *vm = vlib_get_main ();
8669  int rv = 0;
8670  clib_error_t *error;
8671 
8672  error = vnet_punt_add_del (vm, mp->ipv, mp->l4_protocol,
8673  ntohs (mp->l4_port), mp->is_add);
8674  if (error)
8675  {
8676  rv = -1;
8677  clib_error_report (error);
8678  }
8679 
8680  REPLY_MACRO (VL_API_PUNT_REPLY);
8681 }
8682 
8683 static void
8686 {
8687  vlib_main_t *vm = vlib_get_main ();
8689  int rv;
8690  u32 sw_if_index, ip4_table_index, ip6_table_index;
8691 
8692  ip4_table_index = ntohl (mp->ip4_table_index);
8693  ip6_table_index = ntohl (mp->ip6_table_index);
8694  sw_if_index = ntohl (mp->sw_if_index);
8695 
8696  VALIDATE_SW_IF_INDEX (mp);
8697 
8698  rv = vnet_set_flow_classify_intfc (vm, sw_if_index, ip4_table_index,
8699  ip6_table_index, mp->is_add);
8700 
8702 
8703  REPLY_MACRO (VL_API_FLOW_CLASSIFY_SET_INTERFACE_REPLY);
8704 }
8705 
8706 static void
8708  u32 table_index,
8709  unix_shared_memory_queue_t * q, u32 context)
8710 {
8712 
8713  mp = vl_msg_api_alloc (sizeof (*mp));
8714  memset (mp, 0, sizeof (*mp));
8715  mp->_vl_msg_id = ntohs (VL_API_FLOW_CLASSIFY_DETAILS);
8716  mp->context = context;
8717  mp->sw_if_index = htonl (sw_if_index);
8718  mp->table_index = htonl (table_index);
8719 
8720  vl_msg_api_send_shmem (q, (u8 *) & mp);
8721 }
8722 
8723 static void
8725 {
8728  u32 *vec_tbl;
8729  int i;
8730 
8732  if (q == 0)
8733  return;
8734 
8735  vec_tbl = pcm->classify_table_index_by_sw_if_index[mp->type];
8736 
8737  if (vec_len (vec_tbl))
8738  {
8739  for (i = 0; i < vec_len (vec_tbl); i++)
8740  {
8741  if (vec_elt (vec_tbl, i) == ~0)
8742  continue;
8743 
8744  send_flow_classify_details (i, vec_elt (vec_tbl, i), q,
8745  mp->context);
8746  }
8747  }
8748 }
8749 
8750 #define BOUNCE_HANDLER(nn) \
8751 static void vl_api_##nn##_t_handler ( \
8752  vl_api_##nn##_t *mp) \
8753 { \
8754  vpe_client_registration_t *reg; \
8755  vpe_api_main_t * vam = &vpe_api_main; \
8756  unix_shared_memory_queue_t * q; \
8757  \
8758  /* One registration only... */ \
8759  pool_foreach(reg, vam->nn##_registrations, \
8760  ({ \
8761  q = vl_api_client_index_to_input_queue (reg->client_index); \
8762  if (q) { \
8763  /* \
8764  * If the queue is stuffed, turf the msg and complain \
8765  * It's unlikely that the intended recipient is \
8766  * alive; avoid deadlock at all costs. \
8767  */ \
8768  if (q->cursize == q->maxsize) { \
8769  clib_warning ("ERROR: receiver queue full, drop msg"); \
8770  vl_msg_api_free (mp); \
8771  return; \
8772  } \
8773  vl_msg_api_send_shmem (q, (u8 *)&mp); \
8774  return; \
8775  } \
8776  })); \
8777  vl_msg_api_free (mp); \
8778 }
8779 
8780 /*
8781  * vpe_api_hookup
8782  * Add vpe's API message handlers to the table.
8783  * vlib has alread mapped shared memory and
8784  * added the client registration handlers.
8785  * See .../open-repo/vlib/memclnt_vlib.c:memclnt_process()
8786  */
8787 
8788 static clib_error_t *
8790 {
8791  api_main_t *am = &api_main;
8792 
8793 #define _(N,n) \
8794  vl_msg_api_set_handlers(VL_API_##N, #n, \
8795  vl_api_##n##_t_handler, \
8796  vl_noop_handler, \
8797  vl_api_##n##_t_endian, \
8798  vl_api_##n##_t_print, \
8799  sizeof(vl_api_##n##_t), 1);
8801 #undef _
8802 
8803  /*
8804  * Manually register the sr tunnel add del msg, so we trace
8805  * enough bytes to capture a typical segment list
8806  */
8807  vl_msg_api_set_handlers (VL_API_SR_TUNNEL_ADD_DEL,
8808  "sr_tunnel_add_del",
8811  vl_api_sr_tunnel_add_del_t_endian,
8813 
8814 
8815  /*
8816  * Manually register the sr policy add del msg, so we trace
8817  * enough bytes to capture a typical tunnel name list
8818  */
8819  vl_msg_api_set_handlers (VL_API_SR_POLICY_ADD_DEL,
8820  "sr_policy_add_del",
8823  vl_api_sr_policy_add_del_t_endian,
8825 
8826  /*
8827  * Trace space for 8 MPLS encap labels, classifier mask+match
8828  */
8829  am->api_trace_cfg[VL_API_MPLS_ADD_DEL_ENCAP].size += 8 * sizeof (u32);
8830  am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_TABLE].size += 5 * sizeof (u32x4);
8831  am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_SESSION].size
8832  += 5 * sizeof (u32x4);
8833  am->api_trace_cfg[VL_API_VXLAN_ADD_DEL_TUNNEL].size += 16 * sizeof (u32);
8834 
8835  /*
8836  * Thread-safe API messages
8837  */
8838  am->is_mp_safe[VL_API_IP_ADD_DEL_ROUTE] = 1;
8839  am->is_mp_safe[VL_API_GET_NODE_GRAPH] = 1;
8840 
8841  return 0;
8842 }
8843 
8845 
8846 static clib_error_t *
8848 {
8850 
8851  am->vlib_main = vm;
8852  am->vnet_main = vnet_get_main ();
8853  am->interface_events_registration_hash = hash_create (0, sizeof (uword));
8854  am->to_netconf_server_registration_hash = hash_create (0, sizeof (uword));
8855  am->from_netconf_server_registration_hash = hash_create (0, sizeof (uword));
8856  am->to_netconf_client_registration_hash = hash_create (0, sizeof (uword));
8857  am->from_netconf_client_registration_hash = hash_create (0, sizeof (uword));
8858  am->oam_events_registration_hash = hash_create (0, sizeof (uword));
8859 
8860  vl_api_init (vm);
8861  vl_set_memory_region_name ("/vpe-api");
8862  vl_enable_disable_memory_api (vm, 1 /* enable it */ );
8863 
8864  return 0;
8865 }
8866 
8868 
8869 
8870 static clib_error_t *
8872 {
8873  u8 *chroot_path;
8874  u64 baseva, size, pvt_heap_size;
8875  int uid, gid, rv;
8876  const int max_buf_size = 4096;
8877  char *s, *buf;
8878  struct passwd _pw, *pw;
8879  struct group _grp, *grp;
8880  clib_error_t *e;
8881  buf = vec_new (char, 128);
8882  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8883  {
8884  if (unformat (input, "prefix %s", &chroot_path))
8885  {
8886  vec_add1 (chroot_path, 0);
8887  vl_set_memory_root_path ((char *) chroot_path);
8888  }
8889  else if (unformat (input, "uid %d", &uid))
8890  vl_set_memory_uid (uid);
8891  else if (unformat (input, "gid %d", &gid))
8892  vl_set_memory_gid (gid);
8893  else if (unformat (input, "baseva %llx", &baseva))
8894  vl_set_global_memory_baseva (baseva);
8895  else if (unformat (input, "global-size %lldM", &size))
8896  vl_set_global_memory_size (size * (1ULL << 20));
8897  else if (unformat (input, "global-size %lldG", &size))
8898  vl_set_global_memory_size (size * (1ULL << 30));
8899  else if (unformat (input, "global-size %lld", &size))
8901  else if (unformat (input, "global-pvt-heap-size %lldM", &pvt_heap_size))
8902  vl_set_global_pvt_heap_size (pvt_heap_size * (1ULL << 20));
8903  else if (unformat (input, "global-pvt-heap-size size %lld",
8904  &pvt_heap_size))
8905  vl_set_global_pvt_heap_size (pvt_heap_size);
8906  else if (unformat (input, "api-pvt-heap-size %lldM", &pvt_heap_size))
8907  vl_set_api_pvt_heap_size (pvt_heap_size * (1ULL << 20));
8908  else if (unformat (input, "api-pvt-heap-size size %lld",
8909  &pvt_heap_size))
8910  vl_set_api_pvt_heap_size (pvt_heap_size);
8911  else if (unformat (input, "api-size %lldM", &size))
8912  vl_set_api_memory_size (size * (1ULL << 20));
8913  else if (unformat (input, "api-size %lldG", &size))
8914  vl_set_api_memory_size (size * (1ULL << 30));
8915  else if (unformat (input, "api-size %lld", &size))
8916  vl_set_api_memory_size (size);
8917  else if (unformat (input, "uid %s", &s))
8918  {
8919  /* lookup the username */
8920  pw = NULL;
8921  while (((rv =
8922  getpwnam_r (s, &_pw, buf, vec_len (buf), &pw)) == ERANGE)
8923  && (vec_len (buf) <= max_buf_size))
8924  {
8925  vec_resize (buf, vec_len (buf) * 2);
8926  }
8927  if (rv < 0)
8928  {
8929  e = clib_error_return_code (0, rv,
8932  "cannot fetch username %s", s);
8933  vec_free (s);
8934  vec_free (buf);
8935  return e;
8936  }
8937  if (pw == NULL)
8938  {
8939  e =
8940  clib_error_return_fatal (0, "username %s does not exist", s);
8941  vec_free (s);
8942  vec_free (buf);
8943  return e;
8944  }
8945  vec_free (s);
8946  vl_set_memory_uid (pw->pw_uid);
8947  }
8948  else if (unformat (input, "gid %s", &s))
8949  {
8950  /* lookup the group name */
8951  grp = NULL;
8952  while (((rv =
8953  getgrnam_r (s, &_grp, buf, vec_len (buf), &grp)) == ERANGE)
8954  && (vec_len (buf) <= max_buf_size))
8955  {
8956  vec_resize (buf, vec_len (buf) * 2);
8957  }
8958  if (rv != 0)
8959  {
8960  e = clib_error_return_code (0, rv,
8963  "cannot fetch group %s", s);
8964  vec_free (s);
8965  vec_free (buf);
8966  return e;
8967  }
8968  if (grp == NULL)
8969  {
8970  e = clib_error_return_fatal (0, "group %s does not exist", s);
8971  vec_free (s);
8972  vec_free (buf);
8973  return e;
8974  }
8975  vec_free (s);
8976  vec_free (buf);
8977  vl_set_memory_gid (grp->gr_gid);
8978  }
8979  else
8980  return clib_error_return (0, "unknown input `%U'",
8981  format_unformat_error, input);
8982  }
8983  return 0;
8984 }
8985 
8987 
8988 void *
8990 {
8991  return (void *) &unformat_vnet_sw_interface;
8992 }
8993 
8994 #undef vl_api_version
8995 #define vl_api_version(n,v) static u32 vpe_api_version = v;
8996 #include <vpp-api/vpe.api.h>
8997 #undef vl_api_version
8998 
8999 int
9001 {
9002  if (clib_host_to_net_u32 (mp->api_versions[0]) != vpe_api_version)
9003  {
9004  clib_warning ("vpe API mismatch: 0x%08x instead of 0x%08x",
9005  clib_host_to_net_u32 (mp->api_versions[0]),
9006  vpe_api_version);
9007  return -1;
9008  }
9009  return 0;
9010 }
9011 
9012 static u8 *
9013 format_arp_event (u8 * s, va_list * args)
9014 {
9015  vl_api_ip4_arp_event_t *event = va_arg (*args, vl_api_ip4_arp_event_t *);
9016 
9017  s = format (s, "pid %d: ", event->pid);
9018  if (event->mac_ip)
9019  s = format (s, "bd mac/ip4 binding events");
9020  else
9021  s = format (s, "resolution for %U", format_ip4_address, &event->address);
9022  return s;
9023 }
9024 
9025 static u8 *
9026 format_nd_event (u8 * s, va_list * args)
9027 {
9028  vl_api_ip6_nd_event_t *event = va_arg (*args, vl_api_ip6_nd_event_t *);
9029 
9030  s = format (s, "pid %d: ", event->pid);
9031  if (event->mac_ip)
9032  s = format (s, "bd mac/ip6 binding events");
9033  else
9034  s = format (s, "resolution for %U", format_ip6_address, event->address);
9035  return s;
9036 }
9037 
9038 static clib_error_t *
9040  unformat_input_t * input, vlib_cli_command_t * cmd)
9041 {
9043  vl_api_ip4_arp_event_t *arp_event;
9044  vl_api_ip6_nd_event_t *nd_event;
9045 
9046  if ((pool_elts (am->arp_events) == 0) && (pool_elts (am->nd_events) == 0))
9047  {
9048  vlib_cli_output (vm, "No active arp or nd event registrations");
9049  return 0;
9050  }
9051 
9052  /* *INDENT-OFF* */
9053  pool_foreach (arp_event, am->arp_events,
9054  ({
9055  vlib_cli_output (vm, "%U", format_arp_event, arp_event);
9056  }));
9057 
9058  pool_foreach (nd_event, am->nd_events,
9059  ({
9060  vlib_cli_output (vm, "%U", format_nd_event, nd_event);
9061  }));
9062  /* *INDENT-ON* */
9063 
9064  return 0;
9065 }
9066 
9067 /* *INDENT-OFF* */
9069  .path = "show arp-nd-event registrations",
9070  .function = show_ip_arp_nd_events_fn,
9071  .short_help = "Show ip4 arp and ip6 nd event registrations",
9072 };
9073 /* *INDENT-ON* */
9074 
9075 /*
9076  * fd.io coding-style-patch-verification: ON
9077  *
9078  * Local Variables:
9079  * eval: (c-set-style "gnu")
9080  * End:
9081  */
#define ip_prefix_v4(_a)
Definition: lisp_types.h:61
resolve_t
Definition: api.c:474
void lisp_gpe_tenant_l2_iface_unlock(u32 vni)
Release the lock held on the tenant&#39;s L3 interface.
static u32 ip4_fib_lookup(ip4_main_t *im, u32 sw_if_index, ip4_address_t *dst)
Definition: ip4_fib.h:77
vnet_config_main_t config_main
Definition: feature.h:55
u32 sw_if_index
Definition: pg.h:288
Bind/Unbind an MPLS local label to an IP prefix.
Definition: vpe.api:460
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:396
ip46_address_t stop
Definition: ipsec.h:104
DPDK interface HQoS subport parameters set request.
Definition: vpe.api:5188
#define foreach_ip_interface_address(lm, a, sw_if_index, loop, body)
Definition: lookup.h:434
Reply for IPsec: Add/delete Security Association Database entry.
Definition: vpe.api:3639
Reply for classify table session dump request.
Definition: vpe.api:4689
static_always_inline u8 bd_feature_forward(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:157
fib_protocol_t fp_proto
protocol type
Definition: fib_types.h:158
#define VNET_SW_INTERFACE_FLAG_UNNUMBERED
Definition: interface.h:497
static void send_policer_details(u8 *name, sse2_qos_pol_cfg_params_st *config, policer_read_response_type_st *templ, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:7354
static void send_ip_address_details(vpe_api_main_t *am, unix_shared_memory_queue_t *q, u8 *ip, u16 prefix_length, u8 is_ipv6, u32 context)
Definition: api.c:4354
DHCP Proxy config response.
Definition: vpe.api:919
u8 psid_length
Definition: map.h:102
Policer operational state response.
Definition: vpe.api:4324
static void vl_api_dhcp_proxy_set_vss_t_handler(vl_api_dhcp_proxy_set_vss_t *mp)
Definition: api.c:3335
Get list of policers.
Definition: vpe.api:4288
static u8 * format_arp_event(u8 *s, va_list *args)
Definition: api.c:9013
u64 local_cookie[2]
Definition: l2tp.h:32
vmrglw vmrglh hi
u32 fib_entry_get_fib_index(fib_node_index_t fib_entry_index)
Definition: fib_entry.c:1486
DHCP Proxy set / unset vss request.
Definition: vpe.api:934
void unformat_init_vector(unformat_input_t *input, u8 *vector_string)
Definition: unformat.c:1025
static void vl_api_classify_session_dump_t_handler(vl_api_classify_session_dump_t *mp)
Definition: api.c:7956
static void vl_api_tap_delete_t_handler(vl_api_tap_delete_t *mp, vlib_main_t *vm)
Definition: api.c:2209
Proxy ARP add / del request.
Definition: vpe.api:587
void pg_enable_disable(u32 stream_index, int is_enable)
Definition: cli.c:58
Classify get table IDs request.
Definition: vpe.api:4580
void ip_null_dpo_add_and_lock(dpo_proto_t proto, ip_null_dpo_action_t action, dpo_id_t *dpo)
Definition: ip_null_dpo.c:78
static void vl_api_set_arp_neighbor_limit_t_handler(vl_api_set_arp_neighbor_limit_t *mp)
Definition: api.c:3787
#define gid_address_ip_version(_a)
Definition: lisp_types.h:219
u8 crypto_algorithm
Definition: vpe.api:3618
u32 bd_set_flags(vlib_main_t *vm, u32 bd_index, u32 flags, u32 enable)
Set the learn/forward/flood flags for the bridge domain.
Definition: l2_bd.c:190
#define vec_foreach_index(var, v)
Iterate over vector indices.
Add / del ipsec gre tunnel request.
Definition: vpe.api:5083
u32 pitr_map_index
Definition: control.h:149
void mpls_sw_interface_enable_disable(mpls_main_t *mm, u32 sw_if_index, u8 is_enable)
Definition: interface.c:275
u64 packets
packet counter
Definition: counter.h:166
L2 interface vlan tag rewrite response.
Definition: vpe.api:2146
L2 FIB add entry request.
Definition: vpe.api:1572
#define clib_error_return_code(e, code, flags, args...)
Definition: error.h:105
u8 use_extended_sequence_number
Definition: vpe.api:3626
cop: enable/disable whitelist filtration features on an interface Note: the supplied fib_id must matc...
Definition: vpe.api:4053
static void * vl_api_sr_tunnel_add_del_t_print(vl_api_sr_tunnel_add_del_t *mp, void *handle)
Definition: custom_dump.c:1067
static void send_flow_classify_details(u32 sw_if_index, u32 table_index, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:8707
void dhcp_compl_event_callback(u32 client_index, u32 pid, u8 *hostname, u8 is_ipv6, u8 *host_address, u8 *router_address, u8 *host_mac)
Definition: api.c:3372
sse2_qos_pol_cfg_params_st * configs
Definition: policer.h:30
u32 sa_id
Definition: vpe.api:3561
#define hash_set(h, key, value)
Definition: hash.h:254
l2_input_config_t * configs
Definition: l2_input.h:66
gid_address_t leid
Definition: control.h:48
Set bridge flags response.
Definition: vpe.api:1644
Register for ip6 nd resolution events.
Definition: vpe.api:3269
static void vl_api_l2_fib_table_entry_t_handler(vl_api_l2_fib_table_entry_t *mp)
Definition: api.c:4554
Definition: gre.h:99
ip4_address_t tunnel_dst
tunnel IPv4 dst address
Definition: ipsec_gre.h:53
static vpe_api_main_t vpe_api_main
Definition: api.c:516
static void vl_api_l2_patch_add_del_t_handler(vl_api_l2_patch_add_del_t *mp)
Definition: api.c:5094
static clib_error_t * api_segment_config(vlib_main_t *vm, unformat_input_t *input)
Definition: api.c:8871
DHCP Client config response.
Definition: vpe.api:3414
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
u8 integrity_key_length
Definition: vpe.api:3623
void receive_dpo_add_or_lock(dpo_proto_t proto, u32 sw_if_index, const ip46_address_t *nh_addr, dpo_id_t *dpo)
Definition: receive_dpo.c:56
static int nd_change_data_callback(u32 pool_index, u8 *new_mac, u32 sw_if_index, ip6_address_t *address)
Definition: api.c:6480
LISP locator_set status.
Definition: vpe.api:2890
u32 ip4_multicast_rx_feature_vpath
Built-in multicast feature path index.
Definition: ip4.h:144
vnet_main_t * vnet_main
Definition: api.c:512
#define gid_address_type(_a)
Definition: lisp_types.h:215
Args for creating a policy.
Definition: sr.h:130
void vl_enable_disable_memory_api(vlib_main_t *vm, int yesno)
Definition: memory_vlib.c:713
Reset fib table request.
Definition: vpe.api:875
u32 flags
flags
Definition: vxlan_gpe.h:116
static void svm_pop_heap(void *oldheap)
Definition: svm.h:190
static u8 * format_nd_event(u8 *s, va_list *args)
Definition: api.c:9026
IPFIX classify tables dump request.
Definition: vpe.api:4836
u16 stop
Definition: ipsec.h:109
int vnet_tap_modify(vlib_main_t *vm, u32 orig_sw_if_index, u8 *intfc_name, u8 *hwaddr_arg, u32 *sw_if_indexp, u8 renumber, u32 custom_dev_instance)
Modifies tap interface - can result in new interface being created.
Definition: tapcli.c:1141
uword unformat(unformat_input_t *i, char *fmt,...)
Definition: unformat.c:966
Add or Delete MAP rule from a domain (Only used for shared IPv4 per subscriber)
Definition: vpe.api:3925
int map_delete_domain(u32 map_domain_index)
Definition: map.c:351
Reply for get next node index.
Definition: vpe.api:4924
ip46_address_t tunnel_src_addr
Definition: ipsec.h:91
static int mpls_ethernet_add_del_tunnel_2_t_handler(vl_api_mpls_ethernet_add_del_tunnel_2_t *mp)
Definition: api.c:2425
int vnet_set_ip4_flow_hash(u32 table_id, flow_hash_config_t flow_hash_config)
Definition: ip4_forward.c:3115
#define BAD_SW_IF_INDEX_LABEL
Definition: api.c:229
static void vl_api_sw_interface_set_unnumbered_t_handler(vl_api_sw_interface_set_unnumbered_t *mp)
Definition: api.c:3587
vpe parser cli string response
Definition: vpe.api:1250
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
Definition: node_funcs.h:684
add or delete lisp gpe tunnel
Definition: vpe.api:2533
vlib_node_registration_t flow_report_process_node
(constructor) VLIB_REGISTER_NODE (flow_report_process_node)
Definition: flow_report.c:232
u8 tunnel_dst[6]
Definition: mpls.h:38
static void vl_api_lisp_add_del_remote_mapping_t_handler(vl_api_lisp_add_del_remote_mapping_t *mp)
Definition: api.c:5672
a
Definition: bitmap.h:516
u32 l2vtr_configure(vlib_main_t *vlib_main, vnet_main_t *vnet_main, u32 sw_if_index, u32 vtr_op, u32 push_dot1q, u32 vtr_tag1, u32 vtr_tag2)
Configure vtag tag rewrite on the given interface.
Definition: l2_vtr.c:136
sse2_qos_pol_action_params_st conform_action
Definition: xlate.h:151
iOAM disable response
Definition: vpe.api:4170
u8 vnet_lisp_gpe_enable_disable_status(void)
Check if LISP-GPE is enabled.
Definition: lisp_gpe.c:174
VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION(admin_up_down_function)
void vl_set_memory_gid(int gid)
static void vl_api_gre_add_del_tunnel_t_handler(vl_api_gre_add_del_tunnel_t *mp)
Definition: api.c:4991
int dhcpv6_proxy_set_server(ip6_address_t *addr, ip6_address_t *src_address, u32 fib_id, int insert_vss, int is_del)
Definition: proxy_node.c:725
u32 id
Definition: ipsec.h:74
static uword * vlib_process_wait_for_event(vlib_main_t *vm)
Definition: node_funcs.h:604
u16 udp_checksum(udp_header_t *uh, u32 udp_len, void *ih, u8 version)
Definition: packets.c:114
u32 mask_width
Definition: mpls.h:42
static int ip6_add_del_route_t_handler(vl_api_ip_add_del_route_t *mp)
Definition: api.c:1287
static void vl_api_set_ip_flow_hash_t_handler(vl_api_set_ip_flow_hash_t *mp)
Definition: api.c:3578
format_function_t format_ip6_address
Definition: format.h:94
static void send_vxlan_gpe_tunnel_details(vxlan_gpe_tunnel_t *t, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:5194
Reply for IKEv2: Set IKEv2 profile traffic selector parameters.
Definition: vpe.api:3803
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
static void vl_api_lisp_eid_table_add_del_map_t_handler(vl_api_lisp_eid_table_add_del_map_t *mp)
Definition: api.c:5433
dpdk_main_t dpdk_main
Definition: dpdk.h:476
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
clib_error_t * ikev2_add_del_profile(vlib_main_t *vm, u8 *name, int is_add)
Definition: ikev2.c:2008
iOAM Trace profile add / del response
Definition: vpe.api:4148
static_always_inline void ipfix_classify_delete_table(u32 index)
static void vl_api_bridge_flags_t_handler(vl_api_bridge_flags_t *mp)
Definition: api.c:2099
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
Reply for IKEv2: Set IKEv2 profile authentication method.
Definition: vpe.api:3735
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
uword as_uword
Definition: flow_report.h:57
uword * policer_config_by_name
Definition: policer.h:34
Vhost-user interface details structure (fix this)
Definition: vpe.api:2292
u8 tunnel_dst_address[16]
Definition: vpe.api:3631
static void vl_api_sw_interface_add_del_address_t_handler(vl_api_sw_interface_add_del_address_t *mp)
Definition: api.c:1505
u32 bvi_sw_if_index
Definition: l2_bd.h:65
ethernet_main_t * ethernet_get_main(vlib_main_t *vm)
Definition: init.c:126
static_always_inline u8 ipfix_classify_table_index_valid(u32 index)
Definition: pg.h:304
Set/unset policer classify interface.
Definition: vpe.api:4365
static void vl_api_l2_interface_pbb_tag_rewrite_t_handler(vl_api_l2_interface_pbb_tag_rewrite_t *mp)
Definition: api.c:8630
void vl_set_global_pvt_heap_size(u64 size)
configure or disable LISP PITR node
Definition: vpe.api:2662
static void vl_api_tap_connect_t_handler(vl_api_tap_connect_t *mp, vlib_main_t *vm)
Definition: api.c:2157
Set flags on the interface.
Definition: vpe.api:130
Reply for locator_set add/del.
Definition: vpe.api:2442
IKEv2: Add/delete profile.
Definition: vpe.api:3690
int vnet_set_ip6_classify_intfc(vlib_main_t *vm, u32 sw_if_index, u32 table_index)
Definition: ip6_forward.c:3058
L2-GRE over IPSec packet processing.
static void vl_api_ipfix_classify_table_add_del_t_handler(vl_api_ipfix_classify_table_add_del_t *mp)
Definition: api.c:8182
u32 * classify_table_index_by_sw_if_index[INPUT_ACL_N_TABLES]
Definition: input_acl.h:38
ip6_address_t * multicast_address
multicast IP6 address
Definition: sr.h:169
vnet_interface_main_t interface_main
Definition: vnet.h:72
u16 local_port_start
Definition: vpe.api:3556
Control ping from client to api server request.
Definition: vpe.api:1206
static void vl_api_classify_session_details_t_handler(vl_api_classify_session_details_t *mp)
Definition: api.c:7927
static void send_classify_session_details(unix_shared_memory_queue_t *q, u32 table_id, u32 match_length, vnet_classify_entry_t *e, u32 context)
Definition: api.c:7934
static int ip4_add_del_route_t_handler(vl_api_ip_add_del_route_t *mp)
Definition: api.c:1242
#define BAD_RX_SW_IF_INDEX_LABEL
Definition: api.c:245
i32 priority
Definition: ipsec.h:153
LISP map resolver status.
Definition: vpe.api:3119
u32 table_id
Definition: ip4.h:56
Create netmap.
Definition: vpe.api:4419
vl_api_lisp_adjacency_t adjacencies[count]
Definition: vpe.api:3026
#define REPLY_MACRO2(t, body)
Definition: api.c:155
int size
Definition: api.h:71
u8 as_u8[16]
Definition: ip6_packet.h:47
u64 as_u64[2]
Definition: ip6_packet.h:50
static void vl_api_set_ipfix_exporter_t_handler(vl_api_set_ipfix_exporter_t *mp)
Definition: api.c:8006
void fib_entry_get_prefix(fib_node_index_t fib_entry_index, fib_prefix_t *pfx)
Definition: fib_entry.c:1476
uword * table_id_by_vni
Definition: control.h:138
static void vl_api_ip_neighbor_add_del_t_handler(vl_api_ip_neighbor_add_del_t *mp, vlib_main_t *vm)
Definition: api.c:2629
IPsec: Update Security Association keys.
Definition: vpe.api:3658
void send_oam_event(oam_target_t *t)
Definition: api.c:3028
static int arp_change_data_callback(u32 pool_index, u8 *new_mac, u32 sw_if_index, u32 address)
Definition: api.c:6443
OAM event structure.
Definition: vpe.api:811
static void vl_api_vnet_get_summary_stats_t_handler(vl_api_vnet_get_summary_stats_t *mp)
Definition: api.c:3066
#define VALIDATE_SW_IF_INDEX(mp)
Definition: api.c:219
void lisp_gpe_tenant_l3_iface_unlock(u32 vni)
Release the lock held on the tenant&#39;s L3 interface.
Reply for gpe_iface add/del.
Definition: vpe.api:2650
static void send_l2fib_table_entry(vpe_api_main_t *am, unix_shared_memory_queue_t *q, l2fib_entry_key_t *l2fe_key, l2fib_entry_result_t *l2fe_res, u32 context)
Definition: api.c:4560
Fixed length block allocator.
static void vl_api_cli_inband_t_handler(vl_api_cli_inband_t *mp)
Definition: api.c:3759
static void vl_api_create_loopback_t_handler(vl_api_create_loopback_t *mp)
Definition: api.c:3640
L2TP tunnel set cookies response.
Definition: vpe.api:1948
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
u8 is_add
Definition: vpe.api:3538
clib_error_t * vnet_lisp_gpe_enable_disable(vnet_lisp_gpe_enable_disable_args_t *a)
Enable/disable LISP-GPE.
Definition: lisp_gpe.c:183
#define NULL
Definition: clib.h:55
static void vl_api_sw_interface_details_t_handler(vl_api_sw_interface_details_t *mp)
Definition: api.c:2757
static void vl_api_bridge_domain_details_t_handler(vl_api_bridge_domain_details_t *mp)
Definition: api.c:1917
static void vl_api_policer_add_del_t_handler(vl_api_policer_add_del_t *mp)
Definition: api.c:7309
iOAM disable
Definition: vpe.api:4159
Reply to IPFIX classify tables dump request.
Definition: vpe.api:4847
int ip6_neighbor_ra_prefix(vlib_main_t *vm, u32 sw_if_index, ip6_address_t *prefix_addr, u8 prefix_len, u8 use_default, u32 val_lifetime, u32 pref_lifetime, u8 no_advertise, u8 off_link, u8 no_autoconfig, u8 no_onlink, u8 is_no)
static void vl_api_sw_interface_ip6_enable_disable_t_handler(vl_api_sw_interface_ip6_enable_disable_t *mp, vlib_main_t *vm)
Definition: api.c:3483
u32 index
Definition: node.h:237
vlib_counter_t * maxi
Shared wide counter pairs.
Definition: counter.h:215
#define L2_FLOOD
Definition: l2_bd.h:98
Request for a single block of summary stats.
Definition: vpe.api:785
static void vl_api_ipfix_classify_table_dump_t_handler(vl_api_ipfix_classify_table_dump_t *mp)
Definition: api.c:8281
static void vl_api_classify_add_del_table_t_handler(vl_api_classify_add_del_table_t *mp)
Definition: api.c:3982
Set max allowed ARP or ip6 neighbor entries request.
Definition: vpe.api:1270
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:182
u32 * tunnel_index_by_sw_if_index
Mapping from sw_if_index to tunnel index.
Definition: vxlan_gpe.h:159
IP unicast adjacency.
Definition: lookup.h:174
locator_t * locator_pool
Definition: control.h:92
int vnet_add_del_ip6_nd_change_event(vnet_main_t *vnm, void *data_callback, u32 pid, void *address_arg, uword node_index, uword type_opaque, uword data, int is_add)
static void vl_api_l2tpv3_create_tunnel_t_handler(vl_api_l2tpv3_create_tunnel_t *mp)
Definition: api.c:4757
L2 bridge domain sw interface operational state response.
Definition: vpe.api:3381
ip6_address_t our_address
Definition: l2tp.h:28
static uword link_state_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: api.c:565
u64 map_error_counter_get(u32 node_index, map_error_t map_error)
Definition: map.c:984
u32 hw_if_index
Definition: mpls.h:44
static void lisp_fid_put_api(u8 *dst, fid_address_t *src, u8 *prefix_length)
Definition: api.c:5872
LISP-GPE global state.
Definition: lisp_gpe.h:89
Reply for IPsec: Add/delete Security Policy Database entry.
Definition: vpe.api:3569
#define L2_FWD
Definition: l2_bd.h:97
ip46_address_t dst
Definition: vxlan.h:72
VXLAN GPE definitions.
u32 vnet_config_del_feature(vlib_main_t *vm, vnet_config_main_t *cm, u32 config_string_heap_index, u32 feature_index, void *feature_config, u32 n_feature_config_bytes)
Definition: config.c:300
uword * stream_index_by_name
Definition: pg.h:316
clib_error_t * ip4_set_arp_limit(u32 arp_limit)
Definition: arp.c:1420
u8 vnet_lisp_get_map_request_mode(void)
Definition: control.c:35
u8 tap_name[64]
Definition: vpe.api:286
static void vl_api_classify_set_interface_l2_tables_t_handler(vl_api_classify_set_interface_l2_tables_t *mp)
Definition: api.c:4076
ipsec_integ_alg_t integ_alg
Definition: ipsec.h:82
u32 l2fib_del_entry(u64 mac, u32 bd_index)
Delete an entry from the l2fib.
Definition: l2_fib.c:596
u32 mpls_label_t
A label value only, i.e.
Definition: packet.h:24
static int ip6_reset_fib_t_handler(vl_api_reset_fib_t *mp)
Definition: api.c:3194
static clib_error_t * show_ip_arp_nd_events_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: api.c:9039
static void vl_api_sw_interface_dump_t_handler(vl_api_sw_interface_dump_t *mp)
Definition: api.c:2987
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define ip_prefix_len(_a)
Definition: lisp_types.h:60
u32 outer_fib_index
The FIB in which the src.dst address are present.
Definition: gre.h:70
vlib_main_t * vlib_main
Definition: stats.h:62
static void vl_api_dhcp_proxy_config_t_handler(vl_api_dhcp_proxy_config_t *mp)
Definition: api.c:3354
vnet_main_t ** vnet_mains
Definition: vnet.h:92
void vl_api_mpls_ip_bind_unbind_t_handler(vl_api_mpls_ip_bind_unbind_t *mp)
Definition: api.c:1487
static void send_mpls_eth_tunnel_entry(vpe_api_main_t *am, unix_shared_memory_queue_t *q, mpls_eth_tunnel_t *et, u32 index, u32 context)
Definition: api.c:7557
IPsec: Add/delete Security Policy Database entry.
Definition: vpe.api:3534
Classify add / del session request.
Definition: vpe.api:1734
#define BAD_TX_SW_IF_INDEX_LABEL
Definition: api.c:261
IPFIX exporter dump request.
Definition: vpe.api:4738
add_epi add_epi sub
Definition: vector_sse2.h:289
static void vl_api_ikev2_profile_set_id_t_handler(vl_api_ikev2_profile_set_id_t *mp)
Definition: api.c:6869
Reply for lisp_add_del_map_request_itr_rlocs.
Definition: vpe.api:2834
int ip6_sr_add_del_policy(ip6_sr_add_del_policy_args_t *a)
Add or Delete a Segment Routing policy.
Definition: sr.c:1434
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:482
int vnet_interface_name_renumber(u32 sw_if_index, u32 new_show_dev_instance)
Definition: interface.c:1177
static void map_domain_counter_unlock(map_main_t *mm)
Definition: map.h:552
LISP locator_set status.
Definition: vpe.api:2906
static void vl_api_ioam_disable_t_handler(vl_api_ioam_disable_t *mp)
Definition: api.c:7248
u32 vni
Definition: vpe.api:2543
static void vl_api_lisp_add_del_adjacency_t_handler(vl_api_lisp_add_del_adjacency_t *mp)
Definition: api.c:5716
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
struct l2fib_entry_result_t::@182::@184 fields
Combined counter to hold both packets and byte differences.
Definition: counter.h:164
LISP-GPE definitions.
u8 is_tunnel
Definition: ipsec.h:89
struct _vlib_node_registration vlib_node_registration_t
Delete netmap response.
Definition: vpe.api:4458
void vnet_l2_input_classify_enable_disable(u32 sw_if_index, int enable_disable)
Enable/disable l2 input classification on a specific interface.
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:521
Dump tap interfaces request.
Definition: vpe.api:327
void fib_table_entry_path_remove(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_protocol_t next_hop_proto, const ip46_address_t *next_hop, u32 next_hop_sw_if_index, u32 next_hop_fib_index, u32 next_hop_weight, fib_route_path_flags_t path_flags)
remove one path to an entry (aka route) in the FIB.
Definition: fib_table.c:624
static void vl_api_ipsec_gre_add_del_tunnel_t_handler(vl_api_ipsec_gre_add_del_tunnel_t *mp)
Definition: api.c:8527
lisp_gpe_fwd_entry_key_t * key
The Entry&#39;s key: {lEID,r-EID,vni}.
l2_flood_member_t * members
Definition: l2_bd.h:71
ip4_address_t src_address
Definition: flow_report.h:96
u8 cmd[length]
Definition: vpe.api:1242
static void vl_api_sr_multicast_map_add_del_t_handler(vl_api_sr_multicast_map_add_del_t *mp)
Definition: api.c:3932
ip6_address_t * tags
"Tag" list, aka segments inserted at the end of the list, past last_seg
Definition: sr.h:111
u32 hw_if_index
Definition: pg.h:363
#define hash_set_mem(h, key, value)
Definition: hash.h:274
ip_lookup_main_t lookup_main
Definition: ip4.h:96
static void vl_api_ikev2_profile_set_ts_t_handler(vl_api_ikev2_profile_set_ts_t *mp)
Definition: api.c:6893
void vl_set_global_memory_baseva(u64 baseva)
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
Reply to sw_interface_clear_stats.
Definition: vpe.api:4119
uword * sub_interface_sw_if_index_by_id
Definition: interface.h:423
vlib_main_t * vlib_main
Definition: api.c:511
cop: interface enable/disable junk filtration reply
Definition: vpe.api:4035
u32 loc_num
Definition: vpe.api:2545
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
Definition: ip4.h:104
static void vl_api_l2_fib_table_dump_t_handler(vl_api_l2_fib_table_dump_t *mp)
Definition: api.c:4585
struct rte_sched_port * hqos
Definition: dpdk.h:183
Request for lisp_eid_table_map_details.
Definition: vpe.api:3057
static vlib_node_registration_t link_state_process_node
(constructor) VLIB_REGISTER_NODE (link_state_process_node)
Definition: api.c:630
static void dhcpv6_proxy_config_2(vl_api_dhcp_proxy_config_2_t *mp)
Definition: api.c:3314
static void send_mpls_fib_encap_details(vpe_api_main_t *am, unix_shared_memory_queue_t *q, show_mpls_fib_t *s, u32 context)
Definition: api.c:7705
vlib_node_registration_t ip4_map_node
(constructor) VLIB_REGISTER_NODE (ip4_map_node)
Definition: ip4_map.c:762
static void vl_api_bridge_domain_add_del_t_handler(vl_api_bridge_domain_add_del_t *mp)
Definition: api.c:1864
Add/Delete classification table request.
Definition: vpe.api:1693
vl_api_ip4_arp_event_t * arp_events
Definition: api.c:505
unformat_function_t unformat_vnet_sw_interface
IPv6 router advertisement config request.
Definition: vpe.api:1008
Reply for tap delete request.
Definition: vpe.api:320
L2 bridge domain request operational state details.
Definition: vpe.api:3347
int mpls_dest_cmp(void *a1, void *a2)
Definition: mpls.c:395
void vl_set_api_pvt_heap_size(u64 size)
#define clib_error_report(e)
Definition: error.h:125
Dump MPLS fib table.
Definition: vpe.api:428
Set bridge domain ip to mac entry response.
Definition: vpe.api:1675
u8 * vlib_node_serialize(vlib_node_main_t *nm, u8 *vector, u32 max_threads, int include_nexts, int include_stats)
Reply for classify get table IDs request.
Definition: vpe.api:4591
#define IP6_ND_EVENT
static void vl_api_ip_source_and_port_range_check_interface_add_del_t_handler(vl_api_ip_source_and_port_range_check_interface_add_del_t *mp)
Definition: api.c:8473
#define VNET_HW_INTERFACE_FLAG_LINK_UP
Definition: interface.h:348
static void vl_api_map_summary_stats_t_handler(vl_api_map_summary_stats_t *mp)
Definition: api.c:7068
static void vl_api_sw_if_l2tpv3_tunnel_dump_t_handler(vl_api_sw_if_l2tpv3_tunnel_dump_t *mp)
Definition: api.c:4448
uword * mpls_encap_by_fib_and_dest
Definition: mpls.h:111
static void dhcpv6_proxy_config(vl_api_dhcp_proxy_config_t *mp)
Definition: api.c:3282
u8 policy
Definition: vpe.api:3560
static void vl_api_classify_set_interface_ip_table_t_handler(vl_api_classify_set_interface_ip_table_t *mp)
Definition: api.c:4053
static void vl_api_flow_classify_set_interface_t_handler(vl_api_flow_classify_set_interface_t *mp)
Definition: api.c:8685
Enable / disable packet generator request.
Definition: vpe.api:4989
Request for gpe tunnel summary status.
Definition: vpe.api:3108
int vnet_vxlan_gpe_add_del_tunnel(vnet_vxlan_gpe_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
Add or Del a VXLAN GPE tunnel.
Definition: vxlan_gpe.c:269
void ip_address_set(ip_address_t *dst, const void *src, u8 version)
Definition: lisp_types.c:721
Definition: l2_fib.h:54
vhost-user interface create request
Definition: vpe.api:2159
static_always_inline u8 bd_feature_uu_flood(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:150
typedef CLIB_PACKED(struct{ip4_address_t address;u32 address_length:6;u32 index:26;})
Definition: api.c:3117
u8 rmt_locs[loc_num]
Definition: vpe.api:2547
u16 remote_port_stop
Definition: vpe.api:3555
Reply for locator add/del.
Definition: vpe.api:2473
TAP CLI interface details struct.
Definition: tapcli.h:41
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:200
format_function_t format_ip4_address
Definition: format.h:78
u8 crypto_key[128]
Definition: vpe.api:3620
static void vl_api_sr_policy_add_del_t_handler(vl_api_sr_policy_add_del_t *mp)
Definition: api.c:3878
static void vl_api_reset_fib_t_handler(vl_api_reset_fib_t *mp)
Definition: api.c:3251
Add/del policer response.
Definition: vpe.api:4275
#define ip_prefix_version(_a)
Definition: lisp_types.h:59
u64 remote_cookie
Definition: l2tp.h:33
LISP adjacency.
Definition: vpe.api:3008
Delete netmap.
Definition: vpe.api:4446
L2 interface ethernet flow point filtering response.
Definition: vpe.api:2012
void fib_table_entry_local_label_remove(u32 fib_index, const fib_prefix_t *prefix, mpls_label_t label)
remove a MPLS local label for the prefix/route.
Definition: fib_table.c:855
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
Definition: node_funcs.h:1063
static void vl_api_interface_name_renumber_t_handler(vl_api_interface_name_renumber_t *mp)
Definition: api.c:6426
Create netmap response.
Definition: vpe.api:4435
trace_cfg_t * api_trace_cfg
Definition: api.h:128
#define fid_addr_mac(_a)
Definition: lisp_types.h:113
static void vl_api_proxy_arp_add_del_t_handler(vl_api_proxy_arp_add_del_t *mp)
Definition: api.c:2560
add or delete gpe_iface
Definition: vpe.api:2636
#define VNET_HW_INTERFACE_FLAG_DUPLEX_MASK
Definition: interface.h:353
u8 crypto_key[128]
Definition: ipsec.h:80
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
int vnet_create_loopback_interface(u32 *sw_if_indexp, u8 *mac_address)
Definition: interface.c:417
int vnet_lisp_set_map_request_mode(u8 mode)
Definition: control.c:1442
static void vl_api_lisp_eid_table_vni_dump_t_handler(vl_api_lisp_eid_table_vni_dump_t *mp)
Definition: api.c:6283
static void vl_api_map_del_domain_t_handler(vl_api_map_del_domain_t *mp)
Definition: api.c:6959
u32 * tunnel_index_by_sw_if_index
Definition: gre.h:114
Reply for show_lisp_map_request_mode.
Definition: vpe.api:2720
int vnet_lisp_add_del_adjacency(vnet_lisp_add_del_adjacency_args_t *a)
Definition: control.c:1195
u32 custom_dev_instance
Definition: vpe.api:289
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
ip4_address_t ipfix_collector
Definition: flow_report.h:94
Request for map resolver summary status.
Definition: vpe.api:3130
ip6_address_t client_address
Definition: l2tp.h:29
static void vl_api_lisp_locator_dump_t_handler(vl_api_lisp_locator_dump_t *mp)
Definition: api.c:5768
Delete sub interface response.
Definition: vpe.api:5147
u8 protocol
Definition: vpe.api:3552
Adjacency to drop this packet.
Definition: lookup.h:62
Interface bridge mode response.
Definition: vpe.api:1556
u32 spi
Definition: ipsec.h:75
u32 index
Definition: ip4.h:59
port_range_t lport
Definition: ipsec.h:161
uword value[0]
Definition: hash.h:164
static u8 fid_type_to_api_type(fid_address_t *fid)
Definition: api.c:5899
int ip6_sr_add_del_multicastmap(ip6_sr_add_del_multicastmap_args_t *a)
Add or Delete a mapping of IP6 multicast address to Segment Routing policy.
Definition: sr.c:1686
IPv6 segment routing tunnel add / del response.
Definition: vpe.api:1352
Get list of map domains.
Definition: vpe.api:3948
map_resolver_t * map_resolvers
Definition: control.h:124
static vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)
ip_prefix_t ippref
Definition: lisp_types.h:104
ip4_address_t tunnel_dst
The tunnel&#39;s destination/remote address.
Definition: gre.h:66
static void vl_api_ip_address_dump_t_handler(vl_api_ip_address_dump_t *mp)
Definition: api.c:4380
fib_node_index_t fib_table_entry_path_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, fib_protocol_t next_hop_proto, const ip46_address_t *next_hop, u32 next_hop_sw_if_index, u32 next_hop_fib_index, u32 next_hop_weight, mpls_label_t next_hop_label, fib_route_path_flags_t path_flags)
Add one path to an entry (aka route) in the FIB.
Definition: fib_table.c:487
static f64 vlib_last_vector_length_per_node(vlib_main_t *vm)
Definition: main.h:273
OAM add / del target response.
Definition: vpe.api:863
static locator_t * unformat_lisp_locs(void *rmt_locs, u32 rloc_num)
Definition: api.c:5480
api_main_t api_main
Definition: api.h:185
Dump ipsec gre tunnel table.
Definition: vpe.api:5109
static void vl_api_pg_enable_disable_t_handler(vl_api_pg_enable_disable_t *mp)
Definition: api.c:8359
ip6_address_t * segments
segment list, when inserting an ip6 SR header
Definition: sr.h:105
dpo_proto_t fp_payload_proto
This protocol determines the payload protocol of packets that will be forwarded by this entry once th...
Definition: fib_types.h:182
add or delete LISP adjacency adjacency
Definition: vpe.api:2792
ipsec_gre_tunnel_t * tunnels
pool of tunnel instances
Definition: ipsec_gre.h:68
u8 pcap_file_name[pcap_name_length]
Definition: vpe.api:4970
#define VNET_HW_INTERFACE_FLAG_SPEED_MASK
Definition: interface.h:365
static void send_lisp_gpe_fwd_entry_details(lisp_gpe_fwd_entry_t *lfe, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:6052
u32 bd_id
Definition: vpe.api:2352
PacketGenerator capture packets on given interface request.
Definition: vpe.api:4962
Create host-interface response.
Definition: vpe.api:4197
u8 mac_address[6]
Definition: vpe.api:287
u32 spd_id
Definition: vpe.api:3540
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
static void vl_api_ipsec_gre_tunnel_dump_t_handler(vl_api_ipsec_gre_tunnel_dump_t *mp)
Definition: api.c:8581
L2 bridge domain operational state response.
Definition: vpe.api:3363
u8 local_address_start[16]
Definition: vpe.api:3549
u32 sw_if_index
Definition: gre.h:72
static void dhcpv4_proxy_config(vl_api_dhcp_proxy_config_t *mp)
Definition: api.c:3266
static void vl_api_sw_interface_ip6nd_ra_prefix_t_handler(vl_api_sw_interface_ip6nd_ra_prefix_t *mp, vlib_main_t *vm)
Definition: api.c:3455
Reply for interface events registration.
Definition: vpe.api:212
static void vl_api_l2fib_add_del_t_handler(vl_api_l2fib_add_del_t *mp)
Definition: api.c:2012
u8 integ_key[128]
Definition: ipsec.h:84
static uword resolver_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: api.c:825
static void vl_api_create_vhost_user_if_t_handler(vl_api_create_vhost_user_if_t *mp)
Definition: api.c:4194
Get node index using name request.
Definition: vpe.api:1829
l2t_main_t l2t_main
Definition: l2tp.c:26
int bd_delete_bd_index(bd_main_t *bdm, u32 bd_id)
Delete a bridge domain.
Definition: l2_bd.c:96
void vl_msg_api_set_handlers(int msg_id, char *msg_name, void *handler, void *cleanup, void *endian, void *print, int msg_size, int traced)
Definition: api_shared.c:659
Proxy ARP add / del request.
Definition: vpe.api:613
u8 is_tunnel
Definition: vpe.api:3628
static void vl_api_ipsec_spd_add_del_entry_t_handler(vl_api_ipsec_spd_add_del_entry_t *mp)
Definition: api.c:6690
#define VNET_SW_INTERFACE_FLAG_PROXY_ARP
Definition: interface.h:495
void vlib_clear_combined_counters(vlib_combined_counter_main_t *cm)
Clear a collection of combined counters.
Definition: counter.c:67
Clear interface statistics.
Definition: vpe.api:4108
TAPCLI definitions.
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:348
static void vl_api_map_add_del_rule_t_handler(vl_api_map_add_del_rule_t *mp)
Definition: api.c:6970
u8 crypto_key_length
Definition: vpe.api:3619
static void vl_api_get_node_graph_t_handler(vl_api_get_node_graph_t *mp)
Definition: api.c:7192
void vl_set_global_memory_size(u64 size)
u32 context
Definition: vpe.api:2351
u32 sad_id
Definition: vpe.api:3612
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:111
Reply for add / del ipsec gre tunnel request.
Definition: vpe.api:5098
ip46_address_t local
tunnel local address
Definition: vxlan_gpe.h:98
static void vl_api_af_packet_delete_t_handler(vl_api_af_packet_delete_t *mp)
Definition: api.c:7291
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type...
Definition: node_funcs.h:527
DHCP Proxy config 2 add / del request.
Definition: vpe.api:1873
static void vl_api_mpls_fib_details_t_handler(vl_api_mpls_fib_details_t *mp)
Definition: api.c:7631
static void * svm_push_data_heap(svm_region_t *rp)
Definition: svm.h:182
Classify sessions dump request.
Definition: vpe.api:4673
void fib_table_entry_special_remove(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Remove a &#39;special&#39; entry from the FIB.
Definition: fib_table.c:399
static void vl_api_lisp_gpe_tunnel_dump_t_handler(vl_api_lisp_gpe_tunnel_dump_t *mp)
Definition: api.c:6079
Reply for IPsec: Update Security Association keys.
Definition: vpe.api:3677
static int arp_change_delete_callback(u32 pool_index, u8 *notused)
Definition: api.c:6519
#define MODE_L2_BRIDGE
Definition: l2_input.h:219
u32 * classify_table_index_by_sw_if_index[FLOW_CLASSIFY_N_TABLES]
Definition: flow_classify.h:36
static void vl_api_l2_fib_clear_table_t_handler(vl_api_l2_fib_clear_table_t *mp)
Definition: api.c:4119
void vl_set_memory_uid(int uid)
Reply for gpe enable/disable.
Definition: vpe.api:2603
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
Definition: vec.h:270
vlib_combined_counter_main_t * combined_sw_if_counters
Definition: interface.h:577
vlib_combined_counter_main_t * domain_counters
Definition: map.h:207
static uword ip6_address_is_equal(ip6_address_t *a, ip6_address_t *b)
Definition: ip6_packet.h:176
ipsec_gre_main_t ipsec_gre_main
Definition: ipsec_gre.c:25
clib_error_t * ikev2_set_profile_auth(vlib_main_t *vm, u8 *name, u8 auth_method, u8 *auth_data, u8 data_hex_format)
Definition: ikev2.c:2038
Recursion constraint of via a host prefix.
Definition: fib_types.h:259
static void vl_api_lisp_add_del_local_eid_t_handler(vl_api_lisp_add_del_local_eid_t *mp)
Definition: api.c:5390
Set interface source and L4 port-range request.
Definition: vpe.api:5052
Reply for the vlan subinterface create request.
Definition: vpe.api:363
u8 is_add
Definition: lisp_gpe.h:180
unsigned long long u32x4
Definition: ixge.c:28
int dhcpv6_proxy_set_vss(u32 tbl_id, u32 oui, u32 fib_id, int is_del)
Definition: proxy_node.c:865
u8 use_esn
Definition: ipsec.h:86
vnet_flow_rewrite_callback_t * rewrite_callback
Definition: flow_report.h:125
int i32
Definition: types.h:81
#define hash_foreach(key_var, value_var, h, body)
Definition: hash.h:418
int vl_api_memclnt_delete_callback(u32 client_index)
Definition: api.c:531
u32 feature_bitmap
Definition: vpe.api:1608
#define clib_error_return_fatal(e, args...)
Definition: error.h:117
#define REPLY_MACRO(t)
Definition: api.c:139
#define gid_address_sd_src(_a)
Definition: lisp_types.h:229
u8 * name
optional name argument - for referencing SR tunnel/policy by name
Definition: sr.h:99
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static vnet_sw_interface_t * vnet_get_sup_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
static clib_error_t * vpe_api_hookup(vlib_main_t *vm)
Definition: api.c:8789
static_always_inline u8 bd_feature_arp_term(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:170
void fib_table_flush(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Flush all entries from a table for the source.
Definition: fib_table.c:1083
Aggregrate type for a prefix.
Definition: fib_types.h:149
int ip6_interface_enabled(vlib_main_t *vm, u32 sw_if_index)
#define L2_UU_FLOOD
Definition: l2_bd.h:99
static int add_del_route_t_handler(u8 is_multipath, u8 is_add, u8 is_drop, u8 is_unreach, u8 is_prohibit, u8 is_local, u8 is_classify, u32 classify_table_index, u8 is_resolve_host, u8 is_resolve_attached, u32 fib_index, const fib_prefix_t *prefix, u8 next_hop_proto_is_ip4, const ip46_address_t *next_hop, u32 next_hop_sw_if_index, u8 next_hop_fib_index, u32 next_hop_weight, u32 next_hop_out_label)
Definition: api.c:1033
u16 start
Definition: ipsec.h:109
svm_region_t * vlib_rp
Definition: api.h:130
static void vl_api_pg_capture_t_handler(vl_api_pg_capture_t *mp)
Definition: api.c:8315
static vlib_node_registration_t vpe_resolver_process_node
(constructor) VLIB_REGISTER_NODE (vpe_resolver_process_node)
Definition: api.c:515
int ipsec_add_del_policy(vlib_main_t *vm, ipsec_policy_t *policy, int is_add)
Definition: ipsec.c:171
static void vl_api_ikev2_set_local_key_t_handler(vl_api_ikev2_set_local_key_t *mp)
Definition: api.c:6916
static void vl_api_mpls_ethernet_add_del_tunnel_2_t_handler(vl_api_mpls_ethernet_add_del_tunnel_2_t *mp)
Definition: api.c:2524
Get LISP map request itr rlocs status.
Definition: vpe.api:3163
get_node_graph_reply
Definition: vpe.api:4096
ip6_address_t * rules
Definition: map.h:92
DPDK interface HQoS subport parameters set reply.
Definition: vpe.api:5203
add or delete map request itr rlocs
Definition: vpe.api:2821
Reply for add / del encapsulation request.
Definition: vpe.api:573
Reply for MPLS Ethernet add / delete tunnel request.
Definition: vpe.api:1461
#define clib_warning(format, args...)
Definition: error.h:59
IPv6 interface enable / disable request.
Definition: vpe.api:1086
Delete host-interface.
Definition: vpe.api:4209
unsigned long u64
Definition: types.h:89
u8 rmt_len
Definition: vpe.api:2541
clib_error_t * ip6_set_neighbor_limit(u32 neighbor_limit)
Set/unset input ACL interface.
Definition: vpe.api:3431
int vnet_l2_output_classify_set_tables(u32 sw_if_index, u32 ip4_table_index, u32 ip6_table_index, u32 other_table_index)
Set l2 per-protocol, per-interface output classification tables.
static void inband_cli_output(uword arg, u8 *buffer, uword buffer_bytes)
Definition: api.c:3747
static vlib_cli_command_t show_ip_arp_nd_events
(constructor) VLIB_CLI_COMMAND (show_ip_arp_nd_events)
Definition: api.c:9068
DPDK interface HQoS pipe profile set reply.
Definition: vpe.api:5173
enum fib_route_path_flags_t_ fib_route_path_flags_t
Path flags from the control plane.
int vnet_lisp_eid_table_map(u32 vni, u32 dp_id, u8 is_l2, u8 is_add)
Definition: control.c:767
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
Definition: vec.h:201
void unformat_init_string(unformat_input_t *input, char *string, int string_len)
Definition: unformat.c:1017
uword * bd_id_by_vni
Definition: control.h:142
#define ip_addr_v4(_a)
Definition: lisp_types.h:41
IKEv2: Set IKEv2 profile local/remote identification.
Definition: vpe.api:3751
u8 * format_ipsec_integ_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:90
Reply for classify table id by interface index request.
Definition: vpe.api:4619
u32 lisp_gpe_tenant_l2_iface_add_or_lock(u32 vni, u32 bd_id)
Add/create and lock a new or find and lock the existing L2 interface for the tenant.
Initialize a new tap interface with the given paramters.
Definition: vpe.api:249
IKEv2: Set IKEv2 profile traffic selector parameters.
Definition: vpe.api:3785
int l2tpv3_interface_enable_disable(vnet_main_t *vnm, u32 sw_if_index, int enable_disable)
Definition: l2tp.c:600
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
Definition: fib_table.c:933
A collection of simple counters.
Definition: counter.h:59
fib_protocol_t dpo_proto_to_fib(dpo_proto_t dpo_proto)
Definition: fib_types.c:238
static lisp_cp_main_t * vnet_lisp_cp_get_main()
Definition: control.h:174
u16 fp_len
The mask length.
Definition: fib_types.h:153
int vnet_set_ip4_classify_intfc(vlib_main_t *vm, u32 sw_if_index, u32 table_index)
Definition: ip4_forward.c:3263
dp_address_t rmt
Reply to IPFIX exporter dump request.
Definition: vpe.api:4754
static void vl_api_sw_interface_vhost_user_details_t_handler(vl_api_sw_interface_vhost_user_details_t *mp)
Definition: api.c:4259
DPDK interface HQoS tctbl entry set reply.
Definition: vpe.api:5229
u8 is_add
Definition: vpe.api:2537
uword * bd_index_by_bd_id
Definition: l2_bd.h:27
int fib_entry_cmp_for_sort(void *i1, void *i2)
Definition: fib_entry.c:1441
u32 * classify_table_index_by_sw_if_index[POLICER_CLASSIFY_N_TABLES]
static void vl_api_delete_loopback_t_handler(vl_api_delete_loopback_t *mp)
Definition: api.c:3657
int vnet_arp_unset_ip4_over_ethernet(vnet_main_t *vnm, u32 sw_if_index, void *a_arg)
Control Plane hook to remove an ARP entry.
Definition: arp.c:1432
dpdk_device_hqos_per_worker_thread_t * hqos_wt
Definition: dpdk.h:240
i32 priority
Definition: vpe.api:3541
Definition: lisp_gpe.h:178
u32 hw_if_index
Definition: l2tp.h:38
Reply for tap connect request.
Definition: vpe.api:265
#define REPLY_MACRO4(t, n, body)
Definition: api.c:187
u8 * pcap_file_name
Definition: pg.h:366
flow_classify_main_t flow_classify_main
Definition: flow_classify.h:45
stats_main_t stats_main
Definition: stats.c:24
u32 set_int_l2_mode(vlib_main_t *vm, vnet_main_t *vnet_main, u32 mode, u32 sw_if_index, u32 bd_index, u32 bvi, u32 shg, u32 xc_sw_if_index)
Set the subinterface to run in l2 or l3 mode.
Definition: l2_input.c:555
clib_error_t * ip6_probe_neighbor(vlib_main_t *vm, ip6_address_t *dst, u32 sw_if_index)
Definition: ip6_forward.c:1749
Classify add / del session response.
Definition: vpe.api:1750
#define ip_addr_version(_a)
Definition: lisp_types.h:43
int map_add_del_psid(u32 map_domain_index, u16 psid, ip6_address_t *tep, u8 is_add)
Definition: map.c:395
l2tpv3 tunnel interface create response
Definition: vpe.api:1928
static void vl_api_bridge_domain_sw_if_details_t_handler(vl_api_bridge_domain_sw_if_details_t *mp)
Definition: api.c:1924
u32 sw_if_index
hardware interface index
Definition: ipsec_gre.h:58
u32 remote_sa_id
remote IPSec SA id
Definition: ipsec_gre.h:57
Dump l2 fib (aka bridge domain) table.
Definition: vpe.api:2364
IPSec-GRE tunnel add/del arguments.
Definition: ipsec_gre.h:93
Definition: fib_entry.h:215
Configure IP source and L4 port-range check.
Definition: vpe.api:5021
Interface set vpath response.
Definition: vpe.api:1428
static void vl_api_policer_classify_set_interface_t_handler(vl_api_policer_classify_set_interface_t *mp)
Definition: api.c:7444
uword * hw_interface_by_name
Definition: interface.h:557
clib_error_t * vnet_lisp_enable_disable(u8 is_enable)
Definition: control.c:2173
Delete tap interface.
Definition: vpe.api:309
u8 local_address_stop[16]
Definition: vpe.api:3550
void vl_api_ip_add_del_route_t_handler(vl_api_ip_add_del_route_t *mp)
Definition: api.c:1396
u32 lsa
local IPSec SA id
Definition: ipsec_gre.h:99
clib_error_t * ip4_add_del_interface_address(vlib_main_t *vm, u32 sw_if_index, ip4_address_t *address, u32 address_length, u32 is_del)
Definition: ip4_forward.c:847
static_always_inline u8 bd_feature_flood(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:143
clib_error_t * ip4_probe_neighbor(vlib_main_t *vm, ip4_address_t *dst, u32 sw_if_index)
Definition: ip4_forward.c:2107
Delete MAP domain.
Definition: vpe.api:3900
vnet_api_error_t api_errno
Definition: vnet.h:86
void dsunlock(stats_main_t *sm)
Definition: stats.c:91
int vnet_set_ip6_ethernet_neighbor(vlib_main_t *vm, u32 sw_if_index, ip6_address_t *a, u8 *link_layer_address, uword n_bytes_link_layer_address, int is_static)
Definition: ip6_neighbor.c:526
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:138
Reply for gpe enable/disable.
Definition: vpe.api:2625
ip4_address_t intfc_address
Definition: mpls.h:39
void vl_set_memory_root_path(char *root_path)
u32 gid_dictionary_lookup(gid_dictionary_t *db, gid_address_t *key)
Args required for add/del tunnel.
Definition: sr.h:89
flow_report_main_t flow_report_main
Definition: flow_report.c:21
#define hash_get(h, key)
Definition: hash.h:248
vl_api_ip_add_del_route_t r
Definition: api.c:486
void ip_address_copy_addr(void *dst, const ip_address_t *src)
Definition: lisp_types.c:715
clib_error_t * ikev2_set_profile_id(vlib_main_t *vm, u8 *name, u8 id_type, u8 *data, int is_local)
Definition: ikev2.c:2070
Set L2 flags request !!! TODO - need more info, feature bits in l2_input.h.
Definition: vpe.api:1602
format_function_t format_vnet_sw_interface_name
Definition: fib_entry.h:219
#define VNET_HW_INTERFACE_FLAG_DUPLEX_SHIFT
Definition: interface.h:350
u8 is_del
Delete the tunnnel?
Definition: sr.h:120
Reply for lisp_pitr_set_locator_set.
Definition: vpe.api:2674
int vnet_lisp_pitr_set_locator_set(u8 *locator_set_name, u8 is_add)
Definition: control.c:1563
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:369
static void vlib_zero_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
Clear a combined counter Clears the set of per-thread u16 counters, and the shared vlib_counter_t...
Definition: counter.h:321
union sse2_qos_pol_cfg_params_st_::@224 rb
static void vl_api_lisp_map_request_mode_t_handler(vl_api_lisp_map_request_mode_t *mp)
Definition: api.c:5624
vnet_sub_interface_t sub
Definition: interface.h:522
static void vl_api_ikev2_profile_set_auth_t_handler(vl_api_ikev2_profile_set_auth_t *mp)
Definition: api.c:6845
static void dhcpv4_proxy_config_2(vl_api_dhcp_proxy_config_2_t *mp)
Definition: api.c:3297
L2 fib clear table request, clear all mac entries in the l2 fib.
Definition: vpe.api:1978
u64 mac
Definition: vpe.api:2353
Set/unset input ACL interface response.
Definition: vpe.api:3446
Flow classify operational state response.
Definition: vpe.api:4899
flow_report_classify_main_t flow_report_classify_main
void ip4_sw_interface_enable_disable(u32 sw_if_index, u32 is_enable)
Definition: ip4_forward.c:709
uword * fib_index_by_table_id
Hash table mapping table id to fib index.
Definition: ip4.h:111
Configure IP source and L4 port-range check reply.
Definition: vpe.api:5039
static void send_mpls_fib_details(vpe_api_main_t *am, unix_shared_memory_queue_t *q, u32 table_id, u32 label, u32 eos, u32 context)
Definition: api.c:7637
Args for mapping of multicast address to policy name.
Definition: sr.h:166
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
Definition: node_funcs.h:931
static void vl_api_lisp_add_del_locator_t_handler(vl_api_lisp_add_del_locator_t *mp)
Definition: api.c:5324
#define clib_error_get_code(err)
Definition: error.h:89
int vnet_classify_add_del_table(vnet_classify_main_t *cm, u8 *mask, u32 nbuckets, u32 memory_size, u32 skip, u32 match, u32 next_table_index, u32 miss_next_index, u32 *table_index, int is_add)
u8 is_tunnel_ip6
Definition: ipsec.h:90
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:172
static void vl_api_lisp_gpe_enable_disable_t_handler(vl_api_lisp_gpe_enable_disable_t *mp)
Definition: api.c:5553
index_t classify_dpo_create(dpo_proto_t proto, u32 classify_table_index)
Definition: classify_dpo.c:43
mpls eth tunnel operational state response
Definition: vpe.api:4529
static void vl_api_mpls_eth_tunnel_dump_t_handler(vl_api_mpls_eth_tunnel_dump_t *mp)
Definition: api.c:7597
#define VNET_HW_INTERFACE_FLAG_SPEED_SHIFT
Definition: interface.h:358
u32 entry_index
Definition: mpls.h:269
int vhost_user_delete_if(vnet_main_t *vnm, vlib_main_t *vm, u32 sw_if_index)
Definition: vhost-user.c:1799
#define gid_address_mac(_a)
Definition: lisp_types.h:221
Struct for VXLAN GPE tunnel.
Definition: vxlan_gpe.h:90
set LISP map-request mode.
Definition: vpe.api:2688
u32 local_session_id
Definition: l2tp.h:34
Set/unset l2 classification tables for an interface response.
Definition: vpe.api:1806
char * vpe_api_get_version(void)
Definition: version.c:88
static clib_error_t * vpe_api_init(vlib_main_t *vm)
Definition: api.c:8847
IPsec: Add/delete Security Policy Database.
Definition: vpe.api:3459
static void vl_api_control_ping_t_handler(vl_api_control_ping_t *mp)
Definition: api.c:3670
struct sse2_qos_pol_cfg_params_st_::@224::@225 kbps
#define ip_prefix_v6(_a)
Definition: lisp_types.h:62
IPv6 segment routing tunnel add / del request.
Definition: vpe.api:1330
IPv6 segment routing multicast map to policy add / del request.
Definition: vpe.api:1391
static void vl_api_sw_interface_ip6_set_link_local_address_t_handler(vl_api_sw_interface_ip6_set_link_local_address_t *mp, vlib_main_t *vm)
Definition: api.c:3516
int vnet_lisp_add_del_local_mapping(vnet_lisp_add_del_mapping_args_t *a, u32 *map_index_result)
Add/update/delete mapping to/in/from map-cache.
Definition: control.c:645
L2 FIB add entry response.
Definition: vpe.api:1589
mpls FIB table response
Definition: vpe.api:439
map_domain_t * domains
Definition: map.h:203
Request for LISP adjacencies.
Definition: vpe.api:3034
static void send_ip_details(vpe_api_main_t *am, unix_shared_memory_queue_t *q, u32 sw_if_index, u32 context)
Definition: api.c:4432
Set/unset l2 classification tables for an interface request.
Definition: vpe.api:1790
static void vl_api_lisp_eid_table_map_dump_t_handler(vl_api_lisp_eid_table_map_dump_t *mp)
Definition: api.c:6172
Add/Delete classification table response.
Definition: vpe.api:1715
Set L2 bits response.
Definition: vpe.api:1615
clib_error_t * set_ip6_link_local_address(vlib_main_t *vm, u32 sw_if_index, ip6_address_t *address, u8 address_length)
L2 bridge domain add or delete response.
Definition: vpe.api:3336
static void vl_api_classify_table_by_interface_t_handler(vl_api_classify_table_by_interface_t *mp)
Definition: api.c:7828
#define hash_free(h)
Definition: hash.h:286
Set bridge domain ip to mac entry request.
Definition: vpe.api:1660
void gid_address_free(gid_address_t *a)
Definition: lisp_types.c:671
int ipsec_add_del_sa(vlib_main_t *vm, ipsec_sa_t *new_sa, int is_add)
Definition: ipsec.c:430
static void vl_api_l2_flags_t_handler(vl_api_l2_flags_t *mp)
Definition: api.c:2072
sse2_qos_pol_action_params_st violate_action
Definition: xlate.h:153
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:214
#define IP4_ARP_EVENT
static void vl_api_bd_ip_mac_add_del_t_handler(vl_api_bd_ip_mac_add_del_t *mp)
Definition: api.c:2131
u8 stream_name[stream_name_length]
Definition: vpe.api:4995
vhost-user interface create response
Definition: vpe.api:2176
uword * sw_if_index_by_sup_and_sub
Definition: interface.h:571
vxlan_gpe_main_t vxlan_gpe_main
Definition: vxlan_gpe.c:24
u8 authoritative
Definition: lisp_types.h:299
add or delete lisp eid-table
Definition: vpe.api:2492
static void vl_api_mpls_fib_encap_dump_t_handler(vl_api_mpls_fib_encap_dump_t *mp)
Definition: api.c:7741
static void send_sw_interface_details(vpe_api_main_t *am, unix_shared_memory_queue_t *q, vnet_sw_interface_t *swif, u8 *interface_name, u32 context)
Definition: api.c:2866
int vnet_mpls_ethernet_add_del_tunnel(u8 *dst, ip4_address_t *intfc, u32 mask_width, u32 inner_fib_id, u32 tx_sw_if_index, u32 *tunnel_sw_if_index, u8 l2_only, u8 is_add)
Definition: interface.c:441
MPLS Route Add / del route.
Definition: vpe.api:393
static void vl_api_delete_vhost_user_if_t_handler(vl_api_delete_vhost_user_if_t *mp)
Definition: api.c:4233
struct vnet_sub_interface_t::@143::@144::@146 flags
VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION(link_up_down_function)
static void * vnet_rewrite_get_data_internal(vnet_rewrite_header_t *rw, int max_size)
Definition: rewrite.h:121
LISP adjacency reply.
Definition: vpe.api:3021
vxlan_main_t vxlan_main
Definition: vxlan.c:35
static void vlib_get_combined_counter(vlib_combined_counter_main_t *cm, u32 index, vlib_counter_t *result)
Get the value of a combined counter, never called in the speed path Scrapes the entire set of mini co...
Definition: counter.h:287
static u32 vnet_mpls_uc_get_label(mpls_label_t label_exp_s_ttl)
Definition: packet.h:77
IPv6 router advertisement prefix config response.
Definition: vpe.api:1074
u16 flags_net_byte_order
Flags, e.g.
Definition: sr.h:117
int cop_whitelist_enable_disable(cop_whitelist_enable_disable_args_t *a)
Definition: cop.c:229
static void vl_api_lisp_add_del_map_resolver_t_handler(vl_api_lisp_add_del_map_resolver_t *mp)
Definition: api.c:5535
u8 protocol
encapsulated protocol
Definition: vxlan_gpe.h:95
Recursion constraint of via an attahced prefix.
Definition: fib_types.h:263
u32 index
Definition: ip6.h:71
u32 tx_sw_if_index
Definition: mpls.h:40
static clib_error_t * link_up_down_function(vnet_main_t *vm, u32 hw_if_index, u32 flags)
Definition: api.c:641
u32 pg_interface_add_or_get(pg_main_t *pg, uword stream_index)
Definition: stream.c:154
u8 l4_protocol
Definition: vpe.api:5282
vlib_simple_counter_main_t * sw_if_counters
Definition: interface.h:576
map_main_t map_main
Definition: map.h:314
clib_error_t * vnet_punt_add_del(vlib_main_t *vm, u8 ipv, u8 protocol, u16 port, int is_add)
Request IP traffic punt to the local TCP/IP stack.
Definition: punt.c:219
ip46_address_range_t laddr
Definition: ipsec.h:158
void ip_del_all_interface_addresses(vlib_main_t *vm, u32 sw_if_index)
Definition: ip46_cli.c:72
Tell client about an ip4 arp resolution event.
Definition: vpe.api:3251
u8 is_add
Definition: vpe.api:3610
MPLS Ethernet add/ del tunnel 2.
Definition: vpe.api:1480
Set unnumbered interface add / del response.
Definition: vpe.api:1150
Get list of flow classify interfaces and tables.
Definition: vpe.api:4888
static void vl_api_policer_dump_t_handler(vl_api_policer_dump_t *mp)
Definition: api.c:7395
int ip6_sr_add_del_tunnel(ip6_sr_add_del_tunnel_args_t *a)
Add or Delete a Segment Routing tunnel.
Definition: sr.c:821
Set or delete one or all ip addresses on a specified interface.
Definition: vpe.api:170
mpls gre tunnel operational state response
Definition: vpe.api:5123
Enable or Disable MPLS on and interface.
Definition: vpe.api:224
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:575
u16 local_port_stop
Definition: vpe.api:3557
static int unformat_lisp_eid_api(gid_address_t *dst, u32 vni, u8 type, void *src, u8 len)
Definition: api.c:5358
ip46_address_t remote
tunnel remote address
Definition: vxlan_gpe.h:100
int vnet_lisp_add_del_mapping(gid_address_t *eid, locator_t *rlocs, u8 action, u8 authoritative, u32 ttl, u8 is_add, u8 is_static, u32 *res_map_index)
Adds/removes/updates mapping.
Definition: control.c:979
void ip_prefix_normalize(ip_prefix_t *a)
Definition: lisp_types.c:801
int vhost_user_dump_ifs(vnet_main_t *vnm, vlib_main_t *vm, vhost_user_intf_details_t **out_vuids)
Definition: vhost-user.c:2199
Set/unset interface classification table response.
Definition: vpe.api:1776
IPFIX classify stream configure response.
Definition: vpe.api:4783
struct fib_table_t_ * fibs
A pool of all the MPLS FIBs.
Definition: mpls.h:92
IOAM enable : Enable in-band OAM.
Definition: vpe.api:4132
u32 vni
VXLAN GPE VNI in HOST byte order, shifted left 8 bits.
Definition: vxlan_gpe.h:108
int ip6_neighbor_ra_config(vlib_main_t *vm, u32 sw_if_index, u8 suppress, u8 managed, u8 other, u8 ll_option, u8 send_unicast, u8 cease, u8 use_lifetime, u32 lifetime, u32 initial_count, u32 initial_interval, u32 max_interval, u32 min_interval, u8 is_no)
cop: interface enable/disable junk filtration reply
Definition: vpe.api:4069
Reply to sw_interface_set_flags.
Definition: vpe.api:145
ip6_to_l2_lookup_t lookup_type
Definition: l2tp.h:68
Call from VLIB_INIT_FUNCTION to set the Linux kernel inject node name.
clib_error_t * ikev2_set_local_key(vlib_main_t *vm, u8 *file)
Definition: ikev2.c:1996
#define ip_addr_v6(_a)
Definition: lisp_types.h:42
vnet_hw_interface_class_t ethernet_hw_interface_class
clib_error_t * ikev2_set_profile_ts(vlib_main_t *vm, u8 *name, u8 protocol_id, u16 start_port, u16 end_port, ip4_address_t start_addr, ip4_address_t end_addr, int is_local)
Definition: ikev2.c:2109
#define gid_address_ippref(_a)
Definition: lisp_types.h:216
Classify table info.
Definition: vpe.api:4634
u8 bvi_mac
Definition: vpe.api:2357
static void vl_api_l2_interface_efp_filter_t_handler(vl_api_l2_interface_efp_filter_t *mp)
Definition: api.c:4137
sse2_qos_pol_action_params_st exceed_action
Definition: xlate.h:152
ip46_address_t tunnel_dst_addr
Definition: ipsec.h:92
static void shmem_cli_output(uword arg, u8 *buffer, uword buffer_bytes)
Definition: api.c:3684
IP Set the next node for a given node response.
Definition: vpe.api:1855
lisp_adjacency_t * vnet_lisp_adjacencies_get_by_vni(u32 vni)
Returns vector of adjacencies.
Definition: control.c:469
uword * fib_index_by_table_id
Definition: ip6.h:148
ip6_address_t * src_address
Key (header imposition case)
Definition: sr.h:92
static void vl_api_set_ipfix_classify_stream_t_handler(vl_api_set_ipfix_classify_stream_t *mp)
Definition: api.c:8132
#define foreach_vpe_api_msg
Definition: api.c:278
static void vl_api_mpls_eth_tunnel_details_t_handler(vl_api_mpls_eth_tunnel_details_t *mp)
Definition: api.c:7550
u32 l2pbb_configure(vlib_main_t *vlib_main, vnet_main_t *vnet_main, u32 sw_if_index, u32 vtr_op, u8 *b_dmac, u8 *b_smac, u16 b_vlanid, u32 i_sid, u16 vlan_outer_tag)
Definition: l2_vtr.c:54
Get node index using name request.
Definition: vpe.api:1817
static int mpls_route_add_del_t_handler(vnet_main_t *vnm, vl_api_mpls_route_add_del_t *mp)
Definition: api.c:1331
Reply for IPsec: Add/delete Security Policy Database entry.
Definition: vpe.api:3472
Reply for lisp_add_del_adjacency.
Definition: vpe.api:2809
static uword vlib_process_get_events_with_type(vlib_main_t *vm, uword **data_vector, uword with_type_opaque)
Definition: node_funcs.h:582
L2 fib clear table response.
Definition: vpe.api:1988
static void vl_api_sw_interface_set_table_t_handler(vl_api_sw_interface_set_table_t *mp)
Definition: api.c:1533
u8 * policy_name
optional policy name
Definition: sr.h:102
static clib_error_t * admin_up_down_function(vnet_main_t *vm, u32 hw_if_index, u32 flags)
Definition: api.c:654
Reply for lisp_map_request_mode.
Definition: vpe.api:2699
#define VNET_HW_INTERFACE_BOND_INFO_SLAVE
Definition: interface.h:434
u32 sw_if_index
Definition: lisp_types.h:266
int vnet_vxlan_add_del_tunnel(vnet_vxlan_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
Definition: vxlan.c:203
#define foreach_classify_add_del_table_field
Definition: api.c:3972
mpls fib encap table response
Definition: vpe.api:4564
Delete loopback interface response.
Definition: vpe.api:1196
static void vl_api_cop_whitelist_enable_disable_t_handler(vl_api_cop_whitelist_enable_disable_t *mp)
Definition: api.c:7169
IPsec: Add/delete SPD from interface.
Definition: vpe.api:3488
IPFIX classify stream configure request.
Definition: vpe.api:4772
Request for lisp-gpe protocol status.
Definition: vpe.api:3140
ipfix_classify_table_t * tables
static void vl_api_lisp_eid_table_dump_t_handler(vl_api_lisp_eid_table_dump_t *mp)
Definition: api.c:6010
u32 vni
VNI/tenant id in HOST byte order.
Definition: lisp_gpe.h:207
int ipsec_set_sa_key(vlib_main_t *vm, ipsec_sa_t *sa_update)
Definition: ipsec.c:468
#define VLIB_EARLY_CONFIG_FUNCTION(x, n,...)
Definition: init.h:139
int vhost_user_create_if(vnet_main_t *vnm, vlib_main_t *vm, const char *sock_filename, u8 is_server, u32 *sw_if_index, u64 feature_mask, u8 renumber, u32 custom_dev_instance, u8 *hwaddr)
Definition: vhost-user.c:2021
u8 is_add
1 - add, 0 - delete
Definition: ipsec_gre.h:95
vl_api_mpls_ethernet_add_del_tunnel_2_t t
Definition: api.c:487
PacketGenerator create interface request.
Definition: vpe.api:4936
u32 * tunnel_index_by_sw_if_index
mapping from sw_if_index to tunnel index
Definition: ipsec_gre.h:74
Struct for VXLAN GPE add/del args.
Definition: vxlan_gpe.h:176
#define pub_sub_handler(lca, UCA)
Definition: api.c:670
vnet_feature_config_main_t feature_config_mains[VNET_N_IP_FEAT]
rx unicast, multicast, tx interface/feature configuration.
Definition: lookup.h:360
Set the ip flow hash config for a fib request.
Definition: vpe.api:967
fib_node_index_t fib_table_entry_special_dpo_update(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, const dpo_id_t *dpo)
Update a &#39;special&#39; entry to the FIB that links to the DPO passed A special entry is an entry that the...
Definition: fib_table.c:327
void * vl_msg_api_alloc(int nbytes)
u16 remote_port_start
Definition: vpe.api:3554
u16 encap_fib_index
Definition: vxlan.h:81
int vnet_lisp_add_del_mreq_itr_rlocs(vnet_lisp_add_del_mreq_itr_rloc_args_t *a)
Definition: control.c:2674
static void vl_api_ipfix_exporter_dump_t_handler(vl_api_ipfix_exporter_dump_t *mp)
Definition: api.c:8097
Reply for Proxy ARP interface enable / disable request.
Definition: vpe.api:626
enable or disable LISP feature
Definition: vpe.api:2614
fib_node_index_t fib_table_entry_local_label_add(u32 fib_index, const fib_prefix_t *prefix, mpls_label_t label)
Add a MPLS local label for the prefix/route.
Definition: fib_table.c:828
Reply for interface events registration.
Definition: vpe.api:3236
mpls_main_t mpls_main
Definition: mpls.c:25
Reply to IPFIX exporter configure request.
Definition: vpe.api:4728
Reply for lisp_add_del_remote_mapping.
Definition: vpe.api:2774
u32 ft_table_id
Table ID (hash key) for this FIB.
Definition: fib_table.h:56
void l2fib_clear_table(uint keep_static)
Definition: l2_fib.c:243
Create host-interface.
Definition: vpe.api:4183
dpdk_device_t * devices
Definition: dpdk.h:406
vhost-user interface delete response
Definition: vpe.api:2223
static void vl_api_vxlan_gpe_add_del_tunnel_t_handler(vl_api_vxlan_gpe_add_del_tunnel_t *mp)
Definition: api.c:5118
int vnet_set_flow_classify_intfc(vlib_main_t *vm, u32 sw_if_index, u32 ip4_table_index, u32 ip6_table_index, u32 is_add)
Definition: flow_classify.c:50
u8 remote_address_stop[16]
Definition: vpe.api:3548
Shows relationship between vni and vrf/bd.
Definition: vpe.api:3045
static void send_sw_interface_tap_details(vpe_api_main_t *am, unix_shared_memory_queue_t *q, tapcli_interface_details_t *tap_if, u32 context)
Definition: api.c:4470
L2 interface patch add / del response.
Definition: vpe.api:1308
pending_route_t * pending_routes
Definition: api.c:502
void gid_address_ip_set(gid_address_t *dst, void *src, u8 version)
Definition: lisp_types.c:1310
int vnet_delete_sub_interface(u32 sw_if_index)
Definition: interface.c:568
static void vl_api_ikev2_profile_add_del_t_handler(vl_api_ikev2_profile_add_del_t *mp)
Definition: api.c:6823
static void vl_api_sw_interface_set_flags_t_handler(vl_api_sw_interface_set_flags_t *mp)
Definition: api.c:2763
cop: enable/disable junk filtration features on an interface
Definition: vpe.api:4022
u32 bd_add_del_ip_mac(u32 bd_index, u8 *ip_addr, u8 *mac_addr, u8 is_ip6, u8 is_add)
Add/delete IP address to MAC address mapping.
Definition: l2_bd.c:573
IPsec: Add/delete Security Association Database entry.
Definition: vpe.api:3606
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:300
int map_create_domain(ip4_address_t *ip4_prefix, u8 ip4_prefix_len, ip6_address_t *ip6_prefix, u8 ip6_prefix_len, ip6_address_t *ip6_src, u8 ip6_src_len, u8 ea_bits_len, u8 psid_offset, u8 psid_length, u32 *map_domain_index, u16 mtu, u8 flags)
Definition: map.c:165
void fib_table_entry_delete(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Delete a FIB entry.
Definition: fib_table.c:793
static void vl_api_bridge_domain_dump_t_handler(vl_api_bridge_domain_dump_t *mp)
Definition: api.c:1973
int vnet_delete_loopback_interface(u32 sw_if_index)
Definition: interface.c:553
#define gid_address_ippref_len(_a)
Definition: lisp_types.h:217
static ip4_fib_t * ip4_fib_get(u32 index)
Get the FIB at the given index.
Definition: ip4_fib.h:71
Definition: ip6.h:66
u64 bytes
byte counter
Definition: counter.h:167
Set/unset the classification table for an interface request.
Definition: vpe.api:1763
Delete host-interface response.
Definition: vpe.api:4221
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:32
Definition: ip4.h:48
Dump mpls fib table.
Definition: vpe.api:4550
DPDK interface HQoS tctbl entry set request.
Definition: vpe.api:5216
int vhost_user_modify_if(vnet_main_t *vnm, vlib_main_t *vm, const char *sock_filename, u8 is_server, u32 sw_if_index, u64 feature_mask, u8 renumber, u32 custom_dev_instance)
Definition: vhost-user.c:2062
IPv6 segment routing multicast map to policy add / del response.
Definition: vpe.api:1404
ip46_address_t start
Definition: ipsec.h:104
static_always_inline u8 bd_feature_learn(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:163
vl_api_ip6_nd_event_t * nd_events
Definition: api.c:508
static void set_ip4_flow_hash(vl_api_set_ip_flow_hash_t *mp)
Definition: api.c:3558
u32 locator_set_index
Definition: lisp_types.h:295
char * vpe_api_get_build_directory(void)
Definition: version.c:82
IPv6 interface enable / disable response.
Definition: vpe.api:1098
#define clib_memcpy(a, b, c)
Definition: string.h:64
Reply for map_summary_stats request.
Definition: vpe.api:4004
u8 remote_address_start[16]
Definition: vpe.api:3547
int cop_interface_enable_disable(u32 sw_if_index, int enable_disable)
Definition: cop.c:151
struct vnet_sub_interface_t::@143 eth
int netmap_create_if(vlib_main_t *vm, u8 *if_name, u8 *hw_addr_set, u8 is_pipe, u8 is_master, u32 *sw_if_index)
Definition: netmap.c:113
ip4_address_t tunnel_src
The tunnel&#39;s source/local address.
Definition: gre.h:62
static void vl_api_sw_interface_tap_dump_t_handler(vl_api_sw_interface_tap_dump_t *mp)
Definition: api.c:4488
clib_error_t * ip6_ioam_enable(int has_trace_option, int has_pot_option, int has_seqno_option, int has_analyse_option)
static void vnet_interface_counter_unlock(vnet_interface_main_t *im)
Definition: interface.h:600
static void send_lisp_map_resolver_details(ip_address_t *ip, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:6105
int vnet_mpls_add_del_encap(ip4_address_t *dest, u32 fib_id, u32 *labels_host_byte_order, u32 policy_tunnel_index, int no_dst_hash, u32 *indexp, int is_add)
Definition: mpls.c:196
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:28
struct l2fib_entry_key_t::@178::@180 fields
add or delete map-resolver
Definition: vpe.api:2568
Set/unset flow classify interface.
Definition: vpe.api:4865
Definitions for punt infrastructure.
Reply for IP Neighbor add / delete request.
Definition: vpe.api:661
int vnet_l2_input_classify_set_tables(u32 sw_if_index, u32 ip4_table_index, u32 ip6_table_index, u32 other_table_index)
Set l2 per-protocol, per-interface input classification tables.
static void vl_api_get_node_index_t_handler(vl_api_get_node_index_t *mp)
Definition: api.c:4653
u8 lcl_len
Definition: vpe.api:2542
Reply for lisp_eid_table_add_del_map.
Definition: vpe.api:2861
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:211
vlib_main_t vlib_global_main
Definition: main.c:1536
u8 tunnel_src_address[16]
Definition: vpe.api:3630
#define REPLY_MACRO3(t, n, body)
Definition: api.c:171
int ipsec_add_del_spd(vlib_main_t *vm, u32 spd_id, int is_add)
Definition: ipsec.c:105
Delete sub interface request.
Definition: vpe.api:5137
#define ARRAY_LEN(x)
Definition: clib.h:59
static void vl_api_lisp_gpe_add_del_fwd_entry_t_handler(vl_api_lisp_gpe_add_del_fwd_entry_t *mp)
Definition: api.c:5503
IPSec-GRE state.
Definition: ipsec_gre.h:66
static void send_eid_table_vni(u32 vni, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:6204
u32 decap_next_index
Definition: vxlan.h:78
This packet matches an "incomplete adjacency" and packets need to be passed to ARP to find rewrite st...
Definition: lookup.h:72
void vnet_register_ip4_arp_resolution_event(vnet_main_t *vnm, void *address_arg, uword node_index, uword type_opaque, uword data)
Definition: arp.c:639
mpls_eth_tunnel_t * eth_tunnels
Definition: mpls.h:106
void dpo_set(dpo_id_t *dpo, dpo_type_t type, dpo_proto_t proto, index_t index)
Set/create a DPO ID The DPO will be locked.
Definition: dpo.c:134
u32 rsa
remote IPSec SA id
Definition: ipsec_gre.h:100
Request for map lisp locator status.
Definition: vpe.api:2874
static void vl_api_tap_modify_t_handler(vl_api_tap_modify_t *mp, vlib_main_t *vm)
Definition: api.c:2183
clib_error_t * enable_ip6_interface(vlib_main_t *vm, u32 sw_if_index)
void l2fib_add_entry(u64 mac, u32 bd_index, u32 sw_if_index, u32 static_mac, u32 filter_mac, u32 bvi_mac)
Add an entry to the l2fib.
Definition: l2_fib.c:298
static void vl_api_mpls_add_del_encap_t_handler(vl_api_mpls_add_del_encap_t *mp)
Definition: api.c:2536
lisp_gpe_main_t lisp_gpe_main
LISP-GPE global state.
Definition: lisp_gpe.c:27
static void vl_api_cop_interface_enable_disable_t_handler(vl_api_cop_interface_enable_disable_t *mp)
Definition: api.c:7150
static_always_inline ipfix_classify_table_t * ipfix_classify_add_table(void)
PacketGenerator capture packets response.
Definition: vpe.api:4977
int vnet_proxy_arp_add_del(ip4_address_t *lo_addr, ip4_address_t *hi_addr, u32 fib_index, int is_del)
Definition: arp.c:1792
Delete loopback interface request.
Definition: vpe.api:1185
static void vl_api_ipsec_spd_add_del_t_handler(vl_api_ipsec_spd_add_del_t *mp)
Definition: api.c:6644
Reply for MPLS route add / del request.
Definition: vpe.api:419
port_range_t rport
Definition: ipsec.h:162
static void map_domain_counter_lock(map_main_t *mm)
Definition: map.h:545
static void vl_api_lisp_locator_set_dump_t_handler(vl_api_lisp_locator_set_dump_t *mp)
Definition: api.c:5843
static void vl_api_sw_interface_set_dpdk_hqos_pipe_t_handler(vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp)
Definition: api.c:1719
static void vl_api_mpls_fib_encap_details_t_handler(vl_api_mpls_fib_encap_details_t *mp)
Definition: api.c:7699
Reply for local_eid add/del.
Definition: vpe.api:2508
Set/unset policer classify interface response.
Definition: vpe.api:4380
u8 * policy_name
name of policy to map to
Definition: sr.h:172
int dhcp_proxy_set_server(ip4_address_t *addr, ip4_address_t *src_address, u32 fib_id, int insert_option_82, int is_del)
Definition: proxy_node.c:776
void handle_ip6_nd_event(u32 pool_index)
Definition: api.c:776
#define fid_addr_ippref(_a)
Definition: lisp_types.h:112
static void vl_api_sw_interface_set_l2_bridge_t_handler(vl_api_sw_interface_set_l2_bridge_t *mp)
Definition: api.c:1684
vhost-user interface modify request
Definition: vpe.api:2188
int vnet_ipsec_gre_add_del_tunnel(vnet_ipsec_gre_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
Add or delete ipsec-gre tunnel interface.
Definition: interface.c:92
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:154
int vnet_lisp_gpe_add_del_fwd_entry(vnet_lisp_gpe_add_del_fwd_entry_args_t *a, u32 *hw_if_indexp)
Forwarding entry create/remove dispatcher.
struct _vnet_classify_main vnet_classify_main_t
Definition: vnet_classify.h:50
input_acl_main_t input_acl_main
Definition: input_acl.c:19
u8 vnet_lisp_enable_disable_status(void)
Definition: control.c:2257
u32 sw_if_index
Definition: vpe.api:2354
#define foreach_flow_hash_bit
Definition: lookup.h:146
ip46_address_range_t raddr
Definition: ipsec.h:159
int vnet_arp_set_ip4_over_ethernet(vnet_main_t *vnm, u32 sw_if_index, void *a_arg, int is_static)
Definition: arp.c:1775
u32 ip6_multicast_rx_feature_vpath
Definition: ip6.h:178
Set L2 XConnect between two interfaces request.
Definition: vpe.api:1513
static void vl_api_ipfix_classify_stream_dump_t_handler(vl_api_ipfix_classify_stream_dump_t *mp)
Definition: api.c:8160
Policer iclassify operational state response.
Definition: vpe.api:4403
static void send_sw_interface_flags(vpe_api_main_t *am, unix_shared_memory_queue_t *q, vnet_sw_interface_t *swif)
Definition: api.c:2944
#define API_LINK_STATE_EVENT
Definition: api.c:552
u32 fib_index
Definition: mpls.h:268
static void vnet_interface_counter_lock(vnet_interface_main_t *im)
Definition: interface.h:592
#define hash_create(elts, value_bytes)
Definition: hash.h:658
foreach_registration_hash u8 link_state_process_up
Definition: api.c:499
struct _gid_address_t gid_address_t
DHCP proxy set / unset vss response.
Definition: vpe.api:949
static void vl_api_sw_interface_set_vpath_t_handler(vl_api_sw_interface_set_vpath_t *mp)
Definition: api.c:1571
Reset fib response.
Definition: vpe.api:887
Dump lisp eid-table.
Definition: vpe.api:2950
static void send_ipsec_gre_tunnel_details(ipsec_gre_tunnel_t *t, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:8563
ip4_address_t src
tunnel IPv4 src address
Definition: ipsec_gre.h:97
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
Definition: interface.h:490
#define VALIDATE_RX_SW_IF_INDEX(mp)
Definition: api.c:235
l2 fib table entry structure
Definition: vpe.api:2349
IP neighbor add / del request.
Definition: vpe.api:643
Set L2 XConnect response.
Definition: vpe.api:1526
static void vl_api_modify_vhost_user_if_t_handler(vl_api_modify_vhost_user_if_t *mp)
Definition: api.c:4217
Reply for tap dump request.
Definition: vpe.api:337
#define pool_put_index(p, i)
Free pool element with given index.
Definition: pool.h:228
#define ASSERT(truth)
#define fid_addr_type(_a)
Definition: lisp_types.h:114
Reply for vnet_get_summary_stats request.
Definition: vpe.api:798
IPv6 router advertisement config response.
Definition: vpe.api:1032
static uword ip6_address_is_zero(ip6_address_t *a)
Definition: ip6_packet.h:234
u32 remote_session_id
Definition: l2tp.h:35
static void vl_api_add_node_next_t_handler(vl_api_add_node_next_t *mp)
Definition: api.c:4724
unsigned int u32
Definition: types.h:88
static void lisp_adjacency_copy(vl_api_lisp_adjacency_t *dst, lisp_adjacency_t *adjs)
Definition: api.c:6217
Request for eid table summary status.
Definition: vpe.api:2986
static void vl_api_lisp_adjacencies_get_t_handler(vl_api_lisp_adjacencies_get_t *mp)
Definition: api.c:6259
static void vl_api_gre_tunnel_dump_t_handler(vl_api_gre_tunnel_dump_t *mp)
Definition: api.c:5057
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
static void vl_api_lisp_get_map_request_itr_rlocs_t_handler(vl_api_lisp_get_map_request_itr_rlocs_t *mp)
Definition: api.c:6341
int vnet_lisp_clear_all_remote_adjacencies(void)
Definition: control.c:1094
ip6_main_t ip6_main
Definition: ip6_forward.c:2655
static void set_ip6_flow_hash(vl_api_set_ip_flow_hash_t *mp)
Definition: api.c:3547
static void vl_api_ipsec_sa_set_key_t_handler(vl_api_ipsec_sa_set_key_t *mp)
Definition: api.c:7128
Request for locator_set summary status.
Definition: vpe.api:2922
Reply for enable / disable packet generator.
Definition: vpe.api:5002
ip_lookup_main_t lookup_main
Definition: ip6.h:132
#define gid_address_sd_dst(_a)
Definition: lisp_types.h:230
clib_error_t * policer_add_del(vlib_main_t *vm, u8 *name, sse2_qos_pol_cfg_params_st *cfg, u32 *policer_index, u8 is_add)
Definition: policer.c:20
Struct for VXLAN GPE node state.
Definition: vxlan_gpe.h:146
Get list of policer classify interfaces and tables.
Definition: vpe.api:4391
u32 spi
Definition: vpe.api:3614
int vpe_oam_add_del_target(ip4_address_t *src_address, ip4_address_t *dst_address, u32 fib_id, int is_add)
Definition: oam.c:64
map/unmap vni/bd_index to vrf
Definition: vpe.api:2847
static_always_inline l2_bridge_domain_t * l2input_bd_config_from_index(l2input_main_t *l2im, u32 bd_index)
Definition: l2_input.h:81
IPSec-GRE tunnel parameters.
Definition: ipsec_gre.h:50
int create_l2tpv3_ipv6_tunnel(l2t_main_t *lm, ip6_address_t *client_address, ip6_address_t *our_address, u32 local_session_id, u32 remote_session_id, u64 local_cookie, u64 remote_cookie, int l2_sublayer_present, u32 encap_fib_index, u32 *sw_if_index)
Definition: l2tp.c:292
Reply for add / del route request.
Definition: vpe.api:542
ip_address_t address
Definition: control.h:62
gid_dictionary_t mapping_index_by_gid
Definition: control.h:86
Definition: l2_fib.h:33
u8 * name
policy name
Definition: sr.h:133
IPv6 router advertisement prefix config request.
Definition: vpe.api:1053
static int event_data_cmp(void *a1, void *a2)
Definition: api.c:556
static void vl_api_show_version_t_handler(vl_api_show_version_t *mp)
Definition: api.c:4624
static void vl_api_lisp_enable_disable_t_handler(vl_api_lisp_enable_disable_t *mp)
Definition: api.c:5567
Reply for IPsec: Add/delete SPD from interface.
Definition: vpe.api:3503
gre_tunnel_t * tunnels
Definition: gre.h:101
IPv4 main type.
Definition: ip4.h:95
Reply for tap modify request.
Definition: vpe.api:297
int stats_memclnt_delete_callback(u32 client_index)
Definition: stats.c:897
u32 size
Definition: vhost-user.h:76
u16 l4_port
Definition: vpe.api:5283
Reply for proxy arp add / del request.
Definition: vpe.api:601
Control ping from the client to the server response.
Definition: vpe.api:1218
clib_error_t * pg_capture(pg_capture_args_t *a)
Definition: cli.c:81
locator_set_t * locator_set_pool
Definition: control.h:95
u32 ip6_unicast_rx_feature_vpath
Definition: ip6.h:172
void l2_efp_filter_configure(vnet_main_t *vnet_main, u32 sw_if_index, u32 enable)
Enable/disable the EFP Filter check on the subinterface.
int dhcp_client_config(vlib_main_t *vm, u32 sw_if_index, u8 *hostname, u32 is_add, u32 client_index, void *event_callback, u32 pid)
Definition: client.c:836
static void vl_api_classify_table_ids_t_handler(vl_api_classify_table_ids_t *mp)
Definition: api.c:7792
Status of lisp pitr, enable or disable.
Definition: vpe.api:3193
static void vl_api_lisp_add_del_map_request_itr_rlocs_t_handler(vl_api_lisp_add_del_map_request_itr_rlocs_t *mp)
Definition: api.c:5651
static void vl_api_delete_subif_t_handler(vl_api_delete_subif_t *mp)
Definition: api.c:8618
static void vl_api_vxlan_tunnel_dump_t_handler(vl_api_vxlan_tunnel_dump_t *mp)
Definition: api.c:4954
IKEv2: Set IKEv2 profile authentication method.
Definition: vpe.api:3719
vnet_main_t * vnet_main
Definition: l2tp.h:81
Bitmaps built as vectors of machine words.
u8 integ_key_len
Definition: ipsec.h:83
Set the next node for a given node request.
Definition: vpe.api:1842
uword * next_slot_by_node
Definition: node.h:302
static void send_bridge_domain_details(unix_shared_memory_queue_t *q, l2_bridge_domain_t *bd_config, u32 n_sw_ifs, u32 context)
Definition: api.c:1930
void vnet_flow_reports_reset(flow_report_main_t *frm)
Definition: flow_report.c:329
dpdk_device_hqos_per_hqos_thread_t * hqos_ht
Definition: dpdk.h:241
mpls_label_t label_exp_s_ttl
Definition: packet.h:31
u32 fib_table_find_or_create_and_lock(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
Definition: fib_table.c:949
Query relative index via node names.
Definition: vpe.api:4911
u32 sw_if_index
Definition: vxlan.h:85
Is Address Reachable request - DISABLED.
Definition: vpe.api:699
show version
Definition: vpe.api:2260
u8 is_del
Delete the policy?
Definition: sr.h:139
add or delete locator_set
Definition: vpe.api:2427
u32 vnet_config_add_feature(vlib_main_t *vm, vnet_config_main_t *cm, u32 config_string_heap_index, u32 feature_index, void *feature_config, u32 n_feature_config_bytes)
Definition: config.c:239
static void vlib_zero_simple_counter(vlib_simple_counter_main_t *cm, u32 index)
Clear a simple counter Clears the set of per-thread u16 counters, and the u64 counter.
Definition: counter.h:143
int vnet_tap_delete(vlib_main_t *vm, u32 sw_if_index)
Delete TAP interface.
Definition: tapcli.c:1050
vnet_classify_main_t vnet_classify_main
Definition: vnet_classify.c:21
Request for a single block of summary stats.
Definition: vpe.api:3990
Set max allowed ARP or ip6 neighbor entries response.
Definition: vpe.api:1282
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
Definition: fib_types.c:202
ipsec_protocol_t protocol
Definition: ipsec.h:76
uword * thread_registrations_by_name
Definition: threads.h:285
Reply for MAP domain add.
Definition: vpe.api:3888
static void vl_api_sw_interface_vhost_user_dump_t_handler(vl_api_sw_interface_vhost_user_dump_t *mp)
Definition: api.c:4293
gid_address_t rmt_eid
remote eid
Definition: lisp_gpe.h:192
From the control plane API.
Definition: fib_entry.h:57
#define vec_set(v, val)
Set all vector elements to given value.
Definition: vec.h:852
int vnet_unset_ip6_ethernet_neighbor(vlib_main_t *vm, u32 sw_if_index, ip6_address_t *a, u8 *link_layer_address, uword n_bytes_link_layer_address)
Definition: ip6_neighbor.c:678
IPv6 segment routing policy add / del response.
Definition: vpe.api:1378
static void vl_api_map_rule_dump_t_handler(vl_api_map_rule_dump_t *mp)
Definition: api.c:7025
OAM add / del target request.
Definition: vpe.api:849
static void vl_api_input_acl_set_interface_t_handler(vl_api_input_acl_set_interface_t *mp)
Definition: api.c:6621
Route added as a result of interface configuration.
Definition: fib_entry.h:49
static void * clib_mem_alloc(uword size)
Definition: mem.h:109
#define MODE_L2_XC
Definition: l2_input.h:220
u32 flow_hash_config_t
A flow hash configuration is a mask of the flow hash options.
Definition: lookup.h:157
int vnet_classify_add_del_session(vnet_classify_main_t *cm, u32 table_index, u8 *match, u32 hit_next_index, u32 opaque_index, i32 advance, int is_add)
static int mpls_ip_bind_unbind_handler(vnet_main_t *vnm, vl_api_mpls_ip_bind_unbind_t *mp)
Definition: api.c:1432
static void vl_api_mpls_fib_dump_t_handler(vl_api_mpls_fib_dump_t *mp)
Definition: api.c:7656
Classify table ids by interface index request.
Definition: vpe.api:4604
pg_main_t pg_main
Definition: init.c:44
static void send_eid_table_map_pair(hash_pair_t *p, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:6156
static void send_bd_sw_if_details(l2input_main_t *l2im, unix_shared_memory_queue_t *q, l2_flood_member_t *member, u32 bd_id, u32 context)
Definition: api.c:1953
vxlan_gpe_tunnel_t * tunnels
vector of encap tunnel instances
Definition: vxlan_gpe.h:148
u8 lcl_locs[loc_num]
Definition: vpe.api:2546
u64 uword
Definition: types.h:112
u8 teb
Definition: gre.h:73
u8 action
Definition: vpe.api:2548
static void vl_api_punt_t_handler(vl_api_punt_t *mp)
Definition: api.c:8665
#define vec_elt(v, i)
Get vector value at index i.
u32 l2input_intf_bitmap_enable(u32 sw_if_index, u32 feature_bitmap, u32 enable)
Enable (or disable) the feature in the bitmap for the given interface.
Definition: l2_input.c:514
void vl_set_memory_region_name(char *name)
Definition: memory_vlib.c:1244
void dslock(stats_main_t *sm, int release_hint, int tag)
Definition: stats.c:65
static void send_lisp_eid_table_details(mapping_t *mapit, unix_shared_memory_queue_t *q, u32 context, u8 filter)
Definition: api.c:5922
u8 rmt_eid[16]
Definition: vpe.api:2539
u8 crypto_key_len
Definition: ipsec.h:79
static void send_policer_classify_details(u32 sw_if_index, u32 table_index, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:7468
template key/value backing page structure
Definition: bihash_doc.h:44
fib_node_index_t fib_table_entry_update_one_path(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, fib_protocol_t next_hop_proto, const ip46_address_t *next_hop, u32 next_hop_sw_if_index, u32 next_hop_fib_index, u32 next_hop_weight, mpls_label_t next_hop_label, fib_route_path_flags_t path_flags)
Update the entry to have just one path.
Definition: fib_table.c:711
Add / del route request.
Definition: vpe.api:508
static void vl_api_want_ip6_nd_events_t_handler(vl_api_want_ip6_nd_events_t *mp)
Definition: api.c:6582
int vnet_lisp_add_del_locator_set(vnet_lisp_add_del_locator_set_args_t *a, u32 *ls_result)
Definition: control.c:2033
#define gid_address_ip(_a)
Definition: lisp_types.h:218
Status of lisp, enable or disable.
Definition: vpe.api:3151
static void vl_api_want_ip4_arp_events_t_handler(vl_api_want_ip4_arp_events_t *mp)
Definition: api.c:6543
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
Definition: node.c:45
static void vl_api_l2tpv3_set_tunnel_cookies_t_handler(vl_api_l2tpv3_set_tunnel_cookies_t *mp)
Definition: api.c:4810
Interface bridge mode request.
Definition: vpe.api:1541
Definition: defs.h:47
negative_fwd_actions_e action
action for negative mappings
Definition: lisp_gpe.h:186
static void vl_api_cli_request_t_handler(vl_api_cli_request_t *mp)
Definition: api.c:3711
u8 static_mac
Definition: vpe.api:2355
unsigned short u16
Definition: types.h:57
l2input_main_t l2input_main
Definition: l2_input.c:87
static void vl_api_af_packet_create_t_handler(vl_api_af_packet_create_t *mp)
Definition: api.c:7265
u8 eid_type
Definition: vpe.api:2538
#define gid_address_vni(_a)
Definition: lisp_types.h:222
u32 decap_fib_index
FIB indices - inner IP packet lookup here.
Definition: vxlan_gpe.h:105
int vnet_gre_add_del_tunnel(vnet_gre_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
Definition: interface.c:422
static void vl_api_lisp_pitr_set_locator_set_t_handler(vl_api_lisp_pitr_set_locator_set_t *mp)
Definition: api.c:5635
u32 local_sa_id
local IPSec SA id
Definition: ipsec_gre.h:56
static void vl_api_classify_table_info_t_handler(vl_api_classify_table_info_t *mp)
Definition: api.c:7877
i64 word
Definition: types.h:111
static void * vl_api_sr_policy_add_del_t_print(vl_api_sr_policy_add_del_t *mp, void *handle)
Definition: custom_dump.c:1142
u32 eid_fib_index
The FIB index for the overlay, i.e.
static void vl_api_sw_interface_set_l2_xconnect_t_handler(vl_api_sw_interface_set_l2_xconnect_t *mp)
Definition: api.c:1654
ip4_address_t dst
tunnel IPv4 dst address
Definition: ipsec_gre.h:98
static void vl_api_show_lisp_status_t_handler(vl_api_show_lisp_status_t *mp)
Definition: api.c:6318
static void vl_api_map_add_domain_t_handler(vl_api_map_add_domain_t *mp)
Definition: api.c:6936
struct lisp_gpe_fwd_entry_t_ * lisp_fwd_entry_pool
A Pool of all LISP forwarding entries.
Definition: lisp_gpe.h:100
IKEv2: Set IKEv2 local RSA private key.
Definition: vpe.api:3815
u32 bd_find_or_add_bd_index(bd_main_t *bdm, u32 bd_id)
Get or create a bridge domain.
Definition: l2_bd.c:64
static void vl_api_classify_add_del_session_t_handler(vl_api_classify_add_del_session_t *mp)
Definition: api.c:4032
#define RESOLUTION_PENDING_EVENT
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
double f64
Definition: types.h:142
Reply to IPFIX classify stream dump request.
Definition: vpe.api:4802
vnet_interface_main_t * interface_main
Definition: stats.h:64
unsigned char u8
Definition: types.h:56
ip_lookup_next_t lookup_next_index
Definition: lookup.h:183
static void vl_api_l2tpv3_interface_enable_disable_t_handler(vl_api_l2tpv3_interface_enable_disable_t *mp)
Definition: api.c:4829
#define hash_foreach_pair(p, v, body)
Iterate over hash pairs.
Definition: hash.h:349
u8 is_outbound
Definition: ipsec.h:154
vlib_node_main_t node_main
Definition: main.h:115
u32 flags
Definition: vxlan.h:93
Reply for gpe_fwd_entry add/del.
Definition: vpe.api:2555
u8 integrity_algorithm
Definition: vpe.api:3622
#define API_ADMIN_UP_DOWN_EVENT
Definition: api.c:553
static void vl_api_ipsec_interface_add_del_spd_t_handler(vl_api_ipsec_interface_add_del_spd_t *mp)
Definition: api.c:6665
static void vl_api_show_lisp_pitr_t_handler(vl_api_show_lisp_pitr_t *mp)
Definition: api.c:6379
static void send_ipfix_classify_table_details(u32 table_index, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:8259
#define L2_ARP_TERM
Definition: l2_bd.h:100
Process a vpe parser cli string request.
Definition: vpe.api:1231
int vnet_stream_change(flow_report_main_t *frm, u32 old_domain_id, u16 old_src_port, u32 new_domain_id, u16 new_src_port)
Definition: flow_report.c:358
u8 integrity_key[128]
Definition: vpe.api:3624
u8 is_tunnel_ipv6
Definition: vpe.api:3629
static void send_vxlan_tunnel_details(vxlan_tunnel_t *t, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:4922
add or delete locator for locator_set
Definition: vpe.api:2458
Configure IPFIX exporter process request.
Definition: vpe.api:4712
u32 dp_table
generic access
Definition: lisp_gpe.h:219
#define VXLAN_TUNNEL_IS_IPV4
Definition: vxlan.h:97
u32 inner_fib_index
Definition: mpls.h:41
L2 interface ethernet flow point filtering enable/disable request.
Definition: vpe.api:2000
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:920
u8 * ipfix_classify_template_rewrite(flow_report_main_t *frm, flow_report_t *fr, ip4_address_t *collector_address, ip4_address_t *src_address, u16 collector_port)
int vnet_l2_patch_add_del(u32 rx_sw_if_index, u32 tx_sw_if_index, int is_add)
Definition: l2_patch.c:247
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:568
static void vl_api_sw_interface_set_dpdk_hqos_subport_t_handler(vl_api_sw_interface_set_dpdk_hqos_subport_t *mp)
Definition: api.c:1754
int vnet_lisp_add_del_locator(vnet_lisp_add_del_locator_set_args_t *a, locator_set_t *ls, u32 *ls_result)
Definition: control.c:1943
locator_pair_t * locator_pairs
vector of locator pairs
Definition: lisp_gpe.h:195
mapping_t * mapping_pool
Definition: control.h:89
PacketGenerator create interface response.
Definition: vpe.api:4947
#define DPO_INVALID
An initialiser for DPos declared on the stack.
Definition: dpo.h:164
static void vl_api_map_domain_dump_t_handler(vl_api_map_domain_dump_t *mp)
Definition: api.c:6983
void vnet_l2_output_classify_enable_disable(u32 sw_if_index, int enable_disable)
Enable/disable l2 input classification on a specific interface.
Create loopback interface request.
Definition: vpe.api:1161
Reply for interface events registration.
Definition: vpe.api:186
Set unnumbered interface add / del request.
Definition: vpe.api:1137
uword * locator_set_index_by_name
Definition: control.h:101
static int nd_change_delete_callback(u32 pool_index, u8 *notused)
Definition: api.c:6531
show version response
Definition: vpe.api:2273
add or delete remote static mapping
Definition: vpe.api:2752
l2t_session_t * sessions
Definition: l2tp.h:61
int ip4_source_and_port_range_check_add_del(ip4_address_t *address, u32 length, u32 vrf_id, u16 *low_ports, u16 *high_ports, int is_add)
L2 interface vlan tag rewrite configure request.
Definition: vpe.api:2131
static void vl_api_pg_create_interface_t_handler(vl_api_pg_create_interface_t *mp)
Definition: api.c:8297
void * get_unformat_vnet_sw_interface(void)
Definition: api.c:8989
fib_table_t * fib_table_get(fib_node_index_t index, fib_protocol_t proto)
Get a pointer to a FIB table.
Definition: fib_table.c:27
get_node_graph - get a copy of the vpp node graph including the current set of graph arcs...
Definition: vpe.api:4082
static u64 l2fib_make_key(u8 *mac_address, u16 bd_index)
Definition: l2_fib.h:95
void gid_address_copy(gid_address_t *dst, gid_address_t *src)
Definition: lisp_types.c:1244
l2_bridge_domain_t * bd_configs
Definition: l2_input.h:69
ip6_address_t * dst_address
Definition: sr.h:93
A collection of combined counters.
Definition: counter.h:212
IPFIX add classifier table response.
Definition: vpe.api:4827
u32 encap_index
Definition: mpls.h:43
Create a new subinterface with the given vlan id.
Definition: vpe.api:350
Definition: lisp_types.h:24
static void send_sw_interface_flags_deleted(vpe_api_main_t *am, unix_shared_memory_queue_t *q, u32 sw_if_index)
Definition: api.c:2969
gid_address_t eid
Definition: lisp_types.h:292
gid_address_t reid
Definition: control.h:49
static void vl_api_l2tpv3_set_lookup_key_t_handler(vl_api_l2tpv3_set_lookup_key_t *mp)
Definition: api.c:4846
vnet_flow_data_callback_t * flow_data_callback
Definition: flow_report.h:124
u32 custom_dev_instance
Definition: vpe.api:257
u8 ** tunnel_names
tunnel names
Definition: sr.h:136
Add MAP domains.
Definition: vpe.api:3866
gid_address_t address
Definition: lisp_types.h:267
static void send_sw_if_l2tpv3_tunnel_details(vpe_api_main_t *am, unix_shared_memory_queue_t *q, l2t_session_t *s, l2t_main_t *lm, u32 context)
Definition: api.c:4319
Create loopback interface response.
Definition: vpe.api:1173
u32 * tunnel_index_by_sw_if_index
Definition: vxlan.h:131
u32 dev_instance
Definition: pg.h:364
L2 interface patch add / del request.
Definition: vpe.api:1295
#define hash_get_mem(h, key)
Definition: hash.h:268
void mac_copy(void *dst, void *src)
Definition: lisp_types.c:864
Tell client about an ip6 nd resolution or mac/ip event.
Definition: vpe.api:3297
void l2fib_table_dump(u32 bd_index, l2fib_entry_key_t **l2fe_key, l2fib_entry_result_t **l2fe_res)
Definition: l2_fib.c:72
u32 client_index
Definition: vpe.api:2336
struct clib_bihash_value offset
template key/value backing page structure
static void vl_api_lisp_gpe_add_del_iface_t_handler(vl_api_lisp_gpe_add_del_iface_t *mp)
Definition: api.c:5577
u8 lcl_eid[16]
Definition: vpe.api:2540
static void vl_api_sw_interface_clear_stats_t_handler(vl_api_sw_interface_clear_stats_t *mp)
Definition: api.c:2803
static void vl_api_ipsec_sad_add_del_entry_t_handler(vl_api_ipsec_sad_add_del_entry_t *mp)
Definition: api.c:6754
policer_read_response_type_st * policer_templates
Definition: policer.h:31
u32 l2vtr_get(vlib_main_t *vlib_main, vnet_main_t *vnet_main, u32 sw_if_index, u32 *vtr_op, u32 *push_dot1q, u32 *vtr_tag1, u32 *vtr_tag2)
Get vtag tag rewrite on the given interface.
Definition: l2_vtr.c:350
u32 encap_fib_index
FIB indices - tunnel partner lookup here.
Definition: vxlan_gpe.h:103
Interface set vpath request.
Definition: vpe.api:1416
static void send_gre_tunnel_details(gre_tunnel_t *t, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:5038
Modify a tap interface with the given paramters.
Definition: vpe.api:280
static void vl_api_get_next_index_t_handler(vl_api_get_next_index_t *mp)
Definition: api.c:4677
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:169
Add/del policer.
Definition: vpe.api:4247
char * vpe_api_get_build_date(void)
Definition: version.c:94
policer_classify_main_t policer_classify_main
Segment Routing header.
u8 * is_mp_safe
Definition: api.h:121
ipsec_crypto_alg_t crypto_alg
Definition: ipsec.h:78
void vlib_clear_simple_counters(vlib_simple_counter_main_t *cm)
Clear a collection of simple counters.
Definition: counter.c:43
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:143
L2 interface pbb tag rewrite configure request.
Definition: vpe.api:5246
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:418
void vl_noop_handler(void *mp)
Definition: api_shared.c:713
int vnet_lisp_add_del_map_resolver(vnet_lisp_add_del_map_resolver_args_t *a)
Definition: control.c:2568
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1060
u32 ip4_unicast_rx_feature_vpath
Built-in unicast feature path index, see vnet_feature_arc_init()
Definition: ip4.h:135
static void vl_api_dhcp_proxy_config_2_t_handler(vl_api_dhcp_proxy_config_2_t *mp)
Definition: api.c:3363
int vnet_tap_connect_renumber(vlib_main_t *vm, u8 *intfc_name, u8 *hwaddr_arg, u32 *sw_if_indexp, u8 renumber, u32 custom_dev_instance)
Renumber a TAP interface.
Definition: tapcli.c:995
u32 sw_if_index
vnet intfc sw_if_index
Definition: vxlan_gpe.h:113
Register for ip4 arp resolution events.
Definition: vpe.api:3223
struct fib_table_t_ * fibs
Vector of FIBs.
Definition: ip4.h:99
DPDK interface HQoS pipe profile set request.
Definition: vpe.api:5160
This packet is to be rewritten and forwarded to the next processing node.
Definition: lookup.h:82
static void vl_api_ip_dump_t_handler(vl_api_ip_dump_t *mp)
Definition: api.c:4513
int dhcp_proxy_set_server_2(ip4_address_t *addr, ip4_address_t *src_address, u32 rx_fib_id, u32 server_fib_id, int insert_option_82, int is_del)
Definition: proxy_node.c:697
u8 is_enabled
Definition: pg.h:365
static void vl_api_dhcp_client_config_t_handler(vl_api_dhcp_client_config_t *mp)
Definition: api.c:3401
static void vl_api_netmap_create_t_handler(vl_api_netmap_create_t *mp)
Definition: api.c:7512
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
Definition: dpo.c:171
L2 interface pbb tag rewrite response.
Definition: vpe.api:5263
#define vec_foreach(var, vec)
Vector iterator.
#define foreach_registration_hash
Definition: api.c:466
Dumps all VNIs used in mappings.
Definition: vpe.api:3068
clib_error_t * clear_ioam_rewrite_fn(void)
#define VALIDATE_TX_SW_IF_INDEX(mp)
Definition: api.c:251
Set bridge flags (such as L2_LEARN, L2_FWD, L2_FLOOD, L2_UU_FLOOD, or L2_ARP_TERM) request...
Definition: vpe.api:1630
Reply for map_resolver add/del.
Definition: vpe.api:2581
Request for map request itr rlocs summary status.
Definition: vpe.api:3171
index_t ip4_fib_table_lookup_lb(ip4_fib_t *fib, const ip4_address_t *addr)
Definition: ip4_fib.c:261
Reply for ip6 nd resolution events registration.
Definition: vpe.api:3282
static void vl_api_is_address_reachable_t_handler(vl_api_is_address_reachable_t *mp)
Definition: api.c:2681
int vnet_set_input_acl_intfc(vlib_main_t *vm, u32 sw_if_index, u32 ip4_table_index, u32 ip6_table_index, u32 l2_table_index, u32 is_add)
Definition: input_acl.c:69
enable or disable lisp-gpe protocol
Definition: vpe.api:2592
u8 is_outbound
Definition: vpe.api:3542
VLIB_API_INIT_FUNCTION(vpe_api_hookup)
static void vl_api_l2_interface_vlan_tag_rewrite_t_handler(vl_api_l2_interface_vlan_tag_rewrite_t *mp)
Definition: api.c:4153
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
Definition: interface.c:530
static void vl_api_proxy_arp_intfc_enable_disable_t_handler(vl_api_proxy_arp_intfc_enable_disable_t *mp)
Definition: api.c:2595
u32 sw_if_index
Definition: l2_bd.h:46
u8 is_ipv6
Definition: vpe.api:3545
IPFIX classify stream dump request.
Definition: vpe.api:4792
static void vl_api_create_vlan_subif_t_handler(vl_api_create_vlan_subif_t *mp)
Definition: api.c:2235
static void vl_api_vxlan_add_del_tunnel_t_handler(vl_api_vxlan_add_del_tunnel_t *mp)
Definition: api.c:4865
int vnet_set_policer_classify_intfc(vlib_main_t *vm, u32 sw_if_index, u32 ip4_table_index, u32 ip6_table_index, u32 l2_table_index, u32 is_add)
u8 filter_mac
Definition: vpe.api:2356
clib_error_t * ip6_add_del_interface_address(vlib_main_t *vm, u32 sw_if_index, ip6_address_t *address, u32 address_length, u32 is_del)
Definition: ip6_forward.c:491
Set/unset flow classify interface response.
Definition: vpe.api:4878
Request for LISP map-request mode.
Definition: vpe.api:2709
format_function_t format_mpls_encap_index
Definition: mpls.h:161
void * vl_msg_api_alloc_as_if_client(int nbytes)
int vl_msg_api_version_check(vl_api_memclnt_create_t *mp)
Definition: api.c:9000
vhost_vring_addr_t addr
Definition: vhost-user.h:81
static void vl_api_mpls_ethernet_add_del_tunnel_t_handler(vl_api_mpls_ethernet_add_del_tunnel_t *mp)
Definition: api.c:2395
static void vl_api_flow_classify_dump_t_handler(vl_api_flow_classify_dump_t *mp)
Definition: api.c:8724
#define clib_error_return(e, args...)
Definition: error.h:111
Set interface source and L4 port-range response.
Definition: vpe.api:5068
static void vl_api_vxlan_gpe_tunnel_dump_t_handler(vl_api_vxlan_gpe_tunnel_dump_t *mp)
Definition: api.c:5228
vhost-user interface delete request
Definition: vpe.api:2212
struct _unformat_input_t unformat_input_t
clib_error_t * vnet_create_sw_interface(vnet_main_t *vnm, vnet_sw_interface_t *template, u32 *sw_if_index)
Definition: interface.c:582
static void * ip_interface_address_get_address(ip_lookup_main_t *lm, ip_interface_address_t *a)
Definition: lookup.h:431
Reply for IKEv2: Add/delete profile.
Definition: vpe.api:3703
vhost-user interface modify response
Definition: vpe.api:2203
u8 l2_sublayer_present
Definition: l2tp.h:45
static void vl_api_policer_classify_dump_t_handler(vl_api_policer_classify_dump_t *mp)
Definition: api.c:7485
Interface details structure (fix this)
Definition: vpe.api:71
int af_packet_create_if(vlib_main_t *vm, u8 *host_if_name, u8 *hw_addr_set, u32 *sw_if_index)
Definition: af_packet.c:175
u8 resolve_type
Definition: api.c:483
u32 flags
Definition: vhost-user.h:75
Definition: lisp_types.h:25
Reply for MPLS state on an interface.
Definition: vpe.api:236
bd_main_t bd_main
Definition: l2_bd.c:43
MPLS Ethernet add / del tunnel request.
Definition: vpe.api:1444
clib_error_t * disable_ip6_interface(vlib_main_t *vm, u32 sw_if_index)
ethernet_interface_t * interfaces
Definition: ethernet.h:243
u32 vni
l2tpv3 tunnel interface create request
Definition: vpe.api:1908
#define VXLAN_GPE_TUNNEL_IS_IPV4
Flags for vxlan_gpe_tunnel_t.
Definition: vxlan_gpe.h:120
int ip6_source_and_port_range_check_add_del(ip6_address_t *address, u32 length, u32 vrf_id, u16 *low_ports, u16 *high_ports, int is_add)
#define L2_LEARN
Definition: l2_bd.h:96
static void vl_api_netmap_delete_t_handler(vl_api_netmap_delete_t *mp)
Definition: api.c:7532
Associate the specified interface with a fib table.
Definition: vpe.api:199
static uword vnet_sw_interface_get_flags(vnet_main_t *vnm, u32 sw_if_index)
u8 * format_ipsec_crypto_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:58
vnet_main_t * vnet_main
Definition: dpdk.h:472
Reply for classify table info request.
Definition: vpe.api:4653
Tell client about a DHCP completion event.
Definition: vpe.api:3841
static void send_sw_interface_vhost_user_details(vpe_api_main_t *am, unix_shared_memory_queue_t *q, vhost_user_intf_details_t *vui, u32 context)
Definition: api.c:4265
static int add_del_route_check(fib_protocol_t table_proto, u32 table_id, u32 next_hop_sw_if_index, fib_protocol_t next_hop_table_proto, u32 next_hop_table_id, u8 create_missing_tables, u32 *fib_index, u32 *next_hop_fib_index)
Definition: api.c:1184
Dump mpls eth tunnel table.
Definition: vpe.api:4510
static void vl_api_oam_add_del_t_handler(vl_api_oam_add_del_t *mp)
Definition: api.c:3053
gid_address_t lcl_eid
local eid
Definition: lisp_gpe.h:189
Add / del MPLS encapsulation request.
Definition: vpe.api:557
void vl_set_api_memory_size(u64 size)
u8 is_del
Delete the mapping.
Definition: sr.h:175
int vnet_tap_dump_ifs(tapcli_interface_details_t **out_tapids)
Dump TAP interfaces.
Definition: tapcli.c:751
struct fib_table_t_ * fibs
Definition: ip6.h:135
reply to lisp_eid_table_vni_dump
Definition: vpe.api:3079
int ipsec_set_interface_spd(vlib_main_t *vm, u32 sw_if_index, u32 spd_id, int is_add)
Definition: ipsec.c:39
u32 * fib_index_by_sw_if_index
Definition: ip6.h:141
vnet_policer_main_t vnet_policer_main
Definition: policer.h:47
static void vl_api_ioam_enable_t_handler(vl_api_ioam_enable_t *mp)
Definition: api.c:7228
u32 mreq_itr_rlocs
Definition: control.h:135
Reply to the punt request.
Definition: vpe.api:5290
int mpls_fib_index_cmp(void *a1, void *a2)
Definition: mpls.c:404
gre_main_t gre_main
Definition: gre.c:22
int vnet_add_del_ip4_arp_change_event(vnet_main_t *vnm, void *data_callback, u32 pid, void *address_arg, uword node_index, uword type_opaque, uword data, int is_add)
Definition: arp.c:670
u32 lisp_gpe_tenant_l3_iface_add_or_lock(u32 vni, u32 table_id)
Add/create and lock a new or find and lock the existing L3 interface for the tenant.
DHCP Client config add / del request.
Definition: vpe.api:3399
static void vl_api_sw_interface_set_mpls_enable_t_handler(vl_api_sw_interface_set_mpls_enable_t *mp)
Definition: api.c:2788
static void vl_api_sr_tunnel_add_del_t_handler(vl_api_sr_tunnel_add_del_t *mp)
Definition: api.c:3815
static void vl_api_create_subif_t_handler(vl_api_create_subif_t *mp)
Definition: api.c:2310
void vlib_cli_input(vlib_main_t *vm, unformat_input_t *input, vlib_cli_output_function_t *function, uword function_arg)
Definition: cli.c:538
Punt traffic to the host.
Definition: vpe.api:5277
int dhcp_proxy_set_option82_vss(u32 vrf_id, u32 oui, u32 fib_id, int is_del)
Definition: proxy_node.c:930
static void vl_api_sw_interface_ip6nd_ra_config_t_handler(vl_api_sw_interface_ip6nd_ra_config_t *mp, vlib_main_t *vm)
Definition: api.c:3421
vxlan_tunnel_t * tunnels
Definition: vxlan.h:121
vlib_frame_t * ipfix_classify_send_flows(flow_report_main_t *frm, flow_report_t *fr, vlib_frame_t *f, u32 *to_next, u32 node_index)
u32 * locator_indices
Definition: lisp_types.h:286
static void vl_api_show_lisp_map_request_mode_t_handler(vl_api_show_lisp_map_request_mode_t *mp)
Definition: api.c:5610
static void send_lisp_locator_details(lisp_cp_main_t *lcm, locator_t *loc, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:5740
void ip6_sw_interface_enable_disable(u32 sw_if_index, u32 is_enable)
Definition: ip6_forward.c:412
#define RESOLUTION_EVENT
pg_interface_t * interfaces
Definition: pg.h:319
uword key
Definition: hash.h:161
IPFIX add or delete classifier table request.
Definition: vpe.api:4815
LISP-GPE definitions.
static void send_lisp_locator_set_details(lisp_cp_main_t *lcm, locator_set_t *lsit, unix_shared_memory_queue_t *q, u32 context, u32 ls_index)
Definition: api.c:5812
mpls_unicast_header_t * labels
Definition: mpls.h:51
Request for lisp pitr status.
Definition: vpe.api:3182
ip46_address_t src
Definition: vxlan.h:71
mpls_encap_t * encaps
Definition: mpls.h:110
clib_error_t * vl_api_init(vlib_main_t *vm)
Definition: api_shared.c:718
Definition: defs.h:46
DHCP Proxy config add / del request.
Definition: vpe.api:903
void vl_api_mpls_route_add_del_t_handler(vl_api_mpls_route_add_del_t *mp)
Definition: api.c:1415
ip4_address_t tunnel_src
tunnel IPv4 src address
Definition: ipsec_gre.h:52
pthread_mutex_t mutex
Definition: svm.h:42
#define ip_prefix_addr(_a)
Definition: lisp_types.h:58
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
static ip_adjacency_t * ip_get_adjacency(ip_lookup_main_t *lm, u32 adj_index)
Definition: lookup.h:385
A protocol Independent FIB table.
Definition: fib_table.h:29
static void vl_api_sw_interface_set_dpdk_hqos_tctbl_t_handler(vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp)
Definition: api.c:1797
u8 protocol
Definition: vpe.api:3616
int vnet_flow_report_add_del(flow_report_main_t *frm, vnet_flow_report_add_del_args_t *a)
Definition: flow_report.c:238
Set the ip flow hash config for a fib response.
Definition: vpe.api:985
#define MODE_L3
Definition: l2_input.h:218
int l2tpv3_set_tunnel_cookies(l2t_main_t *lm, u32 sw_if_index, u64 new_local_cookie, u64 new_remote_cookie)
Definition: l2tp.c:517
static void vl_api_ip_source_and_port_range_check_add_del_t_handler(vl_api_ip_source_and_port_range_check_add_del_t *mp)
Definition: api.c:8387
struct _unix_shared_memory_queue unix_shared_memory_queue_t
u8 is_ip_any
Definition: vpe.api:3546
static void vl_api_lisp_map_resolver_dump_t_handler(vl_api_lisp_map_resolver_dump_t *mp)
Definition: api.c:6137
int netmap_delete_if(vlib_main_t *vm, u8 *host_if_name)
Definition: netmap.c:248
mpls_eos_bit_t fp_eos
Definition: fib_types.h:176
int af_packet_delete_if(vlib_main_t *vm, u8 *host_if_name)
Definition: af_packet.c:286
Reply for MAP domain del.
Definition: vpe.api:3911
A LISP Forwarding Entry.
int set_ip_source_and_port_range_check(vlib_main_t *vm, u32 *fib_index, u32 sw_if_index, u32 is_add)
L2 bridge domain add or delete request.
Definition: vpe.api:3319
IPv6 segment routing policy add / del request.
Definition: vpe.api:1365
u32 dp_table
Definition: vpe.api:2544
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:109