FD.io VPP  v16.09
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 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/unix/tuntap.h>
55 #include <vnet/unix/tapcli.h>
56 #include <vnet/mpls-gre/mpls.h>
57 #include <vnet/dhcp/proxy.h>
58 #include <vnet/dhcp/client.h>
59 #if IPV6SR > 0
60 #include <vnet/sr/sr.h>
61 #endif
62 #include <vnet/dhcpv6/proxy.h>
63 #include <vlib/vlib.h>
64 #include <vlib/unix/unix.h>
65 #include <vlibapi/api.h>
66 #include <vlibmemory/api.h>
70 #include <vnet/l2/l2_classify.h>
71 #include <vnet/vxlan/vxlan.h>
72 #include <vnet/gre/gre.h>
73 #include <vnet/l2/l2_vtr.h>
75 #include <vnet/lisp-gpe/lisp_gpe.h>
76 #include <vnet/lisp-cp/control.h>
77 #include <vnet/map/map.h>
78 #include <vnet/cop/cop.h>
79 #include <vnet/ip/ip6_hop_by_hop.h>
82 #include <vnet/policer/policer.h>
84 #include <vnet/flow/flow_report.h>
86 
87 #undef BIHASH_TYPE
88 #undef __included_bihash_template_h__
89 #include <vnet/l2/l2_fib.h>
90 
91 #if IPSEC > 0
92 #include <vnet/ipsec/ipsec.h>
93 #include <vnet/ipsec/ikev2.h>
94 #endif /* IPSEC */
96 
97 #include <stats/stats.h>
98 #include <oam/oam.h>
99 
100 #include <vnet/ethernet/ethernet.h>
102 #include <vnet/interface.h>
103 
104 #include <vnet/l2/l2_fib.h>
105 #include <vnet/l2/l2_bd.h>
106 #include <vpp-api/vpe_msg_enum.h>
107 
108 #define f64_endian(a)
109 #define f64_print(a,b)
110 
111 #define vl_typedefs /* define message structures */
112 #include <vpp-api/vpe_all_api_h.h>
113 #undef vl_typedefs
114 
115 #define vl_endianfun /* define message structures */
116 #include <vpp-api/vpe_all_api_h.h>
117 #undef vl_endianfun
118 
119 /* instantiate all the print functions we know about */
120 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
121 #define vl_printfun
122 #include <vpp-api/vpe_all_api_h.h>
123 #undef vl_printfun
124 
125 #define REPLY_MACRO(t) \
126 do { \
127  unix_shared_memory_queue_t * q; \
128  rv = vl_msg_api_pd_handler (mp, rv); \
129  q = vl_api_client_index_to_input_queue (mp->client_index); \
130  if (!q) \
131  return; \
132  \
133  rmp = vl_msg_api_alloc (sizeof (*rmp)); \
134  rmp->_vl_msg_id = ntohs((t)); \
135  rmp->context = mp->context; \
136  rmp->retval = ntohl(rv); \
137  \
138  vl_msg_api_send_shmem (q, (u8 *)&rmp); \
139 } while(0);
140 
141 #define REPLY_MACRO2(t, body) \
142 do { \
143  unix_shared_memory_queue_t * q; \
144  rv = vl_msg_api_pd_handler (mp, rv); \
145  q = vl_api_client_index_to_input_queue (mp->client_index); \
146  if (!q) \
147  return; \
148  \
149  rmp = vl_msg_api_alloc (sizeof (*rmp)); \
150  rmp->_vl_msg_id = ntohs((t)); \
151  rmp->context = mp->context; \
152  rmp->retval = ntohl(rv); \
153  do {body;} while (0); \
154  vl_msg_api_send_shmem (q, (u8 *)&rmp); \
155 } while(0);
156 
157 #if (1 || CLIB_DEBUG > 0) /* "trust, but verify" */
158 
159 #define VALIDATE_SW_IF_INDEX(mp) \
160  do { u32 __sw_if_index = ntohl(mp->sw_if_index); \
161  vnet_main_t *__vnm = vnet_get_main(); \
162  if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \
163  __sw_if_index)) { \
164  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \
165  goto bad_sw_if_index; \
166  } \
167 } while(0);
168 
169 #define BAD_SW_IF_INDEX_LABEL \
170 do { \
171 bad_sw_if_index: \
172  ; \
173 } while (0);
174 
175 #define VALIDATE_RX_SW_IF_INDEX(mp) \
176  do { u32 __rx_sw_if_index = ntohl(mp->rx_sw_if_index); \
177  vnet_main_t *__vnm = vnet_get_main(); \
178  if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \
179  __rx_sw_if_index)) { \
180  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \
181  goto bad_rx_sw_if_index; \
182  } \
183 } while(0);
184 
185 #define BAD_RX_SW_IF_INDEX_LABEL \
186 do { \
187 bad_rx_sw_if_index: \
188  ; \
189 } while (0);
190 
191 #define VALIDATE_TX_SW_IF_INDEX(mp) \
192  do { u32 __tx_sw_if_index = ntohl(mp->tx_sw_if_index); \
193  vnet_main_t *__vnm = vnet_get_main(); \
194  if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \
195  __tx_sw_if_index)) { \
196  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \
197  goto bad_tx_sw_if_index; \
198  } \
199 } while(0);
200 
201 #define BAD_TX_SW_IF_INDEX_LABEL \
202 do { \
203 bad_tx_sw_if_index: \
204  ; \
205 } while (0);
206 
207 #else
208 
209 #define VALIDATE_SW_IF_INDEX(mp)
210 #define BAD_SW_IF_INDEX_LABEL
211 #define VALIDATE_RX_SW_IF_INDEX(mp)
212 #define BAD_RX_SW_IF_INDEX_LABEL
213 #define VALIDATE_TX_SW_IF_INDEX(mp)
214 #define BAD_TX_SW_IF_INDEX_LABEL
215 
216 #endif /* CLIB_DEBUG > 0 */
217 
218 #define foreach_vpe_api_msg \
219 _(WANT_INTERFACE_EVENTS, want_interface_events) \
220 _(WANT_OAM_EVENTS, want_oam_events) \
221 _(OAM_ADD_DEL, oam_add_del) \
222 _(SW_INTERFACE_DUMP, sw_interface_dump) \
223 _(SW_INTERFACE_DETAILS, sw_interface_details) \
224 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
225 _(IP_ADD_DEL_ROUTE, ip_add_del_route) \
226 _(IS_ADDRESS_REACHABLE, is_address_reachable) \
227 _(SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address) \
228 _(SW_INTERFACE_SET_TABLE, sw_interface_set_table) \
229 _(SW_INTERFACE_SET_VPATH, sw_interface_set_vpath) \
230 _(SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect) \
231 _(SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge) \
232 _(BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del) \
233 _(BRIDGE_DOMAIN_DUMP, bridge_domain_dump) \
234 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
235 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
236 _(L2FIB_ADD_DEL, l2fib_add_del) \
237 _(L2_FLAGS, l2_flags) \
238 _(BRIDGE_FLAGS, bridge_flags) \
239 _(TAP_CONNECT, tap_connect) \
240 _(TAP_MODIFY, tap_modify) \
241 _(TAP_DELETE, tap_delete) \
242 _(SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump) \
243 _(CREATE_VLAN_SUBIF, create_vlan_subif) \
244 _(CREATE_SUBIF, create_subif) \
245 _(MPLS_GRE_ADD_DEL_TUNNEL, mpls_gre_add_del_tunnel) \
246 _(MPLS_ETHERNET_ADD_DEL_TUNNEL, mpls_ethernet_add_del_tunnel) \
247 _(MPLS_ETHERNET_ADD_DEL_TUNNEL_2, mpls_ethernet_add_del_tunnel_2) \
248 _(MPLS_ADD_DEL_ENCAP, mpls_add_del_encap) \
249 _(MPLS_ADD_DEL_DECAP, mpls_add_del_decap) \
250 _(PROXY_ARP_ADD_DEL, proxy_arp_add_del) \
251 _(PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable) \
252 _(IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del) \
253 _(VNET_GET_SUMMARY_STATS, vnet_get_summary_stats) \
254 _(RESET_FIB, reset_fib) \
255 _(DHCP_PROXY_CONFIG,dhcp_proxy_config) \
256 _(DHCP_PROXY_CONFIG_2,dhcp_proxy_config_2) \
257 _(DHCP_PROXY_SET_VSS,dhcp_proxy_set_vss) \
258 _(DHCP_CLIENT_CONFIG, dhcp_client_config) \
259 _(SET_IP_FLOW_HASH,set_ip_flow_hash) \
260 _(SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config) \
261 _(SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix) \
262 _(SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable ) \
263 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, \
264  sw_interface_ip6_set_link_local_address) \
265 _(SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered) \
266 _(CREATE_LOOPBACK, create_loopback) \
267 _(CONTROL_PING, control_ping) \
268 _(NOPRINT_CONTROL_PING, noprint_control_ping) \
269 _(CLI_REQUEST, cli_request) \
270 _(SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit) \
271 _(L2_PATCH_ADD_DEL, l2_patch_add_del) \
272 _(CLASSIFY_ADD_DEL_TABLE, classify_add_del_table) \
273 _(CLASSIFY_ADD_DEL_SESSION, classify_add_del_session) \
274 _(CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table) \
275 _(CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables) \
276 _(GET_NODE_INDEX, get_node_index) \
277 _(ADD_NODE_NEXT, add_node_next) \
278 _(L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel) \
279 _(L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies) \
280 _(L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable) \
281 _(L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key) \
282 _(SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump) \
283 _(VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel) \
284 _(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump) \
285 _(GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel) \
286 _(GRE_TUNNEL_DUMP, gre_tunnel_dump) \
287 _(L2_FIB_CLEAR_TABLE, l2_fib_clear_table) \
288 _(L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter) \
289 _(L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite) \
290 _(CREATE_VHOST_USER_IF, create_vhost_user_if) \
291 _(MODIFY_VHOST_USER_IF, modify_vhost_user_if) \
292 _(DELETE_VHOST_USER_IF, delete_vhost_user_if) \
293 _(SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump) \
294 _(IP_ADDRESS_DUMP, ip_address_dump) \
295 _(IP_DUMP, ip_dump) \
296 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
297 _(SHOW_VERSION, show_version) \
298 _(L2_FIB_TABLE_DUMP, l2_fib_table_dump) \
299 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
300 _(VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel) \
301 _(VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump) \
302 _(INTERFACE_NAME_RENUMBER, interface_name_renumber) \
303 _(WANT_IP4_ARP_EVENTS, want_ip4_arp_events) \
304 _(INPUT_ACL_SET_INTERFACE, input_acl_set_interface) \
305 _(IPSEC_SPD_ADD_DEL, ipsec_spd_add_del) \
306 _(IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd) \
307 _(IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry) \
308 _(IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry) \
309 _(IPSEC_SA_SET_KEY, ipsec_sa_set_key) \
310 _(IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del) \
311 _(IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth) \
312 _(IKEV2_PROFILE_SET_ID, ikev2_profile_set_id) \
313 _(IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts) \
314 _(IKEV2_SET_LOCAL_KEY, ikev2_set_local_key) \
315 _(DELETE_LOOPBACK, delete_loopback) \
316 _(BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del) \
317 _(MAP_ADD_DOMAIN, map_add_domain) \
318 _(MAP_DEL_DOMAIN, map_del_domain) \
319 _(MAP_ADD_DEL_RULE, map_add_del_rule) \
320 _(MAP_DOMAIN_DUMP, map_domain_dump) \
321 _(MAP_RULE_DUMP, map_rule_dump) \
322 _(MAP_SUMMARY_STATS, map_summary_stats) \
323 _(COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable) \
324 _(COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable) \
325 _(GET_NODE_GRAPH, get_node_graph) \
326 _(SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats) \
327 _(TRACE_PROFILE_ADD, trace_profile_add) \
328 _(TRACE_PROFILE_APPLY, trace_profile_apply) \
329 _(TRACE_PROFILE_DEL, trace_profile_del) \
330 _(LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set) \
331 _(LISP_ADD_DEL_LOCATOR, lisp_add_del_locator) \
332 _(LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid) \
333 _(LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry) \
334 _(LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver) \
335 _(LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable) \
336 _(LISP_ENABLE_DISABLE, lisp_enable_disable) \
337 _(LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface) \
338 _(LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping) \
339 _(LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency) \
340 _(LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set) \
341 _(LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map) \
342 _(LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump) \
343 _(LISP_LOCATOR_DUMP, lisp_locator_dump) \
344 _(LISP_EID_TABLE_DUMP, lisp_eid_table_dump) \
345 _(LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump) \
346 _(LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump) \
347 _(LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump) \
348 _(SHOW_LISP_STATUS, show_lisp_status) \
349 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, \
350  lisp_add_del_map_request_itr_rlocs) \
351 _(LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs) \
352 _(SHOW_LISP_PITR, show_lisp_pitr) \
353 _(SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del) \
354 _(AF_PACKET_CREATE, af_packet_create) \
355 _(AF_PACKET_DELETE, af_packet_delete) \
356 _(POLICER_ADD_DEL, policer_add_del) \
357 _(POLICER_DUMP, policer_dump) \
358 _(POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface) \
359 _(POLICER_CLASSIFY_DUMP, policer_classify_dump) \
360 _(NETMAP_CREATE, netmap_create) \
361 _(NETMAP_DELETE, netmap_delete) \
362 _(MPLS_GRE_TUNNEL_DUMP, mpls_gre_tunnel_dump) \
363 _(MPLS_GRE_TUNNEL_DETAILS, mpls_gre_tunnel_details) \
364 _(MPLS_ETH_TUNNEL_DUMP, mpls_eth_tunnel_dump) \
365 _(MPLS_ETH_TUNNEL_DETAILS, mpls_eth_tunnel_details) \
366 _(MPLS_FIB_ENCAP_DUMP, mpls_fib_encap_dump) \
367 _(MPLS_FIB_ENCAP_DETAILS, mpls_fib_encap_details) \
368 _(MPLS_FIB_DECAP_DUMP, mpls_fib_decap_dump) \
369 _(MPLS_FIB_DECAP_DETAILS, mpls_fib_decap_details) \
370 _(CLASSIFY_TABLE_IDS,classify_table_ids) \
371 _(CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface) \
372 _(CLASSIFY_TABLE_INFO,classify_table_info) \
373 _(CLASSIFY_SESSION_DUMP,classify_session_dump) \
374 _(CLASSIFY_SESSION_DETAILS,classify_session_details) \
375 _(IPFIX_ENABLE,ipfix_enable) \
376 _(IPFIX_DUMP,ipfix_dump) \
377 _(GET_NEXT_INDEX, get_next_index) \
378 _(PG_CREATE_INTERFACE, pg_create_interface) \
379 _(PG_CAPTURE, pg_capture) \
380 _(PG_ENABLE_DISABLE, pg_enable_disable) \
381 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, \
382  ip_source_and_port_range_check_add_del) \
383 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, \
384  ip_source_and_port_range_check_interface_add_del) \
385 _(IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel) \
386 _(IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump)
387 
388 #define QUOTE_(x) #x
389 #define QUOTE(x) QUOTE_(x)
390 
391 #define foreach_registration_hash \
392 _(interface_events) \
393 _(to_netconf_server) \
394 _(from_netconf_server) \
395 _(to_netconf_client) \
396 _(from_netconf_client) \
397 _(oam_events)
398 
399 typedef enum
400 {
404 } resolve_t;
405 
406 typedef struct
407 {
409  union
410  {
413  };
415 
416 typedef struct
417 {
418 
419 #define _(a) uword *a##_registration_hash; \
420  vpe_client_registration_t * a##_registrations;
422 #undef _
423  /* notifications happen really early in the game */
425 
426  /* ip4 pending route adds */
428 
429  /* ip4 arp event registration pool */
431 
432  /* convenience */
436 
439 
440 static void send_sw_interface_flags (vpe_api_main_t * am,
442  vnet_sw_interface_t * swif);
445  u32 sw_if_index);
446 
447 static int arp_change_delete_callback (u32 pool_index, u8 * notused);
448 
449 
450 /* Clean up all registrations belonging to the indicated client */
451 int
453 {
456  uword *p;
457  int stats_memclnt_delete_callback (u32 client_index);
458 
459  stats_memclnt_delete_callback (client_index);
460 
461 #define _(a) \
462  p = hash_get (vam->a##_registration_hash, client_index); \
463  if (p) { \
464  rp = pool_elt_at_index (vam->a##_registrations, p[0]); \
465  pool_put (vam->a##_registrations, rp); \
466  hash_unset (vam->a##_registration_hash, client_index); \
467  }
469 #undef _
470  return 0;
471 }
472 
473 #define API_LINK_STATE_EVENT 1
474 #define API_ADMIN_UP_DOWN_EVENT 2
475 
476 static int
477 event_data_cmp (void *a1, void *a2)
478 {
479  uword *e1 = a1;
480  uword *e2 = a2;
481 
482  return (word) e1[0] - (word) e2[0];
483 }
484 
485 static uword
488 {
490  vnet_main_t *vnm = vam->vnet_main;
491  vnet_sw_interface_t *swif;
492  uword *event_data = 0;
494  int i;
495  u32 prev_sw_if_index;
497 
498  vam->link_state_process_up = 1;
499 
500  while (1)
501  {
503 
504  /* Unified list of changed link or admin state sw_if_indices */
506  (vm, &event_data, API_LINK_STATE_EVENT);
508  (vm, &event_data, API_ADMIN_UP_DOWN_EVENT);
509 
510  /* Sort, so we can eliminate duplicates */
512 
513  prev_sw_if_index = ~0;
514 
515  for (i = 0; i < vec_len (event_data); i++)
516  {
517  /* Only one message per swif */
518  if (prev_sw_if_index == event_data[i])
519  continue;
520  prev_sw_if_index = event_data[i];
521 
522  /* *INDENT-OFF* */
523  pool_foreach(reg, vam->interface_events_registrations,
524  ({
525  q = vl_api_client_index_to_input_queue (reg->client_index);
526  if (q)
527  {
528  /* sw_interface may be deleted already */
529  if (!pool_is_free_index (vnm->interface_main.sw_interfaces,
530  event_data[i]))
531  {
532  swif = vnet_get_sw_interface (vnm, event_data[i]);
533  send_sw_interface_flags (vam, q, swif);
534  }
535  }
536  }));
537  /* *INDENT-ON* */
538  }
539  vec_reset_length (event_data);
540  }
541 
542  return 0;
543 }
544 
545 static clib_error_t *link_up_down_function (vnet_main_t * vm, u32 hw_if_index,
546  u32 flags);
548  u32 hw_if_index, u32 flags);
549 
550 /* *INDENT-OFF* */
552  .function = link_state_process,
553  .type = VLIB_NODE_TYPE_PROCESS,
554  .name = "vpe-link-state-process",
555 };
556 /* *INDENT-ON* */
557 
558 VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION (admin_up_down_function);
559 VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION (link_up_down_function);
560 
561 static clib_error_t *
562 link_up_down_function (vnet_main_t * vm, u32 hw_if_index, u32 flags)
563 {
565  vnet_hw_interface_t *hi = vnet_get_hw_interface (vm, hw_if_index);
566 
567  if (vam->link_state_process_up)
571  return 0;
572 }
573 
574 static clib_error_t *
575 admin_up_down_function (vnet_main_t * vm, u32 sw_if_index, u32 flags)
576 {
578 
579  /*
580  * Note: it's perfectly fair to set a subif admin up / admin down.
581  * Note the subtle distinction between this routine and the previous
582  * routine.
583  */
584  if (vam->link_state_process_up)
587  API_ADMIN_UP_DOWN_EVENT, sw_if_index);
588  return 0;
589 }
590 
591 #define pub_sub_handler(lca,UCA) \
592 static void vl_api_want_##lca##_t_handler ( \
593  vl_api_want_##lca##_t *mp) \
594 { \
595  vpe_api_main_t *vam = &vpe_api_main; \
596  vpe_client_registration_t *rp; \
597  vl_api_want_##lca##_reply_t *rmp; \
598  uword *p; \
599  i32 rv = 0; \
600  \
601  p = hash_get (vam->lca##_registration_hash, mp->client_index); \
602  if (p) { \
603  if (mp->enable_disable) { \
604  clib_warning ("pid %d: already enabled...", mp->pid); \
605  rv = VNET_API_ERROR_INVALID_REGISTRATION; \
606  goto reply; \
607  } else { \
608  rp = pool_elt_at_index (vam->lca##_registrations, p[0]); \
609  pool_put (vam->lca##_registrations, rp); \
610  hash_unset (vam->lca##_registration_hash, \
611  mp->client_index); \
612  goto reply; \
613  } \
614  } \
615  if (mp->enable_disable == 0) { \
616  clib_warning ("pid %d: already disabled...", mp->pid); \
617  rv = VNET_API_ERROR_INVALID_REGISTRATION; \
618  goto reply; \
619  } \
620  pool_get (vam->lca##_registrations, rp); \
621  rp->client_index = mp->client_index; \
622  rp->client_pid = mp->pid; \
623  hash_set (vam->lca##_registration_hash, rp->client_index, \
624  rp - vam->lca##_registrations); \
625  \
626 reply: \
627  REPLY_MACRO (VL_API_WANT_##UCA##_REPLY); \
628 }
629 
630 pub_sub_handler (interface_events, INTERFACE_EVENTS)
631 pub_sub_handler (oam_events, OAM_EVENTS)
632 #define RESOLUTION_EVENT 1
633 #define RESOLUTION_PENDING_EVENT 2
634 #define IP4_ARP_EVENT 3
639 
640  void handle_ip4_arp_event (u32 pool_index)
641 {
643  vnet_main_t *vnm = vam->vnet_main;
644  vlib_main_t *vm = vam->vlib_main;
645  vl_api_ip4_arp_event_t *event;
648 
649  /* Client can cancel, die, etc. */
650  if (pool_is_free_index (vam->arp_events, pool_index))
651  return;
652 
653  event = pool_elt_at_index (vam->arp_events, pool_index);
654 
656  if (!q)
657  {
660  event->pid, &event->address,
661  vpe_resolver_process_node.index, IP4_ARP_EVENT,
662  ~0 /* pool index, notused */ , 0 /* is_add */ );
663  return;
664  }
665 
666  if (q->cursize < q->maxsize)
667  {
668  mp = vl_msg_api_alloc (sizeof (*mp));
669  clib_memcpy (mp, event, sizeof (*mp));
670  vl_msg_api_send_shmem (q, (u8 *) & mp);
671  }
672  else
673  {
674  static f64 last_time;
675  /*
676  * Throttle syslog msgs.
677  * It's pretty tempting to just revoke the registration...
678  */
679  if (vlib_time_now (vm) > last_time + 10.0)
680  {
681  clib_warning ("arp event for %U to pid %d: queue stuffed!",
682  format_ip4_address, &event->address, event->pid);
683  last_time = vlib_time_now (vm);
684  }
685  }
686 }
687 
688 static uword
691 {
692  uword event_type;
693  uword *event_data = 0;
694  f64 timeout = 100.0;
696  pending_route_t *pr;
699  u32 *resolution_failures = 0;
700  int i, rv;
701  clib_error_t *e;
702 
703  while (1)
704  {
706 
707  event_type = vlib_process_get_events (vm, &event_data);
708 
709  switch (event_type)
710  {
712  timeout = 1.0;
713  break;
714 
715  case RESOLUTION_EVENT:
716  for (i = 0; i < vec_len (event_data); i++)
717  {
718  /*
719  * Resolution events can occur long after the
720  * original request has timed out. $$$ add a cancel
721  * mechanism..
722  */
723  if (pool_is_free_index (vam->pending_routes, event_data[i]))
724  continue;
725 
726  pr = pool_elt_at_index (vam->pending_routes, event_data[i]);
727  adr = &pr->r;
728  pme = &pr->t;
729 
730  switch (pr->resolve_type)
731  {
733  rv = ip4_add_del_route_t_handler (adr);
734  clib_warning ("resolver: add %U/%d via %U %s",
736  (ip4_address_t *) & (adr->dst_address),
737  adr->dst_address_length,
739  (ip4_address_t *) & (adr->next_hop_address),
740  (rv >= 0) ? "succeeded" : "failed");
741  break;
742 
744  rv = ip6_add_del_route_t_handler (adr);
745  clib_warning ("resolver: add %U/%d via %U %s",
747  (ip6_address_t *) & (adr->dst_address),
748  adr->dst_address_length,
750  (ip6_address_t *) & (adr->next_hop_address),
751  (rv >= 0) ? "succeeded" : "failed");
752  break;
753 
756  clib_warning ("resolver: add mpls-o-e via %U %s",
758  (ip4_address_t *) &
760  (rv >= 0) ? "succeeded" : "failed");
761  break;
762 
763  default:
764  clib_warning ("resolver: BOGUS TYPE %d", pr->resolve_type);
765  }
766  pool_put (vam->pending_routes, pr);
767  }
768  break;
769 
770  case IP4_ARP_EVENT:
771  for (i = 0; i < vec_len (event_data); i++)
772  handle_ip4_arp_event (event_data[i]);
773  break;
774 
775  case ~0: /* timeout, retry pending resolutions */
776  /* *INDENT-OFF* */
777  pool_foreach (pr, vam->pending_routes,
778  ({
779  int is_adr = 1;
780  adr = &pr->r;
781  pme = &pr->t;
782 
783  /* May fail, e.g. due to interface down */
784  switch (pr->resolve_type)
785  {
786  case RESOLVE_IP4_ADD_DEL_ROUTE:
787  e = ip4_probe_neighbor
788  (vm, (ip4_address_t *)&(adr->next_hop_address),
789  ntohl(adr->next_hop_sw_if_index));
790  break;
791 
792  case RESOLVE_IP6_ADD_DEL_ROUTE:
793  e = ip6_probe_neighbor
794  (vm, (ip6_address_t *)&(adr->next_hop_address),
795  ntohl(adr->next_hop_sw_if_index));
796  break;
797 
798  case RESOLVE_MPLS_ETHERNET_ADD_DEL:
799  is_adr = 0;
800  e = ip4_probe_neighbor
801  (vm,
802  (ip4_address_t *)&(pme->next_hop_ip4_address_in_outer_vrf),
803  pme->resolve_opaque);
804  break;
805 
806  default:
807  e = clib_error_return (0, "resolver: BOGUS TYPE %d",
808  pr->resolve_type);
809  }
810  if (e)
811  {
812  clib_error_report (e);
813  if (is_adr)
814  adr->resolve_attempts = 1;
815  else
816  pme->resolve_attempts = 1;
817  }
818  if (is_adr)
819  {
820  adr->resolve_attempts -= 1;
821  if (adr->resolve_attempts == 0)
822  vec_add1 (resolution_failures,
823  pr - vam->pending_routes);
824  }
825  else
826  {
827  pme->resolve_attempts -= 1;
828  if (pme->resolve_attempts == 0)
829  vec_add1 (resolution_failures,
830  pr - vam->pending_routes);
831  }
832  }));
833  /* *INDENT-ON* */
834  for (i = 0; i < vec_len (resolution_failures); i++)
835  {
837  resolution_failures[i]);
838  adr = &pr->r;
839  pme = &pr->t;
840 
841  switch (pr->resolve_type)
842  {
844  clib_warning ("resolver: add %U/%d via %U retry failure",
846  (ip4_address_t *) & (adr->dst_address),
847  adr->dst_address_length,
849  (ip4_address_t *) & (adr->next_hop_address));
850  break;
851 
853  clib_warning ("resolver: add %U/%d via %U retry failure",
855  (ip6_address_t *) & (adr->dst_address),
856  adr->dst_address_length,
858  (ip6_address_t *) & (adr->next_hop_address));
859  break;
860 
862  clib_warning ("resolver: add mpls-o-e via %U retry failure",
864  (ip4_address_t *) &
866  break;
867 
868  default:
869  clib_warning ("BUG");
870  }
871  pool_put (vam->pending_routes, pr);
872  }
873  vec_reset_length (resolution_failures);
874  break;
875  }
876  if (pool_elts (vam->pending_routes) == 0)
877  timeout = 100.0;
878  vec_reset_length (event_data);
879  }
880  return 0; /* or not */
881 }
882 
883 /* *INDENT-OFF* */
884 VLIB_REGISTER_NODE (vpe_resolver_process_node,static) = {
885  .function = resolver_process,
886  .type = VLIB_NODE_TYPE_PROCESS,
887  .name = "vpe-route-resolver-process",
888 };
889 /* *INDENT-ON* */
890 
891 static int
893 {
894  ip4_main_t *im = &ip4_main;
895  ip_lookup_main_t *lm = &im->lookup_main;
897  stats_main_t *sm = &stats_main;
899  ip4_address_t next_hop_address;
900  u32 fib_index;
902  vnet_main_t *vnm = vam->vnet_main;
903  vlib_main_t *vm = vlib_get_main ();
904  pending_route_t *pr;
906  uword *p;
907  clib_error_t *e;
908  u32 ai;
909  ip_adjacency_t *adj;
910 
911  p = hash_get (im->fib_index_by_table_id, ntohl (mp->vrf_id));
912  if (!p)
913  {
914  if (mp->create_vrf_if_needed)
915  {
916  ip4_fib_t *f;
917  f = find_ip4_fib_by_table_index_or_id (im, ntohl (mp->vrf_id),
918  0 /* flags */ );
919  fib_index = f->index;
920  }
921  else
922  {
923  /* No such VRF, and we weren't asked to create one */
924  return VNET_API_ERROR_NO_SUCH_FIB;
925  }
926  }
927  else
928  {
929  fib_index = p[0];
930  }
931 
932  if (~0 != mp->next_hop_sw_if_index &&
934  ntohl (mp->next_hop_sw_if_index)))
935  return VNET_API_ERROR_NO_MATCHING_INTERFACE;
936 
937  clib_memcpy (next_hop_address.data, mp->next_hop_address,
938  sizeof (next_hop_address.data));
939 
940  /* Arp for the next_hop if necessary */
941  if (mp->is_add && mp->resolve_if_needed && ~0 != mp->next_hop_sw_if_index)
942  {
943  u32 lookup_result;
944  ip_adjacency_t *adj;
945 
946  lookup_result = ip4_fib_lookup_with_table
947  (im, fib_index, &next_hop_address, 1 /* disable default route */ );
948 
949  adj = ip_get_adjacency (lm, lookup_result);
950 
952  {
953  pool_get (vam->pending_routes, pr);
955  adr = &pr->r;
956  clib_memcpy (adr, mp, sizeof (*adr));
957  /* recursion block, "just in case" */
958  adr->resolve_if_needed = 0;
959  adr->resolve_attempts = ntohl (mp->resolve_attempts);
961  (vnm, &next_hop_address, vpe_resolver_process_node.index,
962  RESOLUTION_EVENT, pr - vam->pending_routes);
963 
965  (vm, vpe_resolver_process_node.index,
966  RESOLUTION_PENDING_EVENT, 0 /* data */ );
967 
968  /* The interface may be down, etc. */
970  (vm, (ip4_address_t *) & (mp->next_hop_address),
971  ntohl (mp->next_hop_sw_if_index));
972 
973  if (e)
974  clib_error_report (e);
975 
976  return VNET_API_ERROR_IN_PROGRESS;
977  }
978  }
979 
980  if (mp->is_multipath)
981  {
982  u32 flags;
983 
984  dslock (sm, 1 /* release hint */ , 10 /* tag */ );
985 
986  if (mp->is_add)
987  flags = IP4_ROUTE_FLAG_ADD;
988  else
989  flags = IP4_ROUTE_FLAG_DEL;
990 
991  if (mp->not_last)
993 
994  ip4_add_del_route_next_hop (im, flags,
995  (ip4_address_t *) mp->dst_address,
996  (u32) mp->dst_address_length,
998  ntohl (mp->next_hop_sw_if_index),
999  (u32) mp->next_hop_weight,
1000  ~0 /* adj_index */ ,
1001  fib_index);
1002  dsunlock (sm);
1003  return 0;
1004  }
1005 
1006  memset (&a, 0, sizeof (a));
1008  sizeof (a.dst_address.data));
1009 
1011 
1014  a.table_index_or_table_id = fib_index;
1015  a.add_adj = 0;
1016  a.n_add_adj = 0;
1017 
1018  if (mp->not_last)
1020 
1021  dslock (sm, 1 /* release hint */ , 2 /* tag */ );
1022 
1023  if (mp->is_add)
1024  {
1025  if (mp->is_drop)
1026  ai = lm->drop_adj_index;
1027  else if (mp->is_local)
1028  ai = lm->local_adj_index;
1029  else if (mp->is_classify)
1030  {
1031  if (pool_is_free_index
1032  (cm->tables, ntohl (mp->classify_table_index)))
1033  {
1034  dsunlock (sm);
1035  return VNET_API_ERROR_NO_SUCH_TABLE;
1036  }
1037  adj = ip_add_adjacency (lm,
1038  /* template */ 0,
1039  /* block size */ 1,
1040  &ai);
1041 
1043  adj->classify.table_index = ntohl (mp->classify_table_index);
1044  }
1045  else if (mp->lookup_in_vrf)
1046  {
1047  p = hash_get (im->fib_index_by_table_id, ntohl (mp->lookup_in_vrf));
1048  if (p)
1049  {
1050  adj = ip_add_adjacency (lm,
1051  /* template */ 0,
1052  /* block size */ 1,
1053  &ai);
1054  adj->explicit_fib_index = p[0];
1055  }
1056  else
1057  {
1058  dsunlock (sm);
1059  return VNET_API_ERROR_NO_SUCH_INNER_FIB;
1060  }
1061  }
1062  else
1063  ai = ip4_route_get_next_hop_adj (im,
1064  fib_index,
1065  &next_hop_address,
1066  ntohl (mp->next_hop_sw_if_index),
1067  fib_index);
1068 
1069  if (ai == lm->miss_adj_index)
1070  {
1071  dsunlock (sm);
1072  return VNET_API_ERROR_NO_SUCH_INNER_FIB;
1073  }
1074  }
1075  else
1076  {
1077  ip_adjacency_t *adj;
1078  int disable_default_route = 1;
1079 
1080  /* Trying to delete the default route? */
1081  if (a.dst_address.as_u32 == 0 && a.dst_address_length == 0)
1082  disable_default_route = 0;
1083 
1085  (im, fib_index, &a.dst_address, disable_default_route);
1086  if (ai == lm->miss_adj_index)
1087  {
1088  dsunlock (sm);
1089  return VNET_API_ERROR_UNKNOWN_DESTINATION;
1090  }
1091 
1092  adj = ip_get_adjacency (lm, ai);
1094  {
1095  dsunlock (sm);
1096  return VNET_API_ERROR_ADDRESS_MATCHES_INTERFACE_ADDRESS;
1097  }
1098  }
1099 
1100  a.adj_index = ai;
1101  ip4_add_del_route (im, &a);
1102 
1103  dsunlock (sm);
1104  return 0;
1105 }
1106 
1107 static int
1109 {
1110  ip6_main_t *im = &ip6_main;
1111  ip_lookup_main_t *lm = &im->lookup_main;
1112  vnet_main_t *vnm = vnet_get_main ();
1113  vlib_main_t *vm = vlib_get_main ();
1114  vpe_api_main_t *vam = &vpe_api_main;
1115  stats_main_t *sm = &stats_main;
1117  ip6_address_t next_hop_address;
1118  pending_route_t *pr;
1120 
1121  u32 fib_index;
1122  uword *p;
1123  clib_error_t *e;
1124  ip_adjacency_t *adj = 0;
1125  u32 ai;
1126 
1127  p = hash_get (im->fib_index_by_table_id, ntohl (mp->vrf_id));
1128 
1129  if (!p)
1130  {
1131  if (mp->create_vrf_if_needed)
1132  {
1133  ip6_fib_t *f;
1134  f = find_ip6_fib_by_table_index_or_id (im, ntohl (mp->vrf_id),
1135  0 /* flags */ );
1136  fib_index = f->index;
1137  }
1138  else
1139  {
1140  /* No such VRF, and we weren't asked to create one */
1141  return VNET_API_ERROR_NO_SUCH_FIB;
1142  }
1143  }
1144  else
1145  {
1146  fib_index = p[0];
1147  }
1148 
1149  if (~0 != mp->next_hop_sw_if_index &&
1151  ntohl (mp->next_hop_sw_if_index)))
1152  return VNET_API_ERROR_NO_MATCHING_INTERFACE;
1153 
1154  clib_memcpy (next_hop_address.as_u8, mp->next_hop_address,
1155  sizeof (next_hop_address.as_u8));
1156 
1157  /* Arp for the next_hop if necessary */
1158  if (mp->is_add && mp->resolve_if_needed && ~0 != mp->next_hop_sw_if_index)
1159  {
1160  u32 lookup_result;
1161  ip_adjacency_t *adj;
1162 
1163  lookup_result = ip6_fib_lookup_with_table
1164  (im, fib_index, &next_hop_address);
1165 
1166  adj = ip_get_adjacency (lm, lookup_result);
1167 
1169  {
1170  pool_get (vam->pending_routes, pr);
1171  adr = &pr->r;
1173  clib_memcpy (adr, mp, sizeof (*adr));
1174  /* recursion block, "just in case" */
1175  adr->resolve_if_needed = 0;
1176  adr->resolve_attempts = ntohl (mp->resolve_attempts);
1178  (vnm, &next_hop_address, vpe_resolver_process_node.index,
1179  RESOLUTION_EVENT, pr - vam->pending_routes);
1180 
1182  (vm, vpe_resolver_process_node.index,
1183  RESOLUTION_PENDING_EVENT, 0 /* data */ );
1184 
1185  /* The interface may be down, etc. */
1186  e = ip6_probe_neighbor
1187  (vm, (ip6_address_t *) & (mp->next_hop_address),
1188  ntohl (mp->next_hop_sw_if_index));
1189 
1190  if (e)
1191  clib_error_report (e);
1192 
1193  return VNET_API_ERROR_IN_PROGRESS;
1194  }
1195  }
1196 
1197  if (mp->is_multipath)
1198  {
1199  u32 flags;
1200 
1201  dslock (sm, 1 /* release hint */ , 11 /* tag */ );
1202 
1203  if (mp->is_add)
1204  flags = IP6_ROUTE_FLAG_ADD;
1205  else
1206  flags = IP6_ROUTE_FLAG_DEL;
1207 
1208  if (mp->not_last)
1210 
1211  ip6_add_del_route_next_hop (im, flags,
1212  (ip6_address_t *) mp->dst_address,
1213  (u32) mp->dst_address_length,
1215  ntohl (mp->next_hop_sw_if_index),
1216  (u32) mp->next_hop_weight,
1217  ~0 /* adj_index */ ,
1218  fib_index);
1219  dsunlock (sm);
1220  return 0;
1221  }
1222 
1223  memset (&a, 0, sizeof (a));
1225  sizeof (a.dst_address.as_u8));
1226 
1228 
1231  a.table_index_or_table_id = fib_index;
1232  a.add_adj = 0;
1233  a.n_add_adj = 0;
1234 
1235  if (mp->not_last)
1237 
1238  dslock (sm, 1 /* release hint */ , 3 /* tag */ );
1239 
1240  if (mp->is_add)
1241  {
1242  if (mp->is_drop)
1243  ai = lm->drop_adj_index;
1244  else if (mp->is_local)
1245  ai = lm->local_adj_index;
1246  else if (mp->lookup_in_vrf)
1247  {
1248  p = hash_get (im->fib_index_by_table_id, ntohl (mp->lookup_in_vrf));
1249  if (p)
1250  {
1251  adj = ip_add_adjacency (lm,
1252  /* template */ 0,
1253  /* block size */ 1,
1254  &ai);
1255  adj->explicit_fib_index = p[0];
1256  }
1257  else
1258  {
1259  dsunlock (sm);
1260  return VNET_API_ERROR_NO_SUCH_INNER_FIB;
1261  }
1262  }
1263  else
1264  ai = ip6_route_get_next_hop_adj (im,
1265  fib_index,
1266  &next_hop_address,
1267  ntohl (mp->next_hop_sw_if_index),
1268  fib_index);
1269  if (ai == lm->miss_adj_index)
1270  {
1271  dsunlock (sm);
1272  return VNET_API_ERROR_NEXT_HOP_NOT_IN_FIB;
1273  }
1274  }
1275  else
1276  {
1277  ip_adjacency_t *adj;
1278 
1279  ai = ip6_fib_lookup_with_table (im, fib_index, &a.dst_address);
1280  if (ai == lm->miss_adj_index)
1281  {
1282  dsunlock (sm);
1283  return VNET_API_ERROR_UNKNOWN_DESTINATION;
1284  }
1285  adj = ip_get_adjacency (lm, ai);
1287  {
1288  dsunlock (sm);
1289  return VNET_API_ERROR_ADDRESS_MATCHES_INTERFACE_ADDRESS;
1290  }
1291  }
1292 
1293  a.adj_index = ai;
1294  ip6_add_del_route (im, &a);
1295 
1296  dsunlock (sm);
1297  return 0;
1298 }
1299 
1300 void
1302 {
1304  int rv;
1305  vnet_main_t *vnm = vnet_get_main ();
1306 
1307  vnm->api_errno = 0;
1308 
1309  if (mp->is_ipv6)
1310  rv = ip6_add_del_route_t_handler (mp);
1311  else
1312  rv = ip4_add_del_route_t_handler (mp);
1313 
1314  rv = (rv == 0) ? vnm->api_errno : rv;
1315 
1316  REPLY_MACRO (VL_API_IP_ADD_DEL_ROUTE_REPLY);
1317 }
1318 
1319 void
1320 api_config_default_ip_route (u8 is_ipv6, u8 is_add, u32 vrf_id,
1321  u32 sw_if_index, u8 * next_hop_addr)
1322 {
1324  int rv;
1325 
1326  memset (&mp, 0, sizeof (vl_api_ip_add_del_route_t));
1327 
1328  /*
1329  * Configure default IP route:
1330  * - ip route add 0.0.0.0/1 via <GW IP>
1331  * - ip route add 128.0.0.0/1 via <GW IP>
1332  */
1333  mp.next_hop_sw_if_index = ntohl (sw_if_index);
1334  mp.vrf_id = vrf_id;
1335  mp.resolve_attempts = ~0;
1336  mp.resolve_if_needed = 1;
1337  mp.is_add = is_add;
1338  mp.is_ipv6 = is_ipv6;
1339  mp.next_hop_weight = 1;
1340 
1341  clib_memcpy (&mp.next_hop_address[0], next_hop_addr, 16);
1342 
1343  if (is_ipv6)
1344  rv = ip6_add_del_route_t_handler (&mp);
1345  else
1346  {
1347  mp.dst_address_length = 1;
1348 
1349  mp.dst_address[0] = 0;
1350  rv = ip4_add_del_route_t_handler (&mp);
1351 
1352  mp.dst_address[0] = 128;
1353  rv |= ip4_add_del_route_t_handler (&mp);
1354  }
1355 
1356  if (rv)
1357  clib_error_return (0, "failed to config default IP route");
1358 
1359 }
1360 
1361 static void
1364 {
1365  vlib_main_t *vm = vlib_get_main ();
1367  int rv = 0;
1368  u32 is_del;
1369 
1370  VALIDATE_SW_IF_INDEX (mp);
1371 
1372  is_del = mp->is_add == 0;
1373 
1374  if (mp->del_all)
1375  ip_del_all_interface_addresses (vm, ntohl (mp->sw_if_index));
1376  else if (mp->is_ipv6)
1377  ip6_add_del_interface_address (vm, ntohl (mp->sw_if_index),
1378  (void *) mp->address,
1379  mp->address_length, is_del);
1380  else
1381  ip4_add_del_interface_address (vm, ntohl (mp->sw_if_index),
1382  (void *) mp->address,
1383  mp->address_length, is_del);
1384 
1386 
1387  REPLY_MACRO (VL_API_SW_INTERFACE_ADD_DEL_ADDRESS_REPLY);
1388 }
1389 
1390 static void
1392 {
1393  int rv = 0;
1394  u32 table_id = ntohl (mp->vrf_id);
1395  u32 sw_if_index = ntohl (mp->sw_if_index);
1397  stats_main_t *sm = &stats_main;
1398 
1399  VALIDATE_SW_IF_INDEX (mp);
1400 
1401  dslock (sm, 1 /* release hint */ , 4 /* tag */ );
1402 
1403  if (mp->is_ipv6)
1404  {
1405  ip6_main_t *im = &ip6_main;
1406  ip6_fib_t *fib = find_ip6_fib_by_table_index_or_id (im, table_id,
1408  if (fib)
1409  {
1410  vec_validate (im->fib_index_by_sw_if_index, sw_if_index);
1411  im->fib_index_by_sw_if_index[sw_if_index] = fib->index;
1412  }
1413  else
1414  {
1415  rv = VNET_API_ERROR_NO_SUCH_FIB;
1416  }
1417  }
1418  else
1419  {
1420  ip4_main_t *im = &ip4_main;
1422  (im, table_id, IP4_ROUTE_FLAG_TABLE_ID);
1423 
1424  /* Truthfully this can't fail */
1425  if (fib)
1426  {
1427  vec_validate (im->fib_index_by_sw_if_index, sw_if_index);
1428  im->fib_index_by_sw_if_index[sw_if_index] = fib->index;
1429  }
1430  else
1431  {
1432  rv = VNET_API_ERROR_NO_SUCH_FIB;
1433  }
1434  }
1435  dsunlock (sm);
1436 
1438 
1439  REPLY_MACRO (VL_API_SW_INTERFACE_SET_TABLE_REPLY);
1440 }
1441 
1442 static void
1444 {
1445  vlib_main_t *vm = vlib_get_main ();
1446  ip4_main_t *im4 = &ip4_main;
1447  ip6_main_t *im6 = &ip6_main;
1449  int rv = 0;
1450  u32 ci;
1451  u32 sw_if_index = ntohl (mp->sw_if_index);
1452  ip4_main_t *ip4m = &ip4_main;
1453  ip6_main_t *ip6m = &ip6_main;
1454  ip_lookup_main_t *ip4lm = &ip4m->lookup_main;
1455  ip_lookup_main_t *ip6lm = &ip6m->lookup_main;
1456  ip_config_main_t *rx_cm4u = &ip4lm->rx_config_mains[VNET_UNICAST];
1457  ip_config_main_t *rx_cm4m = &ip4lm->rx_config_mains[VNET_MULTICAST];
1458  ip_config_main_t *rx_cm6u = &ip6lm->rx_config_mains[VNET_UNICAST];
1459  ip_config_main_t *rx_cm6m = &ip6lm->rx_config_mains[VNET_MULTICAST];
1460 
1461  VALIDATE_SW_IF_INDEX (mp);
1462 
1463  l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_VPATH, mp->enable);
1464  if (mp->enable)
1465  {
1466  ci = rx_cm4u->config_index_by_sw_if_index[sw_if_index]; //IP4 unicast
1467  ci = vnet_config_add_feature (vm, &rx_cm4u->config_main,
1468  ci,
1469  im4->ip4_unicast_rx_feature_vpath, 0, 0);
1470  rx_cm4u->config_index_by_sw_if_index[sw_if_index] = ci;
1471  ci = rx_cm4m->config_index_by_sw_if_index[sw_if_index]; //IP4 mcast
1472  ci = vnet_config_add_feature (vm, &rx_cm4m->config_main,
1473  ci,
1475  0, 0);
1476  rx_cm4m->config_index_by_sw_if_index[sw_if_index] = ci;
1477  ci = rx_cm6u->config_index_by_sw_if_index[sw_if_index]; //IP6 unicast
1478  ci = vnet_config_add_feature (vm, &rx_cm6u->config_main,
1479  ci,
1480  im6->ip6_unicast_rx_feature_vpath, 0, 0);
1481  rx_cm6u->config_index_by_sw_if_index[sw_if_index] = ci;
1482  ci = rx_cm6m->config_index_by_sw_if_index[sw_if_index]; //IP6 mcast
1483  ci = vnet_config_add_feature (vm, &rx_cm6m->config_main,
1484  ci,
1486  0, 0);
1487  rx_cm6m->config_index_by_sw_if_index[sw_if_index] = ci;
1488  }
1489  else
1490  {
1491  ci = rx_cm4u->config_index_by_sw_if_index[sw_if_index]; //IP4 unicast
1492  ci = vnet_config_del_feature (vm, &rx_cm4u->config_main,
1493  ci,
1494  im4->ip4_unicast_rx_feature_vpath, 0, 0);
1495  rx_cm4u->config_index_by_sw_if_index[sw_if_index] = ci;
1496  ci = rx_cm4m->config_index_by_sw_if_index[sw_if_index]; //IP4 mcast
1497  ci = vnet_config_del_feature (vm, &rx_cm4m->config_main,
1498  ci,
1500  0, 0);
1501  rx_cm4m->config_index_by_sw_if_index[sw_if_index] = ci;
1502  ci = rx_cm6u->config_index_by_sw_if_index[sw_if_index]; //IP6 unicast
1503  ci = vnet_config_del_feature (vm, &rx_cm6u->config_main,
1504  ci,
1505  im6->ip6_unicast_rx_feature_vpath, 0, 0);
1506  rx_cm6u->config_index_by_sw_if_index[sw_if_index] = ci;
1507  ci = rx_cm6m->config_index_by_sw_if_index[sw_if_index]; //IP6 mcast
1508  ci = vnet_config_del_feature (vm, &rx_cm6m->config_main,
1509  ci,
1511  0, 0);
1512  rx_cm6m->config_index_by_sw_if_index[sw_if_index] = ci;
1513  }
1514 
1516 
1517  REPLY_MACRO (VL_API_SW_INTERFACE_SET_VPATH_REPLY);
1518 }
1519 
1520 static void
1523 {
1525  int rv = 0;
1526  u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index);
1527  u32 tx_sw_if_index = ntohl (mp->tx_sw_if_index);
1528  vlib_main_t *vm = vlib_get_main ();
1529  vnet_main_t *vnm = vnet_get_main ();
1530 
1532 
1533  if (mp->enable)
1534  {
1536  rv = set_int_l2_mode (vm, vnm, MODE_L2_XC,
1537  rx_sw_if_index, 0, 0, 0, tx_sw_if_index);
1538  }
1539  else
1540  {
1541  rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, 0, 0, 0);
1542  }
1543 
1546 
1547  REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_XCONNECT_REPLY);
1548 }
1549 
1550 static void
1553 {
1554  bd_main_t *bdm = &bd_main;
1556  int rv = 0;
1557  u32 rx_sw_if_index = ntohl (mp->rx_sw_if_index);
1558  u32 bd_id = ntohl (mp->bd_id);
1559  u32 bd_index;
1560  u32 bvi = mp->bvi;
1561  u8 shg = mp->shg;
1562  vlib_main_t *vm = vlib_get_main ();
1563  vnet_main_t *vnm = vnet_get_main ();
1564 
1566 
1567  bd_index = bd_find_or_add_bd_index (bdm, bd_id);
1568 
1569  if (mp->enable)
1570  {
1571  //VALIDATE_TX_SW_IF_INDEX(mp);
1572  rv = set_int_l2_mode (vm, vnm, MODE_L2_BRIDGE,
1573  rx_sw_if_index, bd_index, bvi, shg, 0);
1574  }
1575  else
1576  {
1577  rv = set_int_l2_mode (vm, vnm, MODE_L3, rx_sw_if_index, 0, 0, 0, 0);
1578  }
1579 
1581 
1582  REPLY_MACRO (VL_API_SW_INTERFACE_SET_L2_BRIDGE_REPLY);
1583 }
1584 
1585 static void
1587 {
1588  vlib_main_t *vm = vlib_get_main ();
1589  bd_main_t *bdm = &bd_main;
1591  int rv = 0;
1592  u32 enable_flags = 0, disable_flags = 0;
1593  u32 bd_id = ntohl (mp->bd_id);
1594  u32 bd_index;
1595 
1596  if (mp->is_add)
1597  {
1598  bd_index = bd_find_or_add_bd_index (bdm, bd_id);
1599 
1600  if (mp->flood)
1601  enable_flags |= L2_FLOOD;
1602  else
1603  disable_flags |= L2_FLOOD;
1604 
1605  if (mp->uu_flood)
1606  enable_flags |= L2_UU_FLOOD;
1607  else
1608  disable_flags |= L2_UU_FLOOD;
1609 
1610  if (mp->forward)
1611  enable_flags |= L2_FWD;
1612  else
1613  disable_flags |= L2_FWD;
1614 
1615  if (mp->arp_term)
1616  enable_flags |= L2_ARP_TERM;
1617  else
1618  disable_flags |= L2_ARP_TERM;
1619 
1620  if (mp->learn)
1621  enable_flags |= L2_LEARN;
1622  else
1623  disable_flags |= L2_LEARN;
1624 
1625  if (enable_flags)
1626  bd_set_flags (vm, bd_index, enable_flags, 1 /* enable */ );
1627 
1628  if (disable_flags)
1629  bd_set_flags (vm, bd_index, disable_flags, 0 /* disable */ );
1630 
1631  }
1632  else
1633  rv = bd_delete_bd_index (bdm, bd_id);
1634 
1635  REPLY_MACRO (VL_API_BRIDGE_DOMAIN_ADD_DEL_REPLY);
1636 }
1637 
1638 static void
1640 {
1641  clib_warning ("BUG");
1642 }
1643 
1644 static void
1647 {
1648  clib_warning ("BUG");
1649 }
1650 
1651 static void
1653  l2_bridge_domain_t * bd_config,
1654  u32 n_sw_ifs, u32 context)
1655 {
1657 
1658  mp = vl_msg_api_alloc (sizeof (*mp));
1659  memset (mp, 0, sizeof (*mp));
1660  mp->_vl_msg_id = ntohs (VL_API_BRIDGE_DOMAIN_DETAILS);
1661  mp->bd_id = ntohl (bd_config->bd_id);
1662  mp->flood = bd_feature_flood (bd_config);
1663  mp->uu_flood = bd_feature_uu_flood (bd_config);
1664  mp->forward = bd_feature_forward (bd_config);
1665  mp->learn = bd_feature_learn (bd_config);
1666  mp->arp_term = bd_feature_arp_term (bd_config);
1667  mp->bvi_sw_if_index = ntohl (bd_config->bvi_sw_if_index);
1668  mp->n_sw_ifs = ntohl (n_sw_ifs);
1669  mp->context = context;
1670 
1671  vl_msg_api_send_shmem (q, (u8 *) & mp);
1672 }
1673 
1674 static void
1677  l2_flood_member_t * member, u32 bd_id, u32 context)
1678 {
1680  l2_input_config_t *input_cfg;
1681 
1682  mp = vl_msg_api_alloc (sizeof (*mp));
1683  memset (mp, 0, sizeof (*mp));
1684  mp->_vl_msg_id = ntohs (VL_API_BRIDGE_DOMAIN_SW_IF_DETAILS);
1685  mp->bd_id = ntohl (bd_id);
1686  mp->sw_if_index = ntohl (member->sw_if_index);
1687  input_cfg = vec_elt_at_index (l2im->configs, member->sw_if_index);
1688  mp->shg = input_cfg->shg;
1689  mp->context = context;
1690 
1691  vl_msg_api_send_shmem (q, (u8 *) & mp);
1692 }
1693 
1694 static void
1696 {
1697  bd_main_t *bdm = &bd_main;
1698  l2input_main_t *l2im = &l2input_main;
1700  l2_bridge_domain_t *bd_config;
1701  u32 bd_id, bd_index;
1702  u32 end;
1703 
1705 
1706  if (q == 0)
1707  return;
1708 
1709  bd_id = ntohl (mp->bd_id);
1710 
1711  bd_index = (bd_id == ~0) ? 0 : bd_find_or_add_bd_index (bdm, bd_id);
1712  end = (bd_id == ~0) ? vec_len (l2im->bd_configs) : bd_index + 1;
1713  for (; bd_index < end; bd_index++)
1714  {
1715  bd_config = l2input_bd_config_from_index (l2im, bd_index);
1716  /* skip dummy bd_id 0 */
1717  if (bd_config && (bd_config->bd_id > 0))
1718  {
1719  u32 n_sw_ifs;
1720  l2_flood_member_t *m;
1721 
1722  n_sw_ifs = vec_len (bd_config->members);
1723  send_bridge_domain_details (q, bd_config, n_sw_ifs, mp->context);
1724 
1725  vec_foreach (m, bd_config->members)
1726  {
1727  send_bd_sw_if_details (l2im, q, m, bd_config->bd_id, mp->context);
1728  }
1729  }
1730  }
1731 }
1732 
1733 static void
1735 {
1736  bd_main_t *bdm = &bd_main;
1737  l2input_main_t *l2im = &l2input_main;
1739  int rv = 0;
1740  u64 mac = 0;
1741  u32 sw_if_index = ntohl (mp->sw_if_index);
1742  u32 bd_id = ntohl (mp->bd_id);
1743  u32 bd_index;
1744  u32 static_mac;
1745  u32 filter_mac;
1746  u32 bvi_mac;
1747  uword *p;
1748 
1749  mac = mp->mac;
1750 
1751  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
1752  if (!p)
1753  {
1754  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
1755  goto bad_sw_if_index;
1756  }
1757  bd_index = p[0];
1758 
1759  if (mp->is_add)
1760  {
1761  VALIDATE_SW_IF_INDEX (mp);
1762  if (vec_len (l2im->configs) <= sw_if_index)
1763  {
1764  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
1765  goto bad_sw_if_index;
1766  }
1767  else
1768  {
1769  l2_input_config_t *config;
1770  config = vec_elt_at_index (l2im->configs, sw_if_index);
1771  if (config->bridge == 0)
1772  {
1773  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
1774  goto bad_sw_if_index;
1775  }
1776  }
1777  static_mac = mp->static_mac ? 1 : 0;
1778  filter_mac = mp->filter_mac ? 1 : 0;
1779  bvi_mac = mp->bvi_mac ? 1 : 0;
1780  l2fib_add_entry (mac, bd_index, sw_if_index, static_mac, filter_mac,
1781  bvi_mac);
1782  }
1783  else
1784  {
1785  l2fib_del_entry (mac, bd_index);
1786  }
1787 
1789 
1790  REPLY_MACRO (VL_API_L2FIB_ADD_DEL_REPLY);
1791 }
1792 
1793 static void
1795 {
1797  int rv = 0;
1798  u32 sw_if_index = ntohl (mp->sw_if_index);
1799  u32 flags = ntohl (mp->feature_bitmap);
1800  u32 rbm = 0;
1801 
1802  VALIDATE_SW_IF_INDEX (mp);
1803 
1804 #define _(a,b) \
1805  if (flags & L2INPUT_FEAT_ ## a) \
1806  rbm = l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_ ## a, mp->is_set);
1808 #undef _
1809 
1811 
1812  /* *INDENT-OFF* */
1813  REPLY_MACRO2(VL_API_L2_FLAGS_REPLY,
1814  ({
1815  rmp->resulting_feature_bitmap = ntohl(rbm);
1816  }));
1817  /* *INDENT-ON* */
1818 }
1819 
1820 static void
1822 {
1823  vlib_main_t *vm = vlib_get_main ();
1824  bd_main_t *bdm = &bd_main;
1826  int rv = 0;
1827  u32 bd_id = ntohl (mp->bd_id);
1828  u32 bd_index;
1829  u32 flags = ntohl (mp->feature_bitmap);
1830  uword *p;
1831 
1832  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
1833  if (p == 0)
1834  {
1835  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
1836  goto out;
1837  }
1838 
1839  bd_index = p[0];
1840 
1841  bd_set_flags (vm, bd_index, flags, mp->is_set);
1842 
1843 out:
1844  /* *INDENT-OFF* */
1845  REPLY_MACRO2(VL_API_BRIDGE_FLAGS_REPLY,
1846  ({
1847  rmp->resulting_feature_bitmap = ntohl(flags);
1848  }));
1849  /* *INDENT-ON* */
1850 }
1851 
1852 static void
1854 {
1855  bd_main_t *bdm = &bd_main;
1857  int rv = 0;
1858  u32 bd_id = ntohl (mp->bd_id);
1859  u32 bd_index;
1860  uword *p;
1861 
1862  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
1863  if (p == 0)
1864  {
1865  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
1866  goto out;
1867  }
1868 
1869  bd_index = p[0];
1870  if (bd_add_del_ip_mac (bd_index, mp->ip_address,
1871  mp->mac_address, mp->is_ipv6, mp->is_add))
1872  rv = VNET_API_ERROR_UNSPECIFIED;
1873 
1874 out:
1875  REPLY_MACRO (VL_API_BD_IP_MAC_ADD_DEL_REPLY);
1876 }
1877 
1878 static void
1880 {
1881  int rv;
1884  u32 sw_if_index = (u32) ~ 0;
1885 
1886  rv = vnet_tap_connect_renumber (vm, mp->tap_name,
1887  mp->use_random_mac ? 0 : mp->mac_address,
1888  &sw_if_index, mp->renumber,
1889  ntohl (mp->custom_dev_instance));
1890 
1892  if (!q)
1893  return;
1894 
1895  rmp = vl_msg_api_alloc (sizeof (*rmp));
1896  rmp->_vl_msg_id = ntohs (VL_API_TAP_CONNECT_REPLY);
1897  rmp->context = mp->context;
1898  rmp->retval = ntohl (rv);
1899  rmp->sw_if_index = ntohl (sw_if_index);
1900 
1901  vl_msg_api_send_shmem (q, (u8 *) & rmp);
1902 }
1903 
1904 static void
1906 {
1907  int rv;
1910  u32 sw_if_index = (u32) ~ 0;
1911 
1912  rv = vnet_tap_modify (vm, ntohl (mp->sw_if_index), mp->tap_name,
1913  mp->use_random_mac ? 0 : mp->mac_address,
1914  &sw_if_index, mp->renumber,
1915  ntohl (mp->custom_dev_instance));
1916 
1918  if (!q)
1919  return;
1920 
1921  rmp = vl_msg_api_alloc (sizeof (*rmp));
1922  rmp->_vl_msg_id = ntohs (VL_API_TAP_MODIFY_REPLY);
1923  rmp->context = mp->context;
1924  rmp->retval = ntohl (rv);
1925  rmp->sw_if_index = ntohl (sw_if_index);
1926 
1927  vl_msg_api_send_shmem (q, (u8 *) & rmp);
1928 }
1929 
1930 static void
1932 {
1933  int rv;
1934  vpe_api_main_t *vam = &vpe_api_main;
1937  u32 sw_if_index = ntohl (mp->sw_if_index);
1938 
1939  rv = vnet_tap_delete (vm, sw_if_index);
1940 
1942  if (!q)
1943  return;
1944 
1945  rmp = vl_msg_api_alloc (sizeof (*rmp));
1946  rmp->_vl_msg_id = ntohs (VL_API_TAP_DELETE_REPLY);
1947  rmp->context = mp->context;
1948  rmp->retval = ntohl (rv);
1949 
1950  vl_msg_api_send_shmem (q, (u8 *) & rmp);
1951 
1952  if (!rv)
1953  send_sw_interface_flags_deleted (vam, q, sw_if_index);
1954 }
1955 
1956 static void
1958 {
1960  vnet_main_t *vnm = vnet_get_main ();
1961  u32 hw_if_index, sw_if_index = (u32) ~ 0;
1963  int rv = 0;
1964  u32 id;
1965  vnet_sw_interface_t template;
1966  uword *p;
1968  u64 sup_and_sub_key;
1969  u64 *kp;
1971  clib_error_t *error;
1972 
1973  VALIDATE_SW_IF_INDEX (mp);
1974 
1975  hw_if_index = ntohl (mp->sw_if_index);
1976  hi = vnet_get_hw_interface (vnm, hw_if_index);
1977 
1978  id = ntohl (mp->vlan_id);
1979  if (id == 0 || id > 4095)
1980  {
1981  rv = VNET_API_ERROR_INVALID_VLAN;
1982  goto out;
1983  }
1984 
1985  sup_and_sub_key = ((u64) (hi->sw_if_index) << 32) | (u64) id;
1986 
1987  p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
1988  if (p)
1989  {
1990  rv = VNET_API_ERROR_VLAN_ALREADY_EXISTS;
1991  goto out;
1992  }
1993 
1994  kp = clib_mem_alloc (sizeof (*kp));
1995  *kp = sup_and_sub_key;
1996 
1997  memset (&template, 0, sizeof (template));
1998  template.type = VNET_SW_INTERFACE_TYPE_SUB;
1999  template.sup_sw_if_index = hi->sw_if_index;
2000  template.sub.id = id;
2001  template.sub.eth.raw_flags = 0;
2002  template.sub.eth.flags.one_tag = 1;
2003  template.sub.eth.outer_vlan_id = id;
2004  template.sub.eth.flags.exact_match = 1;
2005 
2006  error = vnet_create_sw_interface (vnm, &template, &sw_if_index);
2007  if (error)
2008  {
2009  clib_error_report (error);
2010  rv = VNET_API_ERROR_INVALID_REGISTRATION;
2011  goto out;
2012  }
2013  hash_set (hi->sub_interface_sw_if_index_by_id, id, sw_if_index);
2014  hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index);
2015 
2017 
2018 out:
2020  if (!q)
2021  return;
2022 
2023  rmp = vl_msg_api_alloc (sizeof (*rmp));
2024  rmp->_vl_msg_id = ntohs (VL_API_CREATE_VLAN_SUBIF_REPLY);
2025  rmp->context = mp->context;
2026  rmp->retval = ntohl (rv);
2027  rmp->sw_if_index = ntohl (sw_if_index);
2028  vl_msg_api_send_shmem (q, (u8 *) & rmp);
2029 }
2030 
2031 static void
2033 {
2035  vnet_main_t *vnm = vnet_get_main ();
2036  u32 sw_if_index = ~0;
2037  int rv = 0;
2038  u32 sub_id;
2039  vnet_sw_interface_t *si;
2041  vnet_sw_interface_t template;
2042  uword *p;
2044  u64 sup_and_sub_key;
2045  u64 *kp;
2046  clib_error_t *error;
2047 
2048  VALIDATE_SW_IF_INDEX (mp);
2049 
2050  si = vnet_get_sup_sw_interface (vnm, ntohl (mp->sw_if_index));
2051  hi = vnet_get_sup_hw_interface (vnm, ntohl (mp->sw_if_index));
2052 
2054  {
2055  rv = VNET_API_ERROR_BOND_SLAVE_NOT_ALLOWED;
2056  goto out;
2057  }
2058 
2059  sw_if_index = si->sw_if_index;
2060  sub_id = ntohl (mp->sub_id);
2061 
2062  sup_and_sub_key = ((u64) (sw_if_index) << 32) | (u64) sub_id;
2063 
2064  p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
2065  if (p)
2066  {
2067  if (CLIB_DEBUG > 0)
2068  clib_warning ("sup sw_if_index %d, sub id %d already exists\n",
2069  sw_if_index, sub_id);
2070  rv = VNET_API_ERROR_SUBIF_ALREADY_EXISTS;
2071  goto out;
2072  }
2073 
2074  kp = clib_mem_alloc (sizeof (*kp));
2075  *kp = sup_and_sub_key;
2076 
2077  memset (&template, 0, sizeof (template));
2078  template.type = VNET_SW_INTERFACE_TYPE_SUB;
2079  template.sup_sw_if_index = sw_if_index;
2080  template.sub.id = sub_id;
2081  template.sub.eth.flags.no_tags = mp->no_tags;
2082  template.sub.eth.flags.one_tag = mp->one_tag;
2083  template.sub.eth.flags.two_tags = mp->two_tags;
2084  template.sub.eth.flags.dot1ad = mp->dot1ad;
2085  template.sub.eth.flags.exact_match = mp->exact_match;
2086  template.sub.eth.flags.default_sub = mp->default_sub;
2087  template.sub.eth.flags.outer_vlan_id_any = mp->outer_vlan_id_any;
2088  template.sub.eth.flags.inner_vlan_id_any = mp->inner_vlan_id_any;
2089  template.sub.eth.outer_vlan_id = ntohs (mp->outer_vlan_id);
2090  template.sub.eth.inner_vlan_id = ntohs (mp->inner_vlan_id);
2091 
2092  error = vnet_create_sw_interface (vnm, &template, &sw_if_index);
2093  if (error)
2094  {
2095  clib_error_report (error);
2096  rv = VNET_API_ERROR_SUBIF_CREATE_FAILED;
2097  goto out;
2098  }
2099 
2100  hash_set (hi->sub_interface_sw_if_index_by_id, sub_id, sw_if_index);
2101  hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index);
2102 
2104 
2105 out:
2106 
2107  /* *INDENT-OFF* */
2108  REPLY_MACRO2(VL_API_CREATE_SUBIF_REPLY,
2109  ({
2110  rmp->sw_if_index = ntohl(sw_if_index);
2111  }));
2112  /* *INDENT-ON* */
2113 }
2114 
2115 static void
2117  mp)
2118 {
2120  int rv = 0;
2121  stats_main_t *sm = &stats_main;
2122  u32 tunnel_sw_if_index = ~0;
2123 
2124  dslock (sm, 1 /* release hint */ , 5 /* tag */ );
2125 
2127  (ip4_address_t *) (mp->dst_address),
2128  (ip4_address_t *) (mp->intfc_address),
2129  (u32) (mp->intfc_address_length),
2130  ntohl (mp->inner_vrf_id),
2131  ntohl (mp->outer_vrf_id),
2132  &tunnel_sw_if_index,
2133  mp->l2_only, mp->is_add);
2134  dsunlock (sm);
2135 
2136  /* *INDENT-OFF* */
2137  REPLY_MACRO2(VL_API_MPLS_GRE_ADD_DEL_TUNNEL_REPLY,
2138  ({
2139  rmp->tunnel_sw_if_index = ntohl(tunnel_sw_if_index);
2140  }));
2141  /* *INDENT-ON* */
2142 }
2143 
2144 static void
2147 {
2149  int rv = 0;
2150  stats_main_t *sm = &stats_main;
2151  u32 tunnel_sw_if_index;
2152 
2153  dslock (sm, 1 /* release hint */ , 5 /* tag */ );
2154 
2156  (mp->dst_mac_address, (ip4_address_t *) (mp->adj_address),
2157  (u32) (mp->adj_address_length), ntohl (mp->vrf_id),
2158  ntohl (mp->tx_sw_if_index),
2159  &tunnel_sw_if_index, mp->l2_only, mp->is_add);
2160 
2161  dsunlock (sm);
2162 
2163  /* *INDENT-OFF* */
2164  REPLY_MACRO2(VL_API_MPLS_ETHERNET_ADD_DEL_TUNNEL_REPLY,
2165  ({
2166  rmp->tunnel_sw_if_index = ntohl(tunnel_sw_if_index);
2167  }));
2168  /* *INDENT-ON* */
2169 }
2170 
2171 /*
2172  * This piece of misery brought to you because the control-plane
2173  * can't figure out the tx interface + dst-mac address all by itself
2174  */
2177 {
2178  pending_route_t *pr;
2180  vnet_main_t *vnm = vnet_get_main ();
2181  vlib_main_t *vm = vlib_get_main ();
2182  stats_main_t *sm = &stats_main;
2183  vpe_api_main_t *vam = &vpe_api_main;
2184  u32 inner_fib_index, outer_fib_index;
2185  ip4_main_t *im = &ip4_main;
2186  ip_lookup_main_t *lm = &im->lookup_main;
2187  ip_adjacency_t *adj = 0;
2188  u32 lookup_result;
2189  u32 tx_sw_if_index;
2190  u8 *dst_mac_address;
2191  clib_error_t *e;
2192  uword *p;
2193  int rv;
2194  u32 tunnel_sw_if_index;
2195 
2196  p = hash_get (im->fib_index_by_table_id, ntohl (mp->outer_vrf_id));
2197  if (!p)
2198  return VNET_API_ERROR_NO_SUCH_FIB;
2199  else
2200  outer_fib_index = p[0];
2201 
2202 
2203  p = hash_get (im->fib_index_by_table_id, ntohl (mp->inner_vrf_id));
2204  if (!p)
2205  return VNET_API_ERROR_NO_SUCH_INNER_FIB;
2206  else
2207  inner_fib_index = p[0];
2208 
2209  if (inner_fib_index == outer_fib_index)
2210  return VNET_API_ERROR_INVALID_VALUE;
2211 
2212  lookup_result = ip4_fib_lookup_with_table
2213  (im, outer_fib_index,
2215  1 /* disable default route */ );
2216 
2217  adj = ip_get_adjacency (lm, lookup_result);
2218  tx_sw_if_index = adj->rewrite_header.sw_if_index;
2219 
2220  if (mp->is_add && mp->resolve_if_needed)
2221  {
2223  {
2224  pool_get (vam->pending_routes, pr);
2226  pme = &pr->t;
2227  clib_memcpy (pme, mp, sizeof (*pme));
2228  /* recursion block, "just in case" */
2229  pme->resolve_if_needed = 0;
2230  pme->resolve_attempts = ntohl (mp->resolve_attempts);
2231  pme->resolve_opaque = tx_sw_if_index;
2233  (vnm,
2235  vpe_resolver_process_node.index,
2236  RESOLUTION_EVENT, pr - vam->pending_routes);
2237 
2239  (vm, vpe_resolver_process_node.index,
2240  RESOLUTION_PENDING_EVENT, 0 /* data */ );
2241 
2242  /* The interface may be down, etc. */
2243  e = ip4_probe_neighbor
2245  tx_sw_if_index);
2246 
2247  if (e)
2248  clib_error_report (e);
2249 
2250  return VNET_API_ERROR_IN_PROGRESS;
2251  }
2252  }
2253 
2255  return VNET_API_ERROR_NEXT_HOP_NOT_IN_FIB;
2256 
2257  dst_mac_address =
2259  (&adj->rewrite_header, sizeof (adj->rewrite_data));
2260 
2261  dslock (sm, 1 /* release hint */ , 10 /* tag */ );
2262 
2264  (dst_mac_address, (ip4_address_t *) (mp->adj_address),
2265  (u32) (mp->adj_address_length), ntohl (mp->inner_vrf_id),
2266  tx_sw_if_index, &tunnel_sw_if_index, mp->l2_only, mp->is_add);
2267 
2268  dsunlock (sm);
2269 
2270  return rv;
2271 }
2272 
2273 static void
2276 {
2278  int rv = 0;
2279 
2281 
2282  REPLY_MACRO (VL_API_MPLS_ETHERNET_ADD_DEL_TUNNEL_2_REPLY);
2283 }
2284 
2285 
2286 static void
2288 {
2290  int rv;
2291  static u32 *labels;
2292  int i;
2293 
2294  vec_reset_length (labels);
2295 
2296  for (i = 0; i < mp->nlabels; i++)
2297  vec_add1 (labels, ntohl (mp->labels[i]));
2298 
2299  /* $$$$ fixme */
2301  ntohl (mp->vrf_id), labels,
2302  ~0 /* policy_tunnel_index */ ,
2303  0 /* no_dst_hash */ ,
2304  0 /* indexp */ ,
2305  mp->is_add);
2306 
2307  REPLY_MACRO (VL_API_MPLS_ADD_DEL_ENCAP_REPLY);
2308 }
2309 
2310 static void
2312 {
2314  int rv;
2315 
2316  rv = vnet_mpls_add_del_decap (ntohl (mp->rx_vrf_id), ntohl (mp->tx_vrf_id),
2317  ntohl (mp->label), ntohl (mp->next_index),
2318  mp->s_bit, mp->is_add);
2319 
2320  REPLY_MACRO (VL_API_MPLS_ADD_DEL_DECAP_REPLY);
2321 }
2322 
2323 static void
2325 {
2327  u32 fib_index;
2328  int rv;
2329  ip4_main_t *im = &ip4_main;
2330  stats_main_t *sm = &stats_main;
2331  int vnet_proxy_arp_add_del (ip4_address_t * lo_addr,
2332  ip4_address_t * hi_addr,
2333  u32 fib_index, int is_del);
2334  uword *p;
2335 
2336  dslock (sm, 1 /* release hint */ , 6 /* tag */ );
2337 
2338  p = hash_get (im->fib_index_by_table_id, ntohl (mp->vrf_id));
2339 
2340  if (!p)
2341  {
2342  rv = VNET_API_ERROR_NO_SUCH_FIB;
2343  goto out;
2344  }
2345 
2346  fib_index = p[0];
2347 
2349  (ip4_address_t *) mp->hi_address,
2350  fib_index, mp->is_add == 0);
2351 
2352 out:
2353  dsunlock (sm);
2354  REPLY_MACRO (VL_API_PROXY_ARP_ADD_DEL_REPLY);
2355 }
2356 
2357 static void
2360 {
2361  int rv = 0;
2362  vnet_main_t *vnm = vnet_get_main ();
2364  vnet_sw_interface_t *si;
2365  u32 sw_if_index;
2366 
2367  VALIDATE_SW_IF_INDEX (mp);
2368 
2369  sw_if_index = ntohl (mp->sw_if_index);
2370 
2371  if (pool_is_free_index (vnm->interface_main.sw_interfaces, sw_if_index))
2372  {
2373  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
2374  goto out;
2375  }
2376 
2377  si = vnet_get_sw_interface (vnm, sw_if_index);
2378 
2379  ASSERT (si);
2380 
2381  if (mp->enable_disable)
2383  else
2385 
2387 
2388 out:
2389  REPLY_MACRO (VL_API_PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY);
2390 }
2391 
2392 static void
2394  vlib_main_t * vm)
2395 {
2397  vnet_main_t *vnm = vnet_get_main ();
2398  u32 fib_index;
2399  int rv = 0;
2400  stats_main_t *sm = &stats_main;
2401 
2402  VALIDATE_SW_IF_INDEX (mp);
2403 
2404  dslock (sm, 1 /* release hint */ , 7 /* tag */ );
2405 
2406  if (mp->is_ipv6)
2407  {
2408  if (mp->is_add)
2410  (vm, ntohl (mp->sw_if_index),
2411  (ip6_address_t *) (mp->dst_address),
2412  mp->mac_address, sizeof (mp->mac_address), mp->is_static);
2413  else
2415  (vm, ntohl (mp->sw_if_index),
2416  (ip6_address_t *) (mp->dst_address),
2417  mp->mac_address, sizeof (mp->mac_address));
2418  }
2419  else
2420  {
2421  ip4_main_t *im = &ip4_main;
2422  ip_lookup_main_t *lm = &im->lookup_main;
2423  ethernet_arp_ip4_over_ethernet_address_t a;
2424  u32 ai;
2425  ip_adjacency_t *nh_adj;
2426 
2427  uword *p = hash_get (im->fib_index_by_table_id, ntohl (mp->vrf_id));
2428  if (!p)
2429  {
2430  rv = VNET_API_ERROR_NO_SUCH_FIB;
2431  goto out;
2432  }
2433  fib_index = p[0];
2434 
2435  /*
2436  * Unfortunately, folks have a penchant for
2437  * adding interface addresses to the ARP cache, and
2438  * wondering why the forwarder eventually ASSERTs...
2439  */
2441  (im, fib_index, (ip4_address_t *) (mp->dst_address),
2442  1 /* disable default route */ );
2443 
2444  if (ai != 0)
2445  {
2446  nh_adj = ip_get_adjacency (lm, ai);
2447  /* Never allow manipulation of a local adj! */
2448  if (nh_adj->lookup_next_index == IP_LOOKUP_NEXT_LOCAL)
2449  {
2450  clib_warning ("%U matches local adj",
2452  (ip4_address_t *) (mp->dst_address));
2453  rv = VNET_API_ERROR_ADDRESS_MATCHES_INTERFACE_ADDRESS;
2454  goto out;
2455  }
2456  }
2457 
2458  clib_memcpy (&a.ethernet, mp->mac_address, 6);
2459  clib_memcpy (&a.ip4, mp->dst_address, 4);
2460 
2461  if (mp->is_add)
2462  rv = vnet_arp_set_ip4_over_ethernet (vnm, ntohl (mp->sw_if_index),
2463  fib_index, &a, mp->is_static);
2464  else
2465  rv = vnet_arp_unset_ip4_over_ethernet (vnm, ntohl (mp->sw_if_index),
2466  fib_index, &a);
2467  }
2468 
2470 out:
2471  dsunlock (sm);
2472  REPLY_MACRO (VL_API_IP_NEIGHBOR_ADD_DEL_REPLY);
2473 }
2474 
2475 static void
2477 {
2478 #if 0
2479  vpe_main_t *rm = &vpe_main;
2480  ip4_main_t *im4 = &ip4_main;
2481  ip6_main_t *im6 = &ip6_main;
2482  ip_lookup_main_t *lm;
2483  union
2484  {
2485  ip4_address_t ip4;
2486  ip6_address_t ip6;
2487  } addr;
2488  u32 adj_index, sw_if_index;
2490  ip_adjacency_t *adj;
2492 
2494  if (!q)
2495  {
2496  increment_missing_api_client_counter (rm->vlib_main);
2497  return;
2498  }
2499 
2500  rmp = vl_msg_api_alloc (sizeof (*rmp));
2501  clib_memcpy (rmp, mp, sizeof (*rmp));
2502 
2503  sw_if_index = mp->next_hop_sw_if_index;
2504  clib_memcpy (&addr, mp->address, sizeof (addr));
2505  if (mp->is_ipv6)
2506  {
2507  lm = &im6->lookup_main;
2508  adj_index = ip6_fib_lookup (im6, sw_if_index, &addr.ip6);
2509  }
2510  else
2511  {
2512  lm = &im4->lookup_main;
2513  adj_index = ip4_fib_lookup (im4, sw_if_index, &addr.ip4);
2514  }
2515  if (adj_index == ~0)
2516  {
2517  rmp->is_error = 1;
2518  goto send;
2519  }
2520  adj = ip_get_adjacency (lm, adj_index);
2521 
2523  && adj->rewrite_header.sw_if_index == sw_if_index)
2524  {
2525  rmp->is_known = 1;
2526  }
2527  else
2528  {
2530  && adj->rewrite_header.sw_if_index == sw_if_index)
2531  {
2532  if (mp->is_ipv6)
2533  ip6_probe_neighbor (rm->vlib_main, &addr.ip6, sw_if_index);
2534  else
2535  ip4_probe_neighbor (rm->vlib_main, &addr.ip4, sw_if_index);
2536  }
2537  else if (adj->lookup_next_index == IP_LOOKUP_NEXT_DROP)
2538  {
2539  rmp->is_known = 1;
2540  goto send;
2541  }
2542  rmp->is_known = 0;
2543  }
2544 
2545 send:
2546  vl_msg_api_send_shmem (q, (u8 *) & rmp);
2547 #endif
2548 }
2549 
2550 static void
2552 {
2553  clib_warning ("BUG");
2554 }
2555 
2556 static void
2558 {
2560  vnet_main_t *vnm = vnet_get_main ();
2561  int rv = 0;
2562  clib_error_t *error;
2563  u16 flags;
2564 
2565  VALIDATE_SW_IF_INDEX (mp);
2566 
2568 
2569  error = vnet_sw_interface_set_flags (vnm, ntohl (mp->sw_if_index), flags);
2570  if (error)
2571  {
2572  rv = -1;
2573  clib_error_report (error);
2574  }
2575 
2577  REPLY_MACRO (VL_API_SW_INTERFACE_SET_FLAGS_REPLY);
2578 }
2579 
2580 static void
2582  mp)
2583 {
2585 
2586  vnet_main_t *vnm = vnet_get_main ();
2590  static vnet_main_t **my_vnet_mains;
2591  int i, j, n_counters;
2592  int rv = 0;
2593 
2594  if (mp->sw_if_index != ~0)
2595  VALIDATE_SW_IF_INDEX (mp);
2596 
2597  vec_reset_length (my_vnet_mains);
2598 
2599  for (i = 0; i < vec_len (vnet_mains); i++)
2600  {
2601  if (vnet_mains[i])
2602  vec_add1 (my_vnet_mains, vnet_mains[i]);
2603  }
2604 
2605  if (vec_len (vnet_mains) == 0)
2606  vec_add1 (my_vnet_mains, vnm);
2607 
2608  n_counters = vec_len (im->combined_sw_if_counters);
2609 
2610  for (j = 0; j < n_counters; j++)
2611  {
2612  for (i = 0; i < vec_len (my_vnet_mains); i++)
2613  {
2614  im = &my_vnet_mains[i]->interface_main;
2615  cm = im->combined_sw_if_counters + j;
2616  if (mp->sw_if_index == (u32) ~ 0)
2618  else
2619  vlib_zero_combined_counter (cm, ntohl (mp->sw_if_index));
2620  }
2621  }
2622 
2623  n_counters = vec_len (im->sw_if_counters);
2624 
2625  for (j = 0; j < n_counters; j++)
2626  {
2627  for (i = 0; i < vec_len (my_vnet_mains); i++)
2628  {
2629  im = &my_vnet_mains[i]->interface_main;
2630  sm = im->sw_if_counters + j;
2631  if (mp->sw_if_index == (u32) ~ 0)
2633  else
2634  vlib_zero_simple_counter (sm, ntohl (mp->sw_if_index));
2635  }
2636  }
2637 
2639 
2640  REPLY_MACRO (VL_API_SW_INTERFACE_CLEAR_STATS_REPLY);
2641 }
2642 
2643 static void
2646  vnet_sw_interface_t * swif,
2647  u8 * interface_name, u32 context)
2648 {
2651 
2653 
2654  mp = vl_msg_api_alloc (sizeof (*mp));
2655  memset (mp, 0, sizeof (*mp));
2656  mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_DETAILS);
2657  mp->sw_if_index = ntohl (swif->sw_if_index);
2658  mp->sup_sw_if_index = ntohl (swif->sup_sw_if_index);
2659  mp->admin_up_down = (swif->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? 1 : 0;
2660  mp->link_up_down = (hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP) ? 1 : 0;
2665  mp->link_mtu = ntohs (hi->max_packet_bytes);
2666  mp->context = context;
2667 
2668  strncpy ((char *) mp->interface_name,
2669  (char *) interface_name, ARRAY_LEN (mp->interface_name) - 1);
2670 
2671  /* Send the L2 address for ethernet physical intfcs */
2672  if (swif->sup_sw_if_index == swif->sw_if_index
2674  {
2677 
2678  ei = pool_elt_at_index (em->interfaces, hi->hw_instance);
2679  ASSERT (sizeof (mp->l2_address) >= sizeof (ei->address));
2680  clib_memcpy (mp->l2_address, ei->address, sizeof (ei->address));
2681  mp->l2_address_length = ntohl (sizeof (ei->address));
2682  }
2683  else if (swif->sup_sw_if_index != swif->sw_if_index)
2684  {
2685  vnet_sub_interface_t *sub = &swif->sub;
2686  mp->sub_id = ntohl (sub->id);
2687  mp->sub_dot1ad = sub->eth.flags.dot1ad;
2688  mp->sub_number_of_tags =
2689  sub->eth.flags.one_tag + sub->eth.flags.two_tags * 2;
2690  mp->sub_outer_vlan_id = ntohs (sub->eth.outer_vlan_id);
2691  mp->sub_inner_vlan_id = ntohs (sub->eth.inner_vlan_id);
2692  mp->sub_exact_match = sub->eth.flags.exact_match;
2693  mp->sub_default = sub->eth.flags.default_sub;
2694  mp->sub_outer_vlan_id_any = sub->eth.flags.outer_vlan_id_any;
2695  mp->sub_inner_vlan_id_any = sub->eth.flags.inner_vlan_id_any;
2696 
2697  /* vlan tag rewrite data */
2698  u32 vtr_op = L2_VTR_DISABLED;
2699  u32 vtr_push_dot1q = 0, vtr_tag1 = 0, vtr_tag2 = 0;
2700 
2701  if (l2vtr_get (am->vlib_main, am->vnet_main, swif->sw_if_index,
2702  &vtr_op, &vtr_push_dot1q, &vtr_tag1, &vtr_tag2) != 0)
2703  {
2704  // error - default to disabled
2705  mp->vtr_op = ntohl (L2_VTR_DISABLED);
2706  clib_warning ("cannot get vlan tag rewrite for sw_if_index %d",
2707  swif->sw_if_index);
2708  }
2709  else
2710  {
2711  mp->vtr_op = ntohl (vtr_op);
2712  mp->vtr_push_dot1q = ntohl (vtr_push_dot1q);
2713  mp->vtr_tag1 = ntohl (vtr_tag1);
2714  mp->vtr_tag2 = ntohl (vtr_tag2);
2715  }
2716  }
2717 
2718  vl_msg_api_send_shmem (q, (u8 *) & mp);
2719 }
2720 
2721 static void
2724  vnet_sw_interface_t * swif)
2725 {
2727  vnet_main_t *vnm = am->vnet_main;
2728 
2730  swif->sw_if_index);
2731  mp = vl_msg_api_alloc (sizeof (*mp));
2732  memset (mp, 0, sizeof (*mp));
2733  mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_SET_FLAGS);
2734  mp->sw_if_index = ntohl (swif->sw_if_index);
2735 
2736  mp->admin_up_down = (swif->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? 1 : 0;
2737  mp->link_up_down = (hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP) ? 1 : 0;
2738  vl_msg_api_send_shmem (q, (u8 *) & mp);
2739 }
2740 
2743  u32 sw_if_index)
2744  __attribute__ ((unused));
2745 
2746 static void
2749  u32 sw_if_index)
2750 {
2752 
2753  mp = vl_msg_api_alloc (sizeof (*mp));
2754  memset (mp, 0, sizeof (*mp));
2755  mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_SET_FLAGS);
2756  mp->sw_if_index = ntohl (sw_if_index);
2757 
2758  mp->admin_up_down = 0;
2759  mp->link_up_down = 0;
2760  mp->deleted = 1;
2761  vl_msg_api_send_shmem (q, (u8 *) & mp);
2762 }
2763 
2764 static void
2766 {
2768  vnet_sw_interface_t *swif;
2770  u8 *filter_string = 0, *name_string = 0;
2772  char *strcasestr (char *, char *); /* lnx hdr file botch */
2773 
2775 
2776  if (q == 0)
2777  return;
2778 
2779  if (mp->name_filter_valid)
2780  {
2781  mp->name_filter[ARRAY_LEN (mp->name_filter) - 1] = 0;
2782  filter_string = format (0, "%s%c", mp->name_filter, 0);
2783  }
2784 
2785  /* *INDENT-OFF* */
2786  pool_foreach (swif, im->sw_interfaces,
2787  ({
2788  name_string = format (name_string, "%U%c",
2789  format_vnet_sw_interface_name,
2790  am->vnet_main, swif, 0);
2791 
2792  if (mp->name_filter_valid == 0 ||
2793  strcasestr((char *) name_string, (char *) filter_string)) {
2794 
2795  send_sw_interface_details (am, q, swif, name_string, mp->context);
2796  }
2797  _vec_len (name_string) = 0;
2798  }));
2799  /* *INDENT-ON* */
2800 
2801  vec_free (name_string);
2802  vec_free (filter_string);
2803 }
2804 
2805 void
2807 {
2808  vpe_api_main_t *vam = &vpe_api_main;
2811  vl_api_oam_event_t *mp;
2812 
2813  /* *INDENT-OFF* */
2814  pool_foreach(reg, vam->oam_events_registrations,
2815  ({
2816  q = vl_api_client_index_to_input_queue (reg->client_index);
2817  if (q)
2818  {
2819  mp = vl_msg_api_alloc (sizeof (*mp));
2820  mp->_vl_msg_id = ntohs (VL_API_OAM_EVENT);
2821  clib_memcpy (mp->dst_address, &t->dst_address,
2822  sizeof (mp->dst_address));
2823  mp->state = t->state;
2824  vl_msg_api_send_shmem (q, (u8 *)&mp);
2825  }
2826  }));
2827  /* *INDENT-ON* */
2828 }
2829 
2830 static void
2832 {
2834  int rv;
2835 
2837  (ip4_address_t *) mp->dst_address,
2838  ntohl (mp->vrf_id), (int) (mp->is_add));
2839 
2840  REPLY_MACRO (VL_API_OAM_ADD_DEL_REPLY);
2841 }
2842 
2843 static void
2845 {
2846  stats_main_t *sm = &stats_main;
2850  vlib_counter_t v;
2851  int i, which;
2852  u64 total_pkts[VLIB_N_RX_TX];
2853  u64 total_bytes[VLIB_N_RX_TX];
2854 
2857 
2858  if (!q)
2859  return;
2860 
2861  rmp = vl_msg_api_alloc (sizeof (*rmp));
2862  rmp->_vl_msg_id = ntohs (VL_API_VNET_SUMMARY_STATS_REPLY);
2863  rmp->context = mp->context;
2864  rmp->retval = 0;
2865 
2866  memset (total_pkts, 0, sizeof (total_pkts));
2867  memset (total_bytes, 0, sizeof (total_bytes));
2868 
2870 
2872  {
2873  which = cm - im->combined_sw_if_counters;
2874 
2875  for (i = 0; i < vec_len (cm->maxi); i++)
2876  {
2877  vlib_get_combined_counter (cm, i, &v);
2878  total_pkts[which] += v.packets;
2879  total_bytes[which] += v.bytes;
2880  }
2881  }
2883 
2884  /* Note: in HOST byte order! */
2885  rmp->total_pkts[VLIB_RX] = total_pkts[VLIB_RX];
2886  rmp->total_bytes[VLIB_RX] = total_bytes[VLIB_RX];
2887  rmp->total_pkts[VLIB_TX] = total_pkts[VLIB_TX];
2888  rmp->total_bytes[VLIB_TX] = total_bytes[VLIB_TX];
2890 
2891  vl_msg_api_send_shmem (q, (u8 *) & rmp);
2892 }
2893 
2894 /* *INDENT-OFF* */
2895 typedef CLIB_PACKED (struct {
2896  ip4_address_t address;
2897  u32 address_length: 6;
2898  u32 index:26;
2899 }) ip4_route_t;
2900 /* *INDENT-ON* */
2901 
2902 static int
2903 ip4_reset_fib_t_handler (vl_api_reset_fib_t * mp)
2904 {
2905  vnet_main_t *vnm = vnet_get_main ();
2907  ip4_main_t *im4 = &ip4_main;
2908  static ip4_route_t *routes;
2909  static u32 *sw_if_indices_to_shut;
2910  stats_main_t *sm = &stats_main;
2911  ip4_route_t *r;
2912  ip4_fib_t *fib;
2913  u32 sw_if_index;
2914  int i;
2915  int rv = VNET_API_ERROR_NO_SUCH_FIB;
2916  u32 target_fib_id = ntohl (mp->vrf_id);
2917 
2918  dslock (sm, 1 /* release hint */ , 8 /* tag */ );
2919 
2920  vec_foreach (fib, im4->fibs)
2921  {
2922  vnet_sw_interface_t *si;
2923 
2924  if (fib->table_id != target_fib_id)
2925  continue;
2926 
2927  /* remove any mpls/gre tunnels in this fib */
2929 
2930  /* remove any mpls encap/decap labels */
2932 
2933  /* remove any proxy arps in this fib */
2935 
2936  /* Set the flow hash for this fib to the default */
2938 
2939  vec_reset_length (sw_if_indices_to_shut);
2940 
2941  /* Shut down interfaces in this FIB / clean out intfc routes */
2942  /* *INDENT-OFF* */
2943  pool_foreach (si, im->sw_interfaces,
2944  ({
2945  u32 sw_if_index = si->sw_if_index;
2946 
2947  if (sw_if_index < vec_len (im4->fib_index_by_sw_if_index)
2948  && (im4->fib_index_by_sw_if_index[si->sw_if_index] ==
2949  fib - im4->fibs))
2950  vec_add1 (sw_if_indices_to_shut, si->sw_if_index);
2951  }));
2952  /* *INDENT-ON* */
2953 
2954  for (i = 0; i < vec_len (sw_if_indices_to_shut); i++)
2955  {
2956  sw_if_index = sw_if_indices_to_shut[i];
2957  // vec_foreach (sw_if_index, sw_if_indices_to_shut) {
2958 
2959  u32 flags = vnet_sw_interface_get_flags (vnm, sw_if_index);
2960  flags &= ~(VNET_SW_INTERFACE_FLAG_ADMIN_UP);
2961  vnet_sw_interface_set_flags (vnm, sw_if_index, flags);
2962  }
2963 
2964  vec_reset_length (routes);
2965 
2966  for (i = 0; i < ARRAY_LEN (fib->adj_index_by_dst_address); i++)
2967  {
2968  uword *hash = fib->adj_index_by_dst_address[i];
2969  hash_pair_t *p;
2970  ip4_route_t x;
2971 
2972  x.address_length = i;
2973 
2974  /* *INDENT-OFF* */
2975  hash_foreach_pair (p, hash,
2976  ({
2977  x.address.data_u32 = p->key;
2978  vec_add1 (routes, x);
2979  }));
2980  /* *INDENT-ON* */
2981  }
2982 
2983  vec_foreach (r, routes)
2984  {
2986 
2987  memset (&a, 0, sizeof (a));
2989  a.table_index_or_table_id = fib - im4->fibs;
2990  a.dst_address = r->address;
2991  a.dst_address_length = r->address_length;
2992  a.adj_index = ~0;
2993 
2994  ip4_add_del_route (im4, &a);
2995  ip4_maybe_remap_adjacencies (im4, fib - im4->fibs,
2997  }
2998  rv = 0;
2999  break;
3000  } /* vec_foreach (fib) */
3001 
3002  dsunlock (sm);
3003  return rv;
3004 }
3005 
3006 typedef struct
3007 {
3008  ip6_address_t address;
3009  u32 address_length;
3010  u32 index;
3011 } ip6_route_t;
3012 
3013 typedef struct
3014 {
3015  u32 fib_index;
3016  ip6_route_t **routep;
3018 
3019 static void
3021 {
3022  add_routes_in_fib_arg_t *ap = arg;
3023 
3024  if (kvp->key[2] >> 32 == ap->fib_index)
3025  {
3027  ip6_route_t *r;
3028  addr = (ip6_address_t *) kvp;
3029  vec_add2 (*ap->routep, r, 1);
3030  r->address = addr[0];
3031  r->address_length = kvp->key[2] & 0xFF;
3032  r->index = kvp->value;
3033  }
3034 }
3035 
3036 static int
3038 {
3039  vnet_main_t *vnm = vnet_get_main ();
3041  ip6_main_t *im6 = &ip6_main;
3042  stats_main_t *sm = &stats_main;
3043  static ip6_route_t *routes;
3044  static u32 *sw_if_indices_to_shut;
3045  ip6_route_t *r;
3046  ip6_fib_t *fib;
3047  u32 sw_if_index;
3048  int i;
3049  int rv = VNET_API_ERROR_NO_SUCH_FIB;
3050  u32 target_fib_id = ntohl (mp->vrf_id);
3051  add_routes_in_fib_arg_t _a, *a = &_a;
3052  clib_bihash_24_8_t *h = &im6->ip6_lookup_table;
3053 
3054  dslock (sm, 1 /* release hint */ , 9 /* tag */ );
3055 
3056  vec_foreach (fib, im6->fibs)
3057  {
3058  vnet_sw_interface_t *si;
3059 
3060  if (fib->table_id != target_fib_id)
3061  continue;
3062 
3063  vec_reset_length (sw_if_indices_to_shut);
3064 
3065  /* Shut down interfaces in this FIB / clean out intfc routes */
3066  /* *INDENT-OFF* */
3067  pool_foreach (si, im->sw_interfaces,
3068  ({
3069  if (im6->fib_index_by_sw_if_index[si->sw_if_index] ==
3070  fib - im6->fibs)
3071  vec_add1 (sw_if_indices_to_shut, si->sw_if_index);
3072  }));
3073  /* *INDENT-ON* */
3074 
3075  for (i = 0; i < vec_len (sw_if_indices_to_shut); i++)
3076  {
3077  sw_if_index = sw_if_indices_to_shut[i];
3078  // vec_foreach (sw_if_index, sw_if_indices_to_shut) {
3079 
3080  u32 flags = vnet_sw_interface_get_flags (vnm, sw_if_index);
3081  flags &= ~(VNET_SW_INTERFACE_FLAG_ADMIN_UP);
3082  vnet_sw_interface_set_flags (vnm, sw_if_index, flags);
3083  }
3084 
3085  vec_reset_length (routes);
3086 
3087  a->fib_index = fib - im6->fibs;
3088  a->routep = &routes;
3089 
3090  clib_bihash_foreach_key_value_pair_24_8 (h, add_routes_in_fib, a);
3091 
3092  vec_foreach (r, routes)
3093  {
3095 
3096  memset (&a, 0, sizeof (a));
3098  a.table_index_or_table_id = fib - im6->fibs;
3099  a.dst_address = r->address;
3101  a.adj_index = ~0;
3102 
3103  ip6_add_del_route (im6, &a);
3104  ip6_maybe_remap_adjacencies (im6, fib - im6->fibs,
3106  }
3107  rv = 0;
3108  /* Reinstall the neighbor / router discovery routes */
3109  vnet_ip6_fib_init (im6, fib - im6->fibs);
3110  break;
3111  } /* vec_foreach (fib) */
3112 
3113  dsunlock (sm);
3114  return rv;
3115 }
3116 
3117 static void
3119 {
3120  int rv;
3122 
3123  if (mp->is_ipv6)
3124  rv = ip6_reset_fib_t_handler (mp);
3125  else
3126  rv = ip4_reset_fib_t_handler (mp);
3127 
3128  REPLY_MACRO (VL_API_RESET_FIB_REPLY);
3129 }
3130 
3131 
3132 static void
3134 {
3136  int rv;
3137 
3139  (ip4_address_t *) (&mp->dhcp_src_address),
3140  (u32) ntohl (mp->vrf_id),
3141  (int) mp->insert_circuit_id,
3142  (int) (mp->is_add == 0));
3143 
3144  REPLY_MACRO (VL_API_DHCP_PROXY_CONFIG_REPLY);
3145 }
3146 
3147 
3148 static void
3150 {
3152  int rv = -1;
3153 
3155  (ip6_address_t *) (&mp->dhcp_src_address),
3156  (u32) ntohl (mp->vrf_id),
3157  (int) mp->insert_circuit_id,
3158  (int) (mp->is_add == 0));
3159 
3160  REPLY_MACRO (VL_API_DHCP_PROXY_CONFIG_REPLY);
3161 }
3162 
3163 static void
3165 {
3167  int rv;
3168 
3170  (ip4_address_t *) (&mp->dhcp_src_address),
3171  (u32) ntohl (mp->rx_vrf_id),
3172  (u32) ntohl (mp->server_vrf_id),
3173  (int) mp->insert_circuit_id,
3174  (int) (mp->is_add == 0));
3175 
3176  REPLY_MACRO (VL_API_DHCP_PROXY_CONFIG_2_REPLY);
3177 }
3178 
3179 
3180 static void
3182 {
3184  int rv = -1;
3185 
3186 #if 0 // $$$$ FIXME
3187  rv = dhcpv6_proxy_set_server_2 ((ip6_address_t *) (&mp->dhcp_server),
3188  (ip6_address_t *) (&mp->dhcp_src_address),
3189  (u32) ntohl (mp->rx_vrf_id),
3190  (u32) ntohl (mp->server_vrf_id),
3191  (int) mp->insert_circuit_id,
3192  (int) (mp->is_add == 0));
3193 #else
3194  rv = VNET_API_ERROR_UNIMPLEMENTED;
3195 #endif
3196 
3197  REPLY_MACRO (VL_API_DHCP_PROXY_CONFIG_2_REPLY);
3198 }
3199 
3200 
3201 static void
3203 {
3205  int rv;
3206  if (!mp->is_ipv6)
3207  rv = dhcp_proxy_set_option82_vss (ntohl (mp->tbl_id),
3208  ntohl (mp->oui),
3209  ntohl (mp->fib_id),
3210  (int) mp->is_add == 0);
3211  else
3212  rv = dhcpv6_proxy_set_vss (ntohl (mp->tbl_id),
3213  ntohl (mp->oui),
3214  ntohl (mp->fib_id), (int) mp->is_add == 0);
3215 
3216  REPLY_MACRO (VL_API_DHCP_PROXY_SET_VSS_REPLY);
3217 }
3218 
3219 
3222 {
3223  if (mp->is_ipv6 == 0)
3224  dhcpv4_proxy_config (mp);
3225  else
3226  dhcpv6_proxy_config (mp);
3227 }
3228 
3231 {
3232  if (mp->is_ipv6 == 0)
3233  dhcpv4_proxy_config_2 (mp);
3234  else
3235  dhcpv6_proxy_config_2 (mp);
3236 }
3237 
3238 void
3239 dhcp_compl_event_callback (u32 client_index, u32 pid, u8 * hostname,
3240  u8 is_ipv6, u8 * host_address, u8 * router_address,
3241  u8 * host_mac)
3242 {
3245 
3246  q = vl_api_client_index_to_input_queue (client_index);
3247  if (!q)
3248  return;
3249 
3250  mp = vl_msg_api_alloc (sizeof (*mp));
3251  mp->client_index = client_index;
3252  mp->pid = pid;
3253  mp->is_ipv6 = is_ipv6;
3254  clib_memcpy (&mp->hostname, hostname, vec_len (hostname));
3255  mp->hostname[vec_len (hostname) + 1] = '\n';
3256  clib_memcpy (&mp->host_address[0], host_address, 16);
3257  clib_memcpy (&mp->router_address[0], router_address, 16);
3258  clib_memcpy (&mp->host_mac[0], host_mac, 6);
3259 
3260  mp->_vl_msg_id = ntohs (VL_API_DHCP_COMPL_EVENT);
3261 
3262  vl_msg_api_send_shmem (q, (u8 *) & mp);
3263 }
3264 
3267 {
3268  vlib_main_t *vm = vlib_get_main ();
3270  int rv = 0;
3271 
3272  VALIDATE_SW_IF_INDEX (mp);
3273 
3274  rv = dhcp_client_config (vm, ntohl (mp->sw_if_index),
3275  mp->hostname, mp->is_add, mp->client_index,
3277  NULL, mp->pid);
3278 
3280 
3281  REPLY_MACRO (VL_API_DHCP_CLIENT_CONFIG_REPLY);
3282 }
3283 
3284 static void
3287 {
3289  int rv = 0;
3290  u8 is_no, suppress, managed, other, ll_option, send_unicast, cease,
3291  default_router;
3292 
3293  is_no = mp->is_no == 1;
3294  suppress = mp->suppress == 1;
3295  managed = mp->managed == 1;
3296  other = mp->other == 1;
3297  ll_option = mp->ll_option == 1;
3298  send_unicast = mp->send_unicast == 1;
3299  cease = mp->cease == 1;
3300  default_router = mp->default_router == 1;
3301 
3302  VALIDATE_SW_IF_INDEX (mp);
3303 
3304  rv = ip6_neighbor_ra_config (vm, ntohl (mp->sw_if_index),
3305  suppress, managed, other,
3306  ll_option, send_unicast, cease,
3307  default_router, ntohl (mp->lifetime),
3308  ntohl (mp->initial_count),
3309  ntohl (mp->initial_interval),
3310  ntohl (mp->max_interval),
3311  ntohl (mp->min_interval), is_no);
3312 
3314 
3315  REPLY_MACRO (VL_API_SW_INTERFACE_IP6ND_RA_CONFIG_REPLY);
3316 }
3317 
3318 static void
3321 {
3323  int rv = 0;
3324  u8 is_no, use_default, no_advertise, off_link, no_autoconfig, no_onlink;
3325 
3326  VALIDATE_SW_IF_INDEX (mp);
3327 
3328  is_no = mp->is_no == 1;
3329  use_default = mp->use_default == 1;
3330  no_advertise = mp->no_advertise == 1;
3331  off_link = mp->off_link == 1;
3332  no_autoconfig = mp->no_autoconfig == 1;
3333  no_onlink = mp->no_onlink == 1;
3334 
3335  rv = ip6_neighbor_ra_prefix (vm, ntohl (mp->sw_if_index),
3336  (ip6_address_t *) mp->address,
3337  mp->address_length, use_default,
3338  ntohl (mp->val_lifetime),
3339  ntohl (mp->pref_lifetime), no_advertise,
3340  off_link, no_autoconfig, no_onlink, is_no);
3341 
3343  REPLY_MACRO (VL_API_SW_INTERFACE_IP6ND_RA_PREFIX_REPLY);
3344 }
3345 
3346 static void
3349 {
3351  vnet_main_t *vnm = vnet_get_main ();
3352  int rv = 0;
3353  clib_error_t *error;
3354 
3355  vnm->api_errno = 0;
3356 
3357  VALIDATE_SW_IF_INDEX (mp);
3358 
3359  error =
3360  (mp->enable == 1) ? enable_ip6_interface (vm,
3361  ntohl (mp->sw_if_index)) :
3362  disable_ip6_interface (vm, ntohl (mp->sw_if_index));
3363 
3364  if (error)
3365  {
3366  clib_error_report (error);
3367  rv = VNET_API_ERROR_UNSPECIFIED;
3368  }
3369  else
3370  {
3371  rv = vnm->api_errno;
3372  }
3373 
3375 
3376  REPLY_MACRO (VL_API_SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY);
3377 }
3378 
3379 static void
3382 {
3384  int rv = 0;
3385  clib_error_t *error;
3386  vnet_main_t *vnm = vnet_get_main ();
3387 
3388  vnm->api_errno = 0;
3389 
3390  VALIDATE_SW_IF_INDEX (mp);
3391 
3392  error = set_ip6_link_local_address (vm,
3393  ntohl (mp->sw_if_index),
3394  (ip6_address_t *) mp->address,
3395  mp->address_length);
3396  if (error)
3397  {
3398  clib_error_report (error);
3399  rv = VNET_API_ERROR_UNSPECIFIED;
3400  }
3401  else
3402  {
3403  rv = vnm->api_errno;
3404  }
3405 
3407 
3408  REPLY_MACRO (VL_API_SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY);
3409 }
3410 
3411 static void
3413 {
3415  int rv = VNET_API_ERROR_UNIMPLEMENTED;
3416 
3417  clib_warning ("unimplemented...");
3418 
3419  REPLY_MACRO (VL_API_SET_IP_FLOW_HASH_REPLY);
3420 }
3421 
3422 static void
3424 {
3426  int rv;
3427  u32 table_id;
3428  u32 flow_hash_config = 0;
3429 
3430  table_id = ntohl (mp->vrf_id);
3431 
3432 #define _(a,b) if (mp->a) flow_hash_config |= b;
3434 #undef _
3435 
3436  rv = vnet_set_ip4_flow_hash (table_id, flow_hash_config);
3437 
3438  REPLY_MACRO (VL_API_SET_IP_FLOW_HASH_REPLY);
3439 }
3440 
3441 
3442 static void
3444 {
3445  if (mp->is_ipv6 == 0)
3446  set_ip4_flow_hash (mp);
3447  else
3448  set_ip6_flow_hash (mp);
3449 }
3450 
3453 {
3455  int rv = 0;
3456  vnet_sw_interface_t *si;
3457  vnet_main_t *vnm = vnet_get_main ();
3458  u32 sw_if_index, unnumbered_sw_if_index;
3459 
3460  sw_if_index = ntohl (mp->sw_if_index);
3461  unnumbered_sw_if_index = ntohl (mp->unnumbered_sw_if_index);
3462 
3463  /*
3464  * The API message field names are backwards from
3465  * the underlying data structure names.
3466  * It's not worth changing them now.
3467  */
3469  unnumbered_sw_if_index))
3470  {
3471  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
3472  goto done;
3473  }
3474 
3475  /* Only check the "use loop0" field when setting the binding */
3476  if (mp->is_add &&
3477  pool_is_free_index (vnm->interface_main.sw_interfaces, sw_if_index))
3478  {
3479  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX_2;
3480  goto done;
3481  }
3482 
3483  si = vnet_get_sw_interface (vnm, unnumbered_sw_if_index);
3484 
3485  if (mp->is_add)
3486  {
3488  si->unnumbered_sw_if_index = sw_if_index;
3489  }
3490  else
3491  {
3493  si->unnumbered_sw_if_index = (u32) ~ 0;
3494  }
3495 
3496 done:
3497  REPLY_MACRO (VL_API_SW_INTERFACE_SET_UNNUMBERED_REPLY);
3498 }
3499 
3500 static void
3502 {
3504  u32 sw_if_index;
3505  int rv;
3506 
3507  rv = vnet_create_loopback_interface (&sw_if_index, mp->mac_address);
3508 
3509  /* *INDENT-OFF* */
3510  REPLY_MACRO2(VL_API_CREATE_LOOPBACK_REPLY,
3511  ({
3512  rmp->sw_if_index = ntohl (sw_if_index);
3513  }));
3514  /* *INDENT-ON* */
3515 }
3516 
3517 static void
3519 {
3521  u32 sw_if_index;
3522  int rv;
3523 
3524  sw_if_index = ntohl (mp->sw_if_index);
3525  rv = vnet_delete_loopback_interface (sw_if_index);
3526 
3527  REPLY_MACRO (VL_API_DELETE_LOOPBACK_REPLY);
3528 }
3529 
3530 static void
3532 {
3534  int rv = 0;
3535 
3536  /* *INDENT-OFF* */
3537  REPLY_MACRO2(VL_API_CONTROL_PING_REPLY,
3538  ({
3539  rmp->vpe_pid = ntohl (getpid());
3540  }));
3541  /* *INDENT-ON* */
3542 }
3543 
3546 {
3548  int rv = 0;
3549 
3550  /* *INDENT-OFF* */
3551  REPLY_MACRO2(VL_API_NOPRINT_CONTROL_PING_REPLY,
3552  ({
3553  rmp->vpe_pid = ntohl (getpid());
3554  }));
3555  /* *INDENT-ON* */
3556 }
3557 
3558 static void
3559 shmem_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
3560 {
3561  u8 **shmem_vecp = (u8 **) arg;
3562  u8 *shmem_vec;
3563  void *oldheap;
3564  api_main_t *am = &api_main;
3565  u32 offset;
3566 
3567  shmem_vec = *shmem_vecp;
3568 
3569  offset = vec_len (shmem_vec);
3570 
3571  pthread_mutex_lock (&am->vlib_rp->mutex);
3572  oldheap = svm_push_data_heap (am->vlib_rp);
3573 
3574  vec_validate (shmem_vec, offset + buffer_bytes - 1);
3575 
3576  clib_memcpy (shmem_vec + offset, buffer, buffer_bytes);
3577 
3578  svm_pop_heap (oldheap);
3579  pthread_mutex_unlock (&am->vlib_rp->mutex);
3580 
3581  *shmem_vecp = shmem_vec;
3582 }
3583 
3584 
3585 static void
3587 {
3588  vl_api_cli_reply_t *rp;
3590  vlib_main_t *vm = vlib_get_main ();
3591  api_main_t *am = &api_main;
3592  unformat_input_t input;
3593  u8 *shmem_vec = 0;
3594  void *oldheap;
3595 
3597  if (!q)
3598  return;
3599 
3600  rp = vl_msg_api_alloc (sizeof (*rp));
3601  rp->_vl_msg_id = ntohs (VL_API_CLI_REPLY);
3602  rp->context = mp->context;
3603 
3604  unformat_init_vector (&input, (u8 *) (uword) mp->cmd_in_shmem);
3605 
3606  vlib_cli_input (vm, &input, shmem_cli_output, (uword) & shmem_vec);
3607 
3608  pthread_mutex_lock (&am->vlib_rp->mutex);
3609  oldheap = svm_push_data_heap (am->vlib_rp);
3610 
3611  vec_add1 (shmem_vec, 0);
3612 
3613  svm_pop_heap (oldheap);
3614  pthread_mutex_unlock (&am->vlib_rp->mutex);
3615 
3616  rp->reply_in_shmem = (uword) shmem_vec;
3617 
3618  vl_msg_api_send_shmem (q, (u8 *) & rp);
3619 }
3620 
3621 static void
3623 {
3624  int rv;
3626  vnet_main_t *vnm = vnet_get_main ();
3627  clib_error_t *error;
3628 
3629  vnm->api_errno = 0;
3630 
3631  if (mp->is_ipv6)
3632  error = ip6_set_neighbor_limit (ntohl (mp->arp_neighbor_limit));
3633  else
3634  error = ip4_set_arp_limit (ntohl (mp->arp_neighbor_limit));
3635 
3636  if (error)
3637  {
3638  clib_error_report (error);
3639  rv = VNET_API_ERROR_UNSPECIFIED;
3640  }
3641  else
3642  {
3643  rv = vnm->api_errno;
3644  }
3645 
3646  REPLY_MACRO (VL_API_SET_ARP_NEIGHBOR_LIMIT_REPLY);
3647 }
3648 
3651 {
3652 #if IPV6SR == 0
3653  clib_warning ("unimplemented");
3654 #else
3655  ip6_sr_add_del_tunnel_args_t _a, *a = &_a;
3656  int rv = 0;
3658  ip6_address_t *segments = 0, *seg;
3659  ip6_address_t *tags = 0, *tag;
3660  ip6_address_t *this_address;
3661  int i;
3662 
3663  if (mp->n_segments == 0)
3664  {
3665  rv = -11;
3666  goto out;
3667  }
3668 
3669  memset (a, 0, sizeof (*a));
3670  a->src_address = (ip6_address_t *) & mp->src_address;
3671  a->dst_address = (ip6_address_t *) & mp->dst_address;
3672  a->dst_mask_width = mp->dst_mask_width;
3674  a->is_del = (mp->is_add == 0);
3675  a->rx_table_id = ntohl (mp->outer_vrf_id);
3676  a->tx_table_id = ntohl (mp->inner_vrf_id);
3677 
3678  a->name = format (0, "%s", mp->name);
3679  if (!(vec_len (a->name)))
3680  a->name = 0;
3681 
3682  a->policy_name = format (0, "%s", mp->policy_name);
3683  if (!(vec_len (a->policy_name)))
3684  a->policy_name = 0;
3685 
3686  /* Yank segments and tags out of the API message */
3687  this_address = (ip6_address_t *) mp->segs_and_tags;
3688  for (i = 0; i < mp->n_segments; i++)
3689  {
3690  vec_add2 (segments, seg, 1);
3691  clib_memcpy (seg->as_u8, this_address->as_u8, sizeof (*this_address));
3692  this_address++;
3693  }
3694  for (i = 0; i < mp->n_tags; i++)
3695  {
3696  vec_add2 (tags, tag, 1);
3697  clib_memcpy (tag->as_u8, this_address->as_u8, sizeof (*this_address));
3698  this_address++;
3699  }
3700 
3701  a->segments = segments;
3702  a->tags = tags;
3703 
3704  rv = ip6_sr_add_del_tunnel (a);
3705 
3706 out:
3707 
3708  REPLY_MACRO (VL_API_SR_TUNNEL_ADD_DEL_REPLY);
3709 #endif
3710 }
3711 
3714 {
3715 #if IPV6SR == 0
3716  clib_warning ("unimplemented");
3717 #else
3718  ip6_sr_add_del_policy_args_t _a, *a = &_a;
3719  int rv = 0;
3721  int i;
3722 
3723  memset (a, 0, sizeof (*a));
3724  a->is_del = (mp->is_add == 0);
3725 
3726  a->name = format (0, "%s", mp->name);
3727  if (!(vec_len (a->name)))
3728  {
3729  rv = VNET_API_ERROR_NO_SUCH_NODE2;
3730  goto out;
3731  }
3732 
3733  if (!(mp->tunnel_names[0]))
3734  {
3735  rv = VNET_API_ERROR_NO_SUCH_NODE2;
3736  goto out;
3737  }
3738 
3739  // start deserializing tunnel_names
3740  int num_tunnels = mp->tunnel_names[0]; //number of tunnels
3741  u8 *deser_tun_names = mp->tunnel_names;
3742  deser_tun_names += 1; //moving along
3743 
3744  u8 *tun_name = 0;
3745  int tun_name_len = 0;
3746 
3747  for (i = 0; i < num_tunnels; i++)
3748  {
3749  tun_name_len = *deser_tun_names;
3750  deser_tun_names += 1;
3751  vec_resize (tun_name, tun_name_len);
3752  memcpy (tun_name, deser_tun_names, tun_name_len);
3753  vec_add1 (a->tunnel_names, tun_name);
3754  deser_tun_names += tun_name_len;
3755  tun_name = 0;
3756  }
3757 
3758  rv = ip6_sr_add_del_policy (a);
3759 
3760 out:
3761 
3762  REPLY_MACRO (VL_API_SR_POLICY_ADD_DEL_REPLY);
3763 #endif
3764 }
3765 
3768 {
3769 #if IPV6SR == 0
3770  clib_warning ("unimplemented");
3771 #else
3773  int rv = 0;
3775 
3776  memset (a, 0, sizeof (*a));
3777  a->is_del = (mp->is_add == 0);
3778 
3780  a->policy_name = format (0, "%s", mp->policy_name);
3781 
3782  if (a->multicast_address == 0)
3783  {
3784  rv = -1;
3785  goto out;
3786  }
3787 
3788  if (!(a->policy_name))
3789  {
3790  rv = -2;
3791  goto out;
3792  }
3793 
3794 #if DPDK > 0 /* Cannot call replicate without DPDK */
3795  rv = ip6_sr_add_del_multicastmap (a);
3796 #else
3797  clib_warning ("multicast replication without DPDK not implemented");
3798  rv = VNET_API_ERROR_UNIMPLEMENTED;
3799 #endif /* DPDK */
3800 
3801 out:
3802 
3803  REPLY_MACRO (VL_API_SR_MULTICAST_MAP_ADD_DEL_REPLY);
3804 #endif
3805 }
3806 
3807 #define foreach_classify_add_del_table_field \
3808 _(table_index) \
3809 _(nbuckets) \
3810 _(memory_size) \
3811 _(skip_n_vectors) \
3812 _(match_n_vectors) \
3813 _(next_table_index) \
3814 _(miss_next_index)
3815 
3818 {
3822  int rv;
3823 
3824 #define _(a) u32 a;
3826 #undef _
3827 
3828 #define _(a) a = ntohl(mp->a);
3830 #undef _
3831 
3832  /* The underlying API fails silently, on purpose, so check here */
3833  if (mp->is_add == 0)
3834  if (pool_is_free_index (cm->tables, table_index))
3835  {
3836  rv = VNET_API_ERROR_NO_SUCH_TABLE;
3837  goto out;
3838  }
3839 
3841  (cm, mp->mask, nbuckets, memory_size,
3842  skip_n_vectors, match_n_vectors,
3843  next_table_index, miss_next_index, &table_index, mp->is_add);
3844 
3845 out:
3846  /* *INDENT-OFF* */
3847  REPLY_MACRO2(VL_API_CLASSIFY_ADD_DEL_TABLE_REPLY,
3848  ({
3849  if (rv == 0 && mp->is_add)
3850  {
3851  t = pool_elt_at_index (cm->tables, table_index);
3852  rmp->skip_n_vectors = ntohl(t->skip_n_vectors);
3853  rmp->match_n_vectors = ntohl(t->match_n_vectors);
3854  rmp->new_table_index = ntohl(table_index);
3855  }
3856  else
3857  {
3858  rmp->skip_n_vectors = ~0;
3859  rmp->match_n_vectors = ~0;
3860  rmp->new_table_index = ~0;
3861  }
3862  }));
3863  /* *INDENT-ON* */
3864 }
3865 
3868 {
3871  int rv;
3872  u32 table_index, hit_next_index, opaque_index;
3873  i32 advance;
3874 
3875  table_index = ntohl (mp->table_index);
3876  hit_next_index = ntohl (mp->hit_next_index);
3877  opaque_index = ntohl (mp->opaque_index);
3878  advance = ntohl (mp->advance);
3879 
3881  (cm, table_index, mp->match, hit_next_index, opaque_index,
3882  advance, mp->is_add);
3883 
3884  REPLY_MACRO (VL_API_CLASSIFY_ADD_DEL_SESSION_REPLY);
3885 }
3886 
3889 {
3890  vlib_main_t *vm = vlib_get_main ();
3892  int rv;
3893  u32 table_index, sw_if_index;
3894 
3895  table_index = ntohl (mp->table_index);
3896  sw_if_index = ntohl (mp->sw_if_index);
3897 
3898  VALIDATE_SW_IF_INDEX (mp);
3899 
3900  if (mp->is_ipv6)
3901  rv = vnet_set_ip6_classify_intfc (vm, sw_if_index, table_index);
3902  else
3903  rv = vnet_set_ip4_classify_intfc (vm, sw_if_index, table_index);
3904 
3906 
3907  REPLY_MACRO (VL_API_CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY);
3908 }
3909 
3912 {
3914  int rv;
3915  u32 sw_if_index, ip4_table_index, ip6_table_index, other_table_index;
3916  int enable;
3917 
3918  ip4_table_index = ntohl (mp->ip4_table_index);
3919  ip6_table_index = ntohl (mp->ip6_table_index);
3920  other_table_index = ntohl (mp->other_table_index);
3921  sw_if_index = ntohl (mp->sw_if_index);
3922 
3923  VALIDATE_SW_IF_INDEX (mp);
3924 
3925  rv = vnet_l2_classify_set_tables (sw_if_index, ip4_table_index,
3926  ip6_table_index, other_table_index);
3927 
3928  if (rv == 0)
3929  {
3930  if (ip4_table_index != ~0 || ip6_table_index != ~0
3931  || other_table_index != ~0)
3932  enable = 1;
3933  else
3934  enable = 0;
3935 
3936  vnet_l2_classify_enable_disable (sw_if_index, enable);
3937  }
3938 
3940 
3941  REPLY_MACRO (VL_API_CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY);
3942 }
3943 
3944 static void
3946 {
3947  int rv = 0;
3949 
3950  /* DAW-FIXME: This API should only clear non-static l2fib entries, but
3951  * that is not currently implemented. When that TODO is fixed
3952  * this call should be changed to pass 1 instead of 0.
3953  */
3954  l2fib_clear_table (0);
3955 
3956  REPLY_MACRO (VL_API_L2_FIB_CLEAR_TABLE_REPLY);
3957 }
3958 
3959 extern void l2_efp_filter_configure (vnet_main_t * vnet_main,
3960  u32 sw_if_index, u32 enable);
3961 
3962 static void
3964  mp)
3965 {
3966  int rv;
3968  vnet_main_t *vnm = vnet_get_main ();
3969 
3970  // enable/disable the feature
3972  rv = vnm->api_errno;
3973 
3974  REPLY_MACRO (VL_API_L2_INTERFACE_EFP_FILTER_REPLY);
3975 }
3976 
3977 static void
3980 {
3981  int rv = 0;
3983  vnet_main_t *vnm = vnet_get_main ();
3984  vlib_main_t *vm = vlib_get_main ();
3985  u32 vtr_op;
3986 
3987  VALIDATE_SW_IF_INDEX (mp);
3988 
3989  vtr_op = ntohl (mp->vtr_op);
3990 
3991  /* The L2 code is unsuspicious */
3992  switch (vtr_op)
3993  {
3994  case L2_VTR_DISABLED:
3995  case L2_VTR_PUSH_1:
3996  case L2_VTR_PUSH_2:
3997  case L2_VTR_POP_1:
3998  case L2_VTR_POP_2:
3999  case L2_VTR_TRANSLATE_1_1:
4000  case L2_VTR_TRANSLATE_1_2:
4001  case L2_VTR_TRANSLATE_2_1:
4002  case L2_VTR_TRANSLATE_2_2:
4003  break;
4004 
4005  default:
4006  rv = VNET_API_ERROR_INVALID_VALUE;
4007  goto bad_sw_if_index;
4008  }
4009 
4010  rv = l2vtr_configure (vm, vnm, ntohl (mp->sw_if_index), vtr_op,
4011  ntohl (mp->push_dot1q), ntohl (mp->tag1),
4012  ntohl (mp->tag2));
4013 
4015 
4016  REPLY_MACRO (VL_API_L2_INTERFACE_VLAN_TAG_REWRITE_REPLY);
4017 }
4018 
4019 static void
4021 {
4022  int rv = 0;
4024  u32 sw_if_index = (u32) ~ 0;
4025 
4026  vnet_main_t *vnm = vnet_get_main ();
4027  vlib_main_t *vm = vlib_get_main ();
4028 
4029 #if DPDK > 0 && DPDK_VHOST_USER
4030  rv = dpdk_vhost_user_create_if (
4031 #else
4032  rv = vhost_user_create_if (
4033 #endif
4034  vnm, vm, (char *) mp->sock_filename,
4035  mp->is_server, &sw_if_index, (u64) ~ 0,
4036  mp->renumber, ntohl (mp->custom_dev_instance),
4037  (mp->use_custom_mac) ? mp->mac_address : NULL);
4038 
4039  /* *INDENT-OFF* */
4040  REPLY_MACRO2(VL_API_CREATE_VHOST_USER_IF_REPLY,
4041  ({
4042  rmp->sw_if_index = ntohl (sw_if_index);
4043  }));
4044  /* *INDENT-ON* */
4045 }
4046 
4047 static void
4049 {
4050  int rv = 0;
4052  u32 sw_if_index = ntohl (mp->sw_if_index);
4053 
4054  vnet_main_t *vnm = vnet_get_main ();
4055  vlib_main_t *vm = vlib_get_main ();
4056 
4057 #if DPDK > 0 && DPDK_VHOST_USER
4058  rv = dpdk_vhost_user_modify_if (
4059 #else
4060  rv = vhost_user_modify_if (
4061 #endif
4062  vnm, vm, (char *) mp->sock_filename,
4063  mp->is_server, sw_if_index, (u64) ~ 0,
4064  mp->renumber, ntohl (mp->custom_dev_instance));
4065  REPLY_MACRO (VL_API_MODIFY_VHOST_USER_IF_REPLY);
4066 }
4067 
4068 static void
4070 {
4071  int rv = 0;
4073  vpe_api_main_t *vam = &vpe_api_main;
4074  u32 sw_if_index = ntohl (mp->sw_if_index);
4075 
4076  vnet_main_t *vnm = vnet_get_main ();
4077  vlib_main_t *vm = vlib_get_main ();
4078 
4079 #if DPDK > 0 && DPDK_VHOST_USER
4080  rv = dpdk_vhost_user_delete_if (vnm, vm, sw_if_index);
4081 #else
4082  rv = vhost_user_delete_if (vnm, vm, sw_if_index);
4083 #endif
4084 
4085  REPLY_MACRO (VL_API_DELETE_VHOST_USER_IF_REPLY);
4086  if (!rv)
4087  {
4090  if (!q)
4091  return;
4092 
4093  send_sw_interface_flags_deleted (vam, q, sw_if_index);
4094  }
4095 }
4096 
4097 static void
4100 {
4101  clib_warning ("BUG");
4102 }
4103 
4104 static void
4108  u32 context)
4109 {
4111 
4112  mp = vl_msg_api_alloc (sizeof (*mp));
4113  memset (mp, 0, sizeof (*mp));
4114  mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_VHOST_USER_DETAILS);
4115  mp->sw_if_index = ntohl (vui->sw_if_index);
4116  mp->virtio_net_hdr_sz = ntohl (vui->virtio_net_hdr_sz);
4117  mp->features = clib_net_to_host_u64 (vui->features);
4118  mp->is_server = vui->is_server;
4119  mp->num_regions = ntohl (vui->num_regions);
4120  mp->sock_errno = ntohl (vui->sock_errno);
4121  mp->context = context;
4122 
4123  strncpy ((char *) mp->sock_filename,
4124  (char *) vui->sock_filename, ARRAY_LEN (mp->sock_filename) - 1);
4125  strncpy ((char *) mp->interface_name,
4126  (char *) vui->if_name, ARRAY_LEN (mp->interface_name) - 1);
4127 
4128  vl_msg_api_send_shmem (q, (u8 *) & mp);
4129 }
4130 
4131 static void
4134 {
4135  int rv = 0;
4137  vnet_main_t *vnm = vnet_get_main ();
4138  vlib_main_t *vm = vlib_get_main ();
4139  vhost_user_intf_details_t *ifaces = NULL;
4142 
4144  if (q == 0)
4145  return;
4146 
4147 #if DPDK > 0 && DPDK_VHOST_USER
4148  rv = dpdk_vhost_user_dump_ifs (vnm, vm, &ifaces);
4149 #else
4150  rv = vhost_user_dump_ifs (vnm, vm, &ifaces);
4151 #endif
4152  if (rv)
4153  return;
4154 
4155  vec_foreach (vuid, ifaces)
4156  {
4157  send_sw_interface_vhost_user_details (am, q, vuid, mp->context);
4158  }
4159  vec_free (ifaces);
4160 }
4161 
4162 static void
4165  l2t_session_t * s,
4166  l2t_main_t * lm, u32 context)
4167 {
4169  u8 *if_name = NULL;
4170  vnet_sw_interface_t *si = NULL;
4171 
4173 
4174  if_name = format (if_name, "%U",
4176 
4177  mp = vl_msg_api_alloc (sizeof (*mp));
4178  memset (mp, 0, sizeof (*mp));
4179  mp->_vl_msg_id = ntohs (VL_API_SW_IF_L2TPV3_TUNNEL_DETAILS);
4180  strncpy ((char *) mp->interface_name,
4181  (char *) if_name, ARRAY_LEN (mp->interface_name) - 1);
4182  mp->sw_if_index = ntohl (si->sw_if_index);
4185  mp->local_cookie[0] = s->local_cookie[0];
4186  mp->local_cookie[1] = s->local_cookie[1];
4187  mp->remote_cookie = s->remote_cookie;
4189  sizeof (s->client_address));
4190  clib_memcpy (mp->our_address, &s->our_address, sizeof (s->our_address));
4192  mp->context = context;
4193 
4194  vl_msg_api_send_shmem (q, (u8 *) & mp);
4195 }
4196 
4197 static void
4200  u8 * ip, u16 prefix_length, u8 is_ipv6, u32 context)
4201 {
4203 
4204  mp = vl_msg_api_alloc (sizeof (*mp));
4205  memset (mp, 0, sizeof (*mp));
4206  mp->_vl_msg_id = ntohs (VL_API_IP_ADDRESS_DETAILS);
4207 
4208  if (is_ipv6)
4209  {
4210  clib_memcpy (&mp->ip, ip, sizeof (mp->ip));
4211  }
4212  else
4213  {
4214  u32 *tp = (u32 *) mp->ip;
4215  *tp = ntohl (*(u32 *) ip);
4216  }
4217  mp->prefix_length = prefix_length;
4218  mp->context = context;
4219 
4220  vl_msg_api_send_shmem (q, (u8 *) & mp);
4221 }
4222 
4223 static void
4225 {
4228  ip6_address_t *r6;
4229  ip4_address_t *r4;
4230  ip6_main_t *im6 = &ip6_main;
4231  ip4_main_t *im4 = &ip4_main;
4232  ip_lookup_main_t *lm6 = &im6->lookup_main;
4233  ip_lookup_main_t *lm4 = &im4->lookup_main;
4234  ip_interface_address_t *ia = 0;
4235  u32 sw_if_index = ~0;
4236  int rv __attribute__ ((unused)) = 0;
4237 
4238  VALIDATE_SW_IF_INDEX (mp);
4239 
4240  sw_if_index = ntohl (mp->sw_if_index);
4241 
4243  if (q == 0)
4244  {
4245  return;
4246  }
4247 
4248  if (mp->is_ipv6)
4249  {
4250  /* *INDENT-OFF* */
4251  foreach_ip_interface_address (lm6, ia, sw_if_index,
4252  1 /* honor unnumbered */,
4253  ({
4254  r6 = ip_interface_address_get_address (lm6, ia);
4255  u16 prefix_length = ia->address_length;
4256  send_ip_address_details(am, q, (u8*)r6, prefix_length, 1, mp->context);
4257  }));
4258  /* *INDENT-ON* */
4259  }
4260  else
4261  {
4262  /* *INDENT-OFF* */
4263  foreach_ip_interface_address (lm4, ia, sw_if_index,
4264  1 /* honor unnumbered */,
4265  ({
4266  r4 = ip_interface_address_get_address (lm4, ia);
4267  u16 prefix_length = ia->address_length;
4268  send_ip_address_details(am, q, (u8*)r4, prefix_length, 0, mp->context);
4269  }));
4270  /* *INDENT-ON* */
4271  }
4273 }
4274 
4275 static void
4277  unix_shared_memory_queue_t * q, u32 sw_if_index, u32 context)
4278 {
4279  vl_api_ip_details_t *mp;
4280 
4281  mp = vl_msg_api_alloc (sizeof (*mp));
4282  memset (mp, 0, sizeof (*mp));
4283  mp->_vl_msg_id = ntohs (VL_API_IP_DETAILS);
4284 
4285  mp->sw_if_index = ntohl (sw_if_index);
4286  mp->context = context;
4287 
4288  vl_msg_api_send_shmem (q, (u8 *) & mp);
4289 }
4290 
4291 static void
4293  mp)
4294 {
4296  l2t_main_t *lm = &l2t_main;
4298  l2t_session_t *session;
4299 
4301  if (q == 0)
4302  return;
4303 
4304  /* *INDENT-OFF* */
4305  pool_foreach (session, lm->sessions,
4306  ({
4307  send_sw_if_l2tpv3_tunnel_details (am, q, session, lm, mp->context);
4308  }));
4309  /* *INDENT-ON* */
4310 }
4311 
4312 
4313 static void
4316  tapcli_interface_details_t * tap_if,
4317  u32 context)
4318 {
4320  mp = vl_msg_api_alloc (sizeof (*mp));
4321  memset (mp, 0, sizeof (*mp));
4322  mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_TAP_DETAILS);
4323  mp->sw_if_index = ntohl (tap_if->sw_if_index);
4324  strncpy ((char *) mp->dev_name,
4325  (char *) tap_if->dev_name, ARRAY_LEN (mp->dev_name) - 1);
4326  mp->context = context;
4327 
4328  vl_msg_api_send_shmem (q, (u8 *) & mp);
4329 }
4330 
4331 static void
4333 {
4334  int rv = 0;
4337  tapcli_interface_details_t *tapifs = NULL;
4338  tapcli_interface_details_t *tap_if = NULL;
4339 
4341  if (q == 0)
4342  return;
4343 
4344  rv = vnet_tap_dump_ifs (&tapifs);
4345  if (rv)
4346  return;
4347 
4348  vec_foreach (tap_if, tapifs)
4349  {
4350  send_sw_interface_tap_details (am, q, tap_if, mp->context);
4351  }
4352 
4353  vec_free (tapifs);
4354 }
4355 
4356 static void
4358 {
4360  vnet_main_t *vnm = vnet_get_main ();
4361  vlib_main_t *vm = vlib_get_main ();
4364  vnet_sw_interface_t *si, *sorted_sis;
4365  u32 sw_if_index = ~0;
4366 
4368  if (q == 0)
4369  {
4370  return;
4371  }
4372 
4373  /* Gather interfaces. */
4374  sorted_sis = vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
4375  _vec_len (sorted_sis) = 0;
4376  /* *INDENT-OFF* */
4377  pool_foreach (si, im->sw_interfaces,
4378  ({
4379  vec_add1 (sorted_sis, si[0]);
4380  }));
4381  /* *INDENT-ON* */
4382 
4383  vec_foreach (si, sorted_sis)
4384  {
4386  {
4387  if (mp->is_ipv6 && !ip6_interface_enabled (vm, si->sw_if_index))
4388  {
4389  continue;
4390  }
4391  sw_if_index = si->sw_if_index;
4392  send_ip_details (am, q, sw_if_index, mp->context);
4393  }
4394  }
4395 }
4396 
4397 static void
4399 {
4400  clib_warning ("BUG");
4401 }
4402 
4403 static void
4406  l2fib_entry_key_t * l2fe_key,
4407  l2fib_entry_result_t * l2fe_res, u32 context)
4408 {
4410 
4411  mp = vl_msg_api_alloc (sizeof (*mp));
4412  memset (mp, 0, sizeof (*mp));
4413  mp->_vl_msg_id = ntohs (VL_API_L2_FIB_TABLE_ENTRY);
4414 
4415  mp->bd_id =
4416  ntohl (l2input_main.bd_configs[l2fe_key->fields.bd_index].bd_id);
4417 
4418  mp->mac = l2fib_make_key (l2fe_key->fields.mac, 0);
4419  mp->sw_if_index = ntohl (l2fe_res->fields.sw_if_index);
4420  mp->static_mac = l2fe_res->fields.static_mac;
4421  mp->filter_mac = l2fe_res->fields.filter;
4422  mp->bvi_mac = l2fe_res->fields.bvi;
4423  mp->context = context;
4424 
4425  vl_msg_api_send_shmem (q, (u8 *) & mp);
4426 }
4427 
4428 static void
4430 {
4432  bd_main_t *bdm = &bd_main;
4433  l2fib_entry_key_t *l2fe_key = NULL;
4434  l2fib_entry_result_t *l2fe_res = NULL;
4435  u32 ni, bd_id = ntohl (mp->bd_id);
4436  u32 bd_index;
4438  uword *p;
4439 
4441  if (q == 0)
4442  return;
4443 
4444  /* see l2fib_table_dump: ~0 means "any" */
4445  if (bd_id == ~0)
4446  bd_index = ~0;
4447  else
4448  {
4449  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
4450  if (p == 0)
4451  return;
4452 
4453  bd_index = p[0];
4454  }
4455 
4456  l2fib_table_dump (bd_index, &l2fe_key, &l2fe_res);
4457 
4458  vec_foreach_index (ni, l2fe_key)
4459  {
4460  send_l2fib_table_entry (am, q, vec_elt_at_index (l2fe_key, ni),
4461  vec_elt_at_index (l2fe_res, ni), mp->context);
4462  }
4463  vec_free (l2fe_key);
4464  vec_free (l2fe_res);
4465 }
4466 
4467 static void
4469 {
4471  int rv = 0;
4472  char *vpe_api_get_build_directory (void);
4473  char *vpe_api_get_version (void);
4474  char *vpe_api_get_build_date (void);
4475 
4478 
4479  if (!q)
4480  return;
4481 
4482  /* *INDENT-OFF* */
4483  REPLY_MACRO2(VL_API_SHOW_VERSION_REPLY,
4484  ({
4485  strncpy ((char *) rmp->program, "vpe", ARRAY_LEN(rmp->program)-1);
4486  strncpy ((char *) rmp->build_directory, vpe_api_get_build_directory(),
4487  ARRAY_LEN(rmp->build_directory)-1);
4488  strncpy ((char *) rmp->version, vpe_api_get_version(),
4489  ARRAY_LEN(rmp->version)-1);
4490  strncpy ((char *) rmp->build_date, vpe_api_get_build_date(),
4491  ARRAY_LEN(rmp->build_date)-1);
4492  }));
4493  /* *INDENT-ON* */
4494 }
4495 
4496 static void
4498 {
4499  vlib_main_t *vm = vlib_get_main ();
4501  vlib_node_t *n;
4502  int rv = 0;
4503  u32 node_index = ~0;
4504 
4505  n = vlib_get_node_by_name (vm, mp->node_name);
4506 
4507  if (n == 0)
4508  rv = VNET_API_ERROR_NO_SUCH_NODE;
4509  else
4510  node_index = n->index;
4511 
4512  /* *INDENT-OFF* */
4513  REPLY_MACRO2(VL_API_GET_NODE_INDEX_REPLY,
4514  ({
4515  rmp->node_index = ntohl(node_index);
4516  }));
4517  /* *INDENT-ON* */
4518 }
4519 
4520 static void
4522 {
4523  vlib_main_t *vm = vlib_get_main ();
4525  vlib_node_t *node, *next_node;
4526  int rv = 0;
4527  u32 next_node_index = ~0, next_index = ~0;
4528  uword *p;
4529 
4530  node = vlib_get_node_by_name (vm, mp->node_name);
4531 
4532  if (node == 0)
4533  {
4534  rv = VNET_API_ERROR_NO_SUCH_NODE;
4535  goto out;
4536  }
4537 
4538  next_node = vlib_get_node_by_name (vm, mp->next_name);
4539 
4540  if (next_node == 0)
4541  {
4542  rv = VNET_API_ERROR_NO_SUCH_NODE2;
4543  goto out;
4544  }
4545  else
4546  next_node_index = next_node->index;
4547 
4548  p = hash_get (node->next_slot_by_node, next_node_index);
4549 
4550  if (p == 0)
4551  {
4552  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
4553  goto out;
4554  }
4555  else
4556  next_index = p[0];
4557 
4558 out:
4559  /* *INDENT-OFF* */
4560  REPLY_MACRO2(VL_API_GET_NEXT_INDEX_REPLY,
4561  ({
4562  rmp->next_index = ntohl(next_index);
4563  }));
4564  /* *INDENT-ON* */
4565 }
4566 
4567 static void
4569 {
4570  vlib_main_t *vm = vlib_get_main ();
4572  vlib_node_t *n, *next;
4573  int rv = 0;
4574  u32 next_index = ~0;
4575 
4576  n = vlib_get_node_by_name (vm, mp->node_name);
4577 
4578  if (n == 0)
4579  {
4580  rv = VNET_API_ERROR_NO_SUCH_NODE;
4581  goto out;
4582  }
4583 
4584  next = vlib_get_node_by_name (vm, mp->next_name);
4585 
4586  if (next == 0)
4587  rv = VNET_API_ERROR_NO_SUCH_NODE2;
4588  else
4589  next_index = vlib_node_add_next (vm, n->index, next->index);
4590 
4591 out:
4592  /* *INDENT-OFF* */
4593  REPLY_MACRO2(VL_API_GET_NODE_INDEX_REPLY,
4594  ({
4595  rmp->next_index = ntohl(next_index);
4596  }));
4597  /* *INDENT-ON* */
4598 }
4599 
4602 {
4604  l2t_main_t *lm = &l2t_main;
4605  u32 sw_if_index = (u32) ~ 0;
4606  int rv;
4607 
4608  if (mp->is_ipv6 != 1)
4609  {
4610  rv = VNET_API_ERROR_UNIMPLEMENTED;
4611  goto out;
4612  }
4613 
4614  u32 encap_fib_index;
4615 
4616  if (mp->encap_vrf_id != ~0)
4617  {
4618  uword *p;
4619  ip6_main_t *im = &ip6_main;
4620  if (!
4621  (p =
4622  hash_get (im->fib_index_by_table_id, ntohl (mp->encap_vrf_id))))
4623  {
4624  rv = VNET_API_ERROR_NO_SUCH_FIB;
4625  goto out;
4626  }
4627  encap_fib_index = p[0];
4628  }
4629  else
4630  {
4631  encap_fib_index = ~0;
4632  }
4633 
4634  rv = create_l2tpv3_ipv6_tunnel (lm,
4635  (ip6_address_t *) mp->client_address,
4636  (ip6_address_t *) mp->our_address,
4637  ntohl (mp->local_session_id),
4638  ntohl (mp->remote_session_id),
4639  clib_net_to_host_u64 (mp->local_cookie),
4640  clib_net_to_host_u64 (mp->remote_cookie),
4641  mp->l2_sublayer_present,
4642  encap_fib_index, &sw_if_index);
4643 
4644 out:
4645  /* *INDENT-OFF* */
4646  REPLY_MACRO2(VL_API_L2TPV3_CREATE_TUNNEL_REPLY,
4647  ({
4648  rmp->sw_if_index = ntohl (sw_if_index);
4649  }));
4650  /* *INDENT-ON* */
4651 }
4652 
4655 {
4657  l2t_main_t *lm = &l2t_main;
4658  int rv;
4659 
4660  VALIDATE_SW_IF_INDEX (mp);
4661 
4662  rv = l2tpv3_set_tunnel_cookies (lm, ntohl (mp->sw_if_index),
4663  clib_net_to_host_u64 (mp->new_local_cookie),
4664  clib_net_to_host_u64
4665  (mp->new_remote_cookie));
4666 
4668 
4669  REPLY_MACRO (VL_API_L2TPV3_SET_TUNNEL_COOKIES_REPLY);
4670 }
4671 
4674 {
4675  int rv;
4676  vnet_main_t *vnm = vnet_get_main ();
4678 
4679  VALIDATE_SW_IF_INDEX (mp);
4680 
4682  (vnm, ntohl (mp->sw_if_index), mp->enable_disable);
4683 
4685 
4686  REPLY_MACRO (VL_API_L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY);
4687 }
4688 
4691 {
4692  int rv = 0;
4693  l2t_main_t *lm = &l2t_main;
4695 
4696  if (mp->key > L2T_LOOKUP_SESSION_ID)
4697  {
4698  rv = VNET_API_ERROR_INVALID_VALUE;
4699  goto out;
4700  }
4701 
4702  lm->lookup_type = mp->key;
4703 
4704 out:
4705  REPLY_MACRO (VL_API_L2TPV3_SET_LOOKUP_KEY_REPLY);
4706 }
4707 
4710 {
4712  int rv = 0;
4714  u32 encap_fib_index;
4715  uword *p;
4716  ip4_main_t *im = &ip4_main;
4717  u32 sw_if_index = ~0;
4718 
4719  p = hash_get (im->fib_index_by_table_id, ntohl (mp->encap_vrf_id));
4720  if (!p)
4721  {
4722  rv = VNET_API_ERROR_NO_SUCH_FIB;
4723  goto out;
4724  }
4725  encap_fib_index = p[0];
4726 
4727  /* Check src & dst are different */
4728  if ((mp->is_ipv6 && memcmp (mp->src_address, mp->dst_address, 16) == 0) ||
4729  (!mp->is_ipv6 && memcmp (mp->src_address, mp->dst_address, 4) == 0))
4730  {
4731  rv = VNET_API_ERROR_SAME_SRC_DST;
4732  goto out;
4733  }
4734  memset (a, 0, sizeof (*a));
4735 
4736  a->is_add = mp->is_add;
4737  a->is_ip6 = mp->is_ipv6;
4738 
4739  /* ip addresses sent in network byte order */
4740  if (a->is_ip6)
4741  {
4742  memcpy (&(a->src.ip6), mp->src_address, 16);
4743  memcpy (&(a->dst.ip6), mp->dst_address, 16);
4744  }
4745  else
4746  {
4747  memcpy (&(a->src.ip4), mp->src_address, 4);
4748  memcpy (&(a->dst.ip4), mp->dst_address, 4);
4749  }
4750 
4751  a->encap_fib_index = encap_fib_index;
4752  a->decap_next_index = ntohl (mp->decap_next_index);
4753  a->vni = ntohl (mp->vni);
4754  rv = vnet_vxlan_add_del_tunnel (a, &sw_if_index);
4755 
4756 out:
4757  /* *INDENT-OFF* */
4758  REPLY_MACRO2(VL_API_VXLAN_ADD_DEL_TUNNEL_REPLY,
4759  ({
4760  rmp->sw_if_index = ntohl (sw_if_index);
4761  }));
4762  /* *INDENT-ON* */
4763 }
4764 
4765 static void send_vxlan_tunnel_details
4767 {
4769  ip4_main_t *im4 = &ip4_main;
4770  ip6_main_t *im6 = &ip6_main;
4771  u8 is_ipv6 = !(t->flags & VXLAN_TUNNEL_IS_IPV4);
4772 
4773  rmp = vl_msg_api_alloc (sizeof (*rmp));
4774  memset (rmp, 0, sizeof (*rmp));
4775  rmp->_vl_msg_id = ntohs (VL_API_VXLAN_TUNNEL_DETAILS);
4776  if (is_ipv6)
4777  {
4778  memcpy (rmp->src_address, &(t->src.ip6), 16);
4779  memcpy (rmp->dst_address, &(t->dst.ip6), 16);
4780  rmp->encap_vrf_id = htonl (im6->fibs[t->encap_fib_index].table_id);
4781  }
4782  else
4783  {
4784  memcpy (rmp->src_address, &(t->src.ip4), 4);
4785  memcpy (rmp->dst_address, &(t->dst.ip4), 4);
4786  rmp->encap_vrf_id = htonl (im4->fibs[t->encap_fib_index].table_id);
4787  }
4788  rmp->vni = htonl (t->vni);
4789  rmp->decap_next_index = htonl (t->decap_next_index);
4790  rmp->sw_if_index = htonl (t->sw_if_index);
4791  rmp->is_ipv6 = is_ipv6;
4792  rmp->context = context;
4793 
4794  vl_msg_api_send_shmem (q, (u8 *) & rmp);
4795 }
4796 
4799 {
4801  vxlan_main_t *vxm = &vxlan_main;
4802  vxlan_tunnel_t *t;
4803  u32 sw_if_index;
4804 
4806  if (q == 0)
4807  {
4808  return;
4809  }
4810 
4811  sw_if_index = ntohl (mp->sw_if_index);
4812 
4813  if (~0 == sw_if_index)
4814  {
4815  /* *INDENT-OFF* */
4816  pool_foreach (t, vxm->tunnels,
4817  ({
4818  send_vxlan_tunnel_details(t, q, mp->context);
4819  }));
4820  /* *INDENT-ON* */
4821  }
4822  else
4823  {
4824  if ((sw_if_index >= vec_len (vxm->tunnel_index_by_sw_if_index)) ||
4825  (~0 == vxm->tunnel_index_by_sw_if_index[sw_if_index]))
4826  {
4827  return;
4828  }
4829  t = &vxm->tunnels[vxm->tunnel_index_by_sw_if_index[sw_if_index]];
4830  send_vxlan_tunnel_details (t, q, mp->context);
4831  }
4832 }
4833 
4836 {
4838  int rv = 0;
4839  vnet_gre_add_del_tunnel_args_t _a, *a = &_a;
4840  u32 outer_fib_id;
4841  uword *p;
4842  ip4_main_t *im = &ip4_main;
4843  u32 sw_if_index = ~0;
4844 
4845  p = hash_get (im->fib_index_by_table_id, ntohl (mp->outer_fib_id));
4846  if (!p)
4847  {
4848  rv = VNET_API_ERROR_NO_SUCH_FIB;
4849  goto out;
4850  }
4851  outer_fib_id = p[0];
4852 
4853  /* Check src & dst are different */
4854  if ((mp->is_ipv6 && memcmp (mp->src_address, mp->dst_address, 16) == 0) ||
4855  (!mp->is_ipv6 && memcmp (mp->src_address, mp->dst_address, 4) == 0))
4856  {
4857  rv = VNET_API_ERROR_SAME_SRC_DST;
4858  goto out;
4859  }
4860  memset (a, 0, sizeof (*a));
4861 
4862  a->is_add = mp->is_add;
4863 
4864  /* ip addresses sent in network byte order */
4865  clib_memcpy (&(a->src), mp->src_address, 4);
4866  clib_memcpy (&(a->dst), mp->dst_address, 4);
4867 
4868  a->outer_fib_id = outer_fib_id;
4869  rv = vnet_gre_add_del_tunnel (a, &sw_if_index);
4870 
4871 out:
4872  /* *INDENT-OFF* */
4873  REPLY_MACRO2(VL_API_GRE_ADD_DEL_TUNNEL_REPLY,
4874  ({
4875  rmp->sw_if_index = ntohl (sw_if_index);
4876  }));
4877  /* *INDENT-ON* */
4878 }
4879 
4880 static void send_gre_tunnel_details
4882 {
4884  ip4_main_t *im = &ip4_main;
4885 
4886  rmp = vl_msg_api_alloc (sizeof (*rmp));
4887  memset (rmp, 0, sizeof (*rmp));
4888  rmp->_vl_msg_id = ntohs (VL_API_GRE_TUNNEL_DETAILS);
4889  clib_memcpy (rmp->src_address, &(t->tunnel_src), 4);
4890  clib_memcpy (rmp->dst_address, &(t->tunnel_dst), 4);
4891  rmp->outer_fib_id = htonl (im->fibs[t->outer_fib_index].table_id);
4892  rmp->sw_if_index = htonl (t->sw_if_index);
4893  rmp->context = context;
4894 
4895  vl_msg_api_send_shmem (q, (u8 *) & rmp);
4896 }
4897 
4898 static void
4900 {
4902  gre_main_t *gm = &gre_main;
4903  gre_tunnel_t *t;
4904  u32 sw_if_index;
4905 
4907  if (q == 0)
4908  {
4909  return;
4910  }
4911 
4912  sw_if_index = ntohl (mp->sw_if_index);
4913 
4914  if (~0 == sw_if_index)
4915  {
4916  /* *INDENT-OFF* */
4917  pool_foreach (t, gm->tunnels,
4918  ({
4919  send_gre_tunnel_details(t, q, mp->context);
4920  }));
4921  /* *INDENT-ON* */
4922  }
4923  else
4924  {
4925  if ((sw_if_index >= vec_len (gm->tunnel_index_by_sw_if_index)) ||
4926  (~0 == gm->tunnel_index_by_sw_if_index[sw_if_index]))
4927  {
4928  return;
4929  }
4930  t = &gm->tunnels[gm->tunnel_index_by_sw_if_index[sw_if_index]];
4931  send_gre_tunnel_details (t, q, mp->context);
4932  }
4933 }
4934 
4935 static void
4937 {
4938  extern int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index,
4939  int is_add);
4941  int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index,
4942  int is_add);
4943  int rv = 0;
4944 
4947 
4948  rv = vnet_l2_patch_add_del (ntohl (mp->rx_sw_if_index),
4949  ntohl (mp->tx_sw_if_index),
4950  (int) (mp->is_add != 0));
4951 
4954 
4955  REPLY_MACRO (VL_API_L2_PATCH_ADD_DEL_REPLY);
4956 }
4957 
4958 static void
4961 {
4963  int rv = 0;
4965  u32 encap_fib_index, decap_fib_index;
4966  u8 protocol;
4967  uword *p;
4968  ip4_main_t *im = &ip4_main;
4969  u32 sw_if_index = ~0;
4970 
4971 
4972  p = hash_get (im->fib_index_by_table_id, ntohl (mp->encap_vrf_id));
4973  if (!p)
4974  {
4975  rv = VNET_API_ERROR_NO_SUCH_FIB;
4976  goto out;
4977  }
4978  encap_fib_index = p[0];
4979 
4980  protocol = mp->protocol;
4981 
4982  /* Interpret decap_vrf_id as an opaque if sending to other-than-ip4-input */
4983  if (protocol == VXLAN_GPE_INPUT_NEXT_IP4_INPUT)
4984  {
4985  p = hash_get (im->fib_index_by_table_id, ntohl (mp->decap_vrf_id));
4986  if (!p)
4987  {
4988  rv = VNET_API_ERROR_NO_SUCH_INNER_FIB;
4989  goto out;
4990  }
4991  decap_fib_index = p[0];
4992  }
4993  else
4994  {
4995  decap_fib_index = ntohl (mp->decap_vrf_id);
4996  }
4997 
4998  /* Check src & dst are different */
4999  if ((mp->is_ipv6 && memcmp (mp->local, mp->remote, 16) == 0) ||
5000  (!mp->is_ipv6 && memcmp (mp->local, mp->remote, 4) == 0))
5001  {
5002  rv = VNET_API_ERROR_SAME_SRC_DST;
5003  goto out;
5004  }
5005  memset (a, 0, sizeof (*a));
5006 
5007  a->is_add = mp->is_add;
5008  a->is_ip6 = mp->is_ipv6;
5009  /* ip addresses sent in network byte order */
5010  if (a->is_ip6)
5011  {
5012  clib_memcpy (&(a->local.ip6), mp->local, 16);
5013  clib_memcpy (&(a->remote.ip6), mp->remote, 16);
5014  }
5015  else
5016  {
5017  clib_memcpy (&(a->local.ip4), mp->local, 4);
5018  clib_memcpy (&(a->remote.ip4), mp->remote, 4);
5019  }
5020  a->encap_fib_index = encap_fib_index;
5021  a->decap_fib_index = decap_fib_index;
5022  a->protocol = protocol;
5023  a->vni = ntohl (mp->vni);
5024  rv = vnet_vxlan_gpe_add_del_tunnel (a, &sw_if_index);
5025 
5026 out:
5027  /* *INDENT-OFF* */
5028  REPLY_MACRO2(VL_API_VXLAN_GPE_ADD_DEL_TUNNEL_REPLY,
5029  ({
5030  rmp->sw_if_index = ntohl (sw_if_index);
5031  }));
5032  /* *INDENT-ON* */
5033 }
5034 
5037 {
5039  ip4_main_t *im4 = &ip4_main;
5040  ip6_main_t *im6 = &ip6_main;
5041  u8 is_ipv6 = !(t->flags & VXLAN_GPE_TUNNEL_IS_IPV4);
5042 
5043  rmp = vl_msg_api_alloc (sizeof (*rmp));
5044  memset (rmp, 0, sizeof (*rmp));
5045  rmp->_vl_msg_id = ntohs (VL_API_VXLAN_GPE_TUNNEL_DETAILS);
5046  if (is_ipv6)
5047  {
5048  memcpy (rmp->local, &(t->local.ip6), 16);
5049  memcpy (rmp->remote, &(t->remote.ip6), 16);
5050  rmp->encap_vrf_id = htonl (im6->fibs[t->encap_fib_index].table_id);
5051  rmp->decap_vrf_id = htonl (im6->fibs[t->decap_fib_index].table_id);
5052  }
5053  else
5054  {
5055  memcpy (rmp->local, &(t->local.ip4), 4);
5056  memcpy (rmp->remote, &(t->remote.ip4), 4);
5057  rmp->encap_vrf_id = htonl (im4->fibs[t->encap_fib_index].table_id);
5058  rmp->decap_vrf_id = htonl (im4->fibs[t->decap_fib_index].table_id);
5059  }
5060  rmp->vni = htonl (t->vni);
5061  rmp->protocol = t->protocol;
5062  rmp->sw_if_index = htonl (t->sw_if_index);
5063  rmp->is_ipv6 = is_ipv6;
5064  rmp->context = context;
5065 
5066  vl_msg_api_send_shmem (q, (u8 *) & rmp);
5067 }
5068 
5071 {
5074  vxlan_gpe_tunnel_t *t;
5075  u32 sw_if_index;
5076 
5078  if (q == 0)
5079  {
5080  return;
5081  }
5082 
5083  sw_if_index = ntohl (mp->sw_if_index);
5084 
5085  if (~0 == sw_if_index)
5086  {
5087  /* *INDENT-OFF* */
5088  pool_foreach (t, vgm->tunnels,
5089  ({
5090  send_vxlan_gpe_tunnel_details(t, q, mp->context);
5091  }));
5092  /* *INDENT-ON* */
5093  }
5094  else
5095  {
5096  if ((sw_if_index >= vec_len (vgm->tunnel_index_by_sw_if_index)) ||
5097  (~0 == vgm->tunnel_index_by_sw_if_index[sw_if_index]))
5098  {
5099  return;
5100  }
5101  t = &vgm->tunnels[vgm->tunnel_index_by_sw_if_index[sw_if_index]];
5103  }
5104 }
5105 
5106 /** Used for transferring locators via VPP API */
5107 /* *INDENT-OFF* */
5108 typedef CLIB_PACKED (struct {
5109  u32 sw_if_index; /**< locator sw_if_index */
5110  u8 priority; /**< locator priority */
5111  u8 weight; /**< locator weight */
5112 }) ls_locator_t;
5113 /* *INDENT-ON* */
5114 
5115 static void
5116 vl_api_lisp_add_del_locator_set_t_handler (vl_api_lisp_add_del_locator_set_t *
5117  mp)
5118 {
5120  int rv = 0;
5122  locator_t locator;
5123  ls_locator_t *ls_loc;
5124  u32 ls_index = ~0, locator_num;
5125  u8 *locator_name = NULL;
5126  int i;
5127 
5128  memset (a, 0, sizeof (a[0]));
5129 
5130  locator_name = format (0, "%s", mp->locator_set_name);
5131 
5132  a->name = locator_name;
5133  a->is_add = mp->is_add;
5134  a->local = 1;
5135  locator_num = clib_net_to_host_u32 (mp->locator_num);
5136 
5137  memset (&locator, 0, sizeof (locator));
5138  for (i = 0; i < locator_num; i++)
5139  {
5140  ls_loc = &((ls_locator_t *) mp->locators)[i];
5141  VALIDATE_SW_IF_INDEX (ls_loc);
5142 
5143  locator.sw_if_index = htonl (ls_loc->sw_if_index);
5144  locator.priority = ls_loc->priority;
5145  locator.weight = ls_loc->weight;
5146  locator.local = 1;
5147  vec_add1 (a->locators, locator);
5148  }
5149 
5150  rv = vnet_lisp_add_del_locator_set (a, &ls_index);
5151 
5153 
5154  vec_free (locator_name);
5155  vec_free (a->locators);
5156 
5157  REPLY_MACRO (VL_API_LISP_ADD_DEL_LOCATOR_SET_REPLY);
5158 }
5159 
5160 static void
5162 {
5164  int rv = 0;
5165  locator_t locator, *locators = NULL;
5167  u32 ls_index = ~0;
5168  u8 *locator_name = NULL;
5169 
5170  memset (&locator, 0, sizeof (locator));
5171  memset (a, 0, sizeof (a[0]));
5172 
5173  locator.sw_if_index = ntohl (mp->sw_if_index);
5174  locator.priority = mp->priority;
5175  locator.weight = mp->weight;
5176  locator.local = 1;
5177  vec_add1 (locators, locator);
5178 
5179  locator_name = format (0, "%s", mp->locator_set_name);
5180 
5181  a->name = locator_name;
5182  a->locators = locators;
5183  a->is_add = mp->is_add;
5184  a->local = 1;
5185 
5186  rv = vnet_lisp_add_del_locator (a, NULL, &ls_index);
5187 
5188  vec_free (locators);
5189  vec_free (locator_name);
5190 
5191  REPLY_MACRO (VL_API_LISP_ADD_DEL_LOCATOR_REPLY);
5192 }
5193 
5194 static int
5196  u8 len)
5197 {
5198  switch (type)
5199  {
5200  case 0: /* ipv4 */
5202  gid_address_ip_set (dst, src, IP4);
5203  gid_address_ippref_len (dst) = len;
5205  break;
5206  case 1: /* ipv6 */
5208  gid_address_ip_set (dst, src, IP6);
5209  gid_address_ippref_len (dst) = len;
5211  break;
5212  case 2: /* l2 mac */
5214  clib_memcpy (&gid_address_mac (dst), src, 6);
5215  break;
5216  default:
5217  /* unknown type */
5218  return VNET_API_ERROR_INVALID_VALUE;
5219  }
5220 
5221  gid_address_vni (dst) = vni;
5222 
5223  return 0;
5224 }
5225 
5226 static void
5228 {
5231  int rv = 0;
5232  gid_address_t _eid, *eid = &_eid;
5233  uword *p = NULL;
5234  u32 locator_set_index = ~0, map_index = ~0;
5236  u8 *name = NULL;
5237  memset (a, 0, sizeof (a[0]));
5238  memset (eid, 0, sizeof (eid[0]));
5239 
5240  rv = unformat_lisp_eid_api (eid, clib_net_to_host_u32 (mp->vni),
5241  mp->eid_type, mp->eid, mp->prefix_len);
5242  if (rv)
5243  goto out;
5244 
5245  name = format (0, "%s", mp->locator_set_name);
5246  p = hash_get_mem (lcm->locator_set_index_by_name, name);
5247  if (!p)
5248  {
5249  rv = VNET_API_ERROR_INVALID_VALUE;
5250  goto out;
5251  }
5252  locator_set_index = p[0];
5253 
5254  /* XXX treat batch configuration */
5255  a->is_add = mp->is_add;
5256  gid_address_copy (&a->eid, eid);
5257  a->locator_set_index = locator_set_index;
5258  a->local = 1;
5259  rv = vnet_lisp_add_del_local_mapping (a, &map_index);
5260 
5261 out:
5262  vec_free (name);
5263  gid_address_free (&a->eid);
5264 
5265  REPLY_MACRO (VL_API_LISP_ADD_DEL_LOCAL_EID_REPLY);
5266 }
5267 
5268 static void
5271 {
5273  int rv = 0;
5274  rv = vnet_lisp_eid_table_map (clib_net_to_host_u32 (mp->vni),
5275  clib_net_to_host_u32 (mp->dp_table),
5276  mp->is_l2, mp->is_add);
5277 REPLY_MACRO (VL_API_LISP_EID_TABLE_ADD_DEL_MAP_REPLY)}
5278 
5279 /** Used for transferring locators via VPP API */
5280 /* *INDENT-OFF* */
5281 typedef CLIB_PACKED (struct {
5282  u8 is_ip4; /**< is locator an IPv4 address */
5283  u8 priority; /**< locator priority */
5284  u8 weight; /**< locator weight */
5285  u8 addr[16]; /**< IPv4/IPv6 address */
5286 }) rloc_t;
5287 /* *INDENT-ON* */
5288 
5289 static locator_pair_t *
5290 unformat_lisp_loc_pairs (void *lcl_locs, void *rmt_locs, u32 rloc_num)
5291 {
5292  u32 i;
5293  locator_pair_t *pairs = 0, pair;
5294  rloc_t *r;
5295 
5296  for (i = 0; i < rloc_num; i++)
5297  {
5298  /* local locator */
5299  r = &((rloc_t *) lcl_locs)[i];
5300  memset (&pair.lcl_loc, 0, sizeof (pair.lcl_loc));
5301  ip_address_set (&pair.lcl_loc, &r->addr, r->is_ip4 ? IP4 : IP6);
5302 
5303  /* remote locators */
5304  r = &((rloc_t *) rmt_locs)[i];
5305  memset (&pair.rmt_loc, 0, sizeof (pair.rmt_loc));
5306  ip_address_set (&pair.rmt_loc, &r->addr, r->is_ip4 ? IP4 : IP6);
5307 
5308  pair.priority = r->priority;
5309  pair.weight = r->weight;
5310 
5311  vec_add1 (pairs, pair);
5312  }
5313  return pairs;
5314 }
5315 
5316 static locator_t *
5317 unformat_lisp_locs (void *rmt_locs, u32 rloc_num)
5318 {
5319  u32 i;
5320  locator_t *locs = 0, loc;
5321  rloc_t *r;
5322 
5323  for (i = 0; i < rloc_num; i++)
5324  {
5325  /* remote locators */
5326  r = &((rloc_t *) rmt_locs)[i];
5327  memset (&loc, 0, sizeof (loc));
5328  gid_address_ip_set (&loc.address, &r->addr, r->is_ip4 ? IP4 : IP6);
5329 
5330  loc.priority = r->priority;
5331  loc.weight = r->weight;
5332 
5333  vec_add1 (locs, loc);
5334  }
5335  return locs;
5336 }
5337 
5338 static void
5341 {
5344  locator_pair_t *pairs = 0;
5345  int rv = 0;
5346 
5347  memset (a, 0, sizeof (a[0]));
5348 
5349  rv = unformat_lisp_eid_api (&a->rmt_eid, mp->vni, mp->eid_type,
5350  mp->rmt_eid, mp->rmt_len);
5351  rv |= unformat_lisp_eid_api (&a->lcl_eid, mp->vni, mp->eid_type,
5352  mp->lcl_eid, mp->lcl_len);
5353 
5354  pairs = unformat_lisp_loc_pairs (mp->lcl_locs, mp->rmt_locs, mp->loc_num);
5355 
5356  if (rv || 0 == pairs)
5357  goto send_reply;
5358 
5359  a->is_add = mp->is_add;
5360  a->locator_pairs = pairs;
5361  a->dp_table = mp->dp_table;
5362  a->vni = mp->vni;
5363  a->action = mp->action;
5364 
5365  rv = vnet_lisp_gpe_add_del_fwd_entry (a, 0);
5366  vec_free (pairs);
5367 send_reply:
5368  REPLY_MACRO (VL_API_LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY);
5369 }
5370 
5371 static void
5373  * mp)
5374 {
5376  int rv = 0;
5378 
5379  memset (a, 0, sizeof (a[0]));
5380 
5381  a->is_add = mp->is_add;
5382  ip_address_set (&a->address, mp->ip_address, mp->is_ipv6 ? IP6 : IP4);
5383 
5385 
5386  REPLY_MACRO (VL_API_LISP_ADD_DEL_MAP_RESOLVER_REPLY);
5387 }
5388 
5389 static void
5391  mp)
5392 {
5394  int rv = 0;
5396 
5397  a->is_en = mp->is_en;
5399 
5400  REPLY_MACRO (VL_API_LISP_GPE_ENABLE_DISABLE_REPLY);
5401 }
5402 
5403 static void
5405 {
5407  int rv = 0;
5408 
5410  REPLY_MACRO (VL_API_LISP_ENABLE_DISABLE_REPLY);
5411 }
5412 
5413 static void
5415 {
5417  int rv = 0;
5419 
5420  a->is_add = mp->is_add;
5421  a->dp_table = mp->dp_table;
5422  a->vni = mp->vni;
5423  a->is_l2 = mp->is_l2;
5424  rv = vnet_lisp_gpe_add_del_iface (a, 0);
5425 
5426  REPLY_MACRO (VL_API_LISP_GPE_ADD_DEL_IFACE_REPLY);
5427 }
5428 
5429 static void
5431  * mp)
5432 {
5434  int rv = 0;
5435  u8 *ls_name = 0;
5436 
5437  ls_name = format (0, "%s", mp->ls_name);
5438  rv = vnet_lisp_pitr_set_locator_set (ls_name, mp->is_add);
5439  vec_free (ls_name);
5440 
5441  REPLY_MACRO (VL_API_LISP_PITR_SET_LOCATOR_SET_REPLY);
5442 }
5443 
5444 static void
5447 {
5449  int rv = 0;
5450  u8 *locator_set_name = NULL;
5452 
5453  locator_set_name = format (0, "%s", mp->locator_set_name);
5454 
5455  a->is_add = mp->is_add;
5456  a->locator_set_name = locator_set_name;
5457 
5459 
5460  vec_free (locator_set_name);
5461 
5462  REPLY_MACRO (VL_API_LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY);
5463 }
5464 
5465 static void
5468 {
5469  locator_t *rlocs = 0;
5471  int rv = 0;
5472  gid_address_t _eid, *eid = &_eid;
5473 
5474  memset (eid, 0, sizeof (eid[0]));
5475 
5476  rv = unformat_lisp_eid_api (eid, clib_net_to_host_u32 (mp->vni),
5477  mp->eid_type, mp->eid, mp->eid_len);
5478  if (rv)
5479  goto send_reply;
5480 
5481  rlocs = unformat_lisp_locs (mp->rlocs, clib_net_to_host_u32 (mp->rloc_num));
5482  if (0 == rlocs)
5483  goto send_reply;
5484 
5485  if (!mp->is_add)
5486  {
5488  gid_address_copy (&a->deid, eid);
5489  a->is_add = 0;
5490  rv = vnet_lisp_add_del_adjacency (a);
5491  if (rv)
5492  {
5493  goto out;
5494  }
5495  }
5496 
5497  /* NOTE: for now this works as a static remote mapping, i.e.,
5498  * not authoritative and ttl infinite. */
5499  rv = vnet_lisp_add_del_mapping (eid, rlocs, mp->action, 0, ~0,
5500  mp->is_add, 1 /* is_static */ , 0);
5501 
5502  if (mp->del_all)
5504 
5505 out:
5506  vec_free (rlocs);
5507 send_reply:
5508  REPLY_MACRO (VL_API_LISP_ADD_DEL_REMOTE_MAPPING_REPLY);
5509 }
5510 
5511 static void
5513 {
5516 
5517  int rv = 0;
5518  memset (a, 0, sizeof (a[0]));
5519 
5520  rv = unformat_lisp_eid_api (&a->seid, clib_net_to_host_u32 (mp->vni),
5521  mp->eid_type, mp->seid, mp->seid_len);
5522  rv |= unformat_lisp_eid_api (&a->deid, clib_net_to_host_u32 (mp->vni),
5523  mp->eid_type, mp->deid, mp->deid_len);
5524 
5525  if (rv)
5526  goto send_reply;
5527 
5528  a->is_add = mp->is_add;
5529  rv = vnet_lisp_add_del_adjacency (a);
5530 
5531 send_reply:
5532  REPLY_MACRO (VL_API_LISP_ADD_DEL_ADJACENCY_REPLY);
5533 }
5534 
5535 static void
5537  locator_t * loc,
5538  unix_shared_memory_queue_t * q, u32 context)
5539 {
5541 
5542  rmp = vl_msg_api_alloc (sizeof (*rmp));
5543  memset (rmp, 0, sizeof (*rmp));
5544  rmp->_vl_msg_id = ntohs (VL_API_LISP_LOCATOR_DETAILS);
5545  rmp->context = context;
5546 
5547  rmp->local = loc->local;
5548  if (loc->local)
5549  {
5550  rmp->sw_if_index = ntohl (loc->sw_if_index);
5551  }
5552  else
5553  {
5554  rmp->is_ipv6 = gid_address_ip_version (&loc->address);
5556  }
5557  rmp->priority = loc->priority;
5558  rmp->weight = loc->weight;
5559 
5560  vl_msg_api_send_shmem (q, (u8 *) & rmp);
5561 }
5562 
5563 static void
5565 {
5568  locator_set_t *lsit = 0;
5569  locator_t *loc = 0;
5570  u32 ls_index = ~0, *locit = 0;
5571  u8 filter;
5572 
5574  if (q == 0)
5575  {
5576  return;
5577  }
5578 
5579  ls_index = htonl (mp->locator_set_index);
5580 
5581  lsit = pool_elt_at_index (lcm->locator_set_pool, ls_index);
5582 
5583  filter = mp->filter;
5584  if (filter && !((1 == filter && lsit->local) ||
5585  (2 == filter && !lsit->local)))
5586  {
5587  return;
5588  }
5589 
5590  vec_foreach (locit, lsit->locator_indices)
5591  {
5592  loc = pool_elt_at_index (lcm->locator_pool, locit[0]);
5593  send_lisp_locator_details (lcm, loc, q, mp->context);
5594  };
5595 }
5596 
5597 static void
5599  locator_set_t * lsit,
5601  u32 context, u32 ls_index)
5602 {
5604  u8 *str = 0;
5605 
5606  rmp = vl_msg_api_alloc (sizeof (*rmp));
5607  memset (rmp, 0, sizeof (*rmp));
5608  rmp->_vl_msg_id = ntohs (VL_API_LISP_LOCATOR_SET_DETAILS);
5609  rmp->context = context;
5610 
5611  rmp->local = lsit->local;
5612  rmp->locator_set_index = htonl (ls_index);
5613  if (lsit->local)
5614  {
5615  ASSERT (lsit->name != NULL);
5616  strncpy ((char *) rmp->locator_set_name,
5617  (char *) lsit->name, ARRAY_LEN (rmp->locator_set_name) - 1);
5618  }
5619  else
5620  {
5621  str = format (0, "remote-%d", ls_index);
5622  strncpy ((char *) rmp->locator_set_name, (char *) str,
5623  ARRAY_LEN (rmp->locator_set_name) - 1);
5624  vec_free (str);
5625  }
5626 
5627  vl_msg_api_send_shmem (q, (u8 *) & rmp);
5628 }
5629 
5630 static void
5632 {
5635  locator_set_t *lsit = NULL;
5636  u32 index;
5637  u8 filter;
5638 
5640  if (q == 0)
5641  {
5642  return;
5643  }
5644 
5645  filter = mp->filter;
5646  index = 0;
5647  /* *INDENT-OFF* */
5648  pool_foreach (lsit, lcm->locator_set_pool,
5649  ({
5650  if (filter && !((1 == filter && lsit->local) ||
5651  (2 == filter && !lsit->local))) {
5652  index++;
5653  continue;
5654  }
5655  send_lisp_locator_set_details(lcm, lsit, q, mp->context, index++);
5656  }));
5657  /* *INDENT-ON* */
5658 }
5659 
5660 static void
5663  u32 context, u8 filter)
5664 {
5666  gid_address_t *gid = NULL;
5667  u8 *mac = 0;
5668  ip_prefix_t *ip_prefix = NULL;
5669 
5670  switch (filter)
5671  {
5672  case 0: /* all mappings */
5673  break;
5674 
5675  case 1: /* local only */
5676  if (!mapit->local)
5677  return;
5678  break;
5679  case 2: /* remote only */
5680  if (mapit->local)
5681  return;
5682  break;
5683  default:
5684  clib_warning ("Filter error, unknown filter: %d", filter);
5685  return;
5686  }
5687 
5688  gid = &mapit->eid;
5689  ip_prefix = &gid_address_ippref (gid);
5690  mac = gid_address_mac (gid);
5691 
5692  rmp = vl_msg_api_alloc (sizeof (*rmp));
5693  memset (rmp, 0, sizeof (*rmp));
5694  rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_DETAILS);
5695  rmp->locator_set_index = mapit->locator_set_index;
5696  rmp->is_local = mapit->local;
5697  rmp->ttl = mapit->ttl;
5698  rmp->authoritative = mapit->authoritative;
5699 
5700  switch (gid_address_type (gid))
5701  {
5702  case GID_ADDR_IP_PREFIX:
5703  rmp->eid_prefix_len = ip_prefix_len (ip_prefix);
5704  if (ip_prefix_version (ip_prefix) == IP4)
5705  {
5706  rmp->eid_type = 0; /* ipv4 type */
5707  clib_memcpy (rmp->eid, &ip_prefix_v4 (ip_prefix),
5708  sizeof (ip_prefix_v4 (ip_prefix)));
5709  }
5710  else
5711  {
5712  rmp->eid_type = 1; /* ipv6 type */
5713  clib_memcpy (rmp->eid, &ip_prefix_v6 (ip_prefix),
5714  sizeof (ip_prefix_v6 (ip_prefix)));
5715  }
5716  break;
5717  case GID_ADDR_MAC:
5718  rmp->eid_type = 2; /* l2 mac type */
5719  clib_memcpy (rmp->eid, mac, 6);
5720  break;
5721  default:
5722  ASSERT (0);
5723  }
5724  rmp->context = context;
5725  rmp->vni = clib_host_to_net_u32 (gid_address_vni (gid));
5726  vl_msg_api_send_shmem (q, (u8 *) & rmp);
5727 }
5728 
5729 static void
5731 {
5732  u32 mi;
5735  mapping_t *mapit = NULL;
5736  gid_address_t _eid, *eid = &_eid;
5737 
5739  if (q == 0)
5740  {
5741  return;
5742  }
5743 
5744  if (mp->eid_set)
5745  {
5746  memset (eid, 0, sizeof (*eid));
5747 
5748  unformat_lisp_eid_api (eid, clib_net_to_host_u32 (mp->vni),
5749  mp->eid_type, mp->eid, mp->prefix_length);
5750 
5751  mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, eid);
5752  if ((u32) ~ 0 == mi)
5753  return;
5754 
5755  mapit = pool_elt_at_index (lcm->mapping_pool, mi);
5756  send_lisp_eid_table_details (mapit, q, mp->context,
5757  0 /* ignore filter */ );
5758  }
5759  else
5760  {
5761  /* *INDENT-OFF* */
5762  pool_foreach (mapit, lcm->mapping_pool,
5763  ({
5764  send_lisp_eid_table_details(mapit, q, mp->context,
5765  mp->filter);
5766  }));
5767  /* *INDENT-ON* */
5768  }
5769 }
5770 
5771 static void
5773  unix_shared_memory_queue_t * q, u32 context)
5774 {
5777 
5778  rmp = vl_msg_api_alloc (sizeof (*rmp));
5779  memset (rmp, 0, sizeof (*rmp));
5780  rmp->_vl_msg_id = ntohs (VL_API_LISP_GPE_TUNNEL_DETAILS);
5781 
5782  rmp->tunnels = tunnel - lgm->tunnels;
5783 
5784  rmp->is_ipv6 = ip_addr_version (&tunnel->src) == IP6 ? 1 : 0;
5785  ip_address_copy_addr (rmp->source_ip, &tunnel->src);
5786  ip_address_copy_addr (rmp->destination_ip, &tunnel->dst);
5787 
5788  rmp->encap_fib_id = htonl (tunnel->encap_fib_index);
5789  rmp->decap_fib_id = htonl (tunnel->decap_fib_index);
5790  rmp->dcap_next = htonl (tunnel->decap_next_index);
5791  rmp->lisp_ver = tunnel->ver_res;
5792  rmp->next_protocol = tunnel->next_protocol;
5793  rmp->flags = tunnel->flags;
5794  rmp->ver_res = tunnel->ver_res;
5795  rmp->res = tunnel->res;
5796  rmp->iid = htonl (tunnel->vni);
5797  rmp->context = context;
5798 
5799  vl_msg_api_send_shmem (q, (u8 *) & rmp);
5800 }
5801 
5802 static void
5804 {
5807  lisp_gpe_tunnel_t *tunnel = NULL;
5808 
5809  if (pool_elts (lgm->tunnels) == 0)
5810  {
5811  return;
5812  }
5813 
5815  if (q == 0)
5816  {
5817  return;
5818  }
5819 
5820  /* *INDENT-OFF* */
5821  pool_foreach(tunnel, lgm->tunnels,
5822  ({
5823  send_lisp_gpe_tunnel_details(tunnel, q, mp->context);
5824  }));
5825  /* *INDENT-ON* */
5826 }
5827 
5828 static void
5830  unix_shared_memory_queue_t * q, u32 context)
5831 {
5833 
5834  rmp = vl_msg_api_alloc (sizeof (*rmp));
5835  memset (rmp, 0, sizeof (*rmp));
5836  rmp->_vl_msg_id = ntohs (VL_API_LISP_MAP_RESOLVER_DETAILS);
5837 
5838  switch (ip_addr_version (ip))
5839  {
5840  case IP4:
5841  rmp->is_ipv6 = 0;
5842  clib_memcpy (rmp->ip_address, &ip_addr_v4 (ip),
5843  sizeof (ip_addr_v4 (ip)));
5844  break;
5845 
5846  case IP6:
5847  rmp->is_ipv6 = 1;
5848  clib_memcpy (rmp->ip_address, &ip_addr_v6 (ip),
5849  sizeof (ip_addr_v6 (ip)));
5850  break;
5851 
5852  default:
5853  ASSERT (0);
5854  }
5855  rmp->context = context;
5856 
5857  vl_msg_api_send_shmem (q, (u8 *) & rmp);
5858 }
5859 
5860 static void
5862 {
5865  map_resolver_t *mr;
5866 
5868  if (q == 0)
5869  {
5870  return;
5871  }
5872 
5873  vec_foreach (mr, lcm->map_resolvers)
5874  {
5876  }
5877 }
5878 
5879 static void
5881  unix_shared_memory_queue_t * q, u32 context)
5882 {
5884 
5885  rmp = vl_msg_api_alloc (sizeof (*rmp));
5886  memset (rmp, 0, sizeof (*rmp));
5887  rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_MAP_DETAILS);
5888 
5889  rmp->vni = clib_host_to_net_u32 (p->key);
5890  rmp->vrf = clib_host_to_net_u32 (p->value[0]);
5891  rmp->context = context;
5892  vl_msg_api_send_shmem (q, (u8 *) & rmp);
5893 }
5894 
5895 static void
5897  mp)
5898 {
5901  hash_pair_t *p;
5902 
5904  if (q == 0)
5905  {
5906  return;
5907  }
5908  /* *INDENT-OFF* */
5910  ({
5911  send_eid_table_map_pair (p, q, mp->context);
5912  }));
5913  /* *INDENT-ON* */
5914 }
5915 
5916 static void
5918 {
5921  int rv = 0;
5922 
5924  if (q == 0)
5925  {
5926  return;
5927  }
5928 
5929  /* *INDENT-OFF* */
5930  REPLY_MACRO2(VL_API_SHOW_LISP_STATUS_REPLY,
5931  ({
5934  }));
5935  /* *INDENT-ON* */
5936 }
5937 
5938 static void
5941 {
5945  locator_set_t *loc_set = 0;
5946  u8 *tmp_str = 0;
5947  int rv = 0;
5948 
5950  if (q == 0)
5951  {
5952  return;
5953  }
5954 
5955  if (~0 == lcm->mreq_itr_rlocs)
5956  {
5957  tmp_str = format (0, " ");
5958  }
5959  else
5960  {
5961  loc_set =
5963  tmp_str = format (0, "%s", loc_set->name);
5964  }
5965 
5966  /* *INDENT-OFF* */
5967  REPLY_MACRO2(VL_API_LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY,
5968  ({
5969  strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
5970  ARRAY_LEN(rmp->locator_set_name) - 1);
5971  }));
5972  /* *INDENT-ON* */
5973 
5974  vec_free (tmp_str);
5975 }
5976 
5977 static void
5979 {
5983  mapping_t *m;
5984  locator_set_t *ls = 0;
5985  u8 *tmp_str = 0;
5986  int rv = 0;
5987 
5989  if (q == 0)
5990  {
5991  return;
5992  }
5993 
5994  if (!lcm->lisp_pitr)
5995  {
5996  tmp_str = format (0, "N/A");
5997  }
5998  else
5999  {
6001  if (~0 != m->locator_set_index)
6002  {
6003  ls =
6005  tmp_str = format (0, "%s", ls->name);
6006  }
6007  else
6008  {
6009  tmp_str = format (0, "N/A");
6010  }
6011  }
6012  vec_add1 (tmp_str, 0);
6013 
6014  /* *INDENT-OFF* */
6015  REPLY_MACRO2(VL_API_SHOW_LISP_PITR_REPLY,
6016  ({
6017  rmp->status = lcm->lisp_pitr;
6018  strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
6019  ARRAY_LEN(rmp->locator_set_name) - 1);
6020  }));
6021  /* *INDENT-ON* */
6022 }
6023 
6024 static void
6026  mp)
6027 {
6029  int rv = 0;
6030 
6031  VALIDATE_SW_IF_INDEX (mp);
6032 
6034  (ntohl (mp->sw_if_index), ntohl (mp->new_show_dev_instance));
6035 
6037 
6038  REPLY_MACRO (VL_API_INTERFACE_NAME_RENUMBER_REPLY);
6039 }
6040 
6041 static int
6042 arp_change_data_callback (u32 pool_index, u8 * new_mac,
6043  u32 sw_if_index, u32 address)
6044 {
6046  vlib_main_t *vm = am->vlib_main;
6047  vl_api_ip4_arp_event_t *event;
6048  static f64 arp_event_last_time;
6049  f64 now = vlib_time_now (vm);
6050 
6051  if (pool_is_free_index (am->arp_events, pool_index))
6052  return 1;
6053 
6054  event = pool_elt_at_index (am->arp_events, pool_index);
6055  if (memcmp (&event->new_mac, new_mac, sizeof (event->new_mac)))
6056  {
6057  clib_memcpy (event->new_mac, new_mac, sizeof (event->new_mac));
6058  }
6059  else
6060  { /* same mac */
6061  if ((sw_if_index == event->sw_if_index) && ((address == 0) ||
6062  /* for BD case, also check IP address with 10 sec timeout */
6063  ((address == event->address)
6064  &&
6065  ((now -
6066  arp_event_last_time) <
6067  10.0))))
6068  return 1;
6069  }
6070 
6071  arp_event_last_time = now;
6072  event->sw_if_index = sw_if_index;
6073  if (address)
6074  event->address = address;
6075  return 0;
6076 }
6077 
6078 static int
6079 arp_change_delete_callback (u32 pool_index, u8 * notused)
6080 {
6082 
6083  if (pool_is_free_index (am->arp_events, pool_index))
6084  return 1;
6085 
6086  pool_put_index (am->arp_events, pool_index);
6087  return 0;
6088 }
6089 
6090 static void
6092 {
6094  vnet_main_t *vnm = vnet_get_main ();
6096  vl_api_ip4_arp_event_t *event;
6097  int rv;
6098 
6099  if (mp->enable_disable)
6100  {
6101  pool_get (am->arp_events, event);
6102  memset (event, 0, sizeof (*event));
6103 
6104  event->_vl_msg_id = ntohs (VL_API_IP4_ARP_EVENT);
6105  event->client_index = mp->client_index;
6106  event->context = mp->context;
6107  event->address = mp->address;
6108  event->pid = mp->pid;
6109 
6112  mp->pid, &mp->address /* addr, in net byte order */ ,
6113  vpe_resolver_process_node.index,
6114  IP4_ARP_EVENT, event - am->arp_events, 1 /* is_add */ );
6115  }
6116  else
6117  {
6120  mp->pid, &mp->address /* addr, in net byte order */ ,
6121  vpe_resolver_process_node.index,
6122  IP4_ARP_EVENT, ~0 /* pool index */ , 0 /* is_add */ );
6123  }
6124  REPLY_MACRO (VL_API_WANT_IP4_ARP_EVENTS_REPLY);
6125 }
6126 
6129 {
6130  vlib_main_t *vm = vlib_get_main ();
6132  int rv;
6133  u32 sw_if_index, ip4_table_index, ip6_table_index, l2_table_index;
6134 
6135  ip4_table_index = ntohl (mp->ip4_table_index);
6136  ip6_table_index = ntohl (mp->ip6_table_index);
6137  l2_table_index = ntohl (mp->l2_table_index);
6138  sw_if_index = ntohl (mp->sw_if_index);
6139 
6140  VALIDATE_SW_IF_INDEX (mp);
6141 
6142  rv = vnet_set_input_acl_intfc (vm, sw_if_index, ip4_table_index,
6143  ip6_table_index, l2_table_index, mp->is_add);
6144 
6146 
6147  REPLY_MACRO (VL_API_INPUT_ACL_SET_INTERFACE_REPLY);
6148 }
6149 
6152 {
6153 #if IPSEC == 0
6154  clib_warning ("unimplemented");
6155 #else
6156 
6157  vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
6159  int rv;
6160 
6161 #if DPDK > 0
6162  rv = ipsec_add_del_spd (vm, ntohl (mp->spd_id), mp->is_add);
6163 #else
6164  rv = VNET_API_ERROR_UNIMPLEMENTED;
6165 #endif
6166 
6167  REPLY_MACRO (VL_API_IPSEC_SPD_ADD_DEL_REPLY);
6168 #endif
6169 }
6170 
6173 {
6174  vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
6176  int rv;
6177  u32 sw_if_index __attribute__ ((unused));
6178  u32 spd_id __attribute__ ((unused));
6179 
6180  sw_if_index = ntohl (mp->sw_if_index);
6181  spd_id = ntohl (mp->spd_id);
6182 
6183  VALIDATE_SW_IF_INDEX (mp);
6184 
6185 #if IPSEC > 0
6186  rv = ipsec_set_interface_spd (vm, sw_if_index, spd_id, mp->is_add);
6187 #else
6188  rv = VNET_API_ERROR_UNIMPLEMENTED;
6189 #endif
6190 
6192 
6193  REPLY_MACRO (VL_API_IPSEC_INTERFACE_ADD_DEL_SPD_REPLY);
6194 }
6195 
6198 {
6199  vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
6201  int rv;
6202 
6203 #if IPSEC > 0
6204  ipsec_policy_t p;
6205 
6206  memset (&p, 0, sizeof (p));
6207 
6208  p.id = ntohl (mp->spd_id);
6209  p.priority = ntohl (mp->priority);
6210  p.is_outbound = mp->is_outbound;
6211  p.is_ipv6 = mp->is_ipv6;
6212 
6213  if (mp->is_ipv6 || mp->is_ip_any)
6214  {
6216  clib_memcpy (&p.raddr.stop, mp->remote_address_stop, 16);
6218  clib_memcpy (&p.laddr.stop, mp->local_address_stop, 16);
6219  }
6220  else
6221  {
6222  clib_memcpy (&p.raddr.start.ip4.data, mp->remote_address_start, 4);
6223  clib_memcpy (&p.raddr.stop.ip4.data, mp->remote_address_stop, 4);
6224  clib_memcpy (&p.laddr.start.ip4.data, mp->local_address_start, 4);
6225  clib_memcpy (&p.laddr.stop.ip4.data, mp->local_address_stop, 4);
6226  }
6227  p.protocol = mp->protocol;
6228  p.rport.start = ntohs (mp->remote_port_start);
6229  p.rport.stop = ntohs (mp->remote_port_stop);
6230  p.lport.start = ntohs (mp->local_port_start);
6231  p.lport.stop = ntohs (mp->local_port_stop);
6232  /* policy action resolve unsupported */
6233  if (mp->policy == IPSEC_POLICY_ACTION_RESOLVE)
6234  {
6235  clib_warning ("unsupported action: 'resolve'");
6236  rv = VNET_API_ERROR_UNIMPLEMENTED;
6237  goto out;
6238  }
6239  p.policy = mp->policy;
6240  p.sa_id = ntohl (mp->sa_id);
6241 
6242  rv = ipsec_add_del_policy (vm, &p, mp->is_add);
6243  if (rv)
6244  goto out;
6245 
6246  if (mp->is_ip_any)
6247  {
6248  p.is_ipv6 = 1;
6249  rv = ipsec_add_del_policy (vm, &p, mp->is_add);
6250  }
6251 #else
6252  rv = VNET_API_ERROR_UNIMPLEMENTED;
6253  goto out;
6254 #endif
6255 
6256 out:
6257  REPLY_MACRO (VL_API_IPSEC_SPD_ADD_DEL_ENTRY_REPLY);
6258 }
6259 
6262 {
6263  vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
6265  int rv;
6266 #if IPSEC > 0
6267  ipsec_sa_t sa;
6268 
6269  memset (&sa, 0, sizeof (sa));
6270 
6271  sa.id = ntohl (mp->sad_id);
6272  sa.spi = ntohl (mp->spi);
6273  /* security protocol AH unsupported */
6274  if (mp->protocol == IPSEC_PROTOCOL_AH)
6275  {
6276  clib_warning ("unsupported security protocol 'AH'");
6277  rv = VNET_API_ERROR_UNIMPLEMENTED;
6278  goto out;
6279  }
6280  sa.protocol = mp->protocol;
6281  /* check for unsupported crypto-alg */
6282  if (mp->crypto_algorithm < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
6283  mp->crypto_algorithm > IPSEC_CRYPTO_ALG_AES_CBC_256)
6284  {
6285  clib_warning ("unsupported crypto-alg: '%U'", format_ipsec_crypto_alg,
6286  mp->crypto_algorithm);
6287  rv = VNET_API_ERROR_UNIMPLEMENTED;
6288  goto out;
6289  }
6290  sa.crypto_alg = mp->crypto_algorithm;
6292  clib_memcpy (&sa.crypto_key, mp->crypto_key, sizeof (sa.crypto_key));
6293  /* check for unsupported integ-alg */
6294  if (mp->integrity_algorithm < IPSEC_INTEG_ALG_SHA1_96 ||
6295  mp->integrity_algorithm > IPSEC_INTEG_ALG_SHA_512_256)
6296  {
6297  clib_warning ("unsupported integ-alg: '%U'", format_ipsec_integ_alg,
6298  mp->integrity_algorithm);
6299  rv = VNET_API_ERROR_UNIMPLEMENTED;
6300  goto out;
6301  }
6302  sa.integ_alg = mp->integrity_algorithm;
6304  clib_memcpy (&sa.integ_key, mp->integrity_key, sizeof (sa.integ_key));
6306  sa.is_tunnel = mp->is_tunnel;
6307  sa.is_tunnel_ip6 = mp->is_tunnel_ipv6;
6308  if (sa.is_tunnel_ip6)
6309  {
6312  }
6313  else
6314  {
6315  clib_memcpy (&sa.tunnel_src_addr.ip4.data, mp->tunnel_src_address, 4);
6316  clib_memcpy (&sa.tunnel_dst_addr.ip4.data, mp->tunnel_dst_address, 4);
6317  }
6318 
6319  rv = ipsec_add_del_sa (vm, &sa, mp->is_add);
6320 #else
6321  rv = VNET_API_ERROR_UNIMPLEMENTED;
6322  goto out;
6323 #endif
6324 
6325 out:
6326  REPLY_MACRO (VL_API_IPSEC_SAD_ADD_DEL_ENTRY_REPLY);
6327 }
6328 
6329 static void
6331 {
6333  int rv = 0;
6334 
6335 #if IPSEC > 0
6336  vlib_main_t *vm = vlib_get_main ();
6337  clib_error_t *error;
6338  u8 *tmp = format (0, "%s", mp->name);
6339  error = ikev2_add_del_profile (vm, tmp, mp->is_add);
6340  vec_free (tmp);
6341  if (error)
6342  rv = VNET_API_ERROR_UNSPECIFIED;
6343 #else
6344  rv = VNET_API_ERROR_UNIMPLEMENTED;
6345 #endif
6346 
6347  REPLY_MACRO (VL_API_IKEV2_PROFILE_ADD_DEL_REPLY);
6348 }
6349 
6350 static void
6353 {
6355  int rv = 0;
6356 
6357 #if IPSEC > 0
6358  vlib_main_t *vm = vlib_get_main ();
6359  clib_error_t *error;
6360  u8 *tmp = format (0, "%s", mp->name);
6361  u8 *data = vec_new (u8, mp->data_len);
6362  clib_memcpy (data, mp->data, mp->data_len);
6363  error = ikev2_set_profile_auth (vm, tmp, mp->auth_method, data, mp->is_hex);
6364  vec_free (tmp);
6365  vec_free (data);
6366  if (error)
6367  rv = VNET_API_ERROR_UNSPECIFIED;
6368 #else
6369  rv = VNET_API_ERROR_UNIMPLEMENTED;
6370 #endif
6371 
6372  REPLY_MACRO (VL_API_IKEV2_PROFILE_SET_AUTH_REPLY);
6373 }
6374 
6375 static void
6377 {
6379  int rv = 0;
6380 
6381 #if IPSEC > 0
6382  vlib_main_t *vm = vlib_get_main ();
6383  clib_error_t *error;
6384  u8 *tmp = format (0, "%s", mp->name);
6385  u8 *data = vec_new (u8, mp->data_len);
6386  clib_memcpy (data, mp->data, mp->data_len);
6387  error = ikev2_set_profile_id (vm, tmp, mp->id_type, data, mp->is_local);
6388  vec_free (tmp);
6389  vec_free (data);
6390  if (error)
6391  rv = VNET_API_ERROR_UNSPECIFIED;
6392 #else
6393  rv = VNET_API_ERROR_UNIMPLEMENTED;
6394 #endif
6395 
6396  REPLY_MACRO (VL_API_IKEV2_PROFILE_SET_ID_REPLY);
6397 }
6398 
6399 static void
6401 {
6403  int rv = 0;
6404 
6405 #if IPSEC > 0
6406  vlib_main_t *vm = vlib_get_main ();
6407  clib_error_t *error;
6408  u8 *tmp = format (0, "%s", mp->name);
6409  error = ikev2_set_profile_ts (vm, tmp, mp->proto, mp->start_port,
6410  mp->end_port, (ip4_address_t) mp->start_addr,
6411  (ip4_address_t) mp->end_addr, mp->is_local);
6412  vec_free (tmp);
6413  if (error)
6414  rv = VNET_API_ERROR_UNSPECIFIED;
6415 #else
6416  rv = VNET_API_ERROR_UNIMPLEMENTED;
6417 #endif
6418 
6419  REPLY_MACRO (VL_API_IKEV2_PROFILE_SET_TS_REPLY);
6420 }
6421 
6422 static void
6424 {
6426  int rv = 0;
6427 
6428 #if IPSEC > 0
6429  vlib_main_t *vm = vlib_get_main ();
6430  clib_error_t *error;
6431 
6432  error = ikev2_set_local_key (vm, mp->key_file);
6433  if (error)
6434  rv = VNET_API_ERROR_UNSPECIFIED;
6435 #else
6436  rv = VNET_API_ERROR_UNIMPLEMENTED;
6437 #endif
6438 
6439  REPLY_MACRO (VL_API_IKEV2_SET_LOCAL_KEY_REPLY);
6440 }
6441 
6442 static void
6444 {
6446  int rv = 0;
6447  u32 index;
6448  u8 flags = mp->is_translation ? MAP_DOMAIN_TRANSLATION : 0;
6449  rv =
6451  (ip6_address_t *) & mp->ip6_prefix, mp->ip6_prefix_len,
6452  (ip6_address_t *) & mp->ip6_src,
6454  mp->psid_offset, mp->psid_length, &index,
6455  ntohs (mp->mtu), flags);
6456 
6457  /* *INDENT-OFF* */
6458  REPLY_MACRO2(VL_API_MAP_ADD_DOMAIN_REPLY,
6459  ({
6460  rmp->index = ntohl(index);
6461  }));
6462  /* *INDENT-ON* */
6463 }
6464 
6465 static void
6467 {
6469  int rv = 0;
6470 
6471  rv = map_delete_domain (ntohl (mp->index));
6472 
6473  REPLY_MACRO (VL_API_MAP_DEL_DOMAIN_REPLY);
6474 }
6475 
6476 static void
6478 {
6480  int rv = 0;
6481 
6482  rv =
6483  map_add_del_psid (ntohl (mp->index), ntohs (mp->psid),
6484  (ip6_address_t *) mp->ip6_dst, mp->is_add);
6485 
6486  REPLY_MACRO (VL_API_MAP_ADD_DEL_RULE_REPLY);
6487 }
6488 
6489 static void
6491 {
6493  map_main_t *mm = &map_main;
6494  map_domain_t *d;
6496 
6497  if (pool_elts (mm->domains) == 0)
6498  return;
6499 
6501  if (q == 0)
6502  {
6503  return;
6504  }
6505 
6506  /* *INDENT-OFF* */
6507  pool_foreach(d, mm->domains,
6508  ({
6509  /* Make sure every field is initiated (or don't skip the memset()) */
6510  rmp = vl_msg_api_alloc (sizeof (*rmp));
6511  rmp->_vl_msg_id = ntohs(VL_API_MAP_DOMAIN_DETAILS);
6512  rmp->domain_index = htonl(d - mm->domains);
6513  rmp->ea_bits_len = d->ea_bits_len;
6514  rmp->psid_offset = d->psid_offset;
6515  rmp->psid_length = d->psid_length;
6516  clib_memcpy(rmp->ip4_prefix, &d->ip4_prefix, sizeof(rmp->ip4_prefix));
6517  rmp->ip4_prefix_len = d->ip4_prefix_len;
6518  clib_memcpy(rmp->ip6_prefix, &d->ip6_prefix, sizeof(rmp->ip6_prefix));
6519  rmp->ip6_prefix_len = d->ip6_prefix_len;
6520  clib_memcpy(rmp->ip6_src, &d->ip6_src, sizeof(rmp->ip6_src));
6521  rmp->ip6_src_len = d->ip6_src_len;
6522  rmp->mtu = htons(d->mtu);
6523  rmp->is_translation = (d->flags & MAP_DOMAIN_TRANSLATION);
6524  rmp->context = mp->context;
6525 
6526  vl_msg_api_send_shmem (q, (u8 *)&rmp);
6527  }));
6528  /* *INDENT-ON* */
6529 }
6530 
6531 static void
6533 {
6535  u16 i;
6536  ip6_address_t dst;
6538  map_main_t *mm = &map_main;
6539  u32 domain_index = ntohl (mp->domain_index);
6540  map_domain_t *d;
6541 
6542  if (pool_elts (mm->domains) == 0)
6543  return;
6544 
6545  d = pool_elt_at_index (mm->domains, domain_index);
6546  if (!d || !d->rules)
6547  {
6548  return;
6549  }
6550 
6552  if (q == 0)
6553  {
6554  return;
6555  }
6556 
6557  for (i = 0; i < (0x1 << d->psid_length); i++)
6558  {
6559  dst = d->rules[i];
6560  if (dst.as_u64[0] == 0 && dst.as_u64[1] == 0)
6561  {
6562  continue;
6563  }
6564  rmp = vl_msg_api_alloc (sizeof (*rmp));
6565  memset (rmp, 0, sizeof (*rmp));
6566  rmp->_vl_msg_id = ntohs (VL_API_MAP_RULE_DETAILS);
6567  rmp->psid = htons (i);
6568  clib_memcpy (rmp->ip6_dst, &dst, sizeof (rmp->ip6_dst));
6569  rmp->context = mp->context;
6570  vl_msg_api_send_shmem (q, (u8 *) & rmp);
6571  }
6572 }
6573 
6574 static void
6576 {
6579  vlib_counter_t v;
6580  int i, which;
6581  u64 total_pkts[VLIB_N_RX_TX];
6582  u64 total_bytes[VLIB_N_RX_TX];
6583  map_main_t *mm = &map_main;
6586 
6587  if (!q)
6588  return;
6589 
6590  rmp = vl_msg_api_alloc (sizeof (*rmp));
6591  rmp->_vl_msg_id = ntohs (VL_API_MAP_SUMMARY_STATS_REPLY);
6592  rmp->context = mp->context;
6593  rmp->retval = 0;
6594 
6595  memset (total_pkts, 0, sizeof (total_pkts));
6596  memset (total_bytes, 0, sizeof (total_bytes));
6597 
6599  vec_foreach (cm, mm->domain_counters)
6600  {
6601  which = cm - mm->domain_counters;
6602 
6603  for (i = 0; i < vec_len (cm->maxi); i++)
6604  {
6605  vlib_get_combined_counter (cm, i, &v);
6606  total_pkts[which] += v.packets;
6607  total_bytes[which] += v.bytes;
6608  }
6609  }
6610 
6612 
6613  /* Note: in network byte order! */
6615  clib_host_to_net_u64 (total_pkts[MAP_DOMAIN_COUNTER_RX]);
6617  clib_host_to_net_u64 (total_bytes[MAP_DOMAIN_COUNTER_RX]);
6619  clib_host_to_net_u64 (total_pkts[MAP_DOMAIN_COUNTER_TX]);
6621  clib_host_to_net_u64 (total_bytes[MAP_DOMAIN_COUNTER_TX]);
6622  rmp->total_bindings = clib_host_to_net_u64 (pool_elts (mm->domains));
6623  rmp->total_ip4_fragments = 0; // Not yet implemented. Should be a simple counter.
6625  clib_host_to_net_u64 (map_error_counter_get
6626  (ip4_map_node.index, MAP_ERROR_ENCAP_SEC_CHECK));
6628  clib_host_to_net_u64 (map_error_counter_get
6629  (ip4_map_node.index, MAP_ERROR_DECAP_SEC_CHECK));
6630 
6631  vl_msg_api_send_shmem (q, (u8 *) & rmp);
6632 }
6633 
6634 static void
6636 {
6637  vlib_main_t *vm __attribute__ ((unused)) = vlib_get_main ();
6639  int rv;
6640 #if IPSEC > 0
6641  ipsec_sa_t sa;
6642  sa.id = ntohl (mp->sa_id);
6644  clib_memcpy (&sa.crypto_key, mp->crypto_key, sizeof (sa.crypto_key));
6646  clib_memcpy (&sa.integ_key, mp->integrity_key, sizeof (sa.integ_key));
6647 
6648  rv = ipsec_set_sa_key (vm, &sa);
6649 #else
6650  rv = VNET_API_ERROR_UNIMPLEMENTED;
6651 #endif
6652 
6653  REPLY_MACRO (VL_API_IPSEC_SA_SET_KEY_REPLY);
6654 }
6655 
6658 {
6660  int rv;
6661  u32 sw_if_index = ntohl (mp->sw_if_index);
6662  int enable_disable;
6663 
6664  VALIDATE_SW_IF_INDEX (mp);
6665 
6666  enable_disable = (int) mp->enable_disable;
6667 
6668  rv = cop_interface_enable_disable (sw_if_index, enable_disable);
6669 
6671 
6672  REPLY_MACRO (VL_API_COP_INTERFACE_ENABLE_DISABLE_REPLY);
6673 }
6674 
6677 {
6680  u32 sw_if_index = ntohl (mp->sw_if_index);
6681  int rv;
6682 
6683  VALIDATE_SW_IF_INDEX (mp);
6684 
6685  a->sw_if_index = sw_if_index;
6686  a->ip4 = mp->ip4;
6687  a->ip6 = mp->ip6;
6688  a->default_cop = mp->default_cop;
6689  a->fib_id = ntohl (mp->fib_id);
6690 
6692 
6694 
6695  REPLY_MACRO (VL_API_COP_WHITELIST_ENABLE_DISABLE_REPLY);
6696 }
6697 
6698 static void
6700 {
6701  int rv = 0;
6702  u8 *vector = 0;
6703  api_main_t *am = &api_main;
6704  vlib_main_t *vm = vlib_get_main ();
6705  void *oldheap;
6707 
6708  pthread_mutex_lock (&am->vlib_rp->mutex);
6709  oldheap = svm_push_data_heap (am->vlib_rp);
6710 
6711  /*
6712  * Keep the number of memcpy ops to a minimum (e.g. 1).
6713  */
6714  vec_validate (vector, 16384);
6715  vec_reset_length (vector);
6716 
6717  /* $$$$ FIXME */
6718  vector = vlib_node_serialize (&vm->node_main, vector,
6719  (u32) ~ 0 /* all threads */ ,
6720  1 /* include nexts */ ,
6721  1 /* include stats */ );
6722 
6723  svm_pop_heap (oldheap);
6724  pthread_mutex_unlock (&am->vlib_rp->mutex);
6725 
6726  /* *INDENT-OFF* */
6727  REPLY_MACRO2(VL_API_GET_NODE_GRAPH_REPLY,
6728  ({
6729  rmp->reply_in_shmem = (uword) vector;
6730  }));
6731  /* *INDENT-ON* */
6732 }
6733 
6736 {
6737  int rv = 0;
6739  clib_error_t *error;
6740 
6741  /* Ignoring the profile id as currently a single profile
6742  * is supported */
6744  ntohl (mp->node_id),
6745  ntohl (mp->trace_app_data),
6746  mp->pow_enable, mp->trace_tsp,
6747  mp->trace_ppc);
6748  if (error)
6749  {
6750  clib_error_report (error);
6751  rv = clib_error_get_code (error);
6752  }
6753 
6754  REPLY_MACRO (VL_API_TRACE_PROFILE_ADD_REPLY);
6755 }
6756 
6759 {
6760  int rv = 0;
6762 
6763  if (mp->enable != 0)
6764  {
6766  ntohl (mp->prefix_length),
6767  ntohl (mp->vrf_id),
6768  mp->trace_op == IOAM_HBYH_ADD,
6769  mp->trace_op == IOAM_HBYH_POP,
6770  mp->trace_op == IOAM_HBYH_MOD);
6771  }
6772  else
6773  {
6774  //ip6_ioam_clear_destination(&ip6, mp->prefix_length, mp->vrf_id);
6775  }
6776  REPLY_MACRO (VL_API_TRACE_PROFILE_APPLY_REPLY);
6777 }
6778 
6781 {
6782  int rv = 0;
6784  clib_error_t *error;
6785 
6786  error = clear_ioam_rewrite_fn ();
6787  if (error)
6788  {
6789  clib_error_report (error);
6790  rv = clib_error_get_code (error);
6791  }
6792 
6793  REPLY_MACRO (VL_API_TRACE_PROFILE_DEL_REPLY);
6794 }
6795 
6796 static void
6798 {
6799  vlib_main_t *vm = vlib_get_main ();
6801  int rv = 0;
6802  u8 *host_if_name = NULL;
6803  u32 sw_if_index;
6804 
6805  host_if_name = format (0, "%s", mp->host_if_name);
6806  vec_add1 (host_if_name, 0);
6807 
6808  rv = af_packet_create_if (vm, host_if_name,
6809  mp->use_random_hw_addr ? 0 : mp->hw_addr,
6810  &sw_if_index);
6811 
6812  vec_free (host_if_name);
6813 
6814  /* *INDENT-OFF* */
6815  REPLY_MACRO2(VL_API_AF_PACKET_CREATE_REPLY,
6816  ({
6817  rmp->sw_if_index = clib_host_to_net_u32(sw_if_index);
6818  }));
6819  /* *INDENT-ON* */
6820 }
6821 
6822 static void
6824 {
6825  vlib_main_t *vm = vlib_get_main ();
6827  int rv = 0;
6828  u8 *host_if_name = NULL;
6829 
6830  host_if_name = format (0, "%s", mp->host_if_name);
6831  vec_add1 (host_if_name, 0);
6832 
6833  rv = af_packet_delete_if (vm, host_if_name);
6834 
6835  vec_free (host_if_name);
6836 
6837  REPLY_MACRO (VL_API_AF_PACKET_DELETE_REPLY);
6838 }
6839 
6840 static void
6842 {
6843  vlib_main_t *vm = vlib_get_main ();
6845  int rv = 0;
6846  u8 *name = NULL;
6848  clib_error_t *error;
6849  u32 policer_index;
6850 
6851  name = format (0, "%s", mp->name);
6852 
6853  memset (&cfg, 0, sizeof (cfg));
6854  cfg.rfc = mp->type;
6855  cfg.rnd_type = mp->round_type;
6856  cfg.rate_type = mp->rate_type;
6857  cfg.rb.kbps.cir_kbps = mp->cir;
6858  cfg.rb.kbps.eir_kbps = mp->eir;
6859  cfg.rb.kbps.cb_bytes = mp->cb;
6860  cfg.rb.kbps.eb_bytes = mp->eb;
6862  cfg.conform_action.dscp = mp->conform_dscp;
6864  cfg.exceed_action.dscp = mp->exceed_dscp;
6866  cfg.violate_action.dscp = mp->violate_dscp;
6867  cfg.color_aware = mp->color_aware;
6868 
6869  error = policer_add_del (vm, name, &cfg, &policer_index, mp->is_add);
6870 
6871  if (error)
6872  rv = VNET_API_ERROR_UNSPECIFIED;
6873 
6874  /* *INDENT-OFF* */
6875  REPLY_MACRO2(VL_API_POLICER_ADD_DEL_REPLY,
6876  ({
6877  if (rv == 0 && mp->is_add)
6878  rmp->policer_index = ntohl(policer_index);
6879  else
6880  rmp->policer_index = ~0;
6881  }));
6882  /* *INDENT-ON* */
6883 }
6884 
6885 static void
6887  sse2_qos_pol_cfg_params_st * config,
6889  unix_shared_memory_queue_t * q, u32 context)
6890 {
6892 
6893  mp = vl_msg_api_alloc (sizeof (*mp));
6894  memset (mp, 0, sizeof (*mp));
6895  mp->_vl_msg_id = ntohs (VL_API_POLICER_DETAILS);
6896  mp->context = context;
6897  mp->cir = htonl (config->rb.kbps.cir_kbps);
6898  mp->eir = htonl (config->rb.kbps.eir_kbps);
6899  mp->cb = htonl (config->rb.kbps.cb_bytes);
6900  mp->eb = htonl (config->rb.kbps.eb_bytes);
6901  mp->rate_type = config->rate_type;
6902  mp->round_type = config->rnd_type;
6903  mp->type = config->rfc;
6905  mp->conform_dscp = config->conform_action.dscp;
6907  mp->exceed_dscp = config->exceed_action.dscp;
6909  mp->violate_dscp = config->violate_action.dscp;
6910  mp->single_rate = templ->single_rate ? 1 : 0;
6911  mp->color_aware = templ->color_aware ? 1 : 0;
6912  mp->scale = htonl (templ->scale);
6913  mp->cir_tokens_per_period = htonl (templ->cir_tokens_per_period);
6914  mp->pir_tokens_per_period = htonl (templ->pir_tokens_per_period);
6915  mp->current_limit = htonl (templ->current_limit);
6916  mp->current_bucket = htonl (templ->current_bucket);
6917  mp->extended_limit = htonl (templ->extended_limit);
6918  mp->extended_bucket = htonl (templ->extended_bucket);
6919  mp->last_update_time = clib_host_to_net_u64 (templ->last_update_time);
6920 
6921  strncpy ((char *) mp->name, (char *) name, ARRAY_LEN (mp->name) - 1);
6922 
6923  vl_msg_api_send_shmem (q, (u8 *) & mp);
6924 }
6925 
6926 static void
6928 {
6931  hash_pair_t *hp;
6932  uword *p;
6933  u32 pool_index;
6934  u8 *match_name = 0;
6935  u8 *name;
6938 
6940  if (q == 0)
6941  return;
6942 
6943  if (mp->match_name_valid)
6944  {
6945  match_name = format (0, "%s%c", mp->match_name, 0);
6946  }
6947 
6948  if (mp->match_name_valid)
6949  {
6950  p = hash_get_mem (pm->policer_config_by_name, match_name);
6951  if (p)
6952  {
6953  pool_index = p[0];
6954  config = pool_elt_at_index (pm->configs, pool_index);
6955  templ = pool_elt_at_index (pm->policer_templates, pool_index);
6956  send_policer_details (match_name, config, templ, q, mp->context);
6957  }
6958  }
6959  else
6960  {
6961  /* *INDENT-OFF* */
6963  ({
6964  name = (u8 *) hp->key;
6965  pool_index = hp->value[0];
6966  config = pool_elt_at_index (pm->configs, pool_index);
6967  templ = pool_elt_at_index (pm->policer_templates, pool_index);
6968  send_policer_details(name, config, templ, q, mp->context);
6969  }));
6970  /* *INDENT-ON* */
6971  }
6972 }
6973 
6974 static void
6977 {
6978  vlib_main_t *vm = vlib_get_main ();
6980  int rv;
6981  u32 sw_if_index, ip4_table_index, ip6_table_index, l2_table_index;
6982 
6983  ip4_table_index = ntohl (mp->ip4_table_index);
6984  ip6_table_index = ntohl (mp->ip6_table_index);
6985  l2_table_index = ntohl (mp->l2_table_index);
6986  sw_if_index = ntohl (mp->sw_if_index);
6987 
6988  VALIDATE_SW_IF_INDEX (mp);
6989 
6990  rv = vnet_set_policer_classify_intfc (vm, sw_if_index, ip4_table_index,
6991  ip6_table_index, l2_table_index,
6992  mp->is_add);
6993 
6995 
6996  REPLY_MACRO (VL_API_POLICER_CLASSIFY_SET_INTERFACE_REPLY);
6997 }
6998 
6999 static void
7001  u32 table_index,
7002  unix_shared_memory_queue_t * q, u32 context)
7003 {
7005 
7006  mp = vl_msg_api_alloc (sizeof (*mp));
7007  memset (mp, 0, sizeof (*mp));
7008  mp->_vl_msg_id = ntohs (VL_API_POLICER_CLASSIFY_DETAILS);
7009  mp->context = context;
7010  mp->sw_if_index = htonl (sw_if_index);
7011  mp->table_index = htonl (table_index);
7012 
7013  vl_msg_api_send_shmem (q, (u8 *) & mp);
7014 }
7015 
7016 static void
7018 {
7021  u32 *vec_tbl;
7022  int i;
7023 
7025  if (q == 0)
7026  return;
7027 
7028  vec_tbl = pcm->classify_table_index_by_sw_if_index[mp->type];
7029 
7030  if (vec_len (vec_tbl))
7031  {
7032  for (i = 0; i < vec_len (vec_tbl); i++)
7033  {
7034  if (vec_elt (vec_tbl, i) == ~0)
7035  continue;
7036 
7037  send_policer_classify_details (i, vec_elt (vec_tbl, i), q,
7038  mp->context);
7039  }
7040  }
7041 }
7042 
7043 static void
7045 {
7046  vlib_main_t *vm = vlib_get_main ();
7048  int rv = 0;
7049  u8 *if_name = NULL;
7050 
7051  if_name = format (0, "%s", mp->netmap_if_name);
7052  vec_add1 (if_name, 0);
7053 
7054  rv =
7055  netmap_create_if (vm, if_name, mp->use_random_hw_addr ? 0 : mp->hw_addr,
7056  mp->is_pipe, mp->is_master, 0);
7057 
7058  vec_free (if_name);
7059 
7060  REPLY_MACRO (VL_API_NETMAP_CREATE_REPLY);
7061 }
7062 
7063 static void
7065 {
7066  vlib_main_t *vm = vlib_get_main ();
7068  int rv = 0;
7069  u8 *if_name = NULL;
7070 
7071  if_name = format (0, "%s", mp->netmap_if_name);
7072  vec_add1 (if_name, 0);
7073 
7074  rv = netmap_delete_if (vm, if_name);
7075 
7076  vec_free (if_name);
7077 
7078  REPLY_MACRO (VL_API_NETMAP_DELETE_REPLY);
7079 }
7080 
7081 static void
7083  mp)
7084 {
7085  clib_warning ("BUG");
7086 }
7087 
7088 static void
7091  mpls_gre_tunnel_t * gt, u32 index, u32 context)
7092 {
7094  mpls_main_t *mm = &mpls_main;
7095  mpls_encap_t *e;
7096  int i;
7097  u32 nlabels;
7098 
7099  e = pool_elt_at_index (mm->encaps, gt->encap_index);
7100  nlabels = vec_len (e->labels);
7101 
7102  mp = vl_msg_api_alloc (sizeof (*mp) + nlabels * sizeof (u32));
7103  memset (mp, 0, sizeof (*mp));
7104  mp->_vl_msg_id = ntohs (VL_API_MPLS_GRE_TUNNEL_DETAILS);
7105  mp->context = context;
7106 
7107  mp->tunnel_index = htonl (index);
7108  mp->tunnel_src = gt->tunnel_src.as_u32;
7109  mp->tunnel_dst = gt->tunnel_dst.as_u32;
7111  mp->mask_width = htonl (gt->mask_width);
7112  mp->inner_fib_index = htonl (gt->inner_fib_index);
7113  mp->outer_fib_index = htonl (gt->outer_fib_index);
7114  mp->encap_index = htonl (gt->encap_index);
7115  mp->hw_if_index = htonl (gt->hw_if_index);
7116  mp->l2_only = htonl (gt->l2_only);
7117  mp->nlabels = htonl (nlabels);
7118 
7119  for (i = 0; i < nlabels; i++)
7120  {
7121  mp->labels[i] =
7122  htonl (vnet_mpls_uc_get_label
7123  (clib_host_to_net_u32 (e->labels[i].label_exp_s_ttl)));
7124  }
7125 
7126  vl_msg_api_send_shmem (q, (u8 *) & mp);
7127 }
7128 
7129 static void
7131 {
7134  mpls_main_t *mm = &mpls_main;
7135  mpls_gre_tunnel_t *gt;
7136  u32 index = ntohl (mp->tunnel_index);
7137 
7139  if (q == 0)
7140  return;
7141 
7142  if (index != ~0)
7143  {
7144  if (!pool_is_free_index (mm->gre_tunnels, index))
7145  {
7146  gt = pool_elt_at_index (mm->gre_tunnels, index);
7147  send_mpls_gre_tunnel_entry (am, q, gt, gt - mm->gre_tunnels,
7148  mp->context);
7149  }
7150  }
7151  else
7152  {
7153  /* *INDENT-OFF* */
7154  pool_foreach (gt, mm->gre_tunnels,
7155  ({
7156  send_mpls_gre_tunnel_entry (am, q, gt, gt - mm->gre_tunnels,
7157  mp->context);
7158  }));
7159  /* *INDENT-ON* */
7160  }
7161 }
7162 
7163 static void
7165  mp)
7166 {
7167  clib_warning ("BUG");
7168 }
7169 
7170 static void
7173  mpls_eth_tunnel_t * et, u32 index, u32 context)
7174 {
7175  mpls_main_t *mm = &mpls_main;
7176  mpls_encap_t *e;
7177  int i;
7178  u32 nlabels;
7180 
7181  e = pool_elt_at_index (mm->encaps, et->encap_index);
7182  nlabels = vec_len (e->labels);
7183 
7184  mp = vl_msg_api_alloc (sizeof (*mp) + nlabels * sizeof (u32));
7185  memset (mp, 0, sizeof (*mp));
7186  mp->_vl_msg_id = ntohs (VL_API_MPLS_ETH_TUNNEL_DETAILS);
7187  mp->context = context;
7188 
7189  mp->tunnel_index = htonl (index);
7190  memcpy (mp->tunnel_dst_mac, et->tunnel_dst, 6);
7192  mp->tx_sw_if_index = htonl (et->tx_sw_if_index);
7193  mp->inner_fib_index = htonl (et->inner_fib_index);
7194  mp->mask_width = htonl (et->mask_width);
7195  mp->encap_index = htonl (et->encap_index);
7196  mp->hw_if_index = htonl (et->hw_if_index);
7197  mp->l2_only = htonl (et->l2_only);
7198  mp->nlabels = htonl (nlabels);
7199 
7200  for (i = 0; i < nlabels; i++)
7201  {
7202  mp->labels[i] =
7203  htonl (vnet_mpls_uc_get_label
7204  (clib_host_to_net_u32 (e->labels[i].label_exp_s_ttl)));
7205  }
7206 
7207  vl_msg_api_send_shmem (q, (u8 *) & mp);
7208 }
7209 
7210 static void
7212 {
7215  mpls_main_t *mm = &mpls_main;
7216  mpls_eth_tunnel_t *et;
7217  u32 index = ntohl (mp->tunnel_index);
7218 
7220  if (q == 0)
7221  return;
7222 
7223  if (index != ~0)
7224  {
7225  if (!pool_is_free_index (mm->eth_tunnels, index))
7226  {
7227  et = pool_elt_at_index (mm->eth_tunnels, index);
7228  send_mpls_eth_tunnel_entry (am, q, et, et - mm->eth_tunnels,
7229  mp->context);
7230  }
7231  }
7232  else
7233  {
7234  /* *INDENT-OFF* */
7235  pool_foreach (et, mm->eth_tunnels,
7236  ({
7237  send_mpls_eth_tunnel_entry (am, q, et, et - mm->eth_tunnels,
7238  mp->context);
7239  }));
7240  /* *INDENT-ON* */
7241  }
7242 }
7243 
7244 static void
7246 {
7247  clib_warning ("BUG");
7248 }
7249 
7250 static void
7253  show_mpls_fib_t * s, u32 context)
7254 {
7256  mpls_main_t *mm = &mpls_main;
7257  mpls_encap_t *e;
7258  int i;
7259  u32 nlabels;
7260 
7261  e = pool_elt_at_index (mm->encaps, s->entry_index);
7262  nlabels = vec_len (e->labels);
7263 
7264  mp = vl_msg_api_alloc (sizeof (*mp) + nlabels * sizeof (u32));
7265  memset (mp, 0, sizeof (*mp));
7266  mp->_vl_msg_id = ntohs (VL_API_MPLS_FIB_ENCAP_DETAILS);
7267  mp->context = context;
7268 
7269  mp->fib_index = htonl (s->fib_index);
7270  mp->entry_index = htonl (s->entry_index);
7271  mp->dest = s->dest;
7272  mp->s_bit = htonl (s->s_bit);
7273 
7274  mp->nlabels = htonl (nlabels);
7275 
7276  for (i = 0; i < nlabels; i++)
7277  {
7278  mp->labels[i] =
7279  htonl (vnet_mpls_uc_get_label
7280  (clib_host_to_net_u32 (e->labels[i].label_exp_s_ttl)));
7281  }
7282 
7283  vl_msg_api_send_shmem (q, (u8 *) & mp);
7284 }
7285 
7286 static void
7288 {
7292  u64 key;
7293  u32 value;
7294  show_mpls_fib_t *records = 0;
7295  show_mpls_fib_t *s;
7296  mpls_main_t *mm = &mpls_main;
7297  ip4_main_t *im = &ip4_main;
7298  ip4_fib_t *rx_fib;
7299 
7301  if (q == 0)
7302  return;
7303 
7304  /* *INDENT-OFF* */
7305  hash_foreach (key, value, mm->mpls_encap_by_fib_and_dest,
7306  ({
7307  vec_add2 (records, s, 1);
7308  s->fib_index = (u32)(key>>32);
7309  s->dest = (u32)(key & 0xFFFFFFFF);
7310  s->entry_index = (u32) value;
7311  }));
7312  /* *INDENT-ON* */
7313 
7314  if (0 == vec_len (records))
7315  {
7316  vlib_cli_output (vm, "MPLS encap table empty");
7317  goto out;
7318  }
7319 
7320  /* sort output by dst address within fib */
7323  vlib_cli_output (vm, "MPLS encap table");
7324  vlib_cli_output (vm, "%=6s%=16s%=16s", "Table", "Dest address", "Labels");
7325  vec_foreach (s, records)
7326  {
7327  rx_fib = vec_elt_at_index (im->fibs, s->fib_index);
7328  vlib_cli_output (vm, "%=6d%=16U%=16U", rx_fib->table_id,
7330  mm, s->entry_index);
7331  send_mpls_fib_encap_details (am, q, s, mp->context);
7332  }
7333 
7334 out:
7335  vec_free (records);
7336 }
7337 
7338 static void
7340 {
7341  clib_warning ("BUG");
7342 }
7343 
7344 static void
7347  show_mpls_fib_t * s,
7348  u32 rx_table_id,
7349  u32 tx_table_id, char *swif_tag, u32 context)
7350 {
7352 
7353  mp = vl_msg_api_alloc (sizeof (*mp));
7354  memset (mp, 0, sizeof (*mp));
7355  mp->_vl_msg_id = ntohs (VL_API_MPLS_FIB_DECAP_DETAILS);
7356  mp->context = context;
7357 
7358  mp->fib_index = htonl (s->fib_index);
7359  mp->entry_index = htonl (s->entry_index);
7360  mp->dest = s->dest;
7361  mp->s_bit = htonl (s->s_bit);
7362  mp->label = htonl (s->label);
7363  mp->rx_table_id = htonl (rx_table_id);
7364  mp->tx_table_id = htonl (tx_table_id);
7365  strncpy ((char *) mp->swif_tag,
7366  (char *) swif_tag, ARRAY_LEN (mp->swif_tag) - 1);
7367 
7368  vl_msg_api_send_shmem (q, (u8 *) & mp);
7369 }
7370 
7371 static void
7373 {
7377  u64 key;
7378  u32 value;
7379  show_mpls_fib_t *records = 0;
7380  show_mpls_fib_t *s;
7381  mpls_main_t *mm = &mpls_main;
7382  ip4_main_t *im = &ip4_main;
7383  ip4_fib_t *rx_fib;
7384  ip4_fib_t *tx_fib;
7385  u32 tx_table_id;
7386  char *swif_tag;
7387 
7389  if (q == 0)
7390  return;
7391 
7392  /* *INDENT-OFF* */
7394  ({
7395  vec_add2 (records, s, 1);
7396  s->fib_index = (u32)(key>>32);
7397  s->entry_index = (u32) value;
7398  s->label = ((u32) key)>>12;
7399  s->s_bit = (key & (1<<8)) != 0;
7400  }));
7401  /* *INDENT-ON* */
7402 
7403  if (!vec_len (records))
7404  {
7405  vlib_cli_output (vm, "MPLS decap table empty");
7406  goto out;
7407  }
7408 
7410  vlib_cli_output (vm, "MPLS decap table");
7411  vlib_cli_output (vm, "%=10s%=15s%=6s%=6s", "RX Table", "TX Table/Intfc",
7412  "Label", "S-bit");
7413  vec_foreach (s, records)
7414  {
7415  mpls_decap_t *d;
7416  d = pool_elt_at_index (mm->decaps, s->entry_index);
7417  if (d->next_index == MPLS_INPUT_NEXT_IP4_INPUT)
7418  {
7419  tx_fib = vec_elt_at_index (im->fibs, d->tx_fib_index);
7420  tx_table_id = tx_fib->table_id;
7421  swif_tag = " ";
7422  }
7423  else
7424  {
7425  tx_table_id = d->tx_fib_index;
7426  swif_tag = "(i) ";
7427  }
7428  rx_fib = vec_elt_at_index (im->fibs, s->fib_index);
7429 
7430  vlib_cli_output (vm, "%=10d%=10d%=5s%=6d%=6d", rx_fib->table_id,
7431  tx_table_id, swif_tag, s->label, s->s_bit);
7432 
7433  send_mpls_fib_decap_details (am, q, s, rx_fib->table_id,
7434  tx_table_id, swif_tag, mp->context);
7435  }
7436 
7437 out:
7438  vec_free (records);
7439 }
7440 
7441 static void
7443 {
7445 
7447  if (q == 0)
7448  return;
7449 
7452  u32 *table_ids = 0;
7453  u32 count;
7454 
7455  /* *INDENT-OFF* */
7456  pool_foreach (t, cm->tables,
7457  ({
7458  vec_add1 (table_ids, ntohl(t - cm->tables));
7459  }));
7460  /* *INDENT-ON* */
7461  count = vec_len (table_ids);
7462 
7464  rmp = vl_msg_api_alloc_as_if_client (sizeof (*rmp) + count * sizeof (u32));
7465  rmp->_vl_msg_id = ntohs (VL_API_CLASSIFY_TABLE_IDS_REPLY);
7466  rmp->context = mp->context;
7467  rmp->count = ntohl (count);
7468  clib_memcpy (rmp->ids, table_ids, count * sizeof (u32));
7469  rmp->retval = 0;
7470 
7471  vl_msg_api_send_shmem (q, (u8 *) & rmp);
7472 
7473  vec_free (table_ids);
7474 }
7475 
7476 static void
7479 {
7481  int rv = 0;
7482 
7483  u32 sw_if_index = ntohl (mp->sw_if_index);
7484  u32 *acl = 0;
7485 
7486  vec_validate (acl, INPUT_ACL_N_TABLES - 1);
7487  vec_set (acl, ~0);
7488 
7489  VALIDATE_SW_IF_INDEX (mp);
7490 
7492 
7493  int if_idx;
7494  u32 type;
7495 
7496  for (type = 0; type < INPUT_ACL_N_TABLES; type++)
7497  {
7499  if (vec_len (vec_tbl))
7500  {
7501  for (if_idx = 0; if_idx < vec_len (vec_tbl); if_idx++)
7502  {
7503  if (vec_elt (vec_tbl, if_idx) == ~0 || sw_if_index != if_idx)
7504  {
7505  continue;
7506  }
7507  acl[type] = vec_elt (vec_tbl, if_idx);
7508  }
7509  }
7510  }
7511 
7513 
7514  /* *INDENT-OFF* */
7515  REPLY_MACRO2(VL_API_CLASSIFY_TABLE_BY_INTERFACE_REPLY,
7516  ({
7517  rmp->sw_if_index = ntohl(sw_if_index);
7518  rmp->l2_table_id = ntohl(acl[INPUT_ACL_TABLE_L2]);
7519  rmp->ip4_table_id = ntohl(acl[INPUT_ACL_TABLE_IP4]);
7520  rmp->ip6_table_id = ntohl(acl[INPUT_ACL_TABLE_IP6]);
7521  }));
7522  /* *INDENT-ON* */
7523  vec_free (acl);
7524 }
7525 
7526 static void
7528 {
7530 
7532  if (q == 0)
7533  return;
7534 
7536 
7538  u32 table_id = ntohl (mp->table_id);
7540 
7541  /* *INDENT-OFF* */
7542  pool_foreach (t, cm->tables,
7543  ({
7544  if (table_id == t - cm->tables)
7545  {
7546  rmp = vl_msg_api_alloc_as_if_client
7547  (sizeof (*rmp) + t->match_n_vectors * sizeof (u32x4));
7548  rmp->_vl_msg_id = ntohs (VL_API_CLASSIFY_TABLE_INFO_REPLY);
7549  rmp->context = mp->context;
7550  rmp->table_id = ntohl(table_id);
7551  rmp->nbuckets = ntohl(t->nbuckets);
7552  rmp->match_n_vectors = ntohl(t->match_n_vectors);
7553  rmp->skip_n_vectors = ntohl(t->skip_n_vectors);
7554  rmp->active_sessions = ntohl(t->active_elements);
7555  rmp->next_table_index = ntohl(t->next_table_index);
7556  rmp->miss_next_index = ntohl(t->miss_next_index);
7557  rmp->mask_length = ntohl(t->match_n_vectors * sizeof (u32x4));
7558  clib_memcpy(rmp->mask, t->mask, t->match_n_vectors * sizeof(u32x4));
7559  rmp->retval = 0;
7560  break;
7561  }
7562  }));
7563  /* *INDENT-ON* */
7564 
7565  if (rmp == 0)
7566  {
7567  rmp = vl_msg_api_alloc (sizeof (*rmp));
7568  rmp->_vl_msg_id = ntohs ((VL_API_CLASSIFY_TABLE_INFO_REPLY));
7569  rmp->context = mp->context;
7570  rmp->retval = ntohl (VNET_API_ERROR_CLASSIFY_TABLE_NOT_FOUND);
7571  }
7572 
7573  vl_msg_api_send_shmem (q, (u8 *) & rmp);
7574 }
7575 
7576 static void
7578  mp)
7579 {
7580  clib_warning ("BUG");
7581 }
7582 
7583 static void
7585  u32 table_id,
7586  u32 match_length,
7587  vnet_classify_entry_t * e, u32 context)
7588 {
7590 
7591  rmp = vl_msg_api_alloc (sizeof (*rmp));
7592  memset (rmp, 0, sizeof (*rmp));
7593  rmp->_vl_msg_id = ntohs (VL_API_CLASSIFY_SESSION_DETAILS);
7594  rmp->context = context;
7595  rmp->table_id = ntohl (table_id);
7596  rmp->hit_next_index = ntohl (e->next_index);
7597  rmp->advance = ntohl (e->advance);
7598  rmp->opaque_index = ntohl (e->opaque_index);
7599  rmp->match_length = ntohl (match_length);
7600  clib_memcpy (rmp->match, e->key, match_length);
7601 
7602  vl_msg_api_send_shmem (q, (u8 *) & rmp);
7603 }
7604 
7605 static void
7607 {
7610 
7611  u32 table_id = ntohl (mp->table_id);
7613 
7615 
7616  /* *INDENT-OFF* */
7617  pool_foreach (t, cm->tables,
7618  ({
7619  if (table_id == t - cm->tables)
7620  {
7621  vnet_classify_bucket_t * b;
7622  vnet_classify_entry_t * v, * save_v;
7623  int i, j, k;
7624 
7625  for (i = 0; i < t->nbuckets; i++)
7626  {
7627  b = &t->buckets [i];
7628  if (b->offset == 0)
7629  continue;
7630 
7631  save_v = vnet_classify_get_entry (t, b->offset);
7632  for (j = 0; j < (1<<b->log2_pages); j++)
7633  {
7634  for (k = 0; k < t->entries_per_page; k++)
7635  {
7636  v = vnet_classify_entry_at_index
7637  (t, save_v, j*t->entries_per_page + k);
7638  if (vnet_classify_entry_is_free (v))
7639  continue;
7640 
7641  send_classify_session_details
7642  (q, table_id, t->match_n_vectors * sizeof (u32x4),
7643  v, mp->context);
7644  }
7645  }
7646  }
7647  break;
7648  }
7649  }));
7650  /* *INDENT-ON* */
7651 }
7652 
7653 static void
7655 {
7656  vlib_main_t *vm = vlib_get_main ();
7659  ip4_address_t collector, src;
7660  u16 collector_port = UDP_DST_PORT_ipfix;
7661  u32 path_mtu;
7662  u32 template_interval;
7663  u32 fib_id;
7664  u32 fib_index = ~0;
7665  int rv = 0;
7666 
7667  memcpy (collector.data, mp->collector_address, sizeof (collector.data));
7668  collector_port = ntohs (mp->collector_port);
7669  if (collector_port == (u16) ~ 0)
7670  collector_port = UDP_DST_PORT_ipfix;
7671  memcpy (src.data, mp->src_address, sizeof (src.data));
7672  fib_id = ntohl (mp->vrf_id);
7673 
7674  ip4_main_t *im = &ip4_main;
7675  uword *p = hash_get (im->fib_index_by_table_id, fib_id);
7676  if (!p)
7677  {
7678  rv = VNET_API_ERROR_NO_SUCH_FIB;
7679  goto out;
7680  }
7681  fib_index = p[0];
7682 
7683  path_mtu = ntohl (mp->path_mtu);
7684  if (path_mtu == ~0)
7685  path_mtu = 512; // RFC 7011 section 10.3.3.
7686  template_interval = ntohl (mp->template_interval);
7687  if (template_interval == ~0)
7688  template_interval = 20;
7689 
7690  if (collector.as_u32 == 0)
7691  {
7692  rv = VNET_API_ERROR_INVALID_VALUE;
7693  goto out;
7694  }
7695 
7696  if (src.as_u32 == 0)
7697  {
7698  rv = VNET_API_ERROR_INVALID_VALUE;
7699  goto out;
7700  }
7701 
7702  if (path_mtu > 1450 /* vpp does not support fragmentation */ )
7703  {
7704  rv = VNET_API_ERROR_INVALID_VALUE;
7705  goto out;
7706  }
7707 
7708  if (path_mtu < 68)
7709  {
7710  rv = VNET_API_ERROR_INVALID_VALUE;
7711  goto out;
7712  }
7713 
7714  /* Reset report streams if we are reconfiguring IP addresses */
7715  if (frm->ipfix_collector.as_u32 != collector.as_u32 ||
7716  frm->src_address.as_u32 != src.as_u32 ||
7717  frm->collector_port != collector_port)
7719 
7720  frm->ipfix_collector.as_u32 = collector.as_u32;
7721  frm->collector_port = collector_port;
7722  frm->src_address.as_u32 = src.as_u32;
7723  frm->fib_index = fib_index;
7724  frm->path_mtu = path_mtu;
7725  frm->template_interval = template_interval;
7726 
7727  /* Turn on the flow reporting process */
7729 
7730 out:
7731  REPLY_MACRO (VL_API_IPFIX_ENABLE_REPLY);
7732 }
7733 
7734 static void
7736 {
7740 
7742  if (!q)
7743  return;
7744 
7745  rmp = vl_msg_api_alloc (sizeof (*rmp));
7746  memset (rmp, 0, sizeof (*rmp));
7747  rmp->_vl_msg_id = ntohs (VL_API_IPFIX_DETAILS);
7748  rmp->context = mp->context;
7749  memcpy (rmp->collector_address, frm->ipfix_collector.data,
7750  sizeof (frm->ipfix_collector.data));
7751  rmp->collector_port = htons (frm->collector_port);
7752  memcpy (rmp->src_address, frm->src_address.data,
7753  sizeof (frm->src_address.data));
7754  rmp->fib_index = htonl (frm->fib_index);
7755  rmp->path_mtu = htonl (frm->path_mtu);
7756  rmp->template_interval = htonl (frm->template_interval);
7757 
7758  vl_msg_api_send_shmem (q, (u8 *) & rmp);
7759 }
7760 
7761 static void
7763 {
7765  int rv = 0;
7766 
7767  pg_main_t *pg = &pg_main;
7768  u32 sw_if_index = pg_interface_add_or_get (pg, ntohl (mp->interface_id));
7769 
7770  /* *INDENT-OFF* */
7771  REPLY_MACRO2(VL_API_PG_CREATE_INTERFACE_REPLY,
7772  ({
7773  rmp->sw_if_index = ntohl(sw_if_index);
7774  }));
7775  /* *INDENT-ON* */
7776 }
7777 
7778 static void
7780 {
7782  int rv = 0;
7783 
7784  vnet_main_t *vnm = vnet_get_main ();
7786  vnet_hw_interface_t *hi = 0;
7787 
7788  u8 *intf_name = format (0, "pg%d", ntohl (mp->interface_id), 0);
7789  u32 hw_if_index = ~0;
7790  uword *p = hash_get_mem (im->hw_interface_by_name, intf_name);
7791  if (p)
7792  hw_if_index = *p;
7793  vec_free (intf_name);
7794 
7795  if (hw_if_index != ~0)
7796  {
7797  pg_capture_args_t _a, *a = &_a;
7798 
7799  u32 len = ntohl (mp->pcap_name_length);
7800  u8 *pcap_file_name = vec_new (u8, len);
7801  clib_memcpy (pcap_file_name, mp->pcap_file_name, len);
7802 
7803  hi = vnet_get_sup_hw_interface (vnm, hw_if_index);
7804  a->hw_if_index = hw_if_index;
7805  a->dev_instance = hi->dev_instance;
7806  a->is_enabled = mp->is_enabled;
7807  a->pcap_file_name = pcap_file_name;
7808  a->count = ntohl (mp->count);
7809 
7810  clib_error_t *e = pg_capture (a);
7811  if (e)
7812  {
7813  clib_error_report (e);
7814  rv = VNET_API_ERROR_CANNOT_CREATE_PCAP_FILE;
7815  }
7816 
7817  vec_free (pcap_file_name);
7818  }
7819  REPLY_MACRO (VL_API_PG_CAPTURE_REPLY);
7820 }
7821 
7822 static void
7824 {
7826  int rv = 0;
7827 
7828  pg_main_t *pg = &pg_main;
7829  u32 stream_index = ~0;
7830 
7831  int is_enable = mp->is_enabled != 0;
7832  u32 len = ntohl (mp->stream_name_length) - 1;
7833 
7834  if (len > 0)
7835  {
7836  u8 *stream_name = vec_new (u8, len);
7837  clib_memcpy (stream_name, mp->stream_name, len);
7838  uword *p = hash_get_mem (pg->stream_index_by_name, stream_name);
7839  if (p)
7840  stream_index = *p;
7841  vec_free (stream_name);
7842  }
7843 
7844  pg_enable_disable (stream_index, is_enable);
7845 
7846  REPLY_MACRO (VL_API_PG_ENABLE_DISABLE_REPLY);
7847 }
7848 
7849 static void
7852 {
7854  int rv = 0;
7855 
7856  u8 is_ipv6 = mp->is_ipv6;
7857  u8 is_add = mp->is_add;
7858  u8 mask_length = mp->mask_length;
7859  ip4_address_t ip4_addr;
7860  ip6_address_t ip6_addr;
7861  u16 *low_ports = 0;
7862  u16 *high_ports = 0;
7863  u32 vrf_id;
7864  u16 tmp_low, tmp_high;
7865  u8 num_ranges;
7866  int i;
7867 
7868  // Validate port range
7869  num_ranges = mp->number_of_ranges;
7870  if (num_ranges > 32)
7871  { // This is size of array in VPE.API
7872  rv = VNET_API_ERROR_EXCEEDED_NUMBER_OF_RANGES_CAPACITY;
7873  goto reply;
7874  }
7875 
7876  vec_reset_length (low_ports);
7877  vec_reset_length (high_ports);
7878 
7879  for (i = 0; i < num_ranges; i++)
7880  {
7881  tmp_low = mp->low_ports[i];
7882  tmp_high = mp->high_ports[i];
7883  // If tmp_low <= tmp_high then only need to check tmp_low = 0
7884  // If tmp_low <= tmp_high then only need to check tmp_high > 65535
7885  if (tmp_low > tmp_high || tmp_low == 0 || tmp_high > 65535)
7886  {
7887  rv = VNET_API_ERROR_INVALID_VALUE;
7888  goto reply;
7889  }
7890  vec_add1 (low_ports, tmp_low);
7891  vec_add1 (high_ports, tmp_high + 1);
7892  }
7893 
7894  // Validate mask_length
7895  if ((is_ipv6 && mask_length > 128) || (!is_ipv6 && mask_length > 32))
7896  {
7897  rv = VNET_API_ERROR_ADDRESS_LENGTH_MISMATCH;
7898  goto reply;
7899  }
7900 
7901  vrf_id = ntohl (mp->vrf_id);
7902 
7903  if (vrf_id < 1)
7904  {
7905  rv = VNET_API_ERROR_INVALID_VALUE;
7906  goto reply;
7907  }
7908 
7909 
7910  if (is_ipv6)
7911  {
7912  clib_memcpy (ip6_addr.as_u8, mp->address, sizeof (ip6_addr.as_u8));
7914  mask_length,
7915  vrf_id,
7916  low_ports,
7917  high_ports, is_add);
7918  }
7919  else
7920  {
7921  clib_memcpy (ip4_addr.data, mp->address, sizeof (ip4_addr));
7923  mask_length,
7924  vrf_id,
7925  low_ports,
7926  high_ports, is_add);
7927  }
7928 
7929 reply:
7930  vec_free (low_ports);
7931  vec_free (high_ports);
7932  REPLY_MACRO (VL_API_IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY);
7933 }
7934 
7935 static void
7938 {
7939  vlib_main_t *vm = vlib_get_main ();
7941  ip4_main_t *im = &ip4_main;
7942  int rv;
7943  u32 sw_if_index;
7946  uword *p = 0;
7947  int i;
7948 
7950  ntohl (mp->tcp_out_vrf_id);
7952  ntohl (mp->udp_out_vrf_id);
7954  ntohl (mp->tcp_in_vrf_id);
7956  ntohl (mp->udp_in_vrf_id);
7957 
7958 
7959  for (i = 0; i < IP_SOURCE_AND_PORT_RANGE_CHECK_N_PROTOCOLS; i++)
7960  {
7961  if (vrf_id[i] != 0 && vrf_id[i] != ~0)
7962  {
7963  p = hash_get (im->fib_index_by_table_id, vrf_id[i]);
7964 
7965  if (p == 0)
7966  {
7967  rv = VNET_API_ERROR_INVALID_VALUE;
7968  goto reply;
7969  }
7970 
7971  fib_index[i] = p[0];
7972  }
7973  else
7974  fib_index[i] = ~0;
7975  }
7976  sw_if_index = ntohl (mp->sw_if_index);
7977 
7978  VALIDATE_SW_IF_INDEX (mp);
7979 
7980  rv =
7981  set_ip_source_and_port_range_check (vm, fib_index, sw_if_index,
7982  mp->is_add);
7983 
7985 reply:
7986 
7987  REPLY_MACRO (VL_API_IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY);
7988 }
7989 
7990 static void
7992  mp)
7993 {
7995  int rv = 0;
7997  u32 sw_if_index = ~0;
7998 
7999  /* Check src & dst are different */
8000  if (memcmp (mp->src_address, mp->dst_address, 4) == 0)
8001  {
8002  rv = VNET_API_ERROR_SAME_SRC_DST;
8003  goto out;
8004  }
8005 
8006  memset (a, 0, sizeof (*a));
8007 
8008  /* ip addresses sent in network byte order */
8009  clib_memcpy (&(a->src), mp->src_address, 4);
8010  clib_memcpy (&(a->dst), mp->dst_address, 4);
8011  a->is_add = mp->is_add;
8012  a->lsa = ntohl (mp->local_sa_id);
8013  a->rsa = ntohl (mp->remote_sa_id);
8014 
8015  rv = vnet_ipsec_gre_add_del_tunnel (a, &sw_if_index);
8016 
8017 out:
8018  /* *INDENT-OFF* */
8019  REPLY_MACRO2(VL_API_GRE_ADD_DEL_TUNNEL_REPLY,
8020  ({
8021  rmp->sw_if_index = ntohl (sw_if_index);
8022  }));
8023  /* *INDENT-ON* */
8024 }
8025 
8028 {
8030 
8031  rmp = vl_msg_api_alloc (sizeof (*rmp));
8032  memset (rmp, 0, sizeof (*rmp));
8033  rmp->_vl_msg_id = ntohs (VL_API_IPSEC_GRE_TUNNEL_DETAILS);
8034  clib_memcpy (rmp->src_address, &(t->tunnel_src), 4);
8035  clib_memcpy (rmp->dst_address, &(t->tunnel_dst), 4);
8036  rmp->sw_if_index = htonl (t->sw_if_index);
8037  rmp->local_sa_id = htonl (t->local_sa_id);
8038  rmp->remote_sa_id = htonl (t->remote_sa_id);
8039  rmp->context = context;
8040 
8041  vl_msg_api_send_shmem (q, (u8 *) & rmp);
8042 }
8043 
8046 {
8049  ipsec_gre_tunnel_t *t;
8050  u32 sw_if_index;
8051 
8053  if (q == 0)
8054  {
8055  return;
8056  }
8057 
8058  sw_if_index = ntohl (mp->sw_if_index);
8059 
8060  if (~0 == sw_if_index)
8061  {
8062  /* *INDENT-OFF* */
8063  pool_foreach (t, igm->tunnels,
8064  ({
8065  send_ipsec_gre_tunnel_details(t, q, mp->context);
8066  }));
8067  /* *INDENT-ON* */
8068  }
8069  else
8070  {
8071  if ((sw_if_index >= vec_len (igm->tunnel_index_by_sw_if_index)) ||
8072  (~0 == igm->tunnel_index_by_sw_if_index[sw_if_index]))
8073  {
8074  return;
8075  }
8076  t = &igm->tunnels[igm->tunnel_index_by_sw_if_index[sw_if_index]];
8078  }
8079 }
8080 
8081 #define BOUNCE_HANDLER(nn) \
8082 static void vl_api_##nn##_t_handler ( \
8083  vl_api_##nn##_t *mp) \
8084 { \
8085  vpe_client_registration_t *reg; \
8086  vpe_api_main_t * vam = &vpe_api_main; \
8087  unix_shared_memory_queue_t * q; \
8088  \
8089  /* One registration only... */ \
8090  pool_foreach(reg, vam->nn##_registrations, \
8091  ({ \
8092  q = vl_api_client_index_to_input_queue (reg->client_index); \
8093  if (q) { \
8094  /* \
8095  * If the queue is stuffed, turf the msg and complain \
8096  * It's unlikely that the intended recipient is \
8097  * alive; avoid deadlock at all costs. \
8098  */ \
8099  if (q->cursize == q->maxsize) { \
8100  clib_warning ("ERROR: receiver queue full, drop msg"); \
8101  vl_msg_api_free (mp); \
8102  return; \
8103  } \
8104  vl_msg_api_send_shmem (q, (u8 *)&mp); \
8105  return; \
8106  } \
8107  })); \
8108  vl_msg_api_free (mp); \
8109 }
8110 
8111 /*
8112  * vpe_api_hookup
8113  * Add vpe's API message handlers to the table.
8114  * vlib has alread mapped shared memory and
8115  * added the client registration handlers.
8116  * See .../open-repo/vlib/memclnt_vlib.c:memclnt_process()
8117  */
8118 
8119 static clib_error_t *
8121 {
8122  api_main_t *am = &api_main;
8123 
8124 #define _(N,n) \
8125  vl_msg_api_set_handlers(VL_API_##N, #n, \
8126  vl_api_##n##_t_handler, \
8127  vl_noop_handler, \
8128  vl_api_##n##_t_endian, \
8129  vl_api_##n##_t_print, \
8130  sizeof(vl_api_##n##_t), 1);
8132 #undef _
8133 
8134  /*
8135  * Manually register the sr tunnel add del msg, so we trace
8136  * enough bytes to capture a typical segment list
8137  */
8138  vl_msg_api_set_handlers (VL_API_SR_TUNNEL_ADD_DEL,
8139  "sr_tunnel_add_del",
8142  vl_api_sr_tunnel_add_del_t_endian,
8144 
8145 
8146  /*
8147  * Manually register the sr policy add del msg, so we trace
8148  * enough bytes to capture a typical tunnel name list
8149  */
8150  vl_msg_api_set_handlers (VL_API_SR_POLICY_ADD_DEL,
8151  "sr_policy_add_del",
8154  vl_api_sr_policy_add_del_t_endian,
8156 
8157  /*
8158  * Trace space for 8 MPLS encap labels, classifier mask+match
8159  */
8160  am->api_trace_cfg[VL_API_MPLS_ADD_DEL_ENCAP].size += 8 * sizeof (u32);
8161  am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_TABLE].size += 5 * sizeof (u32x4);
8162  am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_SESSION].size
8163  += 5 * sizeof (u32x4);
8164  am->api_trace_cfg[VL_API_VXLAN_ADD_DEL_TUNNEL].size += 16 * sizeof (u32);
8165 
8166  /*
8167  * Thread-safe API messages
8168  */
8169  am->is_mp_safe[VL_API_IP_ADD_DEL_ROUTE] = 1;
8170  am->is_mp_safe[VL_API_GET_NODE_GRAPH] = 1;
8171 
8172  return 0;
8173 }
8174 
8176 
8177 static clib_error_t *
8179 {
8181 
8182  am->vlib_main = vm;
8183  am->vnet_main = vnet_get_main ();
8184  am->interface_events_registration_hash = hash_create (0, sizeof (uword));
8185  am->to_netconf_server_registration_hash = hash_create (0, sizeof (uword));
8186  am->from_netconf_server_registration_hash = hash_create (0, sizeof (uword));
8187  am->to_netconf_client_registration_hash = hash_create (0, sizeof (uword));
8188  am->from_netconf_client_registration_hash = hash_create (0, sizeof (uword));
8189  am->oam_events_registration_hash = hash_create (0, sizeof (uword));
8190 
8191  vl_api_init (vm);
8192  vl_set_memory_region_name ("/vpe-api");
8193  vl_enable_disable_memory_api (vm, 1 /* enable it */ );
8194 
8195  return 0;
8196 }
8197 
8199 
8200 
8201 static clib_error_t *
8203 {
8204  u8 *chroot_path;
8205  u64 baseva, size, pvt_heap_size;
8206  int uid, gid, rv;
8207  const int max_buf_size = 4096;
8208  char *s, *buf;
8209  struct passwd _pw, *pw;
8210  struct group _grp, *grp;
8211  clib_error_t *e;
8212  buf = vec_new (char, 128);
8213  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8214  {
8215  if (unformat (input, "prefix %s", &chroot_path))
8216  {
8217  vec_add1 (chroot_path, 0);
8218  vl_set_memory_root_path ((char *) chroot_path);
8219  }
8220  else if (unformat (input, "uid %d", &uid))
8221  vl_set_memory_uid (uid);
8222  else if (unformat (input, "gid %d", &gid))
8223  vl_set_memory_gid (gid);
8224  else if (unformat (input, "baseva %llx", &baseva))
8225  vl_set_global_memory_baseva (baseva);
8226  else if (unformat (input, "global-size %lldM", &size))
8227  vl_set_global_memory_size (size * (1ULL << 20));
8228  else if (unformat (input, "global-size %lldG", &size))
8229  vl_set_global_memory_size (size * (1ULL << 30));
8230  else if (unformat (input, "global-size %lld", &size))
8232  else if (unformat (input, "global-pvt-heap-size %lldM", &pvt_heap_size))
8233  vl_set_global_pvt_heap_size (pvt_heap_size * (1ULL << 20));
8234  else if (unformat (input, "global-pvt-heap-size size %lld",
8235  &pvt_heap_size))
8236  vl_set_global_pvt_heap_size (pvt_heap_size);
8237  else if (unformat (input, "api-pvt-heap-size %lldM", &pvt_heap_size))
8238  vl_set_api_pvt_heap_size (pvt_heap_size * (1ULL << 20));
8239  else if (unformat (input, "api-pvt-heap-size size %lld",
8240  &pvt_heap_size))
8241  vl_set_api_pvt_heap_size (pvt_heap_size);
8242  else if (unformat (input, "api-size %lldM", &size))
8243  vl_set_api_memory_size (size * (1ULL << 20));
8244  else if (unformat (input, "api-size %lldG", &size))
8245  vl_set_api_memory_size (size * (1ULL << 30));
8246  else if (unformat (input, "api-size %lld", &size))
8247  vl_set_api_memory_size (size);
8248  else if (unformat (input, "uid %s", &s))
8249  {
8250  /* lookup the username */
8251  pw = NULL;
8252  while (((rv =
8253  getpwnam_r (s, &_pw, buf, vec_len (buf), &pw)) == ERANGE)
8254  && (vec_len (buf) <= max_buf_size))
8255  {
8256  vec_resize (buf, vec_len (buf) * 2);
8257  }
8258  if (rv < 0)
8259  {
8260  e = clib_error_return_code (0, rv,
8263  "cannot fetch username %s", s);
8264  vec_free (s);
8265  vec_free (buf);
8266  return e;
8267  }
8268  if (pw == NULL)
8269  {
8270  e =
8271  clib_error_return_fatal (0, "username %s does not exist", s);
8272  vec_free (s);
8273  vec_free (buf);
8274  return e;
8275  }
8276  vec_free (s);
8277  vl_set_memory_uid (pw->pw_uid);
8278  }
8279  else if (unformat (input, "gid %s", &s))
8280  {
8281  /* lookup the group name */
8282  grp = NULL;
8283  while (((rv =
8284  getgrnam_r (s, &_grp, buf, vec_len (buf), &grp)) == ERANGE)
8285  && (vec_len (buf) <= max_buf_size))
8286  {
8287  vec_resize (buf, vec_len (buf) * 2);
8288  }
8289  if (rv != 0)
8290  {
8291  e = clib_error_return_code (0, rv,
8294  "cannot fetch group %s", s);
8295  vec_free (s);
8296  vec_free (buf);
8297  return e;
8298  }
8299  if (grp == NULL)
8300  {
8301  e = clib_error_return_fatal (0, "group %s does not exist", s);
8302  vec_free (s);
8303  vec_free (buf);
8304  return e;
8305  }
8306  vec_free (s);
8307  vec_free (buf);
8308  vl_set_memory_gid (grp->gr_gid);
8309  }
8310  else
8311  return clib_error_return (0, "unknown input `%U'",
8312  format_unformat_error, input);
8313  }
8314  return 0;
8315 }
8316 
8318 
8319 void *
8321 {
8322  return (void *) &unformat_vnet_sw_interface;
8323 }
8324 
8325 #undef vl_api_version
8326 #define vl_api_version(n,v) static u32 vpe_api_version = v;
8327 #include <vpp-api/vpe.api.h>
8328 #undef vl_api_version
8329 
8330 int
8332 {
8333  if (clib_host_to_net_u32 (mp->api_versions[0]) != vpe_api_version)
8334  {
8335  clib_warning ("vpe API mismatch: 0x%08x instead of 0x%08x",
8336  clib_host_to_net_u32 (mp->api_versions[0]),
8337  vpe_api_version);
8338  return -1;
8339  }
8340  return 0;
8341 }
8342 
8343 static u8 *
8344 format_arp_event (u8 * s, va_list * args)
8345 {
8346  vl_api_ip4_arp_event_t *event = va_arg (*args, vl_api_ip4_arp_event_t *);
8347 
8348  s = format (s, "pid %d: %U", event->pid,
8349  format_ip4_address, &event->address);
8350  return s;
8351 }
8352 
8353 static clib_error_t *
8355  unformat_input_t * input, vlib_cli_command_t * cmd)
8356 {
8358  vl_api_ip4_arp_event_t *event;
8359 
8360  if (pool_elts (am->arp_events) == 0)
8361  {
8362  vlib_cli_output (vm, "No active arp event registrations");
8363  return 0;
8364  }
8365 
8366  /* *INDENT-OFF* */
8367  pool_foreach (event, am->arp_events,
8368  ({
8369  vlib_cli_output (vm, "%U", format_arp_event, event);
8370  }));
8371  /* *INDENT-ON* */
8372 
8373  return 0;
8374 }
8375 
8376 /* *INDENT-OFF* */
8378  .path = "show arp event registrations",
8379  .function = show_ip4_arp_events_fn,
8380  .short_help = "Show arp event registrations",
8381 };
8382 /* *INDENT-ON* */
8383 
8384 /*
8385  * fd.io coding-style-patch-verification: ON
8386  *
8387  * Local Variables:
8388  * eval: (c-set-style "gnu")
8389  * End:
8390  */
#define ip_prefix_v4(_a)
Definition: lisp_types.h:61
resolve_t
Definition: api.c:399
#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
#define foreach_ip_interface_address(lm, a, sw_if_index, loop, body)
Definition: lookup.h:622
Reply for IPsec: Add/delete Security Association Database entry.
Definition: vpe.api:3387
Reply for classify table session dump request.
Definition: vpe.api:4506
static_always_inline u8 bd_feature_forward(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:154
#define VNET_SW_INTERFACE_FLAG_UNNUMBERED
Definition: interface.h:422
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:6886
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:4198
DHCP Proxy config response.
Definition: vpe.api:844
u8 psid_length
Definition: map.h:97
Policer operational state response.
Definition: vpe.api:4107
static void vl_api_dhcp_proxy_set_vss_t_handler(vl_api_dhcp_proxy_set_vss_t *mp)
Definition: api.c:3202
Get list of policers.
Definition: vpe.api:4071
ip4_fib_t * find_ip4_fib_by_table_index_or_id(ip4_main_t *im, u32 table_index_or_id, u32 flags)
Get or create an IPv4 fib.
Definition: ip4_forward.c:120
static u8 * format_arp_event(u8 *s, va_list *args)
Definition: api.c:8344
u64 local_cookie[2]
Definition: l2tp.h:32
vmrglw vmrglh hi
DHCP Proxy set / unset vss request.
Definition: vpe.api:859
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:7606
static void vl_api_tap_delete_t_handler(vl_api_tap_delete_t *mp, vlib_main_t *vm)
Definition: api.c:1931
Proxy ARP add / del request.
Definition: vpe.api:512
void pg_enable_disable(u32 stream_index, int is_enable)
Definition: cli.c:55
Classify get table IDs request.
Definition: vpe.api:4397
Dump mpls gre tunnel table.
Definition: vpe.api:4251
static void vl_api_set_arp_neighbor_limit_t_handler(vl_api_set_arp_neighbor_limit_t *mp)
Definition: api.c:3622
static void send_mpls_gre_tunnel_entry(vpe_api_main_t *am, unix_shared_memory_queue_t *q, mpls_gre_tunnel_t *gt, u32 index, u32 context)
Definition: api.c:7089
#define gid_address_ip_version(_a)
Definition: lisp_types.h:209
u8 crypto_algorithm
Definition: vpe.api:3366
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:180
#define vec_foreach_index(var, v)
Iterate over vector indices.
Add / del ipsec gre tunnel request.
Definition: vpe.api:4757
u32 pitr_map_index
Definition: control.h:136
u64 packets
packet counter
Definition: counter.h:166
L2 interface vlan tag rewrite response.
Definition: vpe.api:2078
L2 FIB add entry request.
Definition: vpe.api:1507
#define clib_error_return_code(e, code, flags, args...)
Definition: error.h:105
u8 use_extended_sequence_number
Definition: vpe.api:3374
cop: enable/disable whitelist filtration features on an interface Note: the supplied fib_id must matc...
Definition: vpe.api:3801
static void * vl_api_sr_tunnel_add_del_t_print(vl_api_sr_tunnel_add_del_t *mp, void *handle)
Definition: custom_dump.c:1042
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:3239
sse2_qos_pol_cfg_params_st * configs
Definition: policer.h:29
u32 sa_id
Definition: vpe.api:3309
#define hash_set(h, key, value)
Definition: hash.h:254
l2_input_config_t * configs
Definition: l2_input.h:66
Set bridge flags response.
Definition: vpe.api:1579
int vnet_mpls_gre_delete_fib_tunnels(u32 fib_id)
Definition: interface.c:964
static void vl_api_l2_fib_table_entry_t_handler(vl_api_l2_fib_table_entry_t *mp)
Definition: api.c:4398
static void vl_api_mpls_gre_add_del_tunnel_t_handler(vl_api_mpls_gre_add_del_tunnel_t *mp)
Definition: api.c:2116
Definition: gre.h:60
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:438
static void vl_api_l2_patch_add_del_t_handler(vl_api_l2_patch_add_del_t *mp)
Definition: api.c:4936
static clib_error_t * api_segment_config(vlib_main_t *vm, unformat_input_t *input)
Definition: api.c:8202
DHCP Client config response.
Definition: vpe.api:3162
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
u8 integrity_key_length
Definition: vpe.api:3371
u32 decap_next_index
Definition: lisp_gpe.h:96
LISP locator_set status.
Definition: vpe.api:2760
u32 ip4_multicast_rx_feature_vpath
Built-in multicast feature path indices.
Definition: ip4.h:163
vnet_main_t * vnet_main
Definition: api.c:434
#define gid_address_type(_a)
Definition: lisp_types.h:205
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:800
u32 flags
flags
Definition: vxlan_gpe.h:116
u32 * config_index_by_sw_if_index
Definition: lookup.h:369
static void svm_pop_heap(void *oldheap)
Definition: svm.h:189
u16 stop
Definition: ipsec.h:109
u32 ip4_route_get_next_hop_adj(ip4_main_t *im, u32 fib_index, ip4_address_t *next_hop, u32 next_hop_sw_if_index, u32 explicit_fib_index)
Definition: ip4_forward.c:307
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:1139
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:3673
int map_delete_domain(u32 map_domain_index)
Definition: map.c:320
u32 local_adj_index
Definition: lookup.h:431
Reply for get next node index.
Definition: vpe.api:4598
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:2176
#define BAD_SW_IF_INDEX_LABEL
Definition: api.c:169
static void vl_api_sw_interface_set_unnumbered_t_handler(vl_api_sw_interface_set_unnumbered_t *mp)
Definition: api.c:3452
vpe parser cli string response
Definition: vpe.api:1192
static void vl_api_trace_profile_apply_t_handler(vl_api_trace_profile_apply_t *mp)
Definition: api.c:6758
static u32 vnet_mpls_uc_get_label(u32 label_exp_s_ttl)
Definition: packet.h:29
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:682
add or delete lisp gpe tunnel
Definition: vpe.api:2456
vlib_node_registration_t flow_report_process_node
(constructor) VLIB_REGISTER_NODE (flow_report_process_node)
Definition: flow_report.c:169
u8 tunnel_dst[6]
Definition: mpls.h:58
static void vl_api_lisp_add_del_remote_mapping_t_handler(vl_api_lisp_add_del_remote_mapping_t *mp)
Definition: api.c:5467
a
Definition: bitmap.h:516
static void send_mpls_fib_decap_details(vpe_api_main_t *am, unix_shared_memory_queue_t *q, show_mpls_fib_t *s, u32 rx_table_id, u32 tx_table_id, char *swif_tag, u32 context)
Definition: api.c:7345
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:48
sse2_qos_pol_action_params_st conform_action
Definition: xlate.h:143
u8 vnet_lisp_gpe_enable_disable_status(void)
Definition: lisp_gpe.c:789
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:4835
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:724
void ip4_add_del_route_next_hop(ip4_main_t *im, u32 flags, ip4_address_t *dst_address, u32 dst_address_length, ip4_address_t *next_hop, u32 next_hop_sw_if_index, u32 next_hop_weight, u32 adj_index, u32 explicit_fib_index)
Definition: ip4_forward.c:385
u32 id
Definition: ipsec.h:74
static uword * vlib_process_wait_for_event(vlib_main_t *vm)
Definition: node_funcs.h:602
u32 ip6_route_get_next_hop_adj(ip6_main_t *im, u32 fib_index, ip6_address_t *next_hop, u32 next_hop_sw_if_index, u32 explicit_fib_index)
Definition: ip6_forward.c:301
u32 mask_width
Definition: mpls.h:62
static int ip6_add_del_route_t_handler(vl_api_ip_add_del_route_t *mp)
Definition: api.c:1108
static void vl_api_set_ip_flow_hash_t_handler(vl_api_set_ip_flow_hash_t *mp)
Definition: api.c:3443
format_function_t format_ip6_address
Definition: format.h:87
static void send_vxlan_gpe_tunnel_details(vxlan_gpe_tunnel_t *t, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:5036
Reply for IKEv2: Set IKEv2 profile traffic selector parameters.
Definition: vpe.api:3551
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:5270
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
static void vl_api_bridge_flags_t_handler(vl_api_bridge_flags_t *mp)
Definition: api.c:1821
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
Reply for IKEv2: Set IKEv2 profile authentication method.
Definition: vpe.api:3483
u8 collector_address[16]
Definition: vpe.api:4571
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
uword * policer_config_by_name
Definition: policer.h:33
Vhost-user interface details structure (fix this)
Definition: vpe.api:2224
u8 tunnel_dst_address[16]
Definition: vpe.api:3379
static void vl_api_sw_interface_add_del_address_t_handler(vl_api_sw_interface_add_del_address_t *mp)
Definition: api.c:1363
u32 bvi_sw_if_index
Definition: l2_bd.h:65
ethernet_main_t * ethernet_get_main(vlib_main_t *vm)
Definition: init.c:96
Definition: pg.h:302
Set/unset policer classify interface.
Definition: vpe.api:4148
void vl_set_global_pvt_heap_size(u64 size)
configure or disable LISP PITR node
Definition: vpe.api:2585
static void vl_api_tap_connect_t_handler(vl_api_tap_connect_t *mp, vlib_main_t *vm)
Definition: api.c:1879
Set flags on the interface.
Definition: vpe.api:130
Reply for locator_set add/del.
Definition: vpe.api:2366
IKEv2: Add/delete profile.
Definition: vpe.api:3438
int vnet_set_ip6_classify_intfc(vlib_main_t *vm, u32 sw_if_index, u32 table_index)
Definition: ip6_forward.c:3229
L2-GRE over IPSec packet processing.
ip4_address_t intfc_address
Definition: mpls.h:47
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:64
u16 local_port_start
Definition: vpe.api:3304
Control ping from client to api server request.
Definition: vpe.api:1131
static void vl_api_classify_session_details_t_handler(vl_api_classify_session_details_t *mp)
Definition: api.c:7577
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:7584
ip_lookup_next_t lookup_next_index
Definition: lookup.h:180
static int ip4_add_del_route_t_handler(vl_api_ip_add_del_route_t *mp)
Definition: api.c:892
#define BAD_RX_SW_IF_INDEX_LABEL
Definition: api.c:185
i32 priority
Definition: ipsec.h:153
LISP map resolver status.
Definition: vpe.api:2915
u32 table_id
Definition: ip4.h:59
Create netmap.
Definition: vpe.api:4202
#define REPLY_MACRO2(t, body)
Definition: api.c:141
int size
Definition: api.h:71
clib_error_t * ip6_ioam_trace_profile_set(u32 trace_option_elts, u32 trace_type, u32 node_id, u32 app_data, int has_pot_option, u32 trace_tsp, int has_ppc_option)
int vnet_lisp_gpe_add_del_fwd_entry(vnet_lisp_gpe_add_del_fwd_entry_args_t *a, u32 *hw_if_indexp)
Definition: lisp_gpe.c:539
u8 as_u8[16]
Definition: ip6_packet.h:47
mpls fib decap table response
Definition: vpe.api:4379
u64 as_u64[2]
Definition: ip6_packet.h:50
IP unicast adjacency.
Definition: lookup.h:164
uword * table_id_by_vni
Definition: control.h:124
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:2393
IPsec: Update Security Association keys.
Definition: vpe.api:3406
void send_oam_event(oam_target_t *t)
Definition: api.c:2806
static int arp_change_data_callback(u32 pool_index, u8 *new_mac, u32 sw_if_index, u32 address)
Definition: api.c:6042
OAM event structure.
Definition: vpe.api:736
static void vl_api_vnet_get_summary_stats_t_handler(vl_api_vnet_get_summary_stats_t *mp)
Definition: api.c:2844
#define VALIDATE_SW_IF_INDEX(mp)
Definition: api.c:159
#define IOAM_HBYH_MOD
Reply for gpe_iface add/del.
Definition: vpe.api:2573
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:4404
Fixed length block allocator.
static void vl_api_create_loopback_t_handler(vl_api_create_loopback_t *mp)
Definition: api.c:3501
L2TP tunnel set cookies response.
Definition: vpe.api:1882
u32 inner_fib_index
Definition: mpls.h:49
u32 next_index
Definition: mpls.h:78
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
u32 miss_adj_index
Adjacency index for routing table misses, local punts, and drops.
Definition: lookup.h:431
u8 is_add
Definition: vpe.api:3286
clib_error_t * vnet_lisp_gpe_enable_disable(vnet_lisp_gpe_enable_disable_args_t *a)
Definition: lisp_gpe.c:797
#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:2551
static void vl_api_bridge_domain_details_t_handler(vl_api_bridge_domain_details_t *mp)
Definition: api.c:1639
static void vl_api_policer_add_del_t_handler(vl_api_policer_add_del_t *mp)
Definition: api.c:6841
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)
struct l2fib_entry_result_t::@159::@161 fields
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:3348
u32 index
Definition: node.h:237
vlib_counter_t * maxi
Shared wide counter pairs.
Definition: counter.h:215
static void vl_api_mpls_add_del_decap_t_handler(vl_api_mpls_add_del_decap_t *mp)
Definition: api.c:2311
#define L2_FLOOD
Definition: l2_bd.h:98
Request for a single block of summary stats.
Definition: vpe.api:710
static void vl_api_classify_add_del_table_t_handler(vl_api_classify_add_del_table_t *mp)
Definition: api.c:3817
Set max allowed ARP or ip6 neighbor entries request.
Definition: vpe.api:1205
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
lisp_gpe_tunnel_t * tunnels
Definition: lisp_gpe.h:175
locator_t * locator_pool
Definition: control.h:78
static void vl_api_l2tpv3_create_tunnel_t_handler(vl_api_l2tpv3_create_tunnel_t *mp)
Definition: api.c:4601
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:1276
L2 bridge domain sw interface operational state response.
Definition: vpe.api:3129
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:486
u64 map_error_counter_get(u32 node_index, map_error_t map_error)
Definition: map.c:978
u32 hw_if_index
Definition: mpls.h:64
Reply for IPsec: Add/delete Security Policy Database entry.
Definition: vpe.api:3317
#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:313
clib_error_t * ip4_set_arp_limit(u32 arp_limit)
Definition: arp.c:1323
Add / del gre tunnel request.
Definition: vpe.api:416
u8 tap_name[64]
Definition: vpe.api:262
static void vl_api_classify_set_interface_l2_tables_t_handler(vl_api_classify_set_interface_l2_tables_t *mp)
Definition: api.c:3911
ip_config_main_t rx_config_mains[VNET_N_CAST]
rx/tx interface/feature configuration.
Definition: lookup.h:452
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:490
static int ip6_reset_fib_t_handler(vl_api_reset_fib_t *mp)
Definition: api.c:3037
static void vl_api_sw_interface_dump_t_handler(vl_api_sw_interface_dump_t *mp)
Definition: api.c:2765
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
Definition: gre.h:55
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:3221
vnet_main_t ** vnet_mains
Definition: vnet.h:84
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:7171
IPsec: Add/delete Security Policy Database entry.
Definition: vpe.api:3282
Classify add / del session request.
Definition: vpe.api:1669
#define BAD_TX_SW_IF_INDEX_LABEL
Definition: api.c:201
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:6376
Reply for lisp_add_del_map_request_itr_rlocs.
Definition: vpe.api:2702
int ip6_sr_add_del_policy(ip6_sr_add_del_policy_args_t *a)
Add or Delete a Segment Routing policy.
Definition: sr.c:1426
#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:1151
static void map_domain_counter_unlock(map_main_t *mm)
Definition: map.h:545
LISP locator_set status.
Definition: vpe.api:2777
u32 vni
Definition: vpe.api:2466
static void vl_api_lisp_add_del_adjacency_t_handler(vl_api_lisp_add_del_adjacency_t *mp)
Definition: api.c:5512
ip_adjacency_t * ip_add_adjacency(ip_lookup_main_t *lm, ip_adjacency_t *copy_adj, u32 n_adj, u32 *adj_index_return)
Definition: lookup.c:167
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
Reply to IPFIX enable and configure request.
Definition: vpe.api:4543
Combined counter to hold both packets and byte differences.
Definition: counter.h:164
u8 is_tunnel
Definition: ipsec.h:89
struct _vlib_node_registration vlib_node_registration_t
Delete netmap response.
Definition: vpe.api:4241
struct vnet_sub_interface_t::@120::@121::@123 flags
#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:303
static void vl_api_ipsec_gre_add_del_tunnel_t_handler(vl_api_ipsec_gre_add_del_tunnel_t *mp)
Definition: api.c:7991
l2_flood_member_t * members
Definition: l2_bd.h:71
ip4_address_t src_address
Definition: flow_report.h:82
static void vl_api_sr_multicast_map_add_del_t_handler(vl_api_sr_multicast_map_add_del_t *mp)
Definition: api.c:3767
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:358
#define hash_set_mem(h, key, value)
Definition: hash.h:274
ip_lookup_main_t lookup_main
Definition: ip4.h:115
static void vl_api_ikev2_profile_set_ts_t_handler(vl_api_ikev2_profile_set_ts_t *mp)
Definition: api.c:6400
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:3867
uword * sub_interface_sw_if_index_by_id
Definition: interface.h:348
vlib_main_t * vlib_main
Definition: api.c:433
cop: interface enable/disable junk filtration reply
Definition: vpe.api:3783
u32 loc_num
Definition: vpe.api:2468
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
Definition: ip4.h:123
static void vl_api_l2_fib_table_dump_t_handler(vl_api_l2_fib_table_dump_t *mp)
Definition: api.c:4429
Request for lisp_eid_table_map_details.
Definition: vpe.api:2876
static vlib_node_registration_t link_state_process_node
(constructor) VLIB_REGISTER_NODE (link_state_process_node)
Definition: api.c:551
static void dhcpv6_proxy_config_2(vl_api_dhcp_proxy_config_2_t *mp)
Definition: api.c:3181
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:7251
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:1586
Add/Delete classification table request.
Definition: vpe.api:1628
vl_api_ip4_arp_event_t * arp_events
Definition: api.c:430
unformat_function_t unformat_vnet_sw_interface
Reply for add / del tunnel request.
Definition: vpe.api:434
IPv6 router advertisement config request.
Definition: vpe.api:933
Reply for tap delete request.
Definition: vpe.api:296
L2 bridge domain request operational state details.
Definition: vpe.api:3095
IPFIX dump request.
Definition: vpe.api:4553
int mpls_dest_cmp(void *a1, void *a2)
Definition: mpls.c:581
void vl_set_api_pvt_heap_size(u64 size)
#define clib_error_report(e)
Definition: error.h:125
Set bridge domain ip to mac entry response.
Definition: vpe.api:1610
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:4408
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:7937
#define VNET_HW_INTERFACE_FLAG_LINK_UP
Definition: interface.h:273
static void vl_api_map_summary_stats_t_handler(vl_api_map_summary_stats_t *mp)
Definition: api.c:6575
static void vl_api_sw_if_l2tpv3_tunnel_dump_t_handler(vl_api_sw_if_l2tpv3_tunnel_dump_t *mp)
Definition: api.c:4292
uword * mpls_encap_by_fib_and_dest
Definition: mpls.h:92
static void dhcpv6_proxy_config(vl_api_dhcp_proxy_config_t *mp)
Definition: api.c:3149
u8 policy
Definition: vpe.api:3308
static void vl_api_classify_set_interface_ip_table_t_handler(vl_api_classify_set_interface_ip_table_t *mp)
Definition: api.c:3888
void ip4_maybe_remap_adjacencies(ip4_main_t *im, u32 table_index_or_table_id, u32 flags)
Definition: ip4_forward.c:590
Enable / disable packet generator request.
Definition: vpe.api:4663
Request for gpe tunnel summary status.
Definition: vpe.api:2904
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:278
Definition: l2_fib.h:54
vhost-user interface create request
Definition: vpe.api:2091
static_always_inline u8 bd_feature_uu_flood(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:147
typedef CLIB_PACKED(struct{ip4_address_t address;u32 address_length:6;u32 index:26;})
Definition: api.c:2895
u8 rmt_locs[loc_num]
Definition: vpe.api:2470
u32 encap_index
Definition: mpls.h:51
u16 remote_port_stop
Definition: vpe.api:3303
Reply for locator add/del.
Definition: vpe.api:2396
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:71
u8 crypto_key[128]
Definition: vpe.api:3368
static void vl_api_sr_policy_add_del_t_handler(vl_api_sr_policy_add_del_t *mp)
Definition: api.c:3713
static void vl_api_reset_fib_t_handler(vl_api_reset_fib_t *mp)
Definition: api.c:3118
Add/del policer response.
Definition: vpe.api:4058
#define ip_prefix_version(_a)
Definition: lisp_types.h:59
u64 remote_cookie
Definition: l2tp.h:33
Delete netmap.
Definition: vpe.api:4229
L2 interface ethernet flow point filtering response.
Definition: vpe.api:1946
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
Definition: node_funcs.h:1061
static void send_lisp_gpe_tunnel_details(lisp_gpe_tunnel_t *tunnel, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:5772
static void vl_api_interface_name_renumber_t_handler(vl_api_interface_name_renumber_t *mp)
Definition: api.c:6025
Create netmap response.
Definition: vpe.api:4218
trace_cfg_t * api_trace_cfg
Definition: api.h:128
static void vl_api_proxy_arp_add_del_t_handler(vl_api_proxy_arp_add_del_t *mp)
Definition: api.c:2324
add or delete gpe_iface
Definition: vpe.api:2559
#define VNET_HW_INTERFACE_FLAG_DUPLEX_MASK
Definition: interface.h:278
u8 crypto_key[128]
Definition: ipsec.h:80
int vnet_create_loopback_interface(u32 *sw_if_indexp, u8 *mac_address)
Definition: interface.c:389
static void vl_api_map_del_domain_t_handler(vl_api_map_del_domain_t *mp)
Definition: api.c:6466
u32 * tunnel_index_by_sw_if_index
Definition: gre.h:75
int vnet_lisp_add_del_adjacency(vnet_lisp_add_del_adjacency_args_t *a)
Definition: control.c:989
u32 custom_dev_instance
Definition: vpe.api:265
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
ip4_address_t ipfix_collector
Definition: flow_report.h:80
Request for map resolver summary status.
Definition: vpe.api:2926
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:5564
u8 protocol
Definition: vpe.api:3300
Adjacency to drop this packet.
Definition: lookup.h:63
Interface bridge mode response.
Definition: vpe.api:1491
u32 spi
Definition: ipsec.h:75
u32 index
Definition: ip4.h:62
port_range_t lport
Definition: ipsec.h:161
uword value[0]
Definition: hash.h:164
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:1678
IPv6 segment routing tunnel add / del response.
Definition: vpe.api:1287
Get list of map domains.
Definition: vpe.api:3696
map_resolver_t * map_resolvers
Definition: control.h:110
static vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)
ip4_address_t tunnel_dst
Definition: gre.h:54
static void vl_api_ip_address_dump_t_handler(vl_api_ip_address_dump_t *mp)
Definition: api.c:4224
static f64 vlib_last_vector_length_per_node(vlib_main_t *vm)
Definition: main.h:273
OAM add / del target response.
Definition: vpe.api:788
static locator_t * unformat_lisp_locs(void *rmt_locs, u32 rloc_num)
Definition: api.c:5317
api_main_t api_main
Definition: api.h:185
Dump ipsec gre tunnel table.
Definition: vpe.api:4783
static void vl_api_pg_enable_disable_t_handler(vl_api_pg_enable_disable_t *mp)
Definition: api.c:7823
ip6_address_t * segments
segment list, when inserting an ip6 SR header
Definition: sr.h:105
add or delete LISP adjacency adjacency
Definition: vpe.api:2660
ipsec_gre_tunnel_t * tunnels
pool of tunnel instances
Definition: ipsec_gre.h:68
u8 pcap_file_name[pcap_name_length]
Definition: vpe.api:4644
#define VNET_HW_INTERFACE_FLAG_SPEED_MASK
Definition: interface.h:290
u32 bd_id
Definition: vpe.api:2284
PacketGenerator capture packets on given interface request.
Definition: vpe.api:4636
Create host-interface response.
Definition: vpe.api:3980
u8 mac_address[6]
Definition: vpe.api:263
u32 spd_id
Definition: vpe.api:3288
vnet_main_t * vnet_get_main(void)
Definition: misc.c:45
static void vl_api_ipsec_gre_tunnel_dump_t_handler(vl_api_ipsec_gre_tunnel_dump_t *mp)
Definition: api.c:8045
L2 bridge domain operational state response.
Definition: vpe.api:3111
u8 local_address_start[16]
Definition: vpe.api:3297
u32 sw_if_index
Definition: gre.h:57
static void dhcpv4_proxy_config(vl_api_dhcp_proxy_config_t *mp)
Definition: api.c:3133
mpls_decap_t * decaps
Definition: mpls.h:95
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:3320
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:1734
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:689
static void vl_api_create_vhost_user_if_t_handler(vl_api_create_vhost_user_if_t *mp)
Definition: api.c:4020
Get node index using name request.
Definition: vpe.api:1763
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:86
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:538
u8 is_tunnel
Definition: vpe.api:3376
static void vl_api_ipsec_spd_add_del_entry_t_handler(vl_api_ipsec_spd_add_del_entry_t *mp)
Definition: api.c:6197
#define VNET_SW_INTERFACE_FLAG_PROXY_ARP
Definition: interface.h:420
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:3856
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:6477
u8 crypto_key_length
Definition: vpe.api:3367
static void vl_api_get_node_graph_t_handler(vl_api_get_node_graph_t *mp)
Definition: api.c:6699
void vl_set_global_memory_size(u64 size)
u32 context
Definition: vpe.api:2283
u32 sad_id
Definition: vpe.api:3360
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:111
Reply for add / del ipsec gre tunnel request.
Definition: vpe.api:4772
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:6823
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:525
static void vl_api_trace_profile_add_t_handler(vl_api_trace_profile_add_t *mp)
Definition: api.c:6735
DHCP Proxy config 2 add / del request.
Definition: vpe.api:1807
static void * svm_push_data_heap(svm_region_t *rp)
Definition: svm.h:181
Classify sessions dump request.
Definition: vpe.api:4490
static void vl_api_lisp_gpe_tunnel_dump_t_handler(vl_api_lisp_gpe_tunnel_dump_t *mp)
Definition: api.c:5803
Reply for IPsec: Update Security Association keys.
Definition: vpe.api:3425
static int arp_change_delete_callback(u32 pool_index, u8 *notused)
Definition: api.c:6079
#define MODE_L2_BRIDGE
Definition: l2_input.h:216
static void vl_api_l2_fib_clear_table_t_handler(vl_api_l2_fib_clear_table_t *mp)
Definition: api.c:3945
void vl_set_memory_uid(int uid)
Reply for gpe enable/disable.
Definition: vpe.api:2526
#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:501
vlib_combined_counter_main_t * domain_counters
Definition: map.h:199
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
static void vl_api_lisp_add_del_local_eid_t_handler(vl_api_lisp_add_del_local_eid_t *mp)
Definition: api.c:5227
Set interface source and L4 port-range request.
Definition: vpe.api:4726
Reply for the vlan subinterface create request.
Definition: vpe.api:339
u8 is_add
Definition: lisp_gpe.h:267
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
int mpls_fib_reset_labels(u32 fib_id)
Definition: mpls.c:703
Delete Trace Profile.
Definition: vpe.api:3942
int i32
Definition: types.h:81
#define hash_foreach(key_var, value_var, h, body)
Definition: hash.h:407
int vl_api_memclnt_delete_callback(u32 client_index)
Definition: api.c:452
u32 feature_bitmap
Definition: vpe.api:1543
#define clib_error_return_fatal(e, args...)
Definition: error.h:117
#define REPLY_MACRO(t)
Definition: api.c:125
u8 * name
optional name argument - for referencing SR tunnel/policy by name
Definition: sr.h:99
ip6_fib_t * find_ip6_fib_by_table_index_or_id(ip6_main_t *im, u32 table_index_or_id, u32 flags)
Get or create an IPv6 fib.
Definition: ip6_forward.c:185
struct sse2_qos_pol_cfg_params_st_::@190::@191 kbps
#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:8120
static_always_inline u8 bd_feature_arp_term(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:167
int ip6_interface_enabled(vlib_main_t *vm, u32 sw_if_index)
#define L2_UU_FLOOD
Definition: l2_bd.h:99
void api_config_default_ip_route(u8 is_ipv6, u8 is_add, u32 vrf_id, u32 sw_if_index, u8 *next_hop_addr)
Definition: api.c:1320
u16 start
Definition: ipsec.h:109
u32 outer_fib_index
Definition: mpls.h:50
u32 ip4_fib_lookup_with_table(ip4_main_t *im, u32 fib_index, ip4_address_t *dst, u32 disable_default_route)
Definition: ip4_forward.c:58
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:7779
static vlib_node_registration_t vpe_resolver_process_node
(constructor) VLIB_REGISTER_NODE (vpe_resolver_process_node)
Definition: api.c:437
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:6423
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:2275
Get LISP map request itr rlocs status.
Definition: vpe.api:2959
get_node_graph_reply
Definition: vpe.api:3844
ip6_address_t * rules
Definition: map.h:87
static vlib_cli_command_t show_ip4_arp_events
(constructor) VLIB_CLI_COMMAND (show_ip4_arp_events)
Definition: api.c:8377
add or delete map request itr rlocs
Definition: vpe.api:2689
Reply for add / del encapsulation request.
Definition: vpe.api:466
Reply for MPLS Ethernet add / delete tunnel request.
Definition: vpe.api:1396
#define clib_warning(format, args...)
Definition: error.h:59
IPv6 interface enable / disable request.
Definition: vpe.api:1011
u32 table_index_or_table_id
Definition: ip6.h:367
Delete host-interface.
Definition: vpe.api:3992
void ip_address_copy_addr(void *dst, ip_address_t *src)
Definition: lisp_types.c:679
unsigned long u64
Definition: types.h:89
u8 rmt_len
Definition: vpe.api:2464
clib_error_t * ip6_set_neighbor_limit(u32 neighbor_limit)
Set/unset input ACL interface.
Definition: vpe.api:3179
void vnet_l2_classify_enable_disable(u32 sw_if_index, int enable_disable)
Definition: l2_classify.c:433
Dump mpls fib decap table.
Definition: vpe.api:4363
Control ping from client to api server request, no print json output.
Definition: vpe.api:1155
int vnet_lisp_eid_table_map(u32 vni, u32 dp_id, u8 is_l2, u8 is_add)
Definition: control.c:643
#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
int vnet_arp_unset_ip4_over_ethernet(vnet_main_t *vnm, u32 sw_if_index, u32 fib_index, void *a_arg)
Definition: arp.c:1461
union sse2_qos_pol_cfg_params_st_::@190 rb
This packet is for one of our own IP addresses.
Definition: lookup.h:68
#define ip_addr_v4(_a)
Definition: lisp_types.h:41
IKEv2: Set IKEv2 profile local/remote identification.
Definition: vpe.api:3499
u8 * format_ipsec_integ_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:90
Trace profile apply response.
Definition: vpe.api:3931
Reply for classify table id by interface index request.
Definition: vpe.api:4436
Initialize a new tap interface with the given paramters.
Definition: vpe.api:225
IKEv2: Set IKEv2 profile traffic selector parameters.
Definition: vpe.api:3533
int l2tpv3_interface_enable_disable(vnet_main_t *vnm, u32 sw_if_index, int enable_disable)
Definition: l2tp.c:614
A collection of simple counters.
Definition: counter.h:59
static lisp_cp_main_t * vnet_lisp_cp_get_main()
Definition: control.h:157
int vnet_set_ip4_classify_intfc(vlib_main_t *vm, u32 sw_if_index, u32 table_index)
Definition: ip4_forward.c:3565
u8 collector_address[16]
Definition: vpe.api:4532
ip6_fib_t * fibs
Definition: ip6.h:118
static void vl_api_sw_interface_vhost_user_details_t_handler(vl_api_sw_interface_vhost_user_details_t *mp)
Definition: api.c:4099
void ip6_add_del_route(ip6_main_t *im, ip6_add_del_route_args_t *args)
Definition: ip6_forward.c:208
u8 is_add
Definition: vpe.api:2460
uword * bd_index_by_bd_id
Definition: l2_bd.h:27
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:3518
mpls_gre_tunnel_t * gre_tunnels
Definition: mpls.h:83
i32 priority
Definition: vpe.api:3289
Definition: lisp_gpe.h:265
u32 hw_if_index
Definition: l2tp.h:38
Reply for tap connect request.
Definition: vpe.api:241
u8 * pcap_file_name
Definition: pg.h:361
stats_main_t stats_main
Definition: stats.c:21
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:542
clib_error_t * ip6_probe_neighbor(vlib_main_t *vm, ip6_address_t *dst, u32 sw_if_index)
Definition: ip6_forward.c:2261
Classify add / del session response.
Definition: vpe.api:1685
#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:390
l2tpv3 tunnel interface create response
Definition: vpe.api:1862
static void vl_api_bridge_domain_sw_if_details_t_handler(vl_api_bridge_domain_sw_if_details_t *mp)
Definition: api.c:1646
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:2296
u32 hw_if_index
Definition: mpls.h:52
IPSec-GRE tunnel add/del arguments.
Definition: ipsec_gre.h:93
Configure IP source and L4 port-range check.
Definition: vpe.api:4695
Interface set vpath response.
Definition: vpe.api:1363
static void vl_api_policer_classify_set_interface_t_handler(vl_api_policer_classify_set_interface_t *mp)
Definition: api.c:6976
uword * hw_interface_by_name
Definition: interface.h:481
clib_error_t * vnet_lisp_enable_disable(u8 is_enable)
Definition: control.c:1884
Delete tap interface.
Definition: vpe.api:285
u8 local_address_stop[16]
Definition: vpe.api:3298
void vl_api_ip_add_del_route_t_handler(vl_api_ip_add_del_route_t *mp)
Definition: api.c:1301
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:1355
static_always_inline u8 bd_feature_flood(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:140
clib_error_t * ip4_probe_neighbor(vlib_main_t *vm, ip4_address_t *dst, u32 sw_if_index)
Definition: ip4_forward.c:2584
Delete MAP domain.
Definition: vpe.api:3648
vnet_api_error_t api_errno
Definition: vnet.h:78
void dsunlock(stats_main_t *sm)
Definition: stats.c:88
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:326
int vnet_set_ip4_flow_hash(u32 table_id, u32 flow_hash_config)
Definition: ip4_forward.c:3502
Reply for gpe enable/disable.
Definition: vpe.api:2548
ip4_address_t intfc_address
Definition: mpls.h:59
void vl_set_memory_root_path(char *root_path)
u32 gid_dictionary_lookup(gid_dictionary_t *db, gid_address_t *key)
ip6_address_t dst_address
Definition: ip6.h:370
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:411
clib_error_t * ikev2_set_profile_id(vlib_main_t *vm, u8 *name, u8 id_type, u8 *data, int is_local)
Definition: ikev2.c:2069
Set L2 flags request !!! TODO - need more info, feature bits in l2_input.h.
Definition: vpe.api:1537
format_function_t format_vnet_sw_interface_name
#define VNET_HW_INTERFACE_FLAG_DUPLEX_SHIFT
Definition: interface.h:275
u8 is_del
Delete the tunnnel?
Definition: sr.h:120
Reply for lisp_pitr_set_locator_set.
Definition: vpe.api:2597
int vnet_lisp_pitr_set_locator_set(u8 *locator_set_name, u8 is_add)
Definition: control.c:1274
#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
static void vl_api_mpls_fib_decap_details_t_handler(vl_api_mpls_fib_decap_details_t *mp)
Definition: api.c:7339
int vnet_l2_classify_set_tables(u32 sw_if_index, u32 ip4_table_index, u32 ip6_table_index, u32 other_table_index)
Definition: l2_classify.c:445
#define IOAM_HBYH_POP
vnet_sub_interface_t sub
Definition: interface.h:447
static void vl_api_ikev2_profile_set_auth_t_handler(vl_api_ikev2_profile_set_auth_t *mp)
Definition: api.c:6352
static void dhcpv4_proxy_config_2(vl_api_dhcp_proxy_config_2_t *mp)
Definition: api.c:3164
L2 fib clear table request, clear all mac entries in the l2 fib.
Definition: vpe.api:1912
u64 mac
Definition: vpe.api:2285
void ip6_maybe_remap_adjacencies(ip6_main_t *im, u32 table_index_or_table_id, u32 flags)
Definition: ip6_forward.c:650
Set/unset input ACL interface response.
Definition: vpe.api:3194
uword * fib_index_by_table_id
Hash table mapping table id to fib index.
Definition: ip4.h:127
Configure IP source and L4 port-range check reply.
Definition: vpe.api:4713
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:929
static void vl_api_lisp_add_del_locator_t_handler(vl_api_lisp_add_del_locator_t *mp)
Definition: api.c:5161
#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
static void vl_api_lisp_gpe_enable_disable_t_handler(vl_api_lisp_gpe_enable_disable_t *mp)
Definition: api.c:5390
mpls eth tunnel operational state response
Definition: vpe.api:4312
static void vl_api_mpls_eth_tunnel_dump_t_handler(vl_api_mpls_eth_tunnel_dump_t *mp)
Definition: api.c:7211
#define VNET_HW_INTERFACE_FLAG_SPEED_SHIFT
Definition: interface.h:283
u32 entry_index
Definition: mpls.h:234
Trace profile add / del response.
Definition: vpe.api:3953
int vhost_user_delete_if(vnet_main_t *vnm, vlib_main_t *vm, u32 sw_if_index)
Definition: vhost-user.c:1632
#define gid_address_mac(_a)
Definition: lisp_types.h:211
Struct for VXLAN GPE tunnel.
Definition: vxlan_gpe.h:90
u32 local_session_id
Definition: l2tp.h:34
Set/unset l2 classification tables for an interface response.
Definition: vpe.api:1740
char * vpe_api_get_version(void)
Definition: version.c:88
static clib_error_t * vpe_api_init(vlib_main_t *vm)
Definition: api.c:8178
IPsec: Add/delete Security Policy Database.
Definition: vpe.api:3207
static void vl_api_control_ping_t_handler(vl_api_control_ping_t *mp)
Definition: api.c:3531
#define ip_prefix_v6(_a)
Definition: lisp_types.h:62
IPv6 segment routing tunnel add / del request.
Definition: vpe.api:1265
IPv6 segment routing multicast map to policy add / del request.
Definition: vpe.api:1326
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:3381
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:521
L2 FIB add entry response.
Definition: vpe.api:1524
map_domain_t * domains
Definition: map.h:195
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:4276
Set/unset l2 classification tables for an interface request.
Definition: vpe.api:1725
static void vl_api_lisp_eid_table_map_dump_t_handler(vl_api_lisp_eid_table_map_dump_t *mp)
Definition: api.c:5896
Add/Delete classification table response.
Definition: vpe.api:1650
ip_adjacency_t * add_adj
Definition: ip6.h:379
Set L2 bits response.
Definition: vpe.api:1550
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:3084
static void vl_api_classify_table_by_interface_t_handler(vl_api_classify_table_by_interface_t *mp)
Definition: api.c:7478
Set bridge domain ip to mac entry request.
Definition: vpe.api:1595
void gid_address_free(gid_address_t *a)
Definition: lisp_types.c:645
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:1794
sse2_qos_pol_action_params_st violate_action
Definition: xlate.h:145
#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:1853
u8 stream_name[stream_name_length]
Definition: vpe.api:4669
vhost-user interface create response
Definition: vpe.api:2108
uword * sw_if_index_by_sup_and_sub
Definition: interface.h:495
vxlan_gpe_main_t vxlan_gpe_main
Definition: vxlan_gpe.c:23
u8 authoritative
Definition: lisp_types.h:287
add or delete lisp eid-table
Definition: vpe.api:2415
static void vl_api_mpls_fib_encap_dump_t_handler(vl_api_mpls_fib_encap_dump_t *mp)
Definition: api.c:7287
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:2644
IOAM Trace : Set TRACE profile.
Definition: vpe.api:3883
static void vl_api_delete_vhost_user_if_t_handler(vl_api_delete_vhost_user_if_t *mp)
Definition: api.c:4069
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:111
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
IPv6 router advertisement prefix config response.
Definition: vpe.api:999
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:5372
u8 protocol
encapsulated protocol
Definition: vxlan_gpe.h:95
u32 index
Definition: ip6.h:69
u32 tx_sw_if_index
Definition: mpls.h:60
static clib_error_t * link_up_down_function(vnet_main_t *vm, u32 hw_if_index, u32 flags)
Definition: api.c:562
u32 pg_interface_add_or_get(pg_main_t *pg, uword stream_index)
Definition: stream.c:146
vlib_simple_counter_main_t * sw_if_counters
Definition: interface.h:500
static void vl_api_trace_profile_del_t_handler(vl_api_trace_profile_del_t *mp)
Definition: api.c:6780
map_main_t map_main
Definition: map.h:306
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:62
Tell client about an ip4 arp resolution event.
Definition: vpe.api:3046
u8 is_add
Definition: vpe.api:3358
MPLS Ethernet add/ del tunnel 2.
Definition: vpe.api:1415
Set unnumbered interface add / del response.
Definition: vpe.api:1075
static void vl_api_policer_dump_t_handler(vl_api_policer_dump_t *mp)
Definition: api.c:6927
int ip6_sr_add_del_tunnel(ip6_sr_add_del_tunnel_args_t *a)
Add or Delete a Segment Routing tunnel.
Definition: sr.c:837
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:4797
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:575
u16 local_port_stop
Definition: vpe.api:3305
static int unformat_lisp_eid_api(gid_address_t *dst, u32 vni, u8 type, void *src, u8 len)
Definition: api.c:5195
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:776
void ip_prefix_normalize(ip_prefix_t *a)
Definition: lisp_types.c:745
int vhost_user_dump_ifs(vnet_main_t *vnm, vlib_main_t *vm, vhost_user_intf_details_t **out_vuids)
Definition: vhost-user.c:2037
Set/unset interface classification table response.
Definition: vpe.api:1711
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)
u32 index
Definition: lookup.c:2179
cop: interface enable/disable junk filtration reply
Definition: vpe.api:3817
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
ip_adjacency_t * add_adj
Definition: ip4.h:337
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:2108
#define gid_address_ippref(_a)
Definition: lisp_types.h:206
Classify table info.
Definition: vpe.api:4451
u8 bvi_mac
Definition: vpe.api:2289
static void vl_api_l2_interface_efp_filter_t_handler(vl_api_l2_interface_efp_filter_t *mp)
Definition: api.c:3963
sse2_qos_pol_action_params_st exceed_action
Definition: xlate.h:144
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:3559
IP Set the next node for a given node response.
Definition: vpe.api:1789
uword * fib_index_by_table_id
Definition: ip6.h:127
u32 mask_width
Definition: mpls.h:48
ip6_address_t * src_address
Key (header imposition case)
Definition: sr.h:92
This packet needs to be classified.
Definition: lookup.h:81
#define foreach_vpe_api_msg
Definition: api.c:218
static void vl_api_mpls_eth_tunnel_details_t_handler(vl_api_mpls_eth_tunnel_details_t *mp)
Definition: api.c:7164
Get node index using name request.
Definition: vpe.api:1751
Reply for IPsec: Add/delete Security Policy Database entry.
Definition: vpe.api:3220
Reply for lisp_add_del_adjacency.
Definition: vpe.api:2677
static uword vlib_process_get_events_with_type(vlib_main_t *vm, uword **data_vector, uword with_type_opaque)
Definition: node_funcs.h:580
L2 fib clear table response.
Definition: vpe.api:1922
static void vl_api_sw_interface_set_table_t_handler(vl_api_sw_interface_set_table_t *mp)
Definition: api.c:1391
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:575
#define VNET_HW_INTERFACE_BOND_INFO_SLAVE
Definition: interface.h:359
Enable and configure IPFIX exporter process request.
Definition: vpe.api:4528
u32 sw_if_index
Definition: lisp_types.h:254
int vnet_vxlan_add_del_tunnel(vnet_vxlan_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
Definition: vxlan.c:213
#define foreach_classify_add_del_table_field
Definition: api.c:3807
mpls fib encap table response
Definition: vpe.api:4347
Delete loopback interface response.
Definition: vpe.api:1121
static void vl_api_cop_whitelist_enable_disable_t_handler(vl_api_cop_whitelist_enable_disable_t *mp)
Definition: api.c:6676
IPsec: Add/delete SPD from interface.
Definition: vpe.api:3236
Request for lisp-gpe protocol status.
Definition: vpe.api:2936
static void vl_api_lisp_eid_table_dump_t_handler(vl_api_lisp_eid_table_dump_t *mp)
Definition: api.c:5730
u32 vni
Definition: lisp_gpe.h:287
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:1859
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:412
PacketGenerator create interface request.
Definition: vpe.api:4610
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:591
Set the ip flow hash config for a fib request.
Definition: vpe.api:892
void * vl_msg_api_alloc(int nbytes)
u16 remote_port_start
Definition: vpe.api:3302
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:2356
Reply for Proxy ARP interface enable / disable request.
Definition: vpe.api:551
enable or disable LISP feature
Definition: vpe.api:2537
Reply for interface events registration.
Definition: vpe.api:3032
mpls_main_t mpls_main
Definition: mpls.c:21
Reply for lisp_add_del_remote_mapping.
Definition: vpe.api:2642
void l2fib_clear_table(uint keep_static)
Definition: l2_fib.c:212
Create host-interface.
Definition: vpe.api:3966
vhost-user interface delete response
Definition: vpe.api:2155
static void vl_api_vxlan_gpe_add_del_tunnel_t_handler(vl_api_vxlan_gpe_add_del_tunnel_t *mp)
Definition: api.c:4960
u8 remote_address_stop[16]
Definition: vpe.api:3296
Shows relationship between vni and vrf.
Definition: vpe.api:2865
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:4314
L2 interface patch add / del response.
Definition: vpe.api:1243
pending_route_t * pending_routes
Definition: api.c:427
int vnet_arp_set_ip4_over_ethernet(vnet_main_t *vnm, u32 sw_if_index, u32 fib_index, void *a_arg, int is_static)
Definition: arp.c:363
void gid_address_ip_set(gid_address_t *dst, void *src, u8 version)
Definition: lisp_types.c:1254
static void vl_api_ikev2_profile_add_del_t_handler(vl_api_ikev2_profile_add_del_t *mp)
Definition: api.c:6330
static void vl_api_sw_interface_set_flags_t_handler(vl_api_sw_interface_set_flags_t *mp)
Definition: api.c:2557
cop: enable/disable junk filtration features on an interface
Definition: vpe.api:3770
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:508
IPsec: Add/delete Security Association Database entry.
Definition: vpe.api:3354
#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:152
static void vl_api_bridge_domain_dump_t_handler(vl_api_bridge_domain_dump_t *mp)
Definition: api.c:1695
int vnet_delete_loopback_interface(u32 sw_if_index)
Definition: interface.c:525
#define gid_address_ippref_len(_a)
Definition: lisp_types.h:207
Definition: ip6.h:64
u64 bytes
byte counter
Definition: counter.h:167
Set/unset the classification table for an interface request.
Definition: vpe.api:1698
u32 drop_adj_index
Definition: lookup.h:431
static void add_routes_in_fib(clib_bihash_kv_24_8_t *kvp, void *arg)
Definition: api.c:3020
Delete host-interface response.
Definition: vpe.api:4004
Definition: ip4.h:48
Dump mpls fib table.
Definition: vpe.api:4333
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:1900
IPv6 segment routing multicast map to policy add / del response.
Definition: vpe.api:1339
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:160
static void set_ip4_flow_hash(vl_api_set_ip_flow_hash_t *mp)
Definition: api.c:3423
u32 locator_set_index
Definition: lisp_types.h:283
char * vpe_api_get_build_directory(void)
Definition: version.c:82
IPv6 interface enable / disable response.
Definition: vpe.api:1023
#define clib_memcpy(a, b, c)
Definition: string.h:63
static u32 ip4_fib_lookup(ip4_main_t *im, u32 sw_if_index, ip4_address_t *dst)
Definition: ip4.h:232
Reply for map_summary_stats request.
Definition: vpe.api:3752
u8 remote_address_start[16]
Definition: vpe.api:3295
int cop_interface_enable_disable(u32 sw_if_index, int enable_disable)
Definition: cop.c:151
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:114
ip4_address_t tunnel_src
Definition: gre.h:53
static void vl_api_sw_interface_tap_dump_t_handler(vl_api_sw_interface_tap_dump_t *mp)
Definition: api.c:4332
u32 ip6_fib_lookup_with_table(ip6_main_t *im, u32 fib_index, ip6_address_t *dst)
Definition: ip6_forward.c:61
int vnet_mpls_add_del_decap(u32 rx_fib_id, u32 tx_fib_id, u32 label_host_byte_order, int s_bit, int next_index, int is_add)
Definition: mpls.c:369
#define IP6_ROUTE_FLAG_DEL
Definition: ip6.h:352
static void vnet_interface_counter_unlock(vnet_interface_main_t *im)
Definition: interface.h:524
static clib_error_t * show_ip4_arp_events_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: api.c:8354
static void send_lisp_map_resolver_details(ip_address_t *ip, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:5829
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:172
add or delete map-resolver
Definition: vpe.api:2491
Reply for IP Neighbor add / delete request.
Definition: vpe.api:586
static void vl_api_get_node_index_t_handler(vl_api_get_node_index_t *mp)
Definition: api.c:4497
u8 lcl_len
Definition: vpe.api:2465
Reply for lisp_eid_table_add_del_map.
Definition: vpe.api:2729
#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:1535
u8 tunnel_src_address[16]
Definition: vpe.api:3378
int ipsec_add_del_spd(vlib_main_t *vm, u32 spd_id, int is_add)
Definition: ipsec.c:105
#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:5340
IPSec-GRE state.
Definition: ipsec_gre.h:66
int vnet_lisp_gpe_add_del_iface(vnet_lisp_gpe_add_del_iface_args_t *a, u32 *hw_if_indexp)
Definition: interface.c:1060
u32 decap_next_index
Definition: vxlan.h:78
This packet matches an "interface route" and packets need to be passed to ARP to find rewrite string ...
Definition: lookup.h:73
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:539
mpls_eth_tunnel_t * eth_tunnels
Definition: mpls.h:87
u32 rsa
remote IPSec SA id
Definition: ipsec_gre.h:100
Request for map lisp locator status.
Definition: vpe.api:2745
static void vl_api_mpls_gre_tunnel_dump_t_handler(vl_api_mpls_gre_tunnel_dump_t *mp)
Definition: api.c:7130
static void vl_api_tap_modify_t_handler(vl_api_tap_modify_t *mp, vlib_main_t *vm)
Definition: api.c:1905
clib_error_t * enable_ip6_interface(vlib_main_t *vm, u32 sw_if_index)
struct ip_adjacency_t::@143::@146 classify
IP_LOOKUP_NEXT_CLASSIFY only.
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:256
static void vl_api_mpls_add_del_encap_t_handler(vl_api_mpls_add_del_encap_t *mp)
Definition: api.c:2287
lisp_gpe_main_t lisp_gpe_main
Definition: lisp_gpe.c:19
static void vl_api_cop_interface_enable_disable_t_handler(vl_api_cop_interface_enable_disable_t *mp)
Definition: api.c:6657
void ip6_add_del_route_next_hop(ip6_main_t *im, u32 flags, ip6_address_t *dst_address, u32 dst_address_length, ip6_address_t *next_hop, u32 next_hop_sw_if_index, u32 next_hop_weight, u32 adj_index, u32 explicit_fib_index)
Definition: ip6_forward.c:397
PacketGenerator capture packets response.
Definition: vpe.api:4651
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:1571
Delete loopback interface request.
Definition: vpe.api:1110
#define IP4_ROUTE_FLAG_DEL
Definition: ip4.h:309
static void vl_api_ipsec_spd_add_del_t_handler(vl_api_ipsec_spd_add_del_t *mp)
Definition: api.c:6151
port_range_t rport
Definition: ipsec.h:162
static void map_domain_counter_lock(map_main_t *mm)
Definition: map.h:538
static void vl_api_lisp_locator_set_dump_t_handler(vl_api_lisp_locator_set_dump_t *mp)
Definition: api.c:5631
static void vl_api_mpls_fib_encap_details_t_handler(vl_api_mpls_fib_encap_details_t *mp)
Definition: api.c:7245
Reply for local_eid add/del.
Definition: vpe.api:2431
Set/unset policer classify interface response.
Definition: vpe.api:4163
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:786
static void vl_api_sw_interface_set_l2_bridge_t_handler(vl_api_sw_interface_set_l2_bridge_t *mp)
Definition: api.c:1552
vhost-user interface modify request
Definition: vpe.api:2120
struct vnet_sub_interface_t::@120 eth
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
static void vl_api_ipfix_enable_t_handler(vl_api_ipfix_enable_t *mp)
Definition: api.c:7654
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:1969
u32 sw_if_index
Definition: vpe.api:2286
#define foreach_flow_hash_bit
Definition: lookup.h:152
ip46_address_range_t raddr
Definition: ipsec.h:159
u32 ip6_multicast_rx_feature_vpath
Definition: ip6.h:158
Set L2 XConnect between two interfaces request.
Definition: vpe.api:1448
Policer iclassify operational state response.
Definition: vpe.api:4186
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:2722
#define API_LINK_STATE_EVENT
Definition: api.c:473
u32 fib_index
Definition: mpls.h:233
static void vnet_interface_counter_lock(vnet_interface_main_t *im)
Definition: interface.h:516
#define hash_create(elts, value_bytes)
Definition: hash.h:647
foreach_registration_hash u8 link_state_process_up
Definition: api.c:424
Reply to IPFIX dump request.
Definition: vpe.api:4568
struct _gid_address_t gid_address_t
DHCP proxy set / unset vss response.
Definition: vpe.api:874
static void vl_api_sw_interface_set_vpath_t_handler(vl_api_sw_interface_set_vpath_t *mp)
Definition: api.c:1443
Reset fib response.
Definition: vpe.api:812
Dump lisp eid-table.
Definition: vpe.api:2817
static void send_ipsec_gre_tunnel_details(ipsec_gre_tunnel_t *t, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:8027
ip4_address_t src
tunnel IPv4 src address
Definition: ipsec_gre.h:97
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
Definition: interface.h:415
#define VALIDATE_RX_SW_IF_INDEX(mp)
Definition: api.c:175
l2 fib table entry structure
Definition: vpe.api:2281
IP neighbor add / del request.
Definition: vpe.api:568
Set L2 XConnect response.
Definition: vpe.api:1461
static void vl_api_modify_vhost_user_if_t_handler(vl_api_modify_vhost_user_if_t *mp)
Definition: api.c:4048
Reply for tap dump request.
Definition: vpe.api:313
#define pool_put_index(p, i)
Free pool element with given index.
Definition: pool.h:228
#define ASSERT(truth)
Trace profile add / del response.
Definition: vpe.api:3901
Reply for vnet_get_summary_stats request.
Definition: vpe.api:723
IPv6 router advertisement config response.
Definition: vpe.api:957
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:4568
unsigned int u32
Definition: types.h:88
Request for eid table summary status.
Definition: vpe.api:2849
static void vl_api_gre_tunnel_dump_t_handler(vl_api_gre_tunnel_dump_t *mp)
Definition: api.c:4899
ip4_fib_t * fibs
Vector of FIBs.
Definition: ip4.h:118
uint32_t cir_tokens_per_period
Definition: police.h:74
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:5940
ip4_address_t dst_address
Definition: ip4.h:328
#define IP4_ROUTE_FLAG_ADD
Definition: ip4.h:308
int vnet_lisp_clear_all_remote_adjacencies(void)
Definition: control.c:889
ip6_main_t ip6_main
Definition: ip6_forward.c:2955
static void set_ip6_flow_hash(vl_api_set_ip_flow_hash_t *mp)
Definition: api.c:3412
static void vl_api_ipsec_sa_set_key_t_handler(vl_api_ipsec_sa_set_key_t *mp)
Definition: api.c:6635
Request for locator_set summary status.
Definition: vpe.api:2794
Reply for enable / disable packet generator.
Definition: vpe.api:4676
ip_lookup_main_t lookup_main
Definition: ip6.h:110
u32 tx_fib_index
Definition: mpls.h:77
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:4174
u32 spi
Definition: vpe.api:3362
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:2715
#define IP6_ROUTE_FLAG_NOT_LAST_IN_GROUP
Definition: ip6.h:357
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
u8 * format(u8 *s, char *fmt,...)
Definition: format.c:418
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:306
Reply for add / del route request.
Definition: vpe.api:397
ip_address_t address
Definition: control.h:55
gid_dictionary_t mapping_index_by_gid
Definition: control.h:72
Definition: l2_fib.h:33
u8 * name
policy name
Definition: sr.h:133
IPv6 router advertisement prefix config request.
Definition: vpe.api:978
static int event_data_cmp(void *a1, void *a2)
Definition: api.c:477
static void vl_api_show_version_t_handler(vl_api_show_version_t *mp)
Definition: api.c:4468
static void vl_api_lisp_enable_disable_t_handler(vl_api_lisp_enable_disable_t *mp)
Definition: api.c:5404
Reply for IPsec: Add/delete SPD from interface.
Definition: vpe.api:3251
gre_tunnel_t * tunnels
Definition: gre.h:62
Reply for MPLS decap add / del request.
Definition: vpe.api:498
IPv4 main type.
Definition: ip4.h:114
Reply for tap modify request.
Definition: vpe.api:273
int stats_memclnt_delete_callback(u32 client_index)
Definition: stats.c:971
u32 size
Definition: vhost-user.h:77
Reply for proxy arp add / del request.
Definition: vpe.api:526
Control ping from the client to the server response.
Definition: vpe.api:1143
clib_error_t * pg_capture(pg_capture_args_t *a)
Definition: cli.c:74
locator_set_t * locator_set_pool
Definition: control.h:81
u32 ip6_unicast_rx_feature_vpath
Definition: ip6.h:154
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:765
static void vl_api_classify_table_ids_t_handler(vl_api_classify_table_ids_t *mp)
Definition: api.c:7442
Status of lisp pitr, enable or disable.
Definition: vpe.api:2989
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:5446
static void vl_api_vxlan_tunnel_dump_t_handler(vl_api_vxlan_tunnel_dump_t *mp)
Definition: api.c:4798
IKEv2: Set IKEv2 profile authentication method.
Definition: vpe.api:3467
vnet_main_t * vnet_main
Definition: l2tp.h:81
Bitmaps built as vectors of machine words.
uword * mpls_decap_by_rx_fib_and_label
Definition: mpls.h:96
u8 integ_key_len
Definition: ipsec.h:83
Set the next node for a given node request.
Definition: vpe.api:1776
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:1652
void vnet_flow_reports_reset(flow_report_main_t *frm)
Definition: flow_report.c:217
static void vl_api_mpls_gre_tunnel_details_t_handler(vl_api_mpls_gre_tunnel_details_t *mp)
Definition: api.c:7082
Query relative index via node names.
Definition: vpe.api:4585
u32 sw_if_index
Definition: vxlan.h:85
Is Address Reachable request - DISABLED.
Definition: vpe.api:624
show version
Definition: vpe.api:2192
u8 is_del
Delete the policy?
Definition: sr.h:139
add or delete locator_set
Definition: vpe.api:2352
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:1048
vnet_classify_main_t vnet_classify_main
Definition: vnet_classify.c:21
Request for a single block of summary stats.
Definition: vpe.api:3738
Set max allowed ARP or ip6 neighbor entries response.
Definition: vpe.api:1217
ipsec_protocol_t protocol
Definition: ipsec.h:76
Reply for MAP domain add.
Definition: vpe.api:3636
static void vl_api_sw_interface_vhost_user_dump_t_handler(vl_api_sw_interface_vhost_user_dump_t *mp)
Definition: api.c:4133
#define IP_FLOW_HASH_DEFAULT
Default: 5-tuple without the "reverse" bit.
Definition: lookup.h:150
gid_address_t rmt_eid
Definition: lisp_gpe.h:275
void vnet_ip6_fib_init(ip6_main_t *im, u32 fib_index)
Definition: ip6_forward.c:101
#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:468
IPv6 segment routing policy add / del response.
Definition: vpe.api:1313
static void vl_api_map_rule_dump_t_handler(vl_api_map_rule_dump_t *mp)
Definition: api.c:6532
OAM add / del target request.
Definition: vpe.api:774
static void vl_api_input_acl_set_interface_t_handler(vl_api_input_acl_set_interface_t *mp)
Definition: api.c:6128
static void * clib_mem_alloc(uword size)
Definition: mem.h:107
#define MODE_L2_XC
Definition: l2_input.h:217
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)
Classify table ids by interface index request.
Definition: vpe.api:4421
pg_main_t pg_main
Definition: init.c:44
mpls gre tunnel operational state response
Definition: vpe.api:4271
static void send_eid_table_map_pair(hash_pair_t *p, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:5880
#define IP6_ROUTE_FLAG_FIB_INDEX
Definition: ip6.h:354
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:1675
vxlan_gpe_tunnel_t * tunnels
vector of encap tunnel instances
Definition: vxlan_gpe.h:148
u8 lcl_locs[loc_num]
Definition: vpe.api:2469
u64 uword
Definition: types.h:112
u8 action
Definition: vpe.api:2471
#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:501
void vl_set_memory_region_name(char *name)
Definition: memory_vlib.c:1201
void dslock(stats_main_t *sm, int release_hint, int tag)
Definition: stats.c:62
static void send_lisp_eid_table_details(mapping_t *mapit, unix_shared_memory_queue_t *q, u32 context, u8 filter)
Definition: api.c:5661
u8 rmt_eid[16]
Definition: vpe.api:2462
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:7000
Add / del route request.
Definition: vpe.api:368
int vnet_lisp_add_del_locator_set(vnet_lisp_add_del_locator_set_args_t *a, u32 *ls_result)
Definition: control.c:1744
#define gid_address_ip(_a)
Definition: lisp_types.h:208
Status of lisp, enable or disable.
Definition: vpe.api:2947
static void vl_api_want_ip4_arp_events_t_handler(vl_api_want_ip4_arp_events_t *mp)
Definition: api.c:6091
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:4654
Interface bridge mode request.
Definition: vpe.api:1476
void vnet_register_ip6_neighbor_resolution_event(vnet_main_t *vnm, void *address_arg, uword node_index, uword type_opaque, uword data)
Definition: defs.h:47
static void vl_api_cli_request_t_handler(vl_api_cli_request_t *mp)
Definition: api.c:3586
ip6_route_t ** routep
Definition: lookup.c:2184
u8 static_mac
Definition: vpe.api:2287
unsigned short u16
Definition: types.h:57
l2input_main_t l2input_main
Definition: l2_input.c:76
static void vl_api_af_packet_create_t_handler(vl_api_af_packet_create_t *mp)
Definition: api.c:6797
u8 eid_type
Definition: vpe.api:2461
#define gid_address_vni(_a)
Definition: lisp_types.h:212
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:38
static void vl_api_lisp_pitr_set_locator_set_t_handler(vl_api_lisp_pitr_set_locator_set_t *mp)
Definition: api.c:5430
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:7527
VLIB_CLI_COMMAND(set_interface_ip_source_and_port_range_check_command, static)
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:1117
static void vl_api_sw_interface_set_l2_xconnect_t_handler(vl_api_sw_interface_set_l2_xconnect_t *mp)
Definition: api.c:1522
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:5917
static void vl_api_map_add_domain_t_handler(vl_api_map_add_domain_t *mp)
Definition: api.c:6443
int vnet_proxy_arp_fib_reset(u32 fib_id)
Definition: arp.c:1612
IKEv2: Set IKEv2 local RSA private key.
Definition: vpe.api:3563
u32 bd_find_or_add_bd_index(bd_main_t *bdm, u32 bd_id)
Get or create a bridge domain.
Definition: l2_bd.c:54
static void vl_api_classify_add_del_session_t_handler(vl_api_classify_add_del_session_t *mp)
Definition: api.c:3867
#define RESOLUTION_PENDING_EVENT
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
double f64
Definition: types.h:142
vnet_interface_main_t * interface_main
Definition: stats.h:64
unsigned char u8
Definition: types.h:56
ip4_address_t tunnel_src
Definition: mpls.h:45
static void vl_api_l2tpv3_interface_enable_disable_t_handler(vl_api_l2tpv3_interface_enable_disable_t *mp)
Definition: api.c:4673
#define hash_foreach_pair(p, v, body)
Definition: hash.h:338
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:2478
u8 integrity_algorithm
Definition: vpe.api:3370
#define API_ADMIN_UP_DOWN_EVENT
Definition: api.c:474
static void vl_api_ipsec_interface_add_del_spd_t_handler(vl_api_ipsec_interface_add_del_spd_t *mp)
Definition: api.c:6172
static void vl_api_show_lisp_pitr_t_handler(vl_api_show_lisp_pitr_t *mp)
Definition: api.c:5978
#define L2_ARP_TERM
Definition: l2_bd.h:100
Process a vpe parser cli string request.
Definition: vpe.api:1180
u8 integrity_key[128]
Definition: vpe.api:3372
u8 is_tunnel_ipv6
Definition: vpe.api:3377
static void send_vxlan_tunnel_details(vxlan_tunnel_t *t, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:4766
add or delete locator for locator_set
Definition: vpe.api:2381
u32 dp_table
Definition: lisp_gpe.h:296
IOAM Trace enable trace profile for a flow.
Definition: vpe.api:3915
#define VXLAN_TUNNEL_IS_IPV4
Definition: vxlan.h:97
u32 inner_fib_index
Definition: mpls.h:61
L2 interface ethernet flow point filtering enable/disable request.
Definition: vpe.api:1934
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:900
#define IP4_ROUTE_FLAG_FIB_INDEX
Definition: ip4.h:311
int vnet_l2_patch_add_del(u32 rx_sw_if_index, u32 tx_sw_if_index, int is_add)
Definition: l2_patch.c:261
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:492
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:1654
locator_pair_t * locator_pairs
Definition: lisp_gpe.h:278
static void vl_api_ipfix_dump_t_handler(vl_api_ipfix_dump_t *mp)
Definition: api.c:7735
mapping_t * mapping_pool
Definition: control.h:75
PacketGenerator create interface response.
Definition: vpe.api:4621
static void vl_api_map_domain_dump_t_handler(vl_api_map_domain_dump_t *mp)
Definition: api.c:6490
Create loopback interface request.
Definition: vpe.api:1086
Reply for interface events registration.
Definition: vpe.api:186
u32 address_length
Definition: lookup.c:2177
Set unnumbered interface add / del request.
Definition: vpe.api:1062
uword * locator_set_index_by_name
Definition: control.h:87
show version response
Definition: vpe.api:2205
add or delete remote static mapping
Definition: vpe.api:2620
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:2063
static void vl_api_pg_create_interface_t_handler(vl_api_pg_create_interface_t *mp)
Definition: api.c:7762
u32 table_index_or_table_id
Definition: ip4.h:325
void * get_unformat_vnet_sw_interface(void)
Definition: api.c:8320
get_node_graph - get a copy of the vpp node graph including the current set of graph arcs...
Definition: vpe.api:3830
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:1188
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
u32 encap_index
Definition: mpls.h:63
Add / del MPLS decapsulation request.
Definition: vpe.api:482
Create a new subinterface with the given vlan id.
Definition: vpe.api:326
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:2747
gid_address_t eid
Definition: lisp_types.h:280
static void vl_api_l2tpv3_set_lookup_key_t_handler(vl_api_l2tpv3_set_lookup_key_t *mp)
Definition: api.c:4690
u32 custom_dev_instance
Definition: vpe.api:233
u8 ** tunnel_names
tunnel names
Definition: sr.h:136
Add MAP domains.
Definition: vpe.api:3614
gid_address_t address
Definition: lisp_types.h:255
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:4163
Create loopback interface response.
Definition: vpe.api:1098
u32 * tunnel_index_by_sw_if_index
Definition: vxlan.h:131
u32 dev_instance
Definition: pg.h:359
L2 interface patch add / del request.
Definition: vpe.api:1230
#define hash_get_mem(h, key)
Definition: hash.h:268
void l2fib_table_dump(u32 bd_index, l2fib_entry_key_t **l2fe_key, l2fib_entry_result_t **l2fe_res)
Definition: l2_fib.c:62
u32 client_index
Definition: vpe.api:2268
struct clib_bihash_value offset
template key/value backing page structure
#define IP4_ROUTE_FLAG_NOT_LAST_IN_GROUP
Definition: ip4.h:315
static void vl_api_lisp_gpe_add_del_iface_t_handler(vl_api_lisp_gpe_add_del_iface_t *mp)
Definition: api.c:5414
u8 lcl_eid[16]
Definition: vpe.api:2463
static void vl_api_sw_interface_clear_stats_t_handler(vl_api_sw_interface_clear_stats_t *mp)
Definition: api.c:2581
static void vl_api_ipsec_sad_add_del_entry_t_handler(vl_api_ipsec_sad_add_del_entry_t *mp)
Definition: api.c:6261
policer_read_response_type_st * policer_templates
Definition: policer.h:30
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:261
u32 encap_fib_index
FIB indices - tunnel partner lookup here.
Definition: vxlan_gpe.h:103
Interface set vpath request.
Definition: vpe.api:1351
static void send_gre_tunnel_details(gre_tunnel_t *t, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:4881
Modify a tap interface with the given paramters.
Definition: vpe.api:256
static void vl_api_get_next_index_t_handler(vl_api_get_next_index_t *mp)
Definition: api.c:4521
ip4_address_t tunnel_dst
Definition: mpls.h:46
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:169
Add/del policer.
Definition: vpe.api:4030
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
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:2250
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1578
#define IP4_ROUTE_FLAG_TABLE_ID
Definition: ip4.h:310
u32 ip4_unicast_rx_feature_vpath
Built-in unicast feature path indice, see ip_feature_init_cast()
Definition: ip4.h:156
static void vl_api_dhcp_proxy_config_2_t_handler(vl_api_dhcp_proxy_config_2_t *mp)
Definition: api.c:3230
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:994
int mpls_label_cmp(void *a1, void *a2)
Definition: mpls.c:599
u32 sw_if_index
vnet intfc sw_if_index
Definition: vxlan_gpe.h:113
Register for ip4 arp resolution events.
Definition: vpe.api:3019
This packet is to be rewritten and forwarded to the next processing node.
Definition: lookup.h:78
#define IP6_ROUTE_FLAG_ADD
Definition: ip6.h:351
static void vl_api_ip_dump_t_handler(vl_api_ip_dump_t *mp)
Definition: api.c:4357
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:696
u8 is_enabled
Definition: pg.h:360
static void vl_api_dhcp_client_config_t_handler(vl_api_dhcp_client_config_t *mp)
Definition: api.c:3266
static void vl_api_netmap_create_t_handler(vl_api_netmap_create_t *mp)
Definition: api.c:7044
#define vec_foreach(var, vec)
Vector iterator.
#define foreach_registration_hash
Definition: api.c:391
clib_error_t * clear_ioam_rewrite_fn(void)
u8 action
Definition: lisp_gpe.h:271
#define VALIDATE_TX_SW_IF_INDEX(mp)
Definition: api.c:191
Set bridge flags (such as L2_LEARN, L2_FWD, L2_FLOOD, L2_UU_FLOOD, or L2_ARP_TERM) request...
Definition: vpe.api:1565
Reply for map_resolver add/del.
Definition: vpe.api:2504
Request for map request itr rlocs summary status.
Definition: vpe.api:2967
static void vl_api_is_address_reachable_t_handler(vl_api_is_address_reachable_t *mp)
Definition: api.c:2476
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:2515
i16 explicit_fib_index
Force re-lookup in a different FIB.
Definition: lookup.h:185
u8 is_outbound
Definition: vpe.api:3290
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:3979
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
Definition: interface.c:521
static void vl_api_proxy_arp_intfc_enable_disable_t_handler(vl_api_proxy_arp_intfc_enable_disable_t *mp)
Definition: api.c:2359
u32 sw_if_index
Definition: l2_bd.h:46
u8 is_ipv6
Definition: vpe.api:3293
static void vl_api_create_vlan_subif_t_handler(vl_api_create_vlan_subif_t *mp)
Definition: api.c:1957
static void vl_api_vxlan_add_del_tunnel_t_handler(vl_api_vxlan_add_del_tunnel_t *mp)
Definition: api.c:4709
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:2288
u32 table_id
Definition: ip6.h:66
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:1204
uword * adj_index_by_dst_address[33]
Definition: ip4.h:50
format_function_t format_mpls_encap_index
Definition: mpls.h:115
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:8331
vhost_vring_addr_t addr
Definition: vhost-user.h:82
static void vl_api_mpls_ethernet_add_del_tunnel_t_handler(vl_api_mpls_ethernet_add_del_tunnel_t *mp)
Definition: api.c:2146
#define clib_error_return(e, args...)
Definition: error.h:111
Set interface source and L4 port-range response.
Definition: vpe.api:4742
static void vl_api_vxlan_gpe_tunnel_dump_t_handler(vl_api_vxlan_gpe_tunnel_dump_t *mp)
Definition: api.c:5070
#define IP6_ROUTE_FLAG_TABLE_ID
Definition: ip6.h:353
vhost-user interface delete request
Definition: vpe.api:2144
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:573
static void * ip_interface_address_get_address(ip_lookup_main_t *lm, ip_interface_address_t *a)
Definition: lookup.h:601
Reply for IKEv2: Add/delete profile.
Definition: vpe.api:3451
vhost-user interface modify response
Definition: vpe.api:2135
void ip4_add_del_route(ip4_main_t *im, ip4_add_del_route_args_t *args)
Definition: ip4_forward.c:228
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:7017
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:408
u32 flags
Definition: vhost-user.h:76
static void vl_api_noprint_control_ping_t_handler(vl_api_noprint_control_ping_t *mp)
Definition: api.c:3545
Definition: lisp_types.h:25
bd_main_t bd_main
Definition: l2_bd.c:35
MPLS Ethernet add / del tunnel request.
Definition: vpe.api:1379
uint32_t pir_tokens_per_period
Definition: police.h:75
clib_error_t * disable_ip6_interface(vlib_main_t *vm, u32 sw_if_index)
ethernet_interface_t * interfaces
Definition: ethernet.h:216
l2tpv3 tunnel interface create request
Definition: vpe.api:1842
#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:7064
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
Reply for classify table info request.
Definition: vpe.api:4470
Tell client about a DHCP completion event.
Definition: vpe.api:3589
int ip6_ioam_set_destination(ip6_address_t *addr, u32 mask_width, u32 vrf_id, int is_add, int is_pop, int is_none)
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:4105
int vnet_mpls_gre_add_del_tunnel(ip4_address_t *src, ip4_address_t *dst, ip4_address_t *intfc, u32 mask_width, u32 inner_fib_id, u32 outer_fib_id, u32 *tunnel_sw_if_index, u8 l2_only, u8 is_add)
Definition: interface.c:728
Dump mpls eth tunnel table.
Definition: vpe.api:4293
static void vl_api_oam_add_del_t_handler(vl_api_oam_add_del_t *mp)
Definition: api.c:2831
gid_address_t lcl_eid
Definition: lisp_gpe.h:274
Add / del MPLS encapsulation request.
Definition: vpe.api:450
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:750
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:123
static void vl_api_mpls_fib_decap_dump_t_handler(vl_api_mpls_fib_decap_dump_t *mp)
Definition: api.c:7372
vnet_policer_main_t vnet_policer_main
Definition: policer.h:46
u32 mreq_itr_rlocs
Definition: control.h:121
int mpls_fib_index_cmp(void *a1, void *a2)
Definition: mpls.c:590
gre_main_t gre_main
Definition: gre.c:21
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:570
DHCP Client config add / del request.
Definition: vpe.api:3147
static void vl_api_sr_tunnel_add_del_t_handler(vl_api_sr_tunnel_add_del_t *mp)
Definition: api.c:3650
static void vl_api_create_subif_t_handler(vl_api_create_subif_t *mp)
Definition: api.c:2032
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
void ip_address_set(ip_address_t *dst, void *src, u8 version)
Definition: lisp_types.c:685
Control ping from the client to the server response.
Definition: vpe.api:1167
int dhcp_proxy_set_option82_vss(u32 vrf_id, u32 oui, u32 fib_id, int is_del)
Definition: proxy_node.c:942
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:3286
vxlan_tunnel_t * tunnels
Definition: vxlan.h:121
u32 * locator_indices
Definition: lisp_types.h:274
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:5536
vnet_config_main_t config_main
Definition: lookup.h:367
#define RESOLUTION_EVENT
uword key
Definition: hash.h:161
ip_address_t src
Definition: lisp_gpe.h:99
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:5598
mpls_unicast_header_t * labels
Definition: mpls.h:70
Request for lisp pitr status.
Definition: vpe.api:2978
ip46_address_t src
Definition: vxlan.h:71
mpls_encap_t * encaps
Definition: mpls.h:91
clib_error_t * vl_api_init(vlib_main_t *vm)
Definition: api_shared.c:718
Definition: defs.h:46
#define IOAM_HBYH_ADD
DHCP Proxy config add / del request.
Definition: vpe.api:828
ip4_address_t tunnel_src
tunnel IPv4 src address
Definition: ipsec_gre.h:52
pthread_mutex_t mutex
Definition: svm.h:42
struct l2fib_entry_key_t::@155::@157 fields
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
u32 ip6_fib_lookup(ip6_main_t *im, u32 sw_if_index, ip6_address_t *dst)
Definition: ip6_forward.c:94
ip_address_t dst
Definition: lisp_gpe.h:99
static ip_adjacency_t * ip_get_adjacency(ip_lookup_main_t *lm, u32 adj_index)
Definition: lookup.h:480
u8 protocol
Definition: vpe.api:3364
Set the ip flow hash config for a fib response.
Definition: vpe.api:910
#define MODE_L3
Definition: l2_input.h:215
int l2tpv3_set_tunnel_cookies(l2t_main_t *lm, u32 sw_if_index, u64 new_local_cookie, u64 new_remote_cookie)
Definition: l2tp.c:531
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:7851
struct _unix_shared_memory_queue unix_shared_memory_queue_t
u8 is_ip_any
Definition: vpe.api:3294
ip6_address_t address
Definition: lookup.c:2175
static void vl_api_lisp_map_resolver_dump_t_handler(vl_api_lisp_map_resolver_dump_t *mp)
Definition: api.c:5861
int netmap_delete_if(vlib_main_t *vm, u8 *host_if_name)
Definition: netmap.c:249
int af_packet_delete_if(vlib_main_t *vm, u8 *host_if_name)
Definition: af_packet.c:284
Reply for MAP domain del.
Definition: vpe.api:3659
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:3067
IPv6 segment routing policy add / del request.
Definition: vpe.api:1300
u32 dp_table
Definition: vpe.api:2467
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:109