FD.io VPP  v16.06
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> // alagalah TODO : committers please pay note, is this ok?
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>
69 #include <vnet/l2/l2_classify.h>
70 #include <vnet/vxlan/vxlan.h>
71 #include <vnet/gre/gre.h>
72 #include <vnet/l2/l2_vtr.h>
74 #include <vnet/lisp-gpe/lisp_gpe.h>
75 #include <vnet/lisp-cp/control.h>
76 #include <vnet/map/map.h>
77 #include <vnet/cop/cop.h>
78 #include <vnet/ip/ip6_hop_by_hop.h>
80 #include <vnet/policer/policer.h>
81 
82 #undef BIHASH_TYPE
83 #undef __included_bihash_template_h__
84 #include <vnet/l2/l2_fib.h>
85 
86 #if IPSEC > 0
87 #include <vnet/ipsec/ipsec.h>
88 #include <vnet/ipsec/ikev2.h>
89 #endif /* IPSEC */
90 #if DPDK > 0
92 #endif
93 
94 #include <stats/stats.h>
95 #include <oam/oam.h>
96 
97 #include <vnet/ethernet/ethernet.h>
99 #include <vnet/interface.h>
100 
101 #include <vnet/l2/l2_fib.h>
102 #include <vnet/l2/l2_bd.h>
103 #include <api/vpe_msg_enum.h>
104 
105 #define f64_endian(a)
106 #define f64_print(a,b)
107 
108 #define vl_typedefs /* define message structures */
109 #include <api/vpe_all_api_h.h>
110 #undef vl_typedefs
111 
112 #define vl_endianfun /* define message structures */
113 #include <api/vpe_all_api_h.h>
114 #undef vl_endianfun
115 
116 /* instantiate all the print functions we know about */
117 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
118 #define vl_printfun
119 #include <api/vpe_all_api_h.h>
120 #undef vl_printfun
121 
122 #define REPLY_MACRO(t) \
123 do { \
124  unix_shared_memory_queue_t * q; \
125  rv = vl_msg_api_pd_handler (mp, rv); \
126  q = vl_api_client_index_to_input_queue (mp->client_index); \
127  if (!q) \
128  return; \
129  \
130  rmp = vl_msg_api_alloc (sizeof (*rmp)); \
131  rmp->_vl_msg_id = ntohs((t)); \
132  rmp->context = mp->context; \
133  rmp->retval = ntohl(rv); \
134  \
135  vl_msg_api_send_shmem (q, (u8 *)&rmp); \
136 } while(0);
137 
138 #define REPLY_MACRO2(t, body) \
139 do { \
140  unix_shared_memory_queue_t * q; \
141  rv = vl_msg_api_pd_handler (mp, rv); \
142  q = vl_api_client_index_to_input_queue (mp->client_index); \
143  if (!q) \
144  return; \
145  \
146  rmp = vl_msg_api_alloc (sizeof (*rmp)); \
147  rmp->_vl_msg_id = ntohs((t)); \
148  rmp->context = mp->context; \
149  rmp->retval = ntohl(rv); \
150  do {body;} while (0); \
151  vl_msg_api_send_shmem (q, (u8 *)&rmp); \
152 } while(0);
153 
154 #if (1 || CLIB_DEBUG > 0) /* "trust, but verify" */
155 
156 #define VALIDATE_SW_IF_INDEX(mp) \
157  do { u32 __sw_if_index = ntohl(mp->sw_if_index); \
158  vnet_main_t *__vnm = vnet_get_main(); \
159  if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \
160  __sw_if_index)) { \
161  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \
162  goto bad_sw_if_index; \
163  } \
164 } while(0);
165 
166 #define BAD_SW_IF_INDEX_LABEL \
167 do { \
168 bad_sw_if_index: \
169  ; \
170 } while (0);
171 
172 #define VALIDATE_RX_SW_IF_INDEX(mp) \
173  do { u32 __rx_sw_if_index = ntohl(mp->rx_sw_if_index); \
174  vnet_main_t *__vnm = vnet_get_main(); \
175  if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \
176  __rx_sw_if_index)) { \
177  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \
178  goto bad_rx_sw_if_index; \
179  } \
180 } while(0);
181 
182 #define BAD_RX_SW_IF_INDEX_LABEL \
183 do { \
184 bad_rx_sw_if_index: \
185  ; \
186 } while (0);
187 
188 #define VALIDATE_TX_SW_IF_INDEX(mp) \
189  do { u32 __tx_sw_if_index = ntohl(mp->tx_sw_if_index); \
190  vnet_main_t *__vnm = vnet_get_main(); \
191  if (pool_is_free_index(__vnm->interface_main.sw_interfaces, \
192  __tx_sw_if_index)) { \
193  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; \
194  goto bad_tx_sw_if_index; \
195  } \
196 } while(0);
197 
198 #define BAD_TX_SW_IF_INDEX_LABEL \
199 do { \
200 bad_tx_sw_if_index: \
201  ; \
202 } while (0);
203 
204 #else
205 
206 #define VALIDATE_SW_IF_INDEX(mp)
207 #define BAD_SW_IF_INDEX_LABEL
208 #define VALIDATE_RX_SW_IF_INDEX(mp)
209 #define BAD_RX_SW_IF_INDEX_LABEL
210 #define VALIDATE_TX_SW_IF_INDEX(mp)
211 #define BAD_TX_SW_IF_INDEX_LABEL
212 
213 #endif /* CLIB_DEBUG > 0 */
214 
215 #define foreach_vpe_api_msg \
216 _(WANT_INTERFACE_EVENTS, want_interface_events) \
217 _(WANT_OAM_EVENTS, want_oam_events) \
218 _(OAM_ADD_DEL, oam_add_del) \
219 _(SW_INTERFACE_DUMP, sw_interface_dump) \
220 _(SW_INTERFACE_DETAILS, sw_interface_details) \
221 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
222 _(IP_ADD_DEL_ROUTE, ip_add_del_route) \
223 _(IS_ADDRESS_REACHABLE, is_address_reachable) \
224 _(SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address) \
225 _(SW_INTERFACE_SET_TABLE, sw_interface_set_table) \
226 _(SW_INTERFACE_SET_VPATH, sw_interface_set_vpath) \
227 _(SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect) \
228 _(SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge) \
229 _(BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del) \
230 _(BRIDGE_DOMAIN_DUMP, bridge_domain_dump) \
231 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
232 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
233 _(L2FIB_ADD_DEL, l2fib_add_del) \
234 _(L2_FLAGS, l2_flags) \
235 _(BRIDGE_FLAGS, bridge_flags) \
236 _(TAP_CONNECT, tap_connect) \
237 _(TAP_MODIFY, tap_modify) \
238 _(TAP_DELETE, tap_delete) \
239 _(SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump) \
240 _(CREATE_VLAN_SUBIF, create_vlan_subif) \
241 _(CREATE_SUBIF, create_subif) \
242 _(MPLS_GRE_ADD_DEL_TUNNEL, mpls_gre_add_del_tunnel) \
243 _(MPLS_ETHERNET_ADD_DEL_TUNNEL, mpls_ethernet_add_del_tunnel) \
244 _(MPLS_ETHERNET_ADD_DEL_TUNNEL_2, mpls_ethernet_add_del_tunnel_2) \
245 _(MPLS_ADD_DEL_ENCAP, mpls_add_del_encap) \
246 _(MPLS_ADD_DEL_DECAP, mpls_add_del_decap) \
247 _(PROXY_ARP_ADD_DEL, proxy_arp_add_del) \
248 _(PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable) \
249 _(IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del) \
250 _(VNET_GET_SUMMARY_STATS, vnet_get_summary_stats) \
251 _(RESET_FIB, reset_fib) \
252 _(DHCP_PROXY_CONFIG,dhcp_proxy_config) \
253 _(DHCP_PROXY_CONFIG_2,dhcp_proxy_config_2) \
254 _(DHCP_PROXY_SET_VSS,dhcp_proxy_set_vss) \
255 _(DHCP_CLIENT_CONFIG, dhcp_client_config) \
256 _(SET_IP_FLOW_HASH,set_ip_flow_hash) \
257 _(SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config) \
258 _(SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix) \
259 _(SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable ) \
260 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, \
261  sw_interface_ip6_set_link_local_address) \
262 _(SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered) \
263 _(CREATE_LOOPBACK, create_loopback) \
264 _(CONTROL_PING, control_ping) \
265 _(CLI_REQUEST, cli_request) \
266 _(SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit) \
267 _(L2_PATCH_ADD_DEL, l2_patch_add_del) \
268 _(CLASSIFY_ADD_DEL_TABLE, classify_add_del_table) \
269 _(CLASSIFY_ADD_DEL_SESSION, classify_add_del_session) \
270 _(CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table) \
271 _(CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables) \
272 _(GET_NODE_INDEX, get_node_index) \
273 _(ADD_NODE_NEXT, add_node_next) \
274 _(L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel) \
275 _(L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies) \
276 _(L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable) \
277 _(L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key) \
278 _(SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump) \
279 _(VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel) \
280 _(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump) \
281 _(GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel) \
282 _(GRE_TUNNEL_DUMP, gre_tunnel_dump) \
283 _(L2_FIB_CLEAR_TABLE, l2_fib_clear_table) \
284 _(L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter) \
285 _(L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite) \
286 _(CREATE_VHOST_USER_IF, create_vhost_user_if) \
287 _(MODIFY_VHOST_USER_IF, modify_vhost_user_if) \
288 _(DELETE_VHOST_USER_IF, delete_vhost_user_if) \
289 _(SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump) \
290 _(IP_ADDRESS_DUMP, ip_address_dump) \
291 _(IP_DUMP, ip_dump) \
292 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
293 _(SHOW_VERSION, show_version) \
294 _(L2_FIB_TABLE_DUMP, l2_fib_table_dump) \
295 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
296 _(VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel) \
297 _(INTERFACE_NAME_RENUMBER, interface_name_renumber) \
298 _(WANT_IP4_ARP_EVENTS, want_ip4_arp_events) \
299 _(INPUT_ACL_SET_INTERFACE, input_acl_set_interface) \
300 _(IPSEC_SPD_ADD_DEL, ipsec_spd_add_del) \
301 _(IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd) \
302 _(IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry) \
303 _(IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry) \
304 _(IPSEC_SA_SET_KEY, ipsec_sa_set_key) \
305 _(IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del) \
306 _(IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth) \
307 _(IKEV2_PROFILE_SET_ID, ikev2_profile_set_id) \
308 _(IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts) \
309 _(IKEV2_SET_LOCAL_KEY, ikev2_set_local_key) \
310 _(DELETE_LOOPBACK, delete_loopback) \
311 _(BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del) \
312 _(MAP_ADD_DOMAIN, map_add_domain) \
313 _(MAP_DEL_DOMAIN, map_del_domain) \
314 _(MAP_ADD_DEL_RULE, map_add_del_rule) \
315 _(MAP_DOMAIN_DUMP, map_domain_dump) \
316 _(MAP_RULE_DUMP, map_rule_dump) \
317 _(MAP_SUMMARY_STATS, map_summary_stats) \
318 _(COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable) \
319 _(COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable) \
320 _(GET_NODE_GRAPH, get_node_graph) \
321 _(SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats) \
322 _(TRACE_PROFILE_ADD, trace_profile_add) \
323 _(TRACE_PROFILE_APPLY, trace_profile_apply) \
324 _(TRACE_PROFILE_DEL, trace_profile_del) \
325 _(LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set) \
326 _(LISP_ADD_DEL_LOCATOR, lisp_add_del_locator) \
327 _(LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid) \
328 _(LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry) \
329 _(LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver) \
330 _(LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable) \
331 _(LISP_ENABLE_DISABLE, lisp_enable_disable) \
332 _(LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface) \
333 _(LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping) \
334 _(LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump) \
335 _(LISP_LOCAL_EID_TABLE_DUMP, lisp_local_eid_table_dump) \
336 _(LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump) \
337 _(LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump) \
338 _(LISP_ENABLE_DISABLE_STATUS_DUMP, \
339  lisp_enable_disable_status_dump) \
340 _(SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del) \
341 _(AF_PACKET_CREATE, af_packet_create) \
342 _(AF_PACKET_DELETE, af_packet_delete) \
343 _(POLICER_ADD_DEL, policer_add_del)
344 
345 #define QUOTE_(x) #x
346 #define QUOTE(x) QUOTE_(x)
347 
348 #define foreach_registration_hash \
349 _(interface_events) \
350 _(to_netconf_server) \
351 _(from_netconf_server) \
352 _(to_netconf_client) \
353 _(from_netconf_client) \
354 _(oam_events)
355 
356 typedef enum {
360 } resolve_t;
361 
362 typedef struct {
364  union {
367  };
369 
370 typedef struct {
371 
372 #define _(a) uword *a##_registration_hash; \
373  vpe_client_registration_t * a##_registrations;
375 #undef _
376 
377  /* notifications happen really early in the game */
379 
380  /* ip4 pending route adds */
382 
383  /* ip4 arp event registration pool */
385 
386  /* convenience */
390 
393 
394 static void send_sw_interface_flags (vpe_api_main_t * am,
396  vnet_sw_interface_t * swif);
399  u32 sw_if_index);
400 
401 static int arp_change_delete_callback (u32 pool_index, u8 * notused);
402 
403 
404 /* Clean up all registrations belonging to the indicated client */
406 {
407  vpe_api_main_t * vam = &vpe_api_main;
409  uword * p;
410  int stats_memclnt_delete_callback (u32 client_index);
411 
412  stats_memclnt_delete_callback (client_index);
413 
414 #define _(a) \
415  p = hash_get (vam->a##_registration_hash, client_index); \
416  if (p) { \
417  rp = pool_elt_at_index (vam->a##_registrations, p[0]); \
418  pool_put (vam->a##_registrations, rp); \
419  hash_unset (vam->a##_registration_hash, client_index); \
420  }
422 #undef _
423  return 0;
424 }
425 
426 #define API_LINK_STATE_EVENT 1
427 #define API_ADMIN_UP_DOWN_EVENT 2
428 
429 static int
430 event_data_cmp (void * a1, void * a2)
431 {
432  uword * e1 = a1;
433  uword * e2 = a2;
434 
435  return (word) e1[0] - (word) e2[0];
436 }
437 
438 static uword
440  vlib_node_runtime_t * rt,
441  vlib_frame_t * f)
442 {
443  vpe_api_main_t * vam = &vpe_api_main;
444  vnet_main_t * vnm = vam->vnet_main;
445  vnet_sw_interface_t * swif;
446  uword * event_data = 0;
448  int i;
449  u32 prev_sw_if_index;
451 
452  vam->link_state_process_up = 1;
453 
454  while (1) {
456 
457  /* Unified list of changed link or admin state sw_if_indices */
459  (vm, &event_data, API_LINK_STATE_EVENT);
461  (vm, &event_data, API_ADMIN_UP_DOWN_EVENT);
462 
463  /* Sort, so we can eliminate duplicates */
465 
466  prev_sw_if_index = ~0;
467 
468  for (i = 0; i < vec_len(event_data); i++) {
469  /* Only one message per swif */
470  if (prev_sw_if_index == event_data[i])
471  continue;
472  prev_sw_if_index = event_data[i];
473 
474  pool_foreach(reg, vam->interface_events_registrations,
475  ({
476  q = vl_api_client_index_to_input_queue (reg->client_index);
477  if (q) {
478  // sw_interface may be deleted already
479  if (!pool_is_free_index (vnm->interface_main.sw_interfaces,
480  event_data[i]))
481  {
482  swif = vnet_get_sw_interface (vnm, event_data[i]);
483  send_sw_interface_flags (vam, q, swif);
484  }
485  }
486  }));
487  }
488  vec_reset_length (event_data);
489  }
490 
491  return 0;
492 }
493 
494 static clib_error_t *
495 link_up_down_function (vnet_main_t *vm, u32 hw_if_index, u32 flags);
496 static clib_error_t *
497 admin_up_down_function (vnet_main_t *vm, u32 hw_if_index, u32 flags);
498 
500  .function = link_state_process,
501  .type = VLIB_NODE_TYPE_PROCESS,
502  .name = "vpe-link-state-process",
503 };
504 
505 VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION (admin_up_down_function);
506 VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION (link_up_down_function);
507 
508 static clib_error_t *
509 link_up_down_function (vnet_main_t *vm, u32 hw_if_index, u32 flags)
510 {
511  vpe_api_main_t * vam = &vpe_api_main;
512  vnet_hw_interface_t *hi = vnet_get_hw_interface (vm, hw_if_index);
513 
514  if (vam->link_state_process_up)
518  hi->sw_if_index);
519  return 0;
520 }
521 
522 static clib_error_t *
523 admin_up_down_function (vnet_main_t *vm, u32 sw_if_index, u32 flags)
524 {
525  vpe_api_main_t * vam = &vpe_api_main;
526 
527  /*
528  * Note: it's perfectly fair to set a subif admin up / admin down.
529  * Note the subtle distinction between this routine and the previous
530  * routine.
531  */
532  if (vam->link_state_process_up)
536  sw_if_index);
537  return 0;
538 }
539 
540 #define pub_sub_handler(lca,UCA) \
541 static void vl_api_want_##lca##_t_handler ( \
542  vl_api_want_##lca##_t *mp) \
543 { \
544  vpe_api_main_t *vam = &vpe_api_main; \
545  vpe_client_registration_t *rp; \
546  vl_api_want_##lca##_reply_t *rmp; \
547  uword *p; \
548  i32 rv = 0; \
549  \
550  p = hash_get (vam->lca##_registration_hash, mp->client_index); \
551  if (p) { \
552  if (mp->enable_disable) { \
553  clib_warning ("pid %d: already enabled...", mp->pid); \
554  rv = VNET_API_ERROR_INVALID_REGISTRATION; \
555  goto reply; \
556  } else { \
557  rp = pool_elt_at_index (vam->lca##_registrations, p[0]); \
558  pool_put (vam->lca##_registrations, rp); \
559  hash_unset (vam->lca##_registration_hash, \
560  mp->client_index); \
561  goto reply; \
562  } \
563  } \
564  if (mp->enable_disable == 0) { \
565  clib_warning ("pid %d: already disabled...", mp->pid); \
566  rv = VNET_API_ERROR_INVALID_REGISTRATION; \
567  goto reply; \
568  } \
569  pool_get (vam->lca##_registrations, rp); \
570  rp->client_index = mp->client_index; \
571  rp->client_pid = mp->pid; \
572  hash_set (vam->lca##_registration_hash, rp->client_index, \
573  rp - vam->lca##_registrations); \
574  \
575 reply: \
576  REPLY_MACRO (VL_API_WANT_##UCA##_REPLY); \
577 }
578 
579 pub_sub_handler (interface_events,INTERFACE_EVENTS)
580 pub_sub_handler (oam_events,OAM_EVENTS)
581 
582 #define RESOLUTION_EVENT 1
583 #define RESOLUTION_PENDING_EVENT 2
584 #define IP4_ARP_EVENT 3
585 
590 
591 void handle_ip4_arp_event (u32 pool_index)
592 {
593  vpe_api_main_t * vam = &vpe_api_main;
594  vnet_main_t * vnm = vam->vnet_main;
595  vlib_main_t * vm = vam->vlib_main;
596  vl_api_ip4_arp_event_t * event;
599 
600  /* Client can cancel, die, etc. */
601  if (pool_is_free_index (vam->arp_events, pool_index))
602  return;
603 
604  event = pool_elt_at_index (vam->arp_events, pool_index);
605 
607  if (!q) {
610  event->pid, &event->address,
611  vpe_resolver_process_node.index, IP4_ARP_EVENT,
612  ~0 /* pool index, notused */, 0 /* is_add */);
613  return;
614  }
615 
616  if (q->cursize < q->maxsize) {
617  mp = vl_msg_api_alloc (sizeof (*mp));
618  clib_memcpy (mp, event, sizeof (*mp));
619  vl_msg_api_send_shmem (q, (u8 *)&mp);
620  } else {
621  static f64 last_time;
622  /*
623  * Throttle syslog msgs.
624  * It's pretty tempting to just revoke the registration...
625  */
626  if (vlib_time_now (vm) > last_time + 10.0) {
627  clib_warning ("arp event for %U to pid %d: queue stuffed!",
628  format_ip4_address, &event->address, event->pid);
629  last_time = vlib_time_now(vm);
630  }
631  }
632 }
633 
634 static uword
636  vlib_node_runtime_t * rt,
637  vlib_frame_t * f)
638 {
639  uword event_type;
640  uword *event_data = 0;
641  f64 timeout = 100.0;
642  vpe_api_main_t * vam = &vpe_api_main;
643  pending_route_t * pr;
646  u32 * resolution_failures = 0;
647  int i, rv;
648  clib_error_t * e;
649 
650  while (1) {
652 
653  event_type = vlib_process_get_events (vm, &event_data);
654 
655  switch (event_type) {
657  timeout = 1.0;
658  break;
659 
660  case RESOLUTION_EVENT:
661  for (i = 0; i < vec_len(event_data); i++) {
662  /*
663  * Resolution events can occur long after the
664  * original request has timed out. $$$ add a cancel
665  * mechanism..
666  */
667  if (pool_is_free_index (vam->pending_routes, event_data[i]))
668  continue;
669 
670  pr = pool_elt_at_index (vam->pending_routes, event_data[i]);
671  adr = &pr->r;
672  pme = &pr->t;
673 
674  switch (pr->resolve_type) {
676  rv = ip4_add_del_route_t_handler (adr);
677  clib_warning ("resolver: add %U/%d via %U %s",
679  (ip4_address_t *)&(adr->dst_address),
680  adr->dst_address_length,
682  (ip4_address_t *)&(adr->next_hop_address),
683  (rv >= 0) ? "succeeded" : "failed");
684  break;
685 
687  rv = ip6_add_del_route_t_handler (adr);
688  clib_warning ("resolver: add %U/%d via %U %s",
690  (ip6_address_t *)&(adr->dst_address),
691  adr->dst_address_length,
693  (ip6_address_t *)&(adr->next_hop_address),
694  (rv >= 0) ? "succeeded" : "failed");
695  break;
696 
699  clib_warning ("resolver: add mpls-o-e via %U %s",
702  (rv >= 0) ? "succeeded" : "failed");
703  break;
704 
705  default:
706  clib_warning ("resolver: BOGUS TYPE %d", pr->resolve_type);
707  }
708  pool_put (vam->pending_routes, pr);
709  }
710  break;
711 
712  case IP4_ARP_EVENT:
713  for (i = 0; i < vec_len(event_data); i++)
714  handle_ip4_arp_event (event_data[i]);
715  break;
716 
717  case ~0: /* timeout, retry pending resolutions */
718  pool_foreach (pr, vam->pending_routes,
719  ({
720  int is_adr = 1;
721  adr = &pr->r;
722  pme = &pr->t;
723 
724  /* May fail, e.g. due to interface down */
725  switch (pr->resolve_type) {
726  case RESOLVE_IP4_ADD_DEL_ROUTE:
727  e = ip4_probe_neighbor
728  (vm, (ip4_address_t *)&(adr->next_hop_address),
729  ntohl(adr->next_hop_sw_if_index));
730  break;
731 
732  case RESOLVE_IP6_ADD_DEL_ROUTE:
733  e = ip6_probe_neighbor
734  (vm, (ip6_address_t *)&(adr->next_hop_address),
735  ntohl(adr->next_hop_sw_if_index));
736  break;
737 
738  case RESOLVE_MPLS_ETHERNET_ADD_DEL:
739  is_adr = 0;
740  e = ip4_probe_neighbor
741  (vm,
742  (ip4_address_t *)&(pme->next_hop_ip4_address_in_outer_vrf),
743  pme->resolve_opaque);
744  break;
745 
746  default:
747  e = clib_error_return (0, "resolver: BOGUS TYPE %d",
748  pr->resolve_type);
749  }
750  if (e) {
751  clib_error_report (e);
752  if (is_adr)
753  adr->resolve_attempts = 1;
754  else
755  pme->resolve_attempts = 1;
756 
757  }
758  if (is_adr) {
759  adr->resolve_attempts -= 1;
760  if (adr->resolve_attempts == 0)
761  vec_add1 (resolution_failures,
762  pr - vam->pending_routes);
763  } else {
764  pme->resolve_attempts -= 1;
765  if (pme->resolve_attempts == 0)
766  vec_add1 (resolution_failures,
767  pr - vam->pending_routes);
768  }
769 
770  }));
771  for (i = 0; i < vec_len (resolution_failures); i++) {
772  pr = pool_elt_at_index (vam->pending_routes,
773  resolution_failures[i]);
774  adr = &pr->r;
775  pme = &pr->t;
776 
777  switch (pr->resolve_type) {
779  clib_warning ("resolver: add %U/%d via %U retry failure",
781  (ip4_address_t *)&(adr->dst_address),
782  adr->dst_address_length,
784  (ip4_address_t *)&(adr->next_hop_address));
785  break;
786 
788  clib_warning ("resolver: add %U/%d via %U retry failure",
790  (ip6_address_t *)&(adr->dst_address),
791  adr->dst_address_length,
793  (ip6_address_t *)&(adr->next_hop_address));
794  break;
795 
797  clib_warning ("resolver: add mpls-o-e via %U retry failure",
800  break;
801 
802  default:
803  clib_warning ("BUG");
804  }
805  pool_put(vam->pending_routes, pr);
806  }
807  vec_reset_length (resolution_failures);
808  break;
809  }
810  if (pool_elts (vam->pending_routes) == 0)
811  timeout = 100.0;
812  vec_reset_length (event_data);
813  }
814  return 0; /* or not */
815 }
816 
817 VLIB_REGISTER_NODE (vpe_resolver_process_node,static) = {
818  .function = resolver_process,
819  .type = VLIB_NODE_TYPE_PROCESS,
820  .name = "vpe-route-resolver-process",
821 };
822 
824 {
825  ip4_main_t * im = &ip4_main;
826  ip_lookup_main_t * lm = &im->lookup_main;
828  stats_main_t * sm = &stats_main;
830  ip4_address_t next_hop_address;
831  u32 fib_index;
832  vpe_api_main_t * vam = &vpe_api_main;
833  vnet_main_t * vnm = vam->vnet_main;
834  vlib_main_t * vm = vlib_get_main();
835  pending_route_t * pr;
837  uword * p;
838  clib_error_t * e;
839  u32 ai;
840  ip_adjacency_t *nh_adj, *add_adj = 0;
841 
842  p = hash_get (im->fib_index_by_table_id, ntohl(mp->vrf_id));
843  if (!p) {
844  if (mp->create_vrf_if_needed) {
845  ip4_fib_t * f;
846  f = find_ip4_fib_by_table_index_or_id (im, ntohl(mp->vrf_id),
847  0 /* flags */);
848  fib_index = f->index;
849  } else {
850  /* No such VRF, and we weren't asked to create one */
851  return VNET_API_ERROR_NO_SUCH_FIB;
852  }
853  } else {
854  fib_index = p[0];
855  }
856 
858  ntohl(mp->next_hop_sw_if_index)))
859  return VNET_API_ERROR_NO_MATCHING_INTERFACE;
860 
861  clib_memcpy (next_hop_address.data, mp->next_hop_address,
862  sizeof (next_hop_address.data));
863 
864  /* Arp for the next_hop if necessary */
865  if (mp->is_add && mp->resolve_if_needed) {
866  u32 lookup_result;
867  ip_adjacency_t * adj;
868 
869  lookup_result = ip4_fib_lookup_with_table
870  (im, fib_index, &next_hop_address, 1 /* disable default route */);
871 
872  adj = ip_get_adjacency (lm, lookup_result);
873 
875  pool_get (vam->pending_routes, pr);
877  adr = &pr->r;
878  clib_memcpy (adr, mp, sizeof (*adr));
879  /* recursion block, "just in case" */
880  adr->resolve_if_needed = 0;
881  adr->resolve_attempts = ntohl(mp->resolve_attempts);
883  (vnm, &next_hop_address, vpe_resolver_process_node.index,
884  RESOLUTION_EVENT, pr - vam->pending_routes);
885 
887  (vm, vpe_resolver_process_node.index,
888  RESOLUTION_PENDING_EVENT, 0 /* data */);
889 
890  /* The interface may be down, etc. */
891  e = ip4_probe_neighbor
892  (vm, (ip4_address_t *)&(mp->next_hop_address),
893  ntohl(mp->next_hop_sw_if_index));
894 
895  if (e)
897 
898  return VNET_API_ERROR_IN_PROGRESS;
899  }
900  }
901 
902  if (mp->is_multipath) {
903  u32 flags;
904 
905  dslock (sm, 1 /* release hint */, 10 /* tag */);
906 
907  if (mp->is_add)
908  flags = IP4_ROUTE_FLAG_ADD;
909  else
910  flags = IP4_ROUTE_FLAG_DEL;
911 
912  if (mp->not_last)
914 
915  ip4_add_del_route_next_hop (im, flags,
916  (ip4_address_t *) mp->dst_address,
917  (u32) mp->dst_address_length,
919  ntohl(mp->next_hop_sw_if_index),
920  (u32) mp->next_hop_weight,
921  ~0 /* adj_index */,
922  fib_index);
923  dsunlock(sm);
924  return 0;
925  }
926 
927  memset (&a, 0, sizeof (a));
929 
931 
934  a.table_index_or_table_id = fib_index;
935  a.add_adj = 0;
936  a.n_add_adj = 0;
937 
938  if (mp->not_last)
940 
941  dslock (sm, 1 /* release hint */, 2 /* tag */);
942 
943  if (mp->is_add) {
944  if (mp->is_drop)
945  ai = lm->drop_adj_index;
946  else if (mp->is_local)
947  ai = lm->local_adj_index;
948  else if (mp->is_classify) {
949  ip_adjacency_t cadj;
950  memset(&cadj, 0, sizeof(cadj));
952  cadj.classify.table_index = ntohl(mp->classify_table_index);
953  if (pool_is_free_index (cm->tables, cadj.classify.table_index)) {
954  dsunlock(sm);
955  return VNET_API_ERROR_NO_SUCH_TABLE;
956  }
957  vec_add1 (add_adj, cadj);
958  goto do_add_del;
959  }
960  else {
962  (im, fib_index, &next_hop_address,
963  1 /* disable default route */);
964  if (ai == lm->miss_adj_index) {
965  dsunlock(sm);
966  return VNET_API_ERROR_NEXT_HOP_NOT_IN_FIB;
967  }
968  }
969 
970  nh_adj = ip_get_adjacency (lm, ai);
971  vec_add1 (add_adj, nh_adj[0]);
972  if (mp->lookup_in_vrf) {
973  p = hash_get (im->fib_index_by_table_id, ntohl(mp->lookup_in_vrf));
974  if (p)
975  add_adj[0].explicit_fib_index = p[0];
976  else {
977  vec_free (add_adj);
978  dsunlock(sm);
979  return VNET_API_ERROR_NO_SUCH_INNER_FIB;
980  }
981  }
982  } else {
983  ip_adjacency_t * adj;
984  int disable_default_route = 1;
985 
986  /* Trying to delete the default route? */
987  if (a.dst_address.as_u32 == 0 &&
988  a.dst_address_length == 0)
989  disable_default_route = 0;
990 
992  (im, fib_index, &a.dst_address, disable_default_route);
993  if (ai == lm->miss_adj_index) {
994  dsunlock(sm);
995  return VNET_API_ERROR_UNKNOWN_DESTINATION;
996  }
997 
998  adj = ip_get_adjacency (lm, ai);
1000  dsunlock(sm);
1001  return VNET_API_ERROR_ADDRESS_MATCHES_INTERFACE_ADDRESS;
1002  }
1003  }
1004 
1005 do_add_del:
1006  a.adj_index = ~0;
1007  a.add_adj = add_adj;
1008  a.n_add_adj = vec_len(add_adj);
1009  ip4_add_del_route (im, &a);
1010 
1011  vec_free (add_adj);
1012 
1013  dsunlock (sm);
1014  return 0;
1015 }
1016 
1018 {
1019  ip6_main_t * im = &ip6_main;
1020  ip_lookup_main_t * lm = &im->lookup_main;
1021  vnet_main_t * vnm = vnet_get_main();
1022  vlib_main_t * vm = vlib_get_main();
1023  vpe_api_main_t * vam = &vpe_api_main;
1024  stats_main_t * sm = &stats_main;
1026  ip6_address_t next_hop_address;
1027  pending_route_t * pr;
1029 
1030  u32 fib_index;
1031  uword * p;
1032  clib_error_t * e;
1033  ip_adjacency_t * nh_adj, * add_adj = 0;
1034  u32 ai;
1035 
1036  p = hash_get (im->fib_index_by_table_id, ntohl(mp->vrf_id));
1037 
1038  if (!p) {
1039  if (mp->create_vrf_if_needed) {
1040  ip6_fib_t * f;
1041  f = find_ip6_fib_by_table_index_or_id (im, ntohl(mp->vrf_id),
1042  0 /* flags */);
1043  fib_index = f->index;
1044  } else {
1045  /* No such VRF, and we weren't asked to create one */
1046  return VNET_API_ERROR_NO_SUCH_FIB;
1047  }
1048  } else {
1049  fib_index = p[0];
1050  }
1051 
1053  ntohl(mp->next_hop_sw_if_index)))
1054  return VNET_API_ERROR_NO_MATCHING_INTERFACE;
1055 
1056  clib_memcpy (next_hop_address.as_u8, mp->next_hop_address,
1057  sizeof (next_hop_address.as_u8));
1058 
1059  /* Arp for the next_hop if necessary */
1060  if (mp->is_add && mp->resolve_if_needed) {
1061  u32 lookup_result;
1062  ip_adjacency_t * adj;
1063 
1064  lookup_result = ip6_fib_lookup_with_table
1065  (im, fib_index, &next_hop_address);
1066 
1067  adj = ip_get_adjacency (lm, lookup_result);
1068 
1069  if (adj->lookup_next_index == IP_LOOKUP_NEXT_ARP) {
1070  pool_get (vam->pending_routes, pr);
1071  adr = &pr->r;
1073  clib_memcpy (adr, mp, sizeof (*adr));
1074  /* recursion block, "just in case" */
1075  adr->resolve_if_needed = 0;
1076  adr->resolve_attempts = ntohl(mp->resolve_attempts);
1078  (vnm, &next_hop_address, vpe_resolver_process_node.index,
1079  RESOLUTION_EVENT, pr - vam->pending_routes);
1080 
1082  (vm, vpe_resolver_process_node.index,
1083  RESOLUTION_PENDING_EVENT, 0 /* data */);
1084 
1085  /* The interface may be down, etc. */
1086  e = ip6_probe_neighbor
1087  (vm, (ip6_address_t *)&(mp->next_hop_address),
1088  ntohl(mp->next_hop_sw_if_index));
1089 
1090  if (e)
1091  clib_error_report(e);
1092 
1093  return VNET_API_ERROR_IN_PROGRESS;
1094  }
1095  }
1096 
1097  if (mp->is_multipath) {
1098  u32 flags;
1099 
1100  dslock (sm, 1 /* release hint */, 11 /* tag */);
1101 
1102  if (mp->is_add)
1103  flags = IP6_ROUTE_FLAG_ADD;
1104  else
1105  flags = IP6_ROUTE_FLAG_DEL;
1106 
1107  if (mp->not_last)
1109 
1111  (u32) mp->dst_address_length,
1113  ntohl(mp->next_hop_sw_if_index),
1114  (u32) mp->next_hop_weight,
1115  ~0 /* adj_index */,
1116  fib_index);
1117  dsunlock(sm);
1118  return 0;
1119  }
1120 
1121  memset (&a, 0, sizeof (a));
1123 
1125 
1128  a.table_index_or_table_id = fib_index;
1129  a.add_adj = 0;
1130  a.n_add_adj = 0;
1131 
1132  if (mp->not_last)
1134 
1135  dslock (sm, 1 /* release hint */, 3 /* tag */);
1136 
1137  if (mp->is_add) {
1138  if (mp->is_drop)
1139  ai = lm->drop_adj_index;
1140  else if (mp->is_local)
1141  ai = lm->local_adj_index;
1142  else {
1144  (im, fib_index, &next_hop_address);
1145  if (ai == lm->miss_adj_index) {
1146  dsunlock(sm);
1147  return VNET_API_ERROR_NEXT_HOP_NOT_IN_FIB;
1148  }
1149  }
1150 
1151  nh_adj = ip_get_adjacency (lm, ai);
1152  vec_add1 (add_adj, nh_adj[0]);
1153  if (mp->lookup_in_vrf) {
1154  p = hash_get (im->fib_index_by_table_id, ntohl(mp->lookup_in_vrf));
1155  if (p)
1156  add_adj[0].explicit_fib_index = p[0];
1157  else {
1158  vec_free (add_adj);
1159  dsunlock(sm);
1160  return VNET_API_ERROR_NO_SUCH_INNER_FIB;
1161  }
1162  }
1163  } else {
1164  ip_adjacency_t * adj;
1165 
1167  (im, fib_index, &a.dst_address);
1168  if (ai == lm->miss_adj_index) {
1169  dsunlock(sm);
1170  return VNET_API_ERROR_UNKNOWN_DESTINATION;
1171  }
1172  adj = ip_get_adjacency (lm, ai);
1173  if (adj->lookup_next_index == IP_LOOKUP_NEXT_ARP) {
1174  dsunlock(sm);
1175  return VNET_API_ERROR_ADDRESS_MATCHES_INTERFACE_ADDRESS;
1176  }
1177  }
1178 
1179  a.adj_index = ~0;
1180  a.add_adj = add_adj;
1181  a.n_add_adj = vec_len(add_adj);
1182  ip6_add_del_route (im, &a);
1183 
1184  vec_free (add_adj);
1185 
1186  dsunlock (sm);
1187  return 0;
1188 }
1189 
1192 {
1194  int rv;
1195  vnet_main_t * vnm = vnet_get_main();
1196 
1197  vnm->api_errno = 0;
1198 
1199  if (mp->is_ipv6)
1200  rv = ip6_add_del_route_t_handler (mp);
1201  else
1202  rv = ip4_add_del_route_t_handler (mp);
1203 
1204  rv = (rv == 0) ? vnm->api_errno : rv;
1205 
1206  REPLY_MACRO(VL_API_IP_ADD_DEL_ROUTE_REPLY);
1207 }
1208 
1209 void api_config_default_ip_route (u8 is_ipv6, u8 is_add, u32 vrf_id,
1210  u32 sw_if_index, u8 *next_hop_addr)
1211 {
1213  int rv;
1214 
1215  memset (&mp, 0, sizeof(vl_api_ip_add_del_route_t));
1216 
1217  /*
1218  * Configure default IP route:
1219  * - ip route add 0.0.0.0/1 via <GW IP>
1220  * - ip route add 128.0.0.0/1 via <GW IP>
1221  */
1222  mp.next_hop_sw_if_index = ntohl(sw_if_index);
1223  mp.vrf_id = vrf_id;
1224  mp.resolve_attempts = ~0;
1225  mp.resolve_if_needed = 1;
1226  mp.is_add = is_add;
1227  mp.is_ipv6 = is_ipv6;
1228  mp.next_hop_weight = 1;
1229 
1230  clib_memcpy (&mp.next_hop_address[0], next_hop_addr, 16);
1231 
1232  if (is_ipv6)
1233  rv = ip6_add_del_route_t_handler (&mp);
1234  else
1235  {
1236  mp.dst_address_length = 1;
1237 
1238  mp.dst_address[0] = 0;
1239  rv = ip4_add_del_route_t_handler (&mp);
1240 
1241  mp.dst_address[0] = 128;
1242  rv |= ip4_add_del_route_t_handler (&mp);
1243  }
1244 
1245  if (rv)
1246  clib_error_return (0, "failed to config default IP route");
1247 
1248 }
1249 
1250 static void
1253 {
1254  vlib_main_t *vm = vlib_get_main();
1256  int rv = 0;
1257  u32 is_del;
1258 
1260 
1261  is_del = mp->is_add == 0;
1262 
1263  if (mp->del_all)
1265  else if (mp->is_ipv6)
1267  (void *)mp->address,
1268  mp->address_length, is_del);
1269  else
1271  (void *) mp->address,
1272  mp->address_length, is_del);
1273 
1275 
1276  REPLY_MACRO(VL_API_SW_INTERFACE_ADD_DEL_ADDRESS_REPLY);
1277 }
1278 
1279 static void
1281 {
1282  int rv = 0;
1283  u32 table_id = ntohl(mp->vrf_id);
1284  u32 sw_if_index = ntohl(mp->sw_if_index);
1286  stats_main_t * sm = &stats_main;
1287 
1289 
1290  dslock (sm, 1 /* release hint */, 4 /* tag */);
1291 
1292  if (mp->is_ipv6) {
1293  ip6_main_t * im = &ip6_main;
1294  ip6_fib_t * fib =
1295  find_ip6_fib_by_table_index_or_id (im, table_id,
1297  if (fib) {
1298  vec_validate (im->fib_index_by_sw_if_index, sw_if_index);
1299  im->fib_index_by_sw_if_index[sw_if_index] = fib->index;
1300  } else {
1301  rv = VNET_API_ERROR_NO_SUCH_FIB;
1302  }
1303  } else {
1304  ip4_main_t * im = &ip4_main;
1306  (im, table_id, IP4_ROUTE_FLAG_TABLE_ID);
1307 
1308  /* Truthfully this can't fail */
1309  if (fib) {
1310  vec_validate (im->fib_index_by_sw_if_index, sw_if_index);
1311  im->fib_index_by_sw_if_index[sw_if_index] = fib->index;
1312  } else {
1313  rv = VNET_API_ERROR_NO_SUCH_FIB;
1314  }
1315  }
1316  dsunlock(sm);
1317 
1319 
1320  REPLY_MACRO(VL_API_SW_INTERFACE_SET_TABLE_REPLY);
1321 }
1322 
1323 static void
1325 {
1326  vlib_main_t *vm = vlib_get_main();
1328  int rv = 0;
1329  u32 ci;
1330  u32 sw_if_index = ntohl(mp->sw_if_index);
1331  ip4_main_t *ip4m = &ip4_main;
1332  ip6_main_t *ip6m = &ip6_main;
1333  ip_lookup_main_t *ip4lm = &ip4m->lookup_main;
1334  ip_lookup_main_t *ip6lm = &ip6m->lookup_main;
1335  ip_config_main_t *rx_cm4u = &ip4lm->rx_config_mains[VNET_UNICAST];
1336  ip_config_main_t *rx_cm4m = &ip4lm->rx_config_mains[VNET_MULTICAST];
1337  ip_config_main_t *rx_cm6u = &ip6lm->rx_config_mains[VNET_UNICAST];
1338  ip_config_main_t *rx_cm6m = &ip6lm->rx_config_mains[VNET_MULTICAST];
1339 
1341 
1342  l2input_intf_bitmap_enable(sw_if_index, L2INPUT_FEAT_VPATH, mp->enable);
1343  if (mp->enable) {
1344  ci = rx_cm4u->config_index_by_sw_if_index[sw_if_index]; //IP4 unicast
1345  ci = vnet_config_add_feature(vm, &rx_cm4u->config_main,
1346  ci, IP4_RX_FEATURE_VPATH, 0, 0);
1347  rx_cm4u->config_index_by_sw_if_index[sw_if_index] = ci;
1348  ci = rx_cm4m->config_index_by_sw_if_index[sw_if_index]; //IP4 mcast
1349  ci = vnet_config_add_feature(vm, &rx_cm4m->config_main,
1350  ci, IP4_RX_FEATURE_VPATH, 0, 0);
1351  rx_cm4m->config_index_by_sw_if_index[sw_if_index] = ci;
1352  ci = rx_cm6u->config_index_by_sw_if_index[sw_if_index]; //IP6 unicast
1353  ci = vnet_config_add_feature(vm, &rx_cm6u->config_main,
1354  ci, IP6_RX_FEATURE_VPATH, 0, 0);
1355  rx_cm6u->config_index_by_sw_if_index[sw_if_index] = ci;
1356  ci = rx_cm6m->config_index_by_sw_if_index[sw_if_index]; //IP6 mcast
1357  ci = vnet_config_add_feature(vm, &rx_cm6m->config_main,
1358  ci, IP6_RX_FEATURE_VPATH, 0, 0);
1359  rx_cm6m->config_index_by_sw_if_index[sw_if_index] = ci;
1360  } else {
1361  ci = rx_cm4u->config_index_by_sw_if_index[sw_if_index]; //IP4 unicast
1362  ci = vnet_config_del_feature(vm, &rx_cm4u->config_main,
1363  ci, IP4_RX_FEATURE_VPATH, 0, 0);
1364  rx_cm4u->config_index_by_sw_if_index[sw_if_index] = ci;
1365  ci = rx_cm4m->config_index_by_sw_if_index[sw_if_index]; //IP4 mcast
1366  ci = vnet_config_del_feature(vm, &rx_cm4m->config_main,
1367  ci, IP4_RX_FEATURE_VPATH, 0, 0);
1368  rx_cm4m->config_index_by_sw_if_index[sw_if_index] = ci;
1369  ci = rx_cm6u->config_index_by_sw_if_index[sw_if_index]; //IP6 unicast
1370  ci = vnet_config_del_feature(vm, &rx_cm6u->config_main,
1371  ci, IP6_RX_FEATURE_VPATH, 0, 0);
1372  rx_cm6u->config_index_by_sw_if_index[sw_if_index] = ci;
1373  ci = rx_cm6m->config_index_by_sw_if_index[sw_if_index]; //IP6 mcast
1374  ci = vnet_config_del_feature(vm, &rx_cm6m->config_main,
1375  ci, IP6_RX_FEATURE_VPATH, 0, 0);
1376  rx_cm6m->config_index_by_sw_if_index[sw_if_index] = ci;
1377  }
1378 
1380 
1381  REPLY_MACRO(VL_API_SW_INTERFACE_SET_VPATH_REPLY);
1382 }
1383 
1384 static void
1387 {
1389  int rv = 0;
1390  u32 rx_sw_if_index = ntohl(mp->rx_sw_if_index);
1391  u32 tx_sw_if_index = ntohl(mp->tx_sw_if_index);
1392  vlib_main_t *vm = vlib_get_main();
1393  vnet_main_t *vnm = vnet_get_main();
1394 
1396 
1397  if (mp->enable) {
1399  rv = set_int_l2_mode(vm, vnm, MODE_L2_XC,
1400  rx_sw_if_index, 0, 0, 0, tx_sw_if_index);
1401  } else {
1402  rv = set_int_l2_mode(vm, vnm, MODE_L3, rx_sw_if_index, 0, 0, 0, 0);
1403  }
1404 
1407 
1408  REPLY_MACRO(VL_API_SW_INTERFACE_SET_L2_XCONNECT_REPLY);
1409 }
1410 
1411 static void
1414 {
1415  bd_main_t * bdm = &bd_main;
1417  int rv = 0;
1418  u32 rx_sw_if_index = ntohl(mp->rx_sw_if_index);
1419  u32 bd_id = ntohl(mp->bd_id);
1420  u32 bd_index;
1421  u32 bvi = mp->bvi;
1422  u8 shg = mp->shg;
1423  vlib_main_t *vm = vlib_get_main();
1424  vnet_main_t *vnm = vnet_get_main();
1425 
1427 
1428  bd_index = bd_find_or_add_bd_index (bdm, bd_id);
1429 
1430  if (mp->enable) {
1431  //VALIDATE_TX_SW_IF_INDEX(mp);
1432  rv = set_int_l2_mode(vm, vnm, MODE_L2_BRIDGE,
1433  rx_sw_if_index, bd_index, bvi, shg, 0);
1434  } else {
1435  rv = set_int_l2_mode(vm, vnm, MODE_L3, rx_sw_if_index, 0, 0, 0, 0);
1436  }
1437 
1439 
1440  REPLY_MACRO(VL_API_SW_INTERFACE_SET_L2_BRIDGE_REPLY);
1441 }
1442 
1443 static void
1446 {
1447  vlib_main_t * vm = vlib_get_main ();
1448  bd_main_t * bdm = &bd_main;
1450  int rv = 0;
1451  u32 enable_flags = 0, disable_flags = 0;
1452  u32 bd_id = ntohl(mp->bd_id);
1453  u32 bd_index;
1454 
1455  if (mp->is_add) {
1456  bd_index = bd_find_or_add_bd_index (bdm, bd_id);
1457 
1458  if (mp->flood)
1459  enable_flags |= L2_FLOOD;
1460  else
1461  disable_flags |= L2_FLOOD;
1462 
1463  if (mp->uu_flood)
1464  enable_flags |= L2_UU_FLOOD;
1465  else
1466  disable_flags |= L2_UU_FLOOD;
1467 
1468  if (mp->forward)
1469  enable_flags |= L2_FWD;
1470  else
1471  disable_flags |= L2_FWD;
1472 
1473  if (mp->arp_term)
1474  enable_flags |= L2_ARP_TERM;
1475  else
1476  disable_flags |= L2_ARP_TERM;
1477 
1478  if (mp->learn)
1479  enable_flags |= L2_LEARN;
1480  else
1481  disable_flags |= L2_LEARN;
1482 
1483  if (enable_flags)
1484  bd_set_flags (vm, bd_index, enable_flags, 1 /* enable */);
1485 
1486  if (disable_flags)
1487  bd_set_flags (vm, bd_index, disable_flags, 0 /* disable */);
1488 
1489  } else
1490  rv = bd_delete_bd_index(bdm, bd_id);
1491 
1492  REPLY_MACRO(VL_API_BRIDGE_DOMAIN_ADD_DEL_REPLY);
1493 }
1494 
1497 {
1498  clib_warning ("BUG");
1499 }
1500 
1503 {
1504  clib_warning ("BUG");
1505 }
1506 
1508  l2_bridge_domain_t * bd_config,
1509  u32 n_sw_ifs,
1510  u32 context)
1511 {
1513 
1514  mp = vl_msg_api_alloc (sizeof (*mp));
1515  memset (mp, 0, sizeof (*mp));
1516  mp->_vl_msg_id = ntohs (VL_API_BRIDGE_DOMAIN_DETAILS);
1517  mp->bd_id = ntohl (bd_config->bd_id);
1518  mp->flood = bd_feature_flood (bd_config);
1519  mp->uu_flood = bd_feature_uu_flood (bd_config);
1520  mp->forward = bd_feature_forward (bd_config);
1521  mp->learn = bd_feature_learn (bd_config);
1522  mp->arp_term = bd_feature_arp_term (bd_config);
1523  mp->bvi_sw_if_index = ntohl (bd_config->bvi_sw_if_index);
1524  mp->n_sw_ifs = ntohl (n_sw_ifs);
1525  mp->context = context;
1526 
1527  vl_msg_api_send_shmem (q, (u8 *)&mp);
1528 }
1529 
1532  l2_flood_member_t * member, u32 bd_id,
1533  u32 context)
1534 {
1536  l2_input_config_t * input_cfg;
1537 
1538  mp = vl_msg_api_alloc (sizeof (*mp));
1539  memset (mp, 0, sizeof (*mp));
1540  mp->_vl_msg_id = ntohs (VL_API_BRIDGE_DOMAIN_SW_IF_DETAILS);
1541  mp->bd_id = ntohl (bd_id);
1542  mp->sw_if_index = ntohl (member->sw_if_index);
1543  input_cfg = vec_elt_at_index (l2im->configs, member->sw_if_index);
1544  mp->shg = input_cfg->shg;
1545  mp->context = context;
1546 
1547  vl_msg_api_send_shmem (q, (u8 *)&mp);
1548 }
1549 
1552 {
1553  bd_main_t * bdm = &bd_main;
1554  l2input_main_t * l2im = &l2input_main;
1556  l2_bridge_domain_t * bd_config;
1557  u32 bd_id, bd_index;
1558  u32 end;
1559 
1561 
1562  if (q == 0)
1563  return;
1564 
1565  bd_id = ntohl(mp->bd_id);
1566 
1567  bd_index = (bd_id == ~0) ? 0 : bd_find_or_add_bd_index (bdm, bd_id);
1568  end = (bd_id == ~0) ? vec_len (l2im->bd_configs) : bd_index + 1;
1569  for (; bd_index < end; bd_index++) {
1570  bd_config = l2input_bd_config_from_index (l2im, bd_index);
1571  /* skip dummy bd_id 0 */
1572  if (bd_config && (bd_config->bd_id > 0)) {
1573  u32 n_sw_ifs;
1574  l2_flood_member_t * m;
1575 
1576  n_sw_ifs = vec_len (bd_config->members);
1577  send_bridge_domain_details (q, bd_config, n_sw_ifs, mp->context);
1578 
1579  vec_foreach (m, bd_config->members) {
1580  send_bd_sw_if_details (l2im, q, m, bd_config->bd_id, mp->context);
1581  }
1582  }
1583  }
1584 }
1585 
1586 static void
1589 {
1590  bd_main_t * bdm = &bd_main;
1591  l2input_main_t * l2im = &l2input_main;
1593  int rv = 0;
1594  u64 mac = 0;
1595  u32 sw_if_index = ntohl(mp->sw_if_index);
1596  u32 bd_id = ntohl(mp->bd_id);
1597  u32 bd_index;
1598  u32 static_mac;
1599  u32 filter_mac;
1600  uword * p;
1601 
1602  mac = mp->mac;
1603 
1604  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
1605  if (!p) {
1606  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
1607  goto bad_sw_if_index;
1608  }
1609  bd_index = p[0];
1610 
1611  if (mp->is_add) {
1613  if (vec_len(l2im->configs) <= sw_if_index) {
1614  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
1615  goto bad_sw_if_index;
1616  } else {
1617  l2_input_config_t * config;
1618  config = vec_elt_at_index(l2im->configs, sw_if_index);
1619  if (config->bridge == 0) {
1620  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
1621  goto bad_sw_if_index;
1622  }
1623  }
1624  static_mac = mp->static_mac ? 1 : 0;
1625  filter_mac = mp->filter_mac ? 1 : 0;
1626  l2fib_add_entry(mac, bd_index, sw_if_index, static_mac, filter_mac,
1627  0 /* bvi_mac */);
1628  } else {
1629  l2fib_del_entry(mac, bd_index);
1630  }
1631 
1633 
1634  REPLY_MACRO(VL_API_L2FIB_ADD_DEL_REPLY);
1635 }
1636 
1637 static void
1639  vl_api_l2_flags_t *mp)
1640 {
1642  int rv = 0;
1643  u32 sw_if_index = ntohl(mp->sw_if_index);
1644  u32 flags = ntohl(mp->feature_bitmap);
1645  u32 rbm = 0;
1646 
1648 
1649 #define _(a,b) \
1650  if (flags & L2INPUT_FEAT_ ## a) \
1651  rbm = l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_ ## a, mp->is_set);
1653 #undef _
1654 
1656 
1657  REPLY_MACRO2(VL_API_L2_FLAGS_REPLY, rmp->resulting_feature_bitmap = ntohl(rbm));
1658 }
1659 
1660 static void
1663 {
1664  vlib_main_t *vm = vlib_get_main();
1665  bd_main_t * bdm = &bd_main;
1667  int rv = 0;
1668  u32 bd_id = ntohl(mp->bd_id);
1669  u32 bd_index;
1670  u32 flags = ntohl(mp->feature_bitmap);
1671  uword * p;
1672 
1673  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
1674  if (p == 0) {
1675  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
1676  goto out;
1677  }
1678 
1679  bd_index = p[0];
1680 
1681  bd_set_flags(vm, bd_index, flags, mp->is_set);
1682 
1683 out:
1684  REPLY_MACRO2(VL_API_BRIDGE_FLAGS_REPLY,
1685  rmp->resulting_feature_bitmap = ntohl(flags));
1686 }
1687 
1688 static void
1691 {
1692  bd_main_t * bdm = &bd_main;
1694  int rv = 0;
1695  u32 bd_id = ntohl(mp->bd_id);
1696  u32 bd_index;
1697  uword * p;
1698 
1699  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
1700  if (p == 0) {
1701  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
1702  goto out;
1703  }
1704 
1705  bd_index = p[0];
1706  if (bd_add_del_ip_mac(bd_index, mp->ip_address,
1707  mp->mac_address, mp->is_ipv6, mp->is_add))
1708  rv = VNET_API_ERROR_UNSPECIFIED;
1709 
1710 out:
1711  REPLY_MACRO(VL_API_BD_IP_MAC_ADD_DEL_REPLY);
1712 }
1713 
1714 static void
1716 {
1717  int rv;
1720  u32 sw_if_index = (u32)~0;
1721 
1722  rv = vnet_tap_connect_renumber (vm, mp->tap_name,
1723  mp->use_random_mac ? 0 : mp->mac_address,
1724  &sw_if_index, mp->renumber,
1725  ntohl(mp->custom_dev_instance));
1726 
1728  if (!q)
1729  return;
1730 
1731  rmp = vl_msg_api_alloc (sizeof (*rmp));
1732  rmp->_vl_msg_id = ntohs(VL_API_TAP_CONNECT_REPLY);
1733  rmp->context = mp->context;
1734  rmp->retval = ntohl(rv);
1735  rmp->sw_if_index = ntohl(sw_if_index);
1736 
1737  vl_msg_api_send_shmem (q, (u8 *)&rmp);
1738 }
1739 
1740 static void
1742 {
1743  int rv;
1746  u32 sw_if_index = (u32)~0;
1747 
1748  rv = vnet_tap_modify (vm, ntohl(mp->sw_if_index), mp->tap_name,
1749  mp->use_random_mac ? 0 : mp->mac_address,
1750  &sw_if_index, mp->renumber,
1751  ntohl(mp->custom_dev_instance));
1752 
1754  if (!q)
1755  return;
1756 
1757  rmp = vl_msg_api_alloc (sizeof (*rmp));
1758  rmp->_vl_msg_id = ntohs(VL_API_TAP_MODIFY_REPLY);
1759  rmp->context = mp->context;
1760  rmp->retval = ntohl(rv);
1761  rmp->sw_if_index = ntohl(sw_if_index);
1762 
1763  vl_msg_api_send_shmem (q, (u8 *)&rmp);
1764 }
1765 
1766 static void
1768 {
1769  int rv;
1770  vpe_api_main_t * vam = &vpe_api_main;
1773  u32 sw_if_index = ntohl(mp->sw_if_index);
1774 
1775  rv = vnet_tap_delete (vm, sw_if_index);
1776 
1778  if (!q)
1779  return;
1780 
1781  rmp = vl_msg_api_alloc (sizeof (*rmp));
1782  rmp->_vl_msg_id = ntohs(VL_API_TAP_DELETE_REPLY);
1783  rmp->context = mp->context;
1784  rmp->retval = ntohl(rv);
1785 
1786  vl_msg_api_send_shmem (q, (u8 *)&rmp);
1787 
1788  if (!rv)
1789  send_sw_interface_flags_deleted (vam, q, sw_if_index);
1790 }
1791 
1792 static void
1794 {
1796  vnet_main_t * vnm = vnet_get_main();
1797  u32 hw_if_index, sw_if_index = (u32)~0;
1799  int rv = 0;
1800  u32 id;
1801  vnet_sw_interface_t template;
1802  uword * p;
1804  u64 sup_and_sub_key;
1805  u64 * kp;
1807  clib_error_t * error;
1808 
1810 
1811  hw_if_index = ntohl(mp->sw_if_index);
1812  hi = vnet_get_hw_interface (vnm, hw_if_index);
1813 
1814  id = ntohl(mp->vlan_id);
1815  if (id == 0 || id > 4095) {
1816  rv = VNET_API_ERROR_INVALID_VLAN;
1817  goto out;
1818  }
1819 
1820  sup_and_sub_key = ((u64)(hi->sw_if_index) << 32) | (u64) id;
1821 
1822  p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
1823  if (p) {
1824  rv = VNET_API_ERROR_VLAN_ALREADY_EXISTS;
1825  goto out;
1826  }
1827 
1828  kp = clib_mem_alloc (sizeof (*kp));
1829  *kp = sup_and_sub_key;
1830 
1831  memset (&template, 0, sizeof (template));
1832  template.type = VNET_SW_INTERFACE_TYPE_SUB;
1833  template.sup_sw_if_index = hi->sw_if_index;
1834  template.sub.id = id;
1835  template.sub.eth.raw_flags = 0;
1836  template.sub.eth.flags.one_tag = 1;
1837  template.sub.eth.outer_vlan_id = id;
1838  template.sub.eth.flags.exact_match = 1;
1839 
1840  error = vnet_create_sw_interface (vnm, &template, &sw_if_index);
1841  if (error) {
1842  clib_error_report(error);
1843  rv = VNET_API_ERROR_INVALID_REGISTRATION;
1844  goto out;
1845  }
1846  hash_set (hi->sub_interface_sw_if_index_by_id, id, sw_if_index);
1847  hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index);
1848 
1850 
1851 out:
1853  if (!q)
1854  return;
1855 
1856  rmp = vl_msg_api_alloc (sizeof (*rmp));
1857  rmp->_vl_msg_id = ntohs(VL_API_CREATE_VLAN_SUBIF_REPLY);
1858  rmp->context = mp->context;
1859  rmp->retval = ntohl(rv);
1860  rmp->sw_if_index = ntohl(sw_if_index);
1861  vl_msg_api_send_shmem (q, (u8 *)&rmp);
1862 }
1863 
1864 static void
1866 {
1868  vnet_main_t * vnm = vnet_get_main();
1869  u32 sw_if_index = ~0;
1870  int rv = 0;
1871  u32 sub_id;
1872  vnet_sw_interface_t *si;
1874  vnet_sw_interface_t template;
1875  uword * p;
1877  u64 sup_and_sub_key;
1878  u64 * kp;
1879  clib_error_t * error;
1880 
1882 
1883  si = vnet_get_sup_sw_interface (vnm, ntohl(mp->sw_if_index));
1884  hi = vnet_get_sup_hw_interface (vnm, ntohl(mp->sw_if_index));
1885 
1887  rv = VNET_API_ERROR_BOND_SLAVE_NOT_ALLOWED;
1888  goto out;
1889  }
1890 
1891  sw_if_index = si->sw_if_index;
1892  sub_id = ntohl(mp->sub_id);
1893 
1894  sup_and_sub_key = ((u64)(sw_if_index) << 32) | (u64) sub_id;
1895 
1896  p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
1897  if (p) {
1898  if (CLIB_DEBUG > 0)
1899  clib_warning ("sup sw_if_index %d, sub id %d already exists\n",
1900  sw_if_index, sub_id);
1901  rv = VNET_API_ERROR_SUBIF_ALREADY_EXISTS;
1902  goto out;
1903  }
1904 
1905  kp = clib_mem_alloc (sizeof (*kp));
1906  *kp = sup_and_sub_key;
1907 
1908  memset (&template, 0, sizeof (template));
1909  template.type = VNET_SW_INTERFACE_TYPE_SUB;
1910  template.sup_sw_if_index = sw_if_index;
1911  template.sub.id = sub_id;
1912  template.sub.eth.flags.no_tags = mp->no_tags;
1913  template.sub.eth.flags.one_tag = mp->one_tag;
1914  template.sub.eth.flags.two_tags = mp->two_tags;
1915  template.sub.eth.flags.dot1ad = mp->dot1ad;
1916  template.sub.eth.flags.exact_match = mp->exact_match;
1917  template.sub.eth.flags.default_sub = mp->default_sub;
1918  template.sub.eth.flags.outer_vlan_id_any = mp->outer_vlan_id_any;
1919  template.sub.eth.flags.inner_vlan_id_any = mp->inner_vlan_id_any;
1920  template.sub.eth.outer_vlan_id = ntohs(mp->outer_vlan_id);
1921  template.sub.eth.inner_vlan_id = ntohs(mp->inner_vlan_id);
1922 
1923  error = vnet_create_sw_interface (vnm, &template, &sw_if_index);
1924  if (error) {
1925  clib_error_report (error);
1926  rv = VNET_API_ERROR_SUBIF_CREATE_FAILED;
1927  goto out;
1928  }
1929 
1930  hash_set (hi->sub_interface_sw_if_index_by_id, sub_id, sw_if_index);
1931  hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index);
1932 
1934 
1935 out:
1936 
1937  REPLY_MACRO2(VL_API_CREATE_SUBIF_REPLY,
1938  ({
1939  rmp->sw_if_index = ntohl(sw_if_index);
1940  }));
1941 }
1942 
1943 static void
1945 {
1947  int rv = 0;
1948  stats_main_t * sm = &stats_main;
1949  u32 tunnel_sw_if_index = ~0;
1950 
1951  dslock (sm, 1 /* release hint */, 5 /* tag */);
1952 
1954  (ip4_address_t *)(mp->dst_address),
1955  (ip4_address_t *)(mp->intfc_address),
1956  (u32)(mp->intfc_address_length),
1957  ntohl(mp->inner_vrf_id),
1958  ntohl(mp->outer_vrf_id),
1959  &tunnel_sw_if_index,
1960  mp->l2_only,
1961  mp->is_add);
1962  dsunlock (sm);
1963 
1964  REPLY_MACRO2(VL_API_MPLS_GRE_ADD_DEL_TUNNEL_REPLY,
1965  ({
1966  rmp->tunnel_sw_if_index = ntohl(tunnel_sw_if_index);
1967  }));
1968 }
1969 
1970 static void
1973 {
1975  int rv = 0;
1976  stats_main_t * sm = &stats_main;
1977  u32 tunnel_sw_if_index;
1978 
1979  dslock (sm, 1 /* release hint */, 5 /* tag */);
1980 
1982  (mp->dst_mac_address, (ip4_address_t *)(mp->adj_address),
1983  (u32)(mp->adj_address_length), ntohl(mp->vrf_id),
1984  ntohl(mp->tx_sw_if_index),
1985  &tunnel_sw_if_index,
1986  mp->l2_only,
1987  mp->is_add);
1988 
1989  dsunlock (sm);
1990 
1991  REPLY_MACRO2(VL_API_MPLS_ETHERNET_ADD_DEL_TUNNEL_REPLY,
1992  ({
1993  rmp->tunnel_sw_if_index = ntohl(tunnel_sw_if_index);
1994  }));
1995 }
1996 
1997 /*
1998  * This piece of misery brought to you because the control-plane
1999  * can't figure out the tx interface + dst-mac address all by itself
2000  */
2003 {
2004  pending_route_t * pr;
2006  vnet_main_t * vnm = vnet_get_main();
2007  vlib_main_t * vm = vlib_get_main();
2008  stats_main_t * sm = &stats_main;
2009  vpe_api_main_t * vam = &vpe_api_main;
2010  u32 inner_fib_index, outer_fib_index;
2011  ip4_main_t * im = &ip4_main;
2012  ip_lookup_main_t * lm = &im->lookup_main;
2013  ip_adjacency_t * adj = 0;
2014  u32 lookup_result;
2015  u32 tx_sw_if_index;
2016  u8 * dst_mac_address;
2017  clib_error_t * e;
2018  uword * p;
2019  int rv;
2020  u32 tunnel_sw_if_index;
2021 
2022  p = hash_get (im->fib_index_by_table_id, ntohl(mp->outer_vrf_id));
2023  if (!p)
2024  return VNET_API_ERROR_NO_SUCH_FIB;
2025  else
2026  outer_fib_index = p[0];
2027 
2028 
2029  p = hash_get (im->fib_index_by_table_id, ntohl(mp->inner_vrf_id));
2030  if (!p)
2031  return VNET_API_ERROR_NO_SUCH_INNER_FIB;
2032  else
2033  inner_fib_index = p[0];
2034 
2035  if (inner_fib_index == outer_fib_index)
2036  return VNET_API_ERROR_INVALID_VALUE;
2037 
2038  lookup_result = ip4_fib_lookup_with_table
2039  (im, outer_fib_index,
2041  1 /* disable default route */);
2042 
2043  adj = ip_get_adjacency (lm, lookup_result);
2044  tx_sw_if_index = adj->rewrite_header.sw_if_index;
2045 
2046  if (mp->is_add && mp->resolve_if_needed) {
2047  if (adj->lookup_next_index == IP_LOOKUP_NEXT_ARP) {
2048  pool_get (vam->pending_routes, pr);
2050  pme = &pr->t;
2051  clib_memcpy (pme, mp, sizeof (*pme));
2052  /* recursion block, "just in case" */
2053  pme->resolve_if_needed = 0;
2054  pme->resolve_attempts = ntohl(mp->resolve_attempts);
2055  pme->resolve_opaque = tx_sw_if_index;
2057  (vnm,
2059  vpe_resolver_process_node.index,
2060  RESOLUTION_EVENT, pr - vam->pending_routes);
2061 
2063  (vm, vpe_resolver_process_node.index,
2064  RESOLUTION_PENDING_EVENT, 0 /* data */);
2065 
2066  /* The interface may be down, etc. */
2067  e = ip4_probe_neighbor
2069  tx_sw_if_index);
2070 
2071  if (e)
2072  clib_error_report(e);
2073 
2074  return VNET_API_ERROR_IN_PROGRESS;
2075  }
2076  }
2077 
2079  return VNET_API_ERROR_NEXT_HOP_NOT_IN_FIB;
2080 
2081  dst_mac_address =
2083  (&adj->rewrite_header, sizeof (adj->rewrite_data));
2084 
2085  dslock (sm, 1 /* release hint */, 10 /* tag */);
2086 
2088  (dst_mac_address, (ip4_address_t *)(mp->adj_address),
2089  (u32)(mp->adj_address_length), ntohl(mp->inner_vrf_id),
2090  tx_sw_if_index, &tunnel_sw_if_index, mp->l2_only, mp->is_add);
2091 
2092  dsunlock (sm);
2093 
2094  return rv;
2095 }
2096 
2097 static void
2100 {
2102  int rv = 0;
2103 
2105 
2106  REPLY_MACRO(VL_API_MPLS_ETHERNET_ADD_DEL_TUNNEL_2_REPLY);
2107 }
2108 
2109 
2110 static void
2112 {
2114  int rv;
2115  static u32 * labels;
2116  int i;
2117 
2118  vec_reset_length (labels);
2119 
2120  for (i = 0; i < mp->nlabels; i++)
2121  vec_add1 (labels, ntohl(mp->labels[i]));
2122 
2123  /* $$$$ fixme */
2125  ntohl(mp->vrf_id), labels,
2126  ~0 /* policy_tunnel_index */,
2127  0 /* no_dst_hash */,
2128  0 /* indexp */,
2129  mp->is_add);
2130 
2131  REPLY_MACRO(VL_API_MPLS_ADD_DEL_ENCAP_REPLY);
2132 }
2133 
2134 static void
2137 {
2139  int rv;
2140 
2141  rv = vnet_mpls_add_del_decap (ntohl(mp->rx_vrf_id), ntohl(mp->tx_vrf_id),
2142  ntohl(mp->label), ntohl(mp->next_index),
2143  mp->s_bit, mp->is_add);
2144 
2145  REPLY_MACRO(VL_API_MPLS_ADD_DEL_DECAP_REPLY);
2146 }
2147 
2148 static void
2150 {
2152  u32 fib_index;
2153  int rv;
2154  ip4_main_t * im = &ip4_main;
2155  stats_main_t * sm = &stats_main;
2156  int vnet_proxy_arp_add_del (ip4_address_t *lo_addr,
2157  ip4_address_t *hi_addr,
2158  u32 fib_index, int is_del);
2159  uword * p;
2160 
2161  dslock (sm, 1 /* release hint */, 6 /* tag */);
2162 
2163  p = hash_get (im->fib_index_by_table_id, ntohl(mp->vrf_id));
2164 
2165  if (! p) {
2166  rv = VNET_API_ERROR_NO_SUCH_FIB;
2167  goto out;
2168  }
2169 
2170  fib_index = p[0];
2171 
2173  (ip4_address_t *)mp->hi_address,
2174  fib_index, mp->is_add == 0);
2175 
2176 out:
2177  dsunlock (sm);
2178  REPLY_MACRO(VL_API_PROXY_ARP_ADD_DEL_REPLY);
2179 }
2180 
2181 static void
2184 {
2185  int rv = 0;
2186  vnet_main_t * vnm = vnet_get_main();
2188  vnet_sw_interface_t * si;
2189  u32 sw_if_index;
2190 
2192 
2193  sw_if_index = ntohl(mp->sw_if_index);
2194 
2196  sw_if_index)) {
2197  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
2198  goto out;
2199  }
2200 
2201  si = vnet_get_sw_interface (vnm, sw_if_index);
2202 
2203  ASSERT(si);
2204 
2205  if (mp->enable_disable)
2207  else
2209 
2211 
2212  out:
2213  REPLY_MACRO(VL_API_PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY);
2214 }
2215 
2216 static void
2218 {
2220  vnet_main_t * vnm = vnet_get_main();
2221  u32 fib_index;
2222  int rv=0;
2223  stats_main_t * sm = &stats_main;
2224 
2226 
2227  dslock (sm, 1 /* release hint */, 7 /* tag */);
2228 
2229  if (mp->is_ipv6) {
2230  if (mp->is_add)
2232  (vm, ntohl(mp->sw_if_index),
2233  (ip6_address_t *)(mp->dst_address),
2234  mp->mac_address, sizeof (mp->mac_address), mp->is_static);
2235  else
2237  (vm, ntohl(mp->sw_if_index),
2238  (ip6_address_t *)(mp->dst_address),
2239  mp->mac_address, sizeof(mp->mac_address));
2240  } else {
2241  ip4_main_t * im = &ip4_main;
2242  ip_lookup_main_t * lm = &im->lookup_main;
2243  ethernet_arp_ip4_over_ethernet_address_t a;
2244  u32 ai;
2245  ip_adjacency_t *nh_adj;
2246 
2247  uword * p = hash_get (im->fib_index_by_table_id, ntohl(mp->vrf_id));
2248  if (! p) {
2249  rv = VNET_API_ERROR_NO_SUCH_FIB;
2250  goto out;
2251  }
2252  fib_index = p[0];
2253 
2254  /*
2255  * Unfortunately, folks have a penchant for
2256  * adding interface addresses to the ARP cache, and
2257  * wondering why the forwarder eventually ASSERTs...
2258  */
2260  (im, fib_index, (ip4_address_t *)(mp->dst_address),
2261  1 /* disable default route */);
2262 
2263  if (ai != 0) {
2264  nh_adj = ip_get_adjacency (lm, ai);
2265  /* Never allow manipulation of a local adj! */
2266  if (nh_adj->lookup_next_index == IP_LOOKUP_NEXT_LOCAL) {
2267  clib_warning("%U matches local adj",
2269  (ip4_address_t *)(mp->dst_address));
2270  rv = VNET_API_ERROR_ADDRESS_MATCHES_INTERFACE_ADDRESS;
2271  goto out;
2272  }
2273  }
2274 
2275  clib_memcpy (&a.ethernet, mp->mac_address, 6);
2276  clib_memcpy (&a.ip4, mp->dst_address, 4);
2277 
2278  if (mp->is_add)
2279  rv = vnet_arp_set_ip4_over_ethernet (vnm, ntohl(mp->sw_if_index),
2280  fib_index, &a, mp->is_static);
2281  else
2282  rv = vnet_arp_unset_ip4_over_ethernet (vnm, ntohl(mp->sw_if_index),
2283  fib_index, &a);
2284  }
2285 
2287  out:
2288  dsunlock (sm);
2289  REPLY_MACRO(VL_API_IP_NEIGHBOR_ADD_DEL_REPLY);
2290 }
2291 
2292 static void
2294 {
2295 #if 0
2296  vpe_main_t *rm = &vpe_main;
2297  ip4_main_t *im4 = &ip4_main;
2298  ip6_main_t *im6 = &ip6_main;
2299  ip_lookup_main_t * lm;
2300  union {
2301  ip4_address_t ip4;
2302  ip6_address_t ip6;
2303  } addr;
2304  u32 adj_index, sw_if_index;
2306  ip_adjacency_t * adj;
2308 
2310  if (!q) {
2311  increment_missing_api_client_counter (rm->vlib_main);
2312  return;
2313  }
2314 
2315  rmp = vl_msg_api_alloc (sizeof (*rmp));
2316  clib_memcpy (rmp, mp, sizeof (*rmp));
2317 
2318  sw_if_index = mp->next_hop_sw_if_index;
2319  clib_memcpy (&addr, mp->address, sizeof (addr));
2320  if (mp->is_ipv6) {
2321  lm = &im6->lookup_main;
2322  adj_index =
2323  ip6_fib_lookup (im6, sw_if_index, &addr.ip6);
2324  } else {
2325  lm = &im4->lookup_main;
2326  adj_index =
2327  ip4_fib_lookup (im4, sw_if_index, &addr.ip4);
2328  }
2329  if (adj_index == ~0) {
2330  rmp->is_error = 1;
2331  goto send;
2332  }
2333  adj = ip_get_adjacency (lm, adj_index);
2334 
2336  && adj->rewrite_header.sw_if_index == sw_if_index) {
2337  rmp->is_known = 1;
2338  } else {
2340  && adj->rewrite_header.sw_if_index == sw_if_index) {
2341  if (mp->is_ipv6)
2342  ip6_probe_neighbor (rm->vlib_main, &addr.ip6, sw_if_index);
2343  else
2344  ip4_probe_neighbor (rm->vlib_main, &addr.ip4, sw_if_index);
2345  } else if (adj->lookup_next_index == IP_LOOKUP_NEXT_DROP) {
2346  rmp->is_known = 1;
2347  goto send;
2348  }
2349  rmp->is_known = 0;
2350  }
2351 
2352 send:
2353  vl_msg_api_send_shmem (q, (u8 *)&rmp);
2354 #endif
2355 }
2356 
2359 {
2360  clib_warning ("BUG");
2361 }
2362 
2365 {
2367  vnet_main_t * vnm = vnet_get_main();
2368  int rv = 0;
2369  clib_error_t * error;
2370  u16 flags;
2371 
2373 
2375 
2376  error = vnet_sw_interface_set_flags (vnm,
2377  ntohl(mp->sw_if_index),
2378  flags);
2379  if (error) {
2380  rv = -1;
2381  clib_error_report (error);
2382  }
2383 
2385  REPLY_MACRO(VL_API_SW_INTERFACE_SET_FLAGS_REPLY);
2386 }
2387 
2390 {
2392 
2393  vnet_main_t * vnm = vnet_get_main();
2397  static vnet_main_t ** my_vnet_mains;
2398  int i, j, n_counters;
2399 
2400  int rv = 0;
2401 
2402  vec_reset_length (my_vnet_mains);
2403 
2404  for (i = 0; i < vec_len (vnet_mains); i++)
2405  {
2406  if (vnet_mains[i])
2407  vec_add1 (my_vnet_mains, vnet_mains[i]);
2408  }
2409 
2410  if (vec_len (vnet_mains) == 0)
2411  vec_add1 (my_vnet_mains, vnm);
2412 
2413  n_counters = vec_len (im->combined_sw_if_counters);
2414 
2415  for (j = 0; j < n_counters; j++)
2416  {
2417  for (i = 0; i < vec_len(my_vnet_mains); i++)
2418  {
2419  im = &my_vnet_mains[i]->interface_main;
2420  cm = im->combined_sw_if_counters + j;
2421  if (mp->sw_if_index == (u32)~0)
2423  else
2424  vlib_zero_combined_counter (cm, ntohl(mp->sw_if_index));
2425  }
2426  }
2427 
2428  n_counters = vec_len (im->sw_if_counters);
2429 
2430  for (j = 0; j < n_counters; j++)
2431  {
2432  for (i = 0; i < vec_len(my_vnet_mains); i++)
2433  {
2434  im = &my_vnet_mains[i]->interface_main;
2435  sm = im->sw_if_counters + j;
2436  if (mp->sw_if_index == (u32)~0)
2438  else
2439  vlib_zero_simple_counter (sm, ntohl(mp->sw_if_index));
2440  }
2441  }
2442 
2443  REPLY_MACRO(VL_API_SW_INTERFACE_CLEAR_STATS_REPLY);
2444 }
2445 
2448  vnet_sw_interface_t * swif,
2449  u8 * interface_name,
2450  u32 context)
2451 {
2454 
2456 
2457  mp = vl_msg_api_alloc (sizeof (*mp));
2458  memset (mp, 0, sizeof (*mp));
2459  mp->_vl_msg_id = ntohs(VL_API_SW_INTERFACE_DETAILS);
2460  mp->sw_if_index = ntohl(swif->sw_if_index);
2461  mp->sup_sw_if_index = ntohl(swif->sup_sw_if_index);
2463  1 : 0;
2465  1 : 0;
2470  mp->link_mtu = ntohs(hi->max_packet_bytes);
2471  mp->context = context;
2472 
2473  strncpy ((char *) mp->interface_name,
2474  (char *) interface_name, ARRAY_LEN(mp->interface_name)-1);
2475 
2476  /* Send the L2 address for ethernet physical intfcs */
2477  if (swif->sup_sw_if_index == swif->sw_if_index
2478  && hi->hw_class_index == ethernet_hw_interface_class.index) {
2481 
2482  ei = pool_elt_at_index (em->interfaces, hi->hw_instance);
2483  ASSERT (sizeof (mp->l2_address) >= sizeof (ei->address));
2484  clib_memcpy (mp->l2_address, ei->address, sizeof (ei->address));
2485  mp->l2_address_length = ntohl(sizeof (ei->address));
2486  } else if (swif->sup_sw_if_index != swif->sw_if_index) {
2487  vnet_sub_interface_t *sub = &swif->sub;
2488  mp->sub_id = ntohl(sub->id);
2489  mp->sub_dot1ad = sub->eth.flags.dot1ad;
2490  mp->sub_number_of_tags = sub->eth.flags.one_tag + sub->eth.flags.two_tags*2;
2491  mp->sub_outer_vlan_id = ntohs(sub->eth.outer_vlan_id);
2492  mp->sub_inner_vlan_id = ntohs(sub->eth.inner_vlan_id);
2493  mp->sub_exact_match = sub->eth.flags.exact_match;
2494  mp->sub_default = sub->eth.flags.default_sub;
2495  mp->sub_outer_vlan_id_any = sub->eth.flags.outer_vlan_id_any;
2496  mp->sub_inner_vlan_id_any = sub->eth.flags.inner_vlan_id_any;
2497 
2498  /* vlan tag rewrite data */
2499  u32 vtr_op = L2_VTR_DISABLED;
2500  u32 vtr_push_dot1q = 0, vtr_tag1 = 0, vtr_tag2 = 0;
2501 
2502  if (l2vtr_get(am->vlib_main, am->vnet_main, swif->sw_if_index,
2503  &vtr_op, &vtr_push_dot1q, &vtr_tag1, &vtr_tag2) != 0) {
2504  // error - default to disabled
2505  mp->vtr_op = ntohl(L2_VTR_DISABLED);
2506  clib_warning("cannot get vlan tag rewrite for sw_if_index %d",
2507  swif->sw_if_index);
2508  } else {
2509  mp->vtr_op = ntohl(vtr_op);
2510  mp->vtr_push_dot1q = ntohl(vtr_push_dot1q);
2511  mp->vtr_tag1 = ntohl(vtr_tag1);
2512  mp->vtr_tag2 = ntohl(vtr_tag2);
2513  }
2514  }
2515 
2516  vl_msg_api_send_shmem (q, (u8 *)&mp);
2517 }
2518 
2521  vnet_sw_interface_t * swif)
2522 {
2524  vnet_main_t * vnm = am->vnet_main;
2525 
2527  swif->sw_if_index);
2528  mp = vl_msg_api_alloc (sizeof (*mp));
2529  memset (mp, 0, sizeof (*mp));
2530  mp->_vl_msg_id = ntohs(VL_API_SW_INTERFACE_SET_FLAGS);
2531  mp->sw_if_index = ntohl(swif->sw_if_index);
2532 
2534  1 : 0;
2536  1 : 0;
2537  vl_msg_api_send_shmem (q, (u8 *)&mp);
2538 }
2539 
2542  u32 sw_if_index)
2543  __attribute__((unused));
2544 
2547  u32 sw_if_index)
2548 {
2550 
2551  mp = vl_msg_api_alloc (sizeof (*mp));
2552  memset (mp, 0, sizeof (*mp));
2553  mp->_vl_msg_id = ntohs(VL_API_SW_INTERFACE_SET_FLAGS);
2554  mp->sw_if_index = ntohl(sw_if_index);
2555 
2556  mp->admin_up_down = 0;
2557  mp->link_up_down = 0;
2558  mp->deleted = 1;
2559  vl_msg_api_send_shmem (q, (u8 *)&mp);
2560 }
2561 
2564 {
2565  vpe_api_main_t * am = &vpe_api_main;
2566  vnet_sw_interface_t * swif;
2568  u8 * filter_string = 0, * name_string = 0;
2570  char * strcasestr (char *, char *); /* lnx hdr file botch */
2571 
2573 
2574  if (q == 0)
2575  return;
2576 
2577  if (mp->name_filter_valid) {
2578  mp->name_filter [ARRAY_LEN(mp->name_filter)-1] = 0;
2579  filter_string = format (0, "%s%c", mp->name_filter, 0);
2580  }
2581 
2582  pool_foreach (swif, im->sw_interfaces,
2583  ({
2584  name_string = format (name_string, "%U%c",
2585  format_vnet_sw_interface_name,
2586  am->vnet_main, swif, 0);
2587 
2588  if (mp->name_filter_valid == 0 ||
2589  strcasestr((char *) name_string, (char *) filter_string)) {
2590 
2591  send_sw_interface_details (am, q, swif, name_string, mp->context);
2592  send_sw_interface_flags (am, q, swif);
2593  }
2594  _vec_len (name_string) = 0;
2595  }));
2596 
2597  vec_free (name_string);
2598  vec_free (filter_string);
2599 }
2600 
2602 {
2603  vpe_api_main_t * vam = &vpe_api_main;
2606  vl_api_oam_event_t * mp;
2607 
2608  pool_foreach(reg, vam->oam_events_registrations,
2609  ({
2610  q = vl_api_client_index_to_input_queue (reg->client_index);
2611  if (q) {
2612  mp = vl_msg_api_alloc (sizeof (*mp));
2613  mp->_vl_msg_id = ntohs (VL_API_OAM_EVENT);
2614  clib_memcpy (mp->dst_address, &t->dst_address, sizeof (mp->dst_address));
2615  mp->state = t->state;
2616  vl_msg_api_send_shmem (q, (u8 *)&mp);
2617  }
2618  }));
2619 }
2620 
2621 static void
2623 {
2625  int rv;
2626 
2628  (ip4_address_t *)mp->dst_address,
2629  ntohl(mp->vrf_id),
2630  (int)(mp->is_add));
2631 
2632  REPLY_MACRO(VL_API_OAM_ADD_DEL_REPLY);
2633 }
2634 
2635 static void
2638 {
2639  stats_main_t * sm = &stats_main;
2643  vlib_counter_t v;
2644  int i, which;
2645  u64 total_pkts[VLIB_N_RX_TX];
2646  u64 total_bytes[VLIB_N_RX_TX];
2647 
2650 
2651  if (!q)
2652  return;
2653 
2654  rmp = vl_msg_api_alloc (sizeof (*rmp));
2655  rmp->_vl_msg_id = ntohs(VL_API_VNET_SUMMARY_STATS_REPLY);
2656  rmp->context = mp->context;
2657  rmp->retval = 0;
2658 
2659  memset (total_pkts, 0, sizeof (total_pkts));
2660  memset (total_bytes, 0, sizeof (total_bytes));
2661 
2663 
2665  which = cm - im->combined_sw_if_counters;
2666 
2667  for (i = 0; i < vec_len (cm->maxi); i++) {
2668  vlib_get_combined_counter (cm, i, &v);
2669  total_pkts[which] += v.packets;
2670  total_bytes[which] += v.bytes;
2671  }
2672  }
2674 
2675  /* Note: in HOST byte order! */
2676  rmp->total_pkts[VLIB_RX] = total_pkts[VLIB_RX];
2677  rmp->total_bytes[VLIB_RX] = total_bytes[VLIB_RX];
2678  rmp->total_pkts[VLIB_TX] = total_pkts[VLIB_TX];
2679  rmp->total_bytes[VLIB_TX] = total_bytes[VLIB_TX];
2681 
2682  vl_msg_api_send_shmem (q, (u8 *)&rmp);
2683 }
2684 
2685 typedef CLIB_PACKED (struct {
2686  ip4_address_t address;
2687 
2688  u32 address_length : 6;
2689 
2690  u32 index : 26;
2691 }) ip4_route_t;
2692 
2693 static int ip4_reset_fib_t_handler (vl_api_reset_fib_t *mp)
2694 {
2695  vnet_main_t * vnm = vnet_get_main();
2697  ip4_main_t * im4 = &ip4_main;
2698  static ip4_route_t * routes;
2699  static u32 * sw_if_indices_to_shut;
2700  stats_main_t * sm = &stats_main;
2701  ip4_route_t * r;
2702  ip4_fib_t * fib;
2703  u32 sw_if_index;
2704  int i;
2705  int rv = VNET_API_ERROR_NO_SUCH_FIB;
2706  u32 target_fib_id = ntohl(mp->vrf_id);
2707 
2708  dslock (sm, 1 /* release hint */, 8 /* tag */);
2709 
2710  vec_foreach (fib, im4->fibs) {
2711  vnet_sw_interface_t * si;
2712 
2713  if (fib->table_id != target_fib_id)
2714  continue;
2715 
2716  /* remove any mpls/gre tunnels in this fib */
2718 
2719  /* remove any mpls encap/decap labels */
2721 
2722  /* remove any proxy arps in this fib */
2724 
2725  /* Set the flow hash for this fib to the default */
2727 
2728  vec_reset_length (sw_if_indices_to_shut);
2729 
2730  /* Shut down interfaces in this FIB / clean out intfc routes */
2731  pool_foreach (si, im->sw_interfaces,
2732  ({
2733  u32 sw_if_index = si->sw_if_index;
2734 
2735  if (sw_if_index < vec_len (im4->fib_index_by_sw_if_index)
2736  && (im4->fib_index_by_sw_if_index[si->sw_if_index] ==
2737  fib - im4->fibs))
2738  vec_add1 (sw_if_indices_to_shut, si->sw_if_index);
2739  }));
2740 
2741  for (i = 0; i < vec_len (sw_if_indices_to_shut); i++) {
2742  sw_if_index = sw_if_indices_to_shut[i];
2743  // vec_foreach (sw_if_index, sw_if_indices_to_shut) {
2744 
2745  u32 flags = vnet_sw_interface_get_flags (vnm, sw_if_index);
2746  flags &= ~(VNET_SW_INTERFACE_FLAG_ADMIN_UP);
2747  vnet_sw_interface_set_flags (vnm, sw_if_index, flags);
2748  }
2749 
2750  vec_reset_length (routes);
2751 
2752  for (i = 0; i < ARRAY_LEN (fib->adj_index_by_dst_address); i++) {
2753  uword * hash = fib->adj_index_by_dst_address[i];
2754  hash_pair_t * p;
2755  ip4_route_t x;
2756 
2757  x.address_length = i;
2758 
2759  hash_foreach_pair (p, hash,
2760  ({
2761  x.address.data_u32 = p->key;
2762  vec_add1 (routes, x);
2763  }));
2764  }
2765 
2766  vec_foreach (r, routes) {
2768 
2769  memset (&a, 0, sizeof (a));
2771  a.table_index_or_table_id = fib - im4->fibs;
2772  a.dst_address = r->address;
2773  a.dst_address_length = r->address_length;
2774  a.adj_index = ~0;
2775 
2776  ip4_add_del_route (im4, &a);
2777  ip4_maybe_remap_adjacencies (im4, fib - im4->fibs,
2779  }
2780  rv = 0;
2781  break;
2782  } /* vec_foreach (fib) */
2783 
2784  dsunlock(sm);
2785  return rv;
2786 }
2787 
2788 typedef struct {
2789  ip6_address_t address;
2790  u32 address_length;
2791  u32 index;
2792 } ip6_route_t;
2793 
2794 typedef struct {
2795  u32 fib_index;
2796  ip6_route_t ** routep;
2798 
2799 static void add_routes_in_fib (clib_bihash_kv_24_8_t * kvp, void *arg)
2800 {
2801  add_routes_in_fib_arg_t * ap = arg;
2802 
2803  if (kvp->key[2]>>32 == ap->fib_index)
2804  {
2806  ip6_route_t * r;
2807  addr = (ip6_address_t *) kvp;
2808  vec_add2 (*ap->routep, r, 1);
2809  r->address = addr[0];
2810  r->address_length = kvp->key[2] & 0xFF;
2811  r->index = kvp->value;
2812  }
2813 }
2814 
2816 {
2817  vnet_main_t * vnm = vnet_get_main();
2819  ip6_main_t * im6 = &ip6_main;
2820  stats_main_t * sm = &stats_main;
2821  static ip6_route_t * routes;
2822  static u32 * sw_if_indices_to_shut;
2823  ip6_route_t * r;
2824  ip6_fib_t * fib;
2825  u32 sw_if_index;
2826  int i;
2827  int rv = VNET_API_ERROR_NO_SUCH_FIB;
2828  u32 target_fib_id = ntohl(mp->vrf_id);
2829  add_routes_in_fib_arg_t _a, *a=&_a;
2830  clib_bihash_24_8_t * h = &im6->ip6_lookup_table;
2831 
2832  dslock (sm, 1 /* release hint */, 9 /* tag */);
2833 
2834  vec_foreach (fib, im6->fibs) {
2835  vnet_sw_interface_t * si;
2836 
2837  if (fib->table_id != target_fib_id)
2838  continue;
2839 
2840  vec_reset_length (sw_if_indices_to_shut);
2841 
2842  /* Shut down interfaces in this FIB / clean out intfc routes */
2843  pool_foreach (si, im->sw_interfaces,
2844  ({
2845  if (im6->fib_index_by_sw_if_index[si->sw_if_index] ==
2846  fib - im6->fibs)
2847  vec_add1 (sw_if_indices_to_shut, si->sw_if_index);
2848  }));
2849 
2850  for (i = 0; i < vec_len (sw_if_indices_to_shut); i++) {
2851  sw_if_index = sw_if_indices_to_shut[i];
2852  // vec_foreach (sw_if_index, sw_if_indices_to_shut) {
2853 
2854  u32 flags = vnet_sw_interface_get_flags (vnm, sw_if_index);
2855  flags &= ~(VNET_SW_INTERFACE_FLAG_ADMIN_UP);
2856  vnet_sw_interface_set_flags (vnm, sw_if_index, flags);
2857  }
2858 
2859  vec_reset_length (routes);
2860 
2861  a->fib_index = fib - im6->fibs;
2862  a->routep = &routes;
2863 
2864  clib_bihash_foreach_key_value_pair_24_8 (h, add_routes_in_fib, a);
2865 
2866  vec_foreach (r, routes) {
2868 
2869  memset (&a, 0, sizeof (a));
2871  a.table_index_or_table_id = fib - im6->fibs;
2872  a.dst_address = r->address;
2874  a.adj_index = ~0;
2875 
2876  ip6_add_del_route (im6, &a);
2877  ip6_maybe_remap_adjacencies (im6, fib - im6->fibs,
2879  }
2880  rv = 0;
2881  /* Reinstall the neighbor / router discovery routes */
2882  vnet_ip6_fib_init (im6, fib - im6->fibs);
2883  break;
2884  } /* vec_foreach (fib) */
2885 
2886  dsunlock(sm);
2887  return rv;
2888 }
2889 
2891 {
2892  int rv;
2894 
2895  if (mp->is_ipv6)
2896  rv = ip6_reset_fib_t_handler (mp);
2897  else
2898  rv = ip4_reset_fib_t_handler (mp);
2899 
2900  REPLY_MACRO(VL_API_RESET_FIB_REPLY);
2901 }
2902 
2903 
2904 static void
2906 {
2908  int rv;
2909 
2911  (ip4_address_t *)(&mp->dhcp_src_address),
2912  (u32) ntohl(mp->vrf_id),
2913  (int) mp->insert_circuit_id,
2914  (int) (mp->is_add == 0));
2915 
2916  REPLY_MACRO(VL_API_DHCP_PROXY_CONFIG_REPLY);
2917 }
2918 
2919 
2920 static void
2922 {
2924  int rv = -1;
2925 
2927  (ip6_address_t *)(&mp->dhcp_src_address),
2928  (u32) ntohl(mp->vrf_id),
2929  (int) mp->insert_circuit_id,
2930  (int) (mp->is_add == 0));
2931 
2932  REPLY_MACRO(VL_API_DHCP_PROXY_CONFIG_REPLY);
2933 }
2934 
2935 static void
2937 {
2939  int rv;
2940 
2942  (ip4_address_t *)(&mp->dhcp_src_address),
2943  (u32) ntohl(mp->rx_vrf_id),
2944  (u32) ntohl(mp->server_vrf_id),
2945  (int) mp->insert_circuit_id,
2946  (int) (mp->is_add == 0));
2947 
2948  REPLY_MACRO(VL_API_DHCP_PROXY_CONFIG_2_REPLY);
2949 }
2950 
2951 
2952 static void
2954 {
2956  int rv = -1;
2957 
2958 #if 0 // $$$$ FIXME
2959  rv = dhcpv6_proxy_set_server_2 ((ip6_address_t *)(&mp->dhcp_server),
2960  (ip6_address_t *)(&mp->dhcp_src_address),
2961  (u32) ntohl(mp->rx_vrf_id),
2962  (u32) ntohl(mp->server_vrf_id),
2963  (int) mp->insert_circuit_id,
2964  (int) (mp->is_add == 0));
2965 #else
2966  rv = VNET_API_ERROR_UNIMPLEMENTED;
2967 #endif
2968 
2969  REPLY_MACRO(VL_API_DHCP_PROXY_CONFIG_2_REPLY);
2970 }
2971 
2972 
2973 static void
2975 {
2977  int rv;
2978  if (!mp->is_ipv6)
2979  rv = dhcp_proxy_set_option82_vss(ntohl(mp->tbl_id),
2980  ntohl(mp->oui),
2981  ntohl(mp->fib_id),
2982  (int)mp->is_add == 0);
2983  else
2984  rv = dhcpv6_proxy_set_vss( ntohl(mp->tbl_id),
2985  ntohl(mp->oui),
2986  ntohl(mp->fib_id),
2987  (int)mp->is_add == 0);
2988 
2989  REPLY_MACRO(VL_API_DHCP_PROXY_SET_VSS_REPLY);
2990 }
2991 
2992 
2995 {
2996  if (mp->is_ipv6 == 0)
2997  dhcpv4_proxy_config (mp);
2998  else
2999  dhcpv6_proxy_config (mp);
3000 }
3001 
3004 {
3005  if (mp->is_ipv6 == 0)
3006  dhcpv4_proxy_config_2 (mp);
3007  else
3008  dhcpv6_proxy_config_2 (mp);
3009 }
3010 
3011 void dhcp_compl_event_callback (u32 client_index, u32 pid, u8 * hostname,
3012  u8 is_ipv6, u8 * host_address, u8 * router_address, u8 * host_mac)
3013 {
3016 
3017  q = vl_api_client_index_to_input_queue (client_index);
3018  if (!q)
3019  return;
3020 
3021  mp = vl_msg_api_alloc (sizeof (*mp));
3022  mp->client_index = client_index;
3023  mp->pid = pid;
3024  mp->is_ipv6 = is_ipv6;
3025  clib_memcpy (&mp->hostname, hostname, vec_len(hostname));
3026  mp->hostname[vec_len(hostname) + 1] = '\n';
3027  clib_memcpy (&mp->host_address[0], host_address, 16);
3028  clib_memcpy (&mp->router_address[0], router_address, 16);
3029  clib_memcpy (&mp->host_mac[0], host_mac, 6);
3030 
3031  mp->_vl_msg_id = ntohs (VL_API_DHCP_COMPL_EVENT);
3032 
3033  vl_msg_api_send_shmem (q, (u8 *)&mp);
3034 }
3035 
3038 {
3039  vlib_main_t *vm = vlib_get_main();
3041  int rv = 0;
3042 
3044 
3045  rv = dhcp_client_config(vm, ntohl(mp->sw_if_index),
3046  mp->hostname, mp->is_add, mp->client_index,
3048  mp->pid);
3049 
3051 
3052  REPLY_MACRO(VL_API_DHCP_CLIENT_CONFIG_REPLY);
3053 }
3054 
3055 static void
3058 {
3060  int rv = 0;
3061  u8 is_no, surpress, managed, other, ll_option, send_unicast, cease, default_router;
3062 
3063  is_no = mp->is_no == 1;
3064  surpress = mp->surpress == 1;
3065  managed = mp->managed == 1;
3066  other = mp->other == 1;
3067  ll_option = mp->ll_option == 1;
3068  send_unicast = mp->send_unicast == 1;
3069  cease = mp->cease == 1;
3070  default_router = mp->default_router == 1;
3071 
3073 
3074  rv = ip6_neighbor_ra_config(vm, ntohl(mp->sw_if_index),
3075  surpress, managed, other,
3076  ll_option, send_unicast, cease,
3077  default_router, ntohl (mp->lifetime),
3078  ntohl(mp->initial_count), ntohl(mp->initial_interval),
3079  ntohl(mp->max_interval), ntohl( mp->min_interval),
3080  is_no);
3081 
3083 
3084  REPLY_MACRO(VL_API_SW_INTERFACE_IP6ND_RA_CONFIG_REPLY);
3085 }
3086 
3087 static void
3090 {
3092  int rv = 0;
3093  u8 is_no, use_default, no_advertise, off_link, no_autoconfig, no_onlink;
3094 
3096 
3097  is_no = mp->is_no == 1;
3098  use_default = mp->use_default == 1;
3099  no_advertise = mp->no_advertise == 1;
3100  off_link = mp->off_link == 1;
3101  no_autoconfig = mp->no_autoconfig == 1;
3102  no_onlink = mp->no_onlink == 1;
3103 
3104  rv = ip6_neighbor_ra_prefix(vm, ntohl(mp->sw_if_index),
3105  (ip6_address_t *)mp->address, mp->address_length,
3106  use_default, ntohl(mp->val_lifetime), ntohl(mp->pref_lifetime),
3107  no_advertise, off_link, no_autoconfig, no_onlink,
3108  is_no);
3109 
3111  REPLY_MACRO(VL_API_SW_INTERFACE_IP6ND_RA_PREFIX_REPLY);
3112 }
3113 
3114 static void
3117 {
3119  vnet_main_t * vnm = vnet_get_main();
3120  int rv = 0;
3121  clib_error_t * error;
3122 
3123  vnm->api_errno = 0;
3124 
3126 
3127  error = ( mp->enable == 1) ? enable_ip6_interface(vm,ntohl(mp->sw_if_index)) :
3128  disable_ip6_interface(vm,ntohl(mp->sw_if_index));
3129 
3130  if (error) {
3131  clib_error_report(error);
3132  rv = VNET_API_ERROR_UNSPECIFIED;
3133  } else {
3134  rv = vnm->api_errno;
3135  }
3136 
3138 
3139  REPLY_MACRO(VL_API_SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY);
3140 }
3141 
3142 static void
3145 {
3147  int rv = 0;
3148  clib_error_t * error;
3149  vnet_main_t * vnm = vnet_get_main();
3150 
3151  vnm->api_errno = 0;
3152 
3154 
3155  error = set_ip6_link_local_address(vm,
3156  ntohl(mp->sw_if_index),
3157  (ip6_address_t *)mp->address,
3158  mp->address_length);
3159  if (error) {
3160  clib_error_report(error);
3161  rv = VNET_API_ERROR_UNSPECIFIED;
3162  } else {
3163  rv = vnm->api_errno;
3164  }
3165 
3167 
3168  REPLY_MACRO(VL_API_SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY);
3169 }
3170 
3172 {
3174  int rv = VNET_API_ERROR_UNIMPLEMENTED;
3175 
3176  clib_warning ("unimplemented...");
3177 
3178  REPLY_MACRO(VL_API_SET_IP_FLOW_HASH_REPLY);
3179 }
3180 
3182 {
3184  int rv;
3185  u32 table_id;
3186  u32 flow_hash_config = 0;
3187 
3188  table_id = ntohl(mp->vrf_id);
3189 
3190 #define _(a,b) if (mp->a) flow_hash_config |= b;
3192 #undef _
3193 
3194  rv = vnet_set_ip4_flow_hash (table_id, flow_hash_config);
3195 
3196  REPLY_MACRO(VL_API_SET_IP_FLOW_HASH_REPLY);
3197 }
3198 
3199 
3202 {
3203  if (mp->is_ipv6 == 0)
3204  set_ip4_flow_hash (mp);
3205  else
3206  set_ip6_flow_hash (mp);
3207 }
3208 
3211 {
3213  int rv = 0;
3214  vnet_sw_interface_t * si;
3215  vnet_main_t *vnm = vnet_get_main();
3216  u32 sw_if_index, unnumbered_sw_if_index;
3217 
3218  sw_if_index = ntohl(mp->sw_if_index);
3219  unnumbered_sw_if_index = ntohl(mp->unnumbered_sw_if_index);
3220 
3221  /*
3222  * The API message field names are backwards from
3223  * the underlying data structure names.
3224  * It's not worth changing them now.
3225  */
3227  unnumbered_sw_if_index)) {
3228  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
3229  goto done;
3230  }
3231 
3232  /* Only check the "use loop0" field when setting the binding */
3233  if (mp->is_add &&
3234  pool_is_free_index (vnm->interface_main.sw_interfaces, sw_if_index)) {
3235  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX_2;
3236  goto done;
3237  }
3238 
3239  si = vnet_get_sw_interface (vnm, unnumbered_sw_if_index);
3240 
3241  if (mp->is_add) {
3243  si->unnumbered_sw_if_index = sw_if_index;
3244  } else {
3246  si->unnumbered_sw_if_index = (u32)~0;
3247  }
3248 
3249  done:
3250  REPLY_MACRO(VL_API_SW_INTERFACE_SET_UNNUMBERED_REPLY);
3251 }
3252 
3255 {
3257  u32 sw_if_index;
3258  int rv;
3259 
3260  rv = vnet_create_loopback_interface (&sw_if_index, mp->mac_address);
3261 
3262  REPLY_MACRO2(VL_API_CREATE_LOOPBACK_REPLY,
3263  ({
3264  rmp->sw_if_index = ntohl (sw_if_index);
3265  }));
3266 }
3267 
3270 {
3272  u32 sw_if_index;
3273  int rv;
3274 
3275  sw_if_index = ntohl (mp->sw_if_index);
3276  rv = vnet_delete_loopback_interface (sw_if_index);
3277 
3278  REPLY_MACRO(VL_API_DELETE_LOOPBACK_REPLY);
3279 }
3280 
3283 {
3285  int rv = 0;
3286 
3287  REPLY_MACRO2(VL_API_CONTROL_PING_REPLY,
3288  ({
3289  rmp->vpe_pid = ntohl (getpid());
3290  }));
3291 }
3292 
3293 static void shmem_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
3294 {
3295  u8 **shmem_vecp = (u8 **)arg;
3296  u8 *shmem_vec;
3297  void *oldheap;
3298  api_main_t * am = &api_main;
3299  u32 offset;
3300 
3301  shmem_vec = *shmem_vecp;
3302 
3303  offset = vec_len (shmem_vec);
3304 
3305  pthread_mutex_lock (&am->vlib_rp->mutex);
3306  oldheap = svm_push_data_heap (am->vlib_rp);
3307 
3308  vec_validate (shmem_vec, offset + buffer_bytes - 1);
3309 
3310  clib_memcpy (shmem_vec + offset, buffer, buffer_bytes);
3311 
3312  svm_pop_heap (oldheap);
3313  pthread_mutex_unlock (&am->vlib_rp->mutex);
3314 
3315  *shmem_vecp = shmem_vec;
3316 }
3317 
3318 
3319 static void vl_api_cli_request_t_handler
3321 {
3322  vl_api_cli_reply_t *rp;
3324  vlib_main_t * vm = vlib_get_main();
3325  api_main_t * am = &api_main;
3326  unformat_input_t input;
3327  u8 *shmem_vec=0;
3328  void *oldheap;
3329 
3331  if (!q)
3332  return;
3333 
3334  rp = vl_msg_api_alloc (sizeof (*rp));
3335  rp->_vl_msg_id = ntohs(VL_API_CLI_REPLY);
3336  rp->context = mp->context;
3337 
3338  unformat_init_vector (&input, (u8 *)(uword)mp->cmd_in_shmem);
3339 
3340  vlib_cli_input (vm, &input, shmem_cli_output,
3341  (uword)&shmem_vec);
3342 
3343  pthread_mutex_lock (&am->vlib_rp->mutex);
3344  oldheap = svm_push_data_heap (am->vlib_rp);
3345 
3346  vec_add1(shmem_vec, 0);
3347 
3348  svm_pop_heap (oldheap);
3349  pthread_mutex_unlock (&am->vlib_rp->mutex);
3350 
3351  rp->reply_in_shmem = (uword)shmem_vec;
3352 
3353  vl_msg_api_send_shmem (q, (u8 *)&rp);
3354 }
3355 
3357 {
3358  int rv;
3360  vnet_main_t *vnm = vnet_get_main();
3361  clib_error_t * error;
3362 
3363  vnm->api_errno = 0;
3364 
3365  if (mp->is_ipv6)
3366  error = ip6_set_neighbor_limit (ntohl(mp->arp_neighbor_limit));
3367  else
3368  error = ip4_set_arp_limit (ntohl(mp->arp_neighbor_limit));
3369 
3370  if (error) {
3371  clib_error_report(error);
3372  rv = VNET_API_ERROR_UNSPECIFIED;
3373  } else {
3374  rv = vnm->api_errno;
3375  }
3376 
3377  REPLY_MACRO(VL_API_SET_ARP_NEIGHBOR_LIMIT_REPLY);
3378 }
3379 
3382 {
3383 #if IPV6SR == 0
3384  clib_warning ("unimplemented");
3385 #else
3387  int rv = 0;
3389  ip6_address_t * segments = 0, * seg;
3390  ip6_address_t * tags = 0, *tag;
3391  ip6_address_t * this_address;
3392  int i;
3393 
3394  if (mp->n_segments == 0) {
3395  rv = -11;
3396  goto out;
3397  }
3398 
3399  memset (a, 0, sizeof (*a));
3400  a->src_address = (ip6_address_t *)&mp->src_address;
3401  a->dst_address = (ip6_address_t *)&mp->dst_address;
3402  a->dst_mask_width = mp->dst_mask_width;
3404  a->is_del = (mp->is_add == 0);
3405  a->rx_table_id = ntohl(mp->outer_vrf_id);
3406  a->tx_table_id = ntohl(mp->inner_vrf_id);
3407 
3408  a->name = format(0, "%s", mp->name);
3409  if (!(vec_len(a->name)))
3410  a->name = 0;
3411 
3412  a->policy_name = format(0, "%s", mp->policy_name);
3413  if (!(vec_len(a->policy_name)))
3414  a->policy_name = 0;
3415 
3416  /* Yank segments and tags out of the API message */
3417  this_address = (ip6_address_t *)mp->segs_and_tags;
3418  for (i = 0; i < mp->n_segments; i++) {
3419  vec_add2 (segments, seg, 1);
3420  clib_memcpy (seg->as_u8, this_address->as_u8, sizeof (*this_address));
3421  this_address++;
3422  }
3423  for (i = 0; i < mp->n_tags; i++) {
3424  vec_add2 (tags, tag, 1);
3425  clib_memcpy (tag->as_u8, this_address->as_u8, sizeof (*this_address));
3426  this_address++;
3427  }
3428 
3429  a->segments = segments;
3430  a->tags = tags;
3431 
3432  rv = ip6_sr_add_del_tunnel (a);
3433 
3434 out:
3435 
3436  REPLY_MACRO(VL_API_SR_TUNNEL_ADD_DEL_REPLY);
3437 #endif
3438 }
3439 
3442 {
3443 #if IPV6SR == 0
3444  clib_warning ("unimplemented");
3445 #else
3447  int rv = 0;
3449  int i;
3450 
3451  memset (a, 0, sizeof (*a));
3452  a->is_del = (mp->is_add == 0);
3453 
3454  a->name = format(0, "%s", mp->name);
3455  if (!(vec_len(a->name)))
3456  {
3457  rv = VNET_API_ERROR_NO_SUCH_NODE2;
3458  goto out;
3459  }
3460 
3461  if (!(mp->tunnel_names[0]))
3462  {
3463  rv = VNET_API_ERROR_NO_SUCH_NODE2;
3464  goto out;
3465  }
3466 
3467  // start deserializing tunnel_names
3468  int num_tunnels = mp->tunnel_names[0]; //number of tunnels
3469  u8 * deser_tun_names = mp->tunnel_names;
3470  deser_tun_names += 1; //moving along
3471 
3472  u8 * tun_name = 0;
3473  int tun_name_len = 0;
3474 
3475  for (i=0; i < num_tunnels; i++)
3476  {
3477  tun_name_len= *deser_tun_names;
3478  deser_tun_names += 1;
3479  vec_resize (tun_name, tun_name_len);
3480  memcpy(tun_name, deser_tun_names, tun_name_len);
3481  vec_add1 (a->tunnel_names, tun_name);
3482  deser_tun_names += tun_name_len;
3483  tun_name = 0;
3484  }
3485 
3486  rv = ip6_sr_add_del_policy (a);
3487 
3488 out:
3489 
3490  REPLY_MACRO(VL_API_SR_POLICY_ADD_DEL_REPLY);
3491 #endif
3492 }
3493 
3496 {
3497 #if IPV6SR == 0
3498  clib_warning ("unimplemented");
3499 #else
3501  int rv = 0;
3503 
3504  memset (a, 0, sizeof (*a));
3505  a->is_del = (mp->is_add == 0);
3506 
3508  a->policy_name = format(0, "%s", mp->policy_name);
3509 
3510  if (a->multicast_address == 0)
3511  {
3512  rv = -1 ;
3513  goto out;
3514  }
3515 
3516  if (!(a->policy_name))
3517  {
3518  rv = -2 ;
3519  goto out;
3520  }
3521 
3522 #if DPDK > 0 /* Cannot call replicate without DPDK */
3523  rv = ip6_sr_add_del_multicastmap (a);
3524 #else
3525  clib_warning ("multicast replication without DPDK not implemented");
3526  rv = VNET_API_ERROR_UNIMPLEMENTED;
3527 #endif /* DPDK */
3528 
3529 out:
3530 
3531  REPLY_MACRO(VL_API_SR_MULTICAST_MAP_ADD_DEL_REPLY);
3532 #endif
3533 }
3534 
3535 #define foreach_classify_add_del_table_field \
3536 _(table_index) \
3537 _(nbuckets) \
3538 _(memory_size) \
3539 _(skip_n_vectors) \
3540 _(match_n_vectors) \
3541 _(next_table_index) \
3542 _(miss_next_index)
3543 
3546 {
3550  int rv;
3551 
3552 #define _(a) u32 a;
3554 #undef _
3555 
3556 #define _(a) a = ntohl(mp->a);
3558 #undef _
3559 
3560  /* The underlying API fails silently, on purpose, so check here */
3561  if (mp->is_add == 0)
3562  if (pool_is_free_index (cm->tables, table_index)) {
3563  rv = VNET_API_ERROR_NO_SUCH_TABLE;
3564  goto out;
3565  }
3566 
3568  (cm, mp->mask, nbuckets, memory_size,
3569  skip_n_vectors, match_n_vectors,
3570  next_table_index, miss_next_index,
3571  &table_index, mp->is_add);
3572 
3573 out:
3574  REPLY_MACRO2(VL_API_CLASSIFY_ADD_DEL_TABLE_REPLY,
3575  ({
3576  if (rv == 0 && mp->is_add) {
3577  t = pool_elt_at_index (cm->tables, table_index);
3578  rmp->skip_n_vectors = ntohl(t->skip_n_vectors);
3579  rmp->match_n_vectors = ntohl(t->match_n_vectors);
3580  rmp->new_table_index = ntohl(table_index);
3581  } else {
3582  rmp->skip_n_vectors = ~0;
3583  rmp->match_n_vectors = ~0;
3584  rmp->new_table_index = ~0;
3585  }
3586  }));
3587 }
3588 
3591 {
3594  int rv;
3595  u32 table_index, hit_next_index, opaque_index;
3596  i32 advance;
3597 
3598  table_index = ntohl (mp->table_index);
3599  hit_next_index = ntohl (mp->hit_next_index);
3600  opaque_index = ntohl (mp->opaque_index);
3601  advance = ntohl (mp->advance);
3602 
3604  (cm, table_index, mp->match, hit_next_index, opaque_index,
3605  advance, mp->is_add);
3606 
3607  REPLY_MACRO(VL_API_CLASSIFY_ADD_DEL_SESSION_REPLY);
3608 }
3609 
3612 {
3613  vlib_main_t * vm = vlib_get_main();
3615  int rv;
3616  u32 table_index, sw_if_index;
3617 
3618  table_index = ntohl (mp->table_index);
3619  sw_if_index = ntohl (mp->sw_if_index);
3620 
3622 
3623  if (mp->is_ipv6)
3624  rv = vnet_set_ip6_classify_intfc (vm, sw_if_index, table_index);
3625  else
3626  rv = vnet_set_ip4_classify_intfc (vm, sw_if_index, table_index);
3627 
3629 
3630  REPLY_MACRO(VL_API_CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY);
3631 }
3632 
3635 {
3637  int rv;
3638  u32 sw_if_index, ip4_table_index, ip6_table_index, other_table_index;
3639  int enable;
3640 
3641  ip4_table_index = ntohl(mp->ip4_table_index);
3642  ip6_table_index = ntohl(mp->ip6_table_index);
3643  other_table_index = ntohl(mp->other_table_index);
3644  sw_if_index = ntohl(mp->sw_if_index);
3645 
3647 
3648  rv = vnet_l2_classify_set_tables (sw_if_index, ip4_table_index,
3649  ip6_table_index, other_table_index);
3650 
3651  if (rv == 0) {
3652  if (ip4_table_index != ~0 || ip6_table_index != ~0
3653  || other_table_index != ~0)
3654  enable = 1;
3655  else
3656  enable = 0;
3657 
3658  vnet_l2_classify_enable_disable (sw_if_index, enable);
3659  }
3660 
3662 
3663  REPLY_MACRO(VL_API_CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY);
3664 }
3665 
3666 static void
3668 {
3669  int rv = 0;
3671 
3672  /* DAW-FIXME: This API should only clear non-static l2fib entries, but
3673  * that is not currently implemented. When that TODO is fixed
3674  * this call should be changed to pass 1 instead of 0.
3675  */
3676  l2fib_clear_table (0);
3677 
3678  REPLY_MACRO(VL_API_L2_FIB_CLEAR_TABLE_REPLY);
3679 }
3680 
3681 extern void l2_efp_filter_configure(vnet_main_t * vnet_main,
3682  u32 sw_if_index,
3683  u32 enable);
3684 
3685 static void
3687 {
3688  int rv;
3690  vnet_main_t *vnm = vnet_get_main();
3691 
3692  // enable/disable the feature
3694  rv = vnm->api_errno;
3695 
3696  REPLY_MACRO(VL_API_L2_INTERFACE_EFP_FILTER_REPLY);
3697 }
3698 
3699 static void
3701 {
3702  int rv = 0;
3704  vnet_main_t * vnm = vnet_get_main();
3705  vlib_main_t * vm = vlib_get_main();
3706  u32 vtr_op;
3707 
3709 
3710  vtr_op = ntohl(mp->vtr_op);
3711 
3712  /* The L2 code is unsuspicious */
3713  switch(vtr_op) {
3714  case L2_VTR_DISABLED:
3715  case L2_VTR_PUSH_1:
3716  case L2_VTR_PUSH_2:
3717  case L2_VTR_POP_1:
3718  case L2_VTR_POP_2:
3719  case L2_VTR_TRANSLATE_1_1:
3720  case L2_VTR_TRANSLATE_1_2:
3721  case L2_VTR_TRANSLATE_2_1:
3722  case L2_VTR_TRANSLATE_2_2:
3723  break;
3724 
3725  default:
3726  rv = VNET_API_ERROR_INVALID_VALUE;
3727  goto bad_sw_if_index;
3728  }
3729 
3730  rv = l2vtr_configure (vm, vnm, ntohl(mp->sw_if_index), vtr_op,
3731  ntohl(mp->push_dot1q), ntohl(mp->tag1),
3732  ntohl(mp->tag2));
3733 
3735 
3736  REPLY_MACRO(VL_API_L2_INTERFACE_VLAN_TAG_REWRITE_REPLY);
3737 }
3738 
3739 static void
3741 {
3742 #if DPDK > 0
3743  int rv = 0;
3745  u32 sw_if_index = (u32)~0;
3746 
3747  vnet_main_t * vnm = vnet_get_main();
3748  vlib_main_t * vm = vlib_get_main();
3749 
3750  rv = dpdk_vhost_user_create_if(vnm, vm, (char *)mp->sock_filename,
3751  mp->is_server, &sw_if_index, (u64)~0,
3752  mp->renumber, ntohl(mp->custom_dev_instance),
3753  (mp->use_custom_mac)?mp->mac_address:NULL);
3754 
3755  REPLY_MACRO2(VL_API_CREATE_VHOST_USER_IF_REPLY,
3756  ({
3757  rmp->sw_if_index = ntohl (sw_if_index);
3758  }));
3759 #endif
3760 }
3761 
3762 static void
3764 {
3765 #if DPDK > 0
3766  int rv = 0;
3768  u32 sw_if_index = ntohl(mp->sw_if_index);
3769 
3770  vnet_main_t * vnm = vnet_get_main();
3771  vlib_main_t * vm = vlib_get_main();
3772 
3773  rv = dpdk_vhost_user_modify_if(vnm, vm, (char *)mp->sock_filename,
3774  mp->is_server, sw_if_index, (u64)~0,
3775  mp->renumber, ntohl(mp->custom_dev_instance));
3776 
3777  REPLY_MACRO(VL_API_MODIFY_VHOST_USER_IF_REPLY);
3778 #endif
3779 }
3780 
3781 static void
3783 {
3784 #if DPDK > 0
3785  int rv = 0;
3786  vpe_api_main_t * vam = &vpe_api_main;
3788  u32 sw_if_index = ntohl(mp->sw_if_index);
3789 
3790  vnet_main_t * vnm = vnet_get_main();
3791  vlib_main_t * vm = vlib_get_main();
3792 
3793  rv = dpdk_vhost_user_delete_if(vnm, vm, sw_if_index);
3794 
3795  REPLY_MACRO(VL_API_DELETE_VHOST_USER_IF_REPLY);
3796  if (!rv) {
3799  if (!q)
3800  return;
3801 
3802  send_sw_interface_flags_deleted (vam, q, sw_if_index);
3803  }
3804 #endif
3805 }
3806 
3809 {
3810  clib_warning ("BUG");
3811 }
3812 
3813 #if DPDK > 0
3814 static void send_sw_interface_vhost_user_details (vpe_api_main_t * am,
3817  u32 context)
3818 {
3820 
3821  mp = vl_msg_api_alloc (sizeof (*mp));
3822  memset (mp, 0, sizeof (*mp));
3823  mp->_vl_msg_id = ntohs(VL_API_SW_INTERFACE_VHOST_USER_DETAILS);
3824  mp->sw_if_index = ntohl(vui->sw_if_index);
3825  mp->virtio_net_hdr_sz = ntohl (vui->virtio_net_hdr_sz);
3826  mp->features = clib_net_to_host_u64 (vui->features);
3827  mp->is_server = vui->is_server;
3828  mp->num_regions = ntohl(vui->num_regions);
3829  mp->sock_errno = ntohl(vui->sock_errno);
3830  mp->context = context;
3831 
3832  strncpy ((char *) mp->sock_filename,
3833  (char *) vui->sock_filename, ARRAY_LEN(mp->sock_filename)-1);
3834  strncpy ((char *) mp->interface_name,
3835  (char *) vui->if_name, ARRAY_LEN(mp->interface_name)-1);
3836 
3837  vl_msg_api_send_shmem (q, (u8 *)&mp);
3838 }
3839 #endif
3840 
3841 static void
3844 {
3845 #if DPDK > 0
3846  int rv = 0;
3847  vpe_api_main_t * am = &vpe_api_main;
3848  vnet_main_t * vnm = vnet_get_main();
3849  vlib_main_t * vm = vlib_get_main();
3850  vhost_user_intf_details_t *ifaces = NULL;
3853 
3855  if (q == 0)
3856  return;
3857 
3858  rv = dpdk_vhost_user_dump_ifs(vnm, vm, &ifaces);
3859  if (rv)
3860  return;
3861 
3862  vec_foreach (vuid, ifaces) {
3863  send_sw_interface_vhost_user_details (am, q, vuid, mp->context);
3864  }
3865  vec_free(ifaces);
3866 #endif
3867 }
3868 
3871  l2t_session_t *s,
3872  l2t_main_t * lm,
3873  u32 context)
3874 {
3876  u8 * if_name = NULL;
3877  vnet_sw_interface_t * si = NULL;
3878 
3880 
3881  if_name = format(if_name, "%U",
3883 
3884  mp = vl_msg_api_alloc (sizeof (*mp));
3885  memset (mp, 0, sizeof (*mp));
3886  mp->_vl_msg_id = ntohs(VL_API_SW_IF_L2TPV3_TUNNEL_DETAILS);
3887  strncpy((char *)mp->interface_name,
3888  (char *)if_name, ARRAY_LEN(mp->interface_name)-1);
3889  mp->sw_if_index = ntohl(si->sw_if_index);
3892  mp->local_cookie[0] = s->local_cookie[0];
3893  mp->local_cookie[1] = s->local_cookie[1];
3894  mp->remote_cookie = s->remote_cookie;
3896  clib_memcpy(mp->our_address, &s->our_address, sizeof(s->our_address));
3898  mp->context = context;
3899 
3900  vl_msg_api_send_shmem (q, (u8 *)&mp);
3901 }
3902 
3905  u8 * ip,
3906  u16 prefix_length,
3907  u8 is_ipv6,
3908  u32 context)
3909 {
3911 
3912  mp = vl_msg_api_alloc (sizeof (*mp));
3913  memset (mp, 0, sizeof (*mp));
3914  mp->_vl_msg_id = ntohs(VL_API_IP_ADDRESS_DETAILS);
3915 
3916  if (is_ipv6) {
3917  clib_memcpy(&mp->ip, ip, sizeof(mp->ip));
3918  } else {
3919  u32 * tp = (u32 *)mp->ip;
3920  *tp = ntohl(*(u32*)ip);
3921  }
3922  mp->prefix_length = prefix_length;
3923  mp->context = context;
3924 
3925  vl_msg_api_send_shmem (q, (u8 *)&mp);
3926 }
3927 
3928 static void
3930 {
3931  vpe_api_main_t * am = &vpe_api_main;
3933  ip6_address_t * r6;
3934  ip4_address_t * r4;
3935  ip6_main_t * im6 = &ip6_main;
3936  ip4_main_t * im4 = &ip4_main;
3937  ip_lookup_main_t * lm6 = &im6->lookup_main;
3938  ip_lookup_main_t * lm4 = &im4->lookup_main;
3939  ip_interface_address_t * ia = 0;
3940  u32 sw_if_index = ~0;
3941  int rv __attribute__ ((unused)) = 0;
3942 
3944 
3945  sw_if_index = ntohl(mp->sw_if_index);
3946 
3948  if (q == 0) {
3949  return;
3950  }
3951 
3952  if (mp->is_ipv6) {
3953  foreach_ip_interface_address (lm6, ia, sw_if_index,
3954  1 /* honor unnumbered */,
3955  ({
3956  r6 = ip_interface_address_get_address (lm6, ia);
3957  u16 prefix_length = ia->address_length;
3958  send_ip_address_details(am, q, (u8*)r6, prefix_length, 1, mp->context);
3959  }));
3960  } else {
3961  foreach_ip_interface_address (lm4, ia, sw_if_index,
3962  1 /* honor unnumbered */,
3963  ({
3964  r4 = ip_interface_address_get_address (lm4, ia);
3965  u16 prefix_length = ia->address_length;
3966  send_ip_address_details(am, q, (u8*)r4, prefix_length, 0, mp->context);
3967  }));
3968  }
3970 }
3971 
3974  u32 sw_if_index,
3975  u32 context)
3976 {
3977  vl_api_ip_details_t * mp;
3978 
3979  mp = vl_msg_api_alloc (sizeof (*mp));
3980  memset (mp, 0, sizeof (*mp));
3981  mp->_vl_msg_id = ntohs(VL_API_IP_DETAILS);
3982 
3983  mp->sw_if_index = ntohl(sw_if_index);
3984  mp->context = context;
3985 
3986  vl_msg_api_send_shmem (q, (u8 *)&mp);
3987 }
3988 
3989 static void
3992 {
3993  vpe_api_main_t * am = &vpe_api_main;
3994  l2t_main_t * lm = &l2t_main;
3996  l2t_session_t *session;
3997 
3999  if (q == 0)
4000  return;
4001 
4002  pool_foreach (session, lm->sessions,
4003  ({
4004  send_sw_if_l2tpv3_tunnel_details (am, q, session, lm, mp->context);
4005  }));
4006 }
4007 
4008 
4012  u32 context)
4013 {
4015  mp = vl_msg_api_alloc (sizeof (*mp));
4016  memset (mp, 0, sizeof (*mp));
4017  mp->_vl_msg_id = ntohs(VL_API_SW_INTERFACE_TAP_DETAILS);
4018  mp->sw_if_index = ntohl(tap_if->sw_if_index);
4019  strncpy((char *)mp->dev_name,
4020  (char *)tap_if->dev_name, ARRAY_LEN(mp->dev_name)-1);
4021  mp->context = context;
4022 
4023  vl_msg_api_send_shmem (q, (u8 *)&mp);
4024 }
4025 
4026 static void
4029 {
4030  int rv = 0;
4031  vpe_api_main_t * am = &vpe_api_main;
4033  tapcli_interface_details_t *tapifs = NULL;
4034  tapcli_interface_details_t *tap_if = NULL;
4035 
4037  if (q == 0)
4038  return;
4039 
4040  rv = vnet_tap_dump_ifs(&tapifs);
4041  if (rv)
4042  return;
4043 
4044  vec_foreach(tap_if, tapifs) {
4045  send_sw_interface_tap_details(am, q, tap_if, mp->context);
4046  }
4047 
4048  vec_free(tapifs);
4049 }
4050 
4051 static void
4053 {
4054  vpe_api_main_t * am = &vpe_api_main;
4055  vnet_main_t * vnm = vnet_get_main();
4056  vlib_main_t * vm = vlib_get_main();
4059  vnet_sw_interface_t * si, * sorted_sis;
4060  u32 sw_if_index = ~0;
4061 
4063  if (q == 0) {
4064  return;
4065  }
4066 
4067  /* Gather interfaces. */
4068  sorted_sis = vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
4069  _vec_len (sorted_sis) = 0;
4070  pool_foreach (si, im->sw_interfaces, ({ vec_add1 (sorted_sis, si[0]); }));
4071 
4072  vec_foreach (si, sorted_sis) {
4074  if (mp->is_ipv6 && !ip6_interface_enabled(vm, si->sw_if_index)) {
4075  continue;
4076  }
4077  sw_if_index = si->sw_if_index;
4078  send_ip_details(am, q, sw_if_index, mp->context);
4079  }
4080  }
4081 }
4082 
4085 {
4086  clib_warning ("BUG");
4087 }
4088 
4091  l2fib_entry_key_t * l2fe_key,
4092  l2fib_entry_result_t * l2fe_res,
4093  u32 context)
4094 {
4096 
4097  mp = vl_msg_api_alloc (sizeof (*mp));
4098  memset (mp, 0, sizeof (*mp));
4099  mp->_vl_msg_id = ntohs(VL_API_L2_FIB_TABLE_ENTRY);
4100 
4101  mp->bd_id = ntohl(l2input_main.bd_configs[l2fe_key->fields.bd_index].bd_id);
4102 
4103  mp->mac = l2fib_make_key (l2fe_key->fields.mac, 0);
4104  mp->sw_if_index = ntohl(l2fe_res->fields.sw_if_index);
4105  mp->static_mac = l2fe_res->fields.static_mac;
4106  mp->filter_mac = l2fe_res->fields.filter;
4107  mp->bvi_mac = l2fe_res->fields.bvi;
4108  mp->context = context;
4109 
4110  vl_msg_api_send_shmem (q, (u8 *)&mp);
4111 }
4112 
4113 static void
4115 {
4116  vpe_api_main_t * am = &vpe_api_main;
4117  bd_main_t * bdm = &bd_main;
4118  l2fib_entry_key_t *l2fe_key = NULL;
4119  l2fib_entry_result_t *l2fe_res = NULL;
4120  u32 ni, bd_id = ntohl (mp->bd_id);
4121  u32 bd_index;
4123  uword * p;
4124 
4126  if (q == 0)
4127  return;
4128 
4129  /* see l2fib_table_dump: ~0 means "any" */
4130  if (bd_id == ~0)
4131  bd_index = ~0;
4132  else {
4133  p = hash_get (bdm->bd_index_by_bd_id, bd_id);
4134  if (p == 0)
4135  return;
4136 
4137  bd_index = p[0];
4138  }
4139 
4140  l2fib_table_dump (bd_index, &l2fe_key, &l2fe_res);
4141 
4142  vec_foreach_index (ni, l2fe_key) {
4143  send_l2fib_table_entry (am, q, vec_elt_at_index(l2fe_key, ni),
4144  vec_elt_at_index(l2fe_res, ni), mp->context);
4145  }
4146  vec_free(l2fe_key);
4147  vec_free(l2fe_res);
4148 }
4149 
4150 static void
4152 {
4154  int rv = 0;
4155  char * vpe_api_get_build_directory(void);
4156  char * vpe_api_get_version(void);
4157  char * vpe_api_get_build_date(void);
4158 
4161 
4162  if (!q)
4163  return;
4164 
4165  REPLY_MACRO2(VL_API_SHOW_VERSION_REPLY,
4166  ({
4167  strncpy ((char *) rmp->program, "vpe", ARRAY_LEN(rmp->program)-1);
4168  strncpy ((char *) rmp->build_directory, vpe_api_get_build_directory(),
4169  ARRAY_LEN(rmp->build_directory)-1);
4170  strncpy ((char *) rmp->version, vpe_api_get_version(),
4171  ARRAY_LEN(rmp->version)-1);
4172  strncpy ((char *) rmp->build_date, vpe_api_get_build_date(),
4173  ARRAY_LEN(rmp->build_date)-1);
4174  }));
4175 }
4176 
4179 {
4180  vlib_main_t * vm = vlib_get_main();
4182  vlib_node_t * n;
4183  int rv = 0;
4184  u32 node_index = ~0;
4185 
4186  n = vlib_get_node_by_name (vm, mp->node_name);
4187 
4188  if (n == 0)
4189  rv = VNET_API_ERROR_NO_SUCH_NODE;
4190  else
4191  node_index = n->index;
4192 
4193  REPLY_MACRO2(VL_API_GET_NODE_INDEX_REPLY,
4194  ({
4195  rmp->node_index = ntohl(node_index);
4196  }))
4197 }
4198 
4201 {
4202  vlib_main_t * vm = vlib_get_main();
4204  vlib_node_t * n, * next;
4205  int rv = 0;
4206  u32 next_index = ~0;
4207 
4208  n = vlib_get_node_by_name (vm, mp->node_name);
4209 
4210  if (n == 0) {
4211  rv = VNET_API_ERROR_NO_SUCH_NODE;
4212  goto out;
4213  }
4214 
4215  next = vlib_get_node_by_name (vm, mp->next_name);
4216 
4217  if (next == 0)
4218  rv = VNET_API_ERROR_NO_SUCH_NODE2;
4219  else
4220  next_index = vlib_node_add_next (vm, n->index, next->index);
4221 
4222 out:
4223  REPLY_MACRO2(VL_API_GET_NODE_INDEX_REPLY,
4224  ({
4225  rmp->next_index = ntohl(next_index);
4226  }))
4227 }
4228 
4231 {
4233  l2t_main_t *lm = &l2t_main;
4234  u32 sw_if_index = (u32)~0;
4235  int rv;
4236 
4237  if (mp->is_ipv6 != 1) {
4238  rv = VNET_API_ERROR_UNIMPLEMENTED;
4239  goto out;
4240  }
4241 
4242  rv = create_l2tpv3_ipv6_tunnel (lm,
4243  (ip6_address_t *) mp->client_address,
4244  (ip6_address_t *) mp->our_address,
4245  ntohl(mp->local_session_id),
4246  ntohl(mp->remote_session_id),
4247  clib_net_to_host_u64(mp->local_cookie),
4248  clib_net_to_host_u64(mp->remote_cookie),
4249  mp->l2_sublayer_present,
4250  &sw_if_index);
4251 
4252 out:
4253  REPLY_MACRO2(VL_API_L2TPV3_CREATE_TUNNEL_REPLY,
4254  ({
4255  rmp->sw_if_index = ntohl (sw_if_index);
4256  }))
4257 }
4258 
4261 {
4263  l2t_main_t *lm = &l2t_main;
4264  int rv;
4265 
4267 
4268  rv = l2tpv3_set_tunnel_cookies (lm, ntohl(mp->sw_if_index),
4269  clib_net_to_host_u64(mp->new_local_cookie),
4270  clib_net_to_host_u64(mp->new_remote_cookie));
4271 
4273 
4274  REPLY_MACRO (VL_API_L2TPV3_SET_TUNNEL_COOKIES_REPLY);
4275 }
4276 
4279 {
4280  int rv;
4281  vnet_main_t * vnm = vnet_get_main();
4283 
4285 
4287  (vnm, ntohl(mp->sw_if_index), mp->enable_disable);
4288 
4290 
4291  REPLY_MACRO (VL_API_L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY);
4292 }
4293 
4296 {
4297  int rv = 0;
4298  l2t_main_t *lm = &l2t_main;
4300 
4301  if (mp->key > L2T_LOOKUP_SESSION_ID) {
4302  rv = VNET_API_ERROR_INVALID_VALUE;
4303  goto out;
4304  }
4305 
4306  lm->lookup_type = mp->key;
4307 
4308 out:
4309  REPLY_MACRO (VL_API_L2TPV3_SET_LOOKUP_KEY_REPLY);
4310 }
4311 
4314 {
4316  int rv = 0;
4318  u32 encap_fib_index;
4319  uword * p;
4320  ip4_main_t * im = &ip4_main;
4321  u32 sw_if_index = ~0;
4322 
4323  p = hash_get (im->fib_index_by_table_id, ntohl(mp->encap_vrf_id));
4324  if (! p) {
4325  rv = VNET_API_ERROR_NO_SUCH_FIB;
4326  goto out;
4327  }
4328  encap_fib_index = p[0];
4329 
4330  /* Check src & dst are different */
4331  if ((mp->is_ipv6 && memcmp(mp->src_address, mp->dst_address, 16) == 0) ||
4332  (!mp->is_ipv6 && memcmp(mp->src_address, mp->dst_address, 4) == 0)) {
4333  rv = VNET_API_ERROR_SAME_SRC_DST;
4334  goto out;
4335  }
4336  memset (a, 0, sizeof (*a));
4337 
4338  a->is_add = mp->is_add;
4339  a->is_ip6 = mp->is_ipv6;
4340 
4341  /* ip addresses sent in network byte order */
4342  if (a->is_ip6) {
4343  memcpy(&(a->src.ip6), mp->src_address, 16);
4344  memcpy(&(a->dst.ip6), mp->dst_address, 16);
4345  } else {
4346  memcpy(&(a->src.ip4), mp->src_address, 4);
4347  memcpy(&(a->dst.ip4), mp->dst_address, 4);
4348  }
4349 
4350  a->encap_fib_index = encap_fib_index;
4351  a->decap_next_index = ntohl(mp->decap_next_index);
4352  a->vni = ntohl(mp->vni);
4353  rv = vnet_vxlan_add_del_tunnel (a, &sw_if_index);
4354 
4355 out:
4356  REPLY_MACRO2(VL_API_VXLAN_ADD_DEL_TUNNEL_REPLY,
4357  ({
4358  rmp->sw_if_index = ntohl (sw_if_index);
4359  }));
4360 }
4361 
4362 static void send_vxlan_tunnel_details
4364 {
4366  ip4_main_t * im4 = &ip4_main;
4367  ip6_main_t * im6 = &ip6_main;
4368  u8 is_ipv6 = !(t->flags & VXLAN_TUNNEL_IS_IPV4);
4369 
4370  rmp = vl_msg_api_alloc (sizeof (*rmp));
4371  memset (rmp, 0, sizeof (*rmp));
4372  rmp->_vl_msg_id = ntohs(VL_API_VXLAN_TUNNEL_DETAILS);
4373  if (is_ipv6) {
4374  memcpy(rmp->src_address, &(t->src.ip6), 16);
4375  memcpy(rmp->dst_address, &(t->dst.ip6), 16);
4376  rmp->encap_vrf_id = htonl(im6->fibs[t->encap_fib_index].table_id);
4377  } else {
4378  memcpy(rmp->src_address, &(t->src.ip4), 4);
4379  memcpy(rmp->dst_address, &(t->dst.ip4), 4);
4380  rmp->encap_vrf_id = htonl(im4->fibs[t->encap_fib_index].table_id);
4381  }
4382  rmp->vni = htonl(t->vni);
4383  rmp->decap_next_index = htonl(t->decap_next_index);
4384  rmp->sw_if_index = htonl(t->sw_if_index);
4385  rmp->is_ipv6 = is_ipv6;
4386  rmp->context = context;
4387 
4388  vl_msg_api_send_shmem (q, (u8 *)&rmp);
4389 }
4390 
4393 {
4395  vxlan_main_t * vxm = &vxlan_main;
4396  vxlan_tunnel_t * t;
4397  u32 sw_if_index;
4398 
4400  if (q == 0) {
4401  return;
4402  }
4403 
4404  sw_if_index = ntohl(mp->sw_if_index);
4405 
4406  if (~0 == sw_if_index) {
4407  pool_foreach (t, vxm->tunnels,
4408  ({
4409  send_vxlan_tunnel_details(t, q, mp->context);
4410  }));
4411  } else {
4412  if ((sw_if_index >= vec_len(vxm->tunnel_index_by_sw_if_index)) ||
4413  (~0 == vxm->tunnel_index_by_sw_if_index[sw_if_index])) {
4414  return;
4415  }
4416  t = &vxm->tunnels[vxm->tunnel_index_by_sw_if_index[sw_if_index]];
4418  }
4419 }
4420 
4423 {
4425  int rv = 0;
4426  vnet_gre_add_del_tunnel_args_t _a, *a = &_a;
4427  u32 outer_table_id;
4428  uword * p;
4429  ip4_main_t * im = &ip4_main;
4430  u32 sw_if_index = ~0;
4431 
4432  p = hash_get (im->fib_index_by_table_id, ntohl(mp->outer_table_id));
4433  if (! p) {
4434  rv = VNET_API_ERROR_NO_SUCH_FIB;
4435  goto out;
4436  }
4437  outer_table_id = p[0];
4438 
4439  /* Check src & dst are different */
4440  if (memcmp(&mp->src_address, &mp->dst_address, 4) == 0) {
4441  rv = VNET_API_ERROR_SAME_SRC_DST;
4442  goto out;
4443  }
4444 
4445  memset (a, 0, sizeof (*a));
4446 
4447  a->is_add = mp->is_add;
4448 
4449  /* ip addresses sent in network byte order */
4450  a->src.as_u32 = mp->src_address;
4451  a->dst.as_u32 = mp->dst_address;
4452 
4453  a->outer_table_id = outer_table_id;
4454  rv = vnet_gre_add_del_tunnel (a, &sw_if_index);
4455 
4456 out:
4457  REPLY_MACRO2(VL_API_GRE_ADD_DEL_TUNNEL_REPLY,
4458  ({
4459  rmp->sw_if_index = ntohl (sw_if_index);
4460  }));
4461 }
4462 
4463 static void send_gre_tunnel_details
4465 {
4467  ip4_main_t * im = &ip4_main;
4468 
4469  rmp = vl_msg_api_alloc (sizeof (*rmp));
4470  memset (rmp, 0, sizeof (*rmp));
4471  rmp->_vl_msg_id = ntohs(VL_API_GRE_TUNNEL_DETAILS);
4472  rmp->src_address = t->tunnel_src.data_u32;
4473  rmp->dst_address = t->tunnel_dst.data_u32;
4474  rmp->outer_table_id = htonl(im->fibs[t->outer_fib_index].table_id);
4475  rmp->sw_if_index = htonl(t->sw_if_index);
4476  rmp->context = context;
4477 
4478  vl_msg_api_send_shmem (q, (u8 *)&rmp);
4479 }
4480 
4483 {
4485  gre_main_t * gm = &gre_main;
4486  gre_tunnel_t * t;
4487  u32 sw_if_index;
4488 
4490  if (q == 0) {
4491  return;
4492  }
4493 
4494  sw_if_index = ntohl(mp->sw_if_index);
4495 
4496  if (~0 == sw_if_index) {
4497  pool_foreach (t, gm->tunnels,
4498  ({
4499  send_gre_tunnel_details(t, q, mp->context);
4500  }));
4501  } else {
4502  if ((sw_if_index >= vec_len(gm->tunnel_index_by_sw_if_index)) ||
4503  (~0 == gm->tunnel_index_by_sw_if_index[sw_if_index])) {
4504  return;
4505  }
4506  t = &gm->tunnels[gm->tunnel_index_by_sw_if_index[sw_if_index]];
4507  send_gre_tunnel_details(t, q, mp->context);
4508  }
4509 }
4510 
4511 static void
4513 {
4514  extern int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index,
4515  int is_add);
4517  int vnet_l2_patch_add_del (u32 rx_sw_if_index, u32 tx_sw_if_index,
4518  int is_add);
4519  int rv = 0;
4520 
4523 
4524  rv = vnet_l2_patch_add_del (ntohl(mp->rx_sw_if_index),
4525  ntohl(mp->tx_sw_if_index),
4526  (int)(mp->is_add != 0));
4527 
4530 
4531  REPLY_MACRO(VL_API_L2_PATCH_ADD_DEL_REPLY);
4532 }
4533 
4534 static void
4537 {
4539  int rv = 0;
4541  u32 encap_fib_index, decap_fib_index;
4542  u8 protocol;
4543  uword * p;
4544  ip4_main_t * im = &ip4_main;
4545  u32 sw_if_index = ~0;
4546 
4547 
4548  p = hash_get (im->fib_index_by_table_id, ntohl(mp->encap_vrf_id));
4549  if (! p) {
4550  rv = VNET_API_ERROR_NO_SUCH_FIB;
4551  goto out;
4552  }
4553  encap_fib_index = p[0];
4554 
4555  protocol = ntohl(mp->protocol);
4556 
4557  /* Interpret decap_vrf_id as an opaque if sending to other-than-ip4-input */
4558  if (protocol == VXLAN_GPE_INPUT_NEXT_IP4_INPUT) {
4559  p = hash_get (im->fib_index_by_table_id, ntohl(mp->decap_vrf_id));
4560  if (! p) {
4561  rv = VNET_API_ERROR_NO_SUCH_INNER_FIB;
4562  goto out;
4563  }
4564  decap_fib_index = p[0];
4565  } else {
4566  decap_fib_index = ntohl(mp->decap_vrf_id);
4567  }
4568 
4569  memset (a, 0, sizeof (*a));
4570 
4571  a->is_add = mp->is_add;
4572  /* ip addresses sent in network byte order */
4573  a->local.as_u32 = ntohl(mp->local);
4574  a->remote.as_u32 = ntohl(mp->remote);
4575  a->encap_fib_index = encap_fib_index;
4576  a->decap_fib_index = decap_fib_index;
4577  a->protocol = protocol;
4578  a->vni = ntohl(mp->vni);
4579  rv = vnet_vxlan_gpe_add_del_tunnel (a, &sw_if_index);
4580 
4581 out:
4582  REPLY_MACRO2(VL_API_VXLAN_GPE_ADD_DEL_TUNNEL_REPLY,
4583  ({
4584  rmp->sw_if_index = ntohl (sw_if_index);
4585  }));
4586 }
4587 
4588 static void
4590 {
4592  int rv = 0;
4594  u32 ls_index = ~0;
4595  u8 *locator_name = NULL;
4596 
4597  memset(a, 0, sizeof(a[0]));
4598 
4599  locator_name = format(0, "%s", mp->locator_set_name);
4600 
4601  a->name = locator_name;
4602  a->locators = NULL;
4603  a->is_add = mp->is_add;
4604  a->local = 1;
4605 
4606  rv = vnet_lisp_add_del_locator_set(a, &ls_index);
4607 
4608  vec_free(locator_name);
4609 
4610  REPLY_MACRO(VL_API_LISP_ADD_DEL_LOCATOR_SET_REPLY);
4611 }
4612 
4613 static void
4616 {
4618  int rv = 0;
4619  locator_t locator, *locators = NULL;
4621  u32 ls_index = ~0;
4622  u8 *locator_name = NULL;
4623 
4624  memset(&locator, 0, sizeof(locator));
4625  memset(a, 0, sizeof(a[0]));
4626 
4627  locator.sw_if_index = ntohl(mp->sw_if_index);
4628  locator.priority = mp->priority;
4629  locator.weight = mp->weight;
4630  locator.local = 1;
4631  vec_add1(locators, locator);
4632 
4633  locator_name = format(0, "%s", mp->locator_set_name);
4634 
4635  a->name = locator_name;
4636  a->locators = locators;
4637  a->is_add = mp->is_add;
4638  a->local = 1;
4639 
4640  rv = vnet_lisp_add_del_locator(a, NULL, &ls_index);
4641 
4642  vec_free(locators);
4643  vec_free(locator_name);
4644 
4645  REPLY_MACRO(VL_API_LISP_ADD_DEL_LOCATOR_REPLY);
4646 }
4647 
4648 static void
4651 {
4654  int rv = 0;
4655  ip_prefix_t *prefp = NULL;
4656  ip_address_t *ip_eid = NULL;
4657  gid_address_t eid;
4658  uword * p = NULL;
4659  u32 locator_set_index = ~0, map_index = ~0;
4661  u8 *name = NULL;
4662 
4663  prefp = &gid_address_ippref(&eid);
4664  ip_eid = &ip_prefix_addr(prefp);
4666 
4667  if (mp->is_ipv6) {
4668  clib_memcpy(&ip_addr_v6(ip_eid), mp->ip_address,
4669  sizeof(ip_addr_v6(ip_eid)));
4670  ip_addr_version(ip_eid) = IP6;
4671  } else {
4672  clib_memcpy(&ip_addr_v4(ip_eid), mp->ip_address,
4673  sizeof(ip_addr_v4(ip_eid)));
4674  ip_addr_version(ip_eid) = IP4;
4675  }
4676  ip_prefix_len(prefp) = mp->prefix_len;
4677 
4678  name = format(0, "%s", mp->locator_set_name);
4679  p = hash_get_mem(lcm->locator_set_index_by_name, name);
4680  if (!p) {
4681  rv = VNET_API_ERROR_INVALID_VALUE;
4682  goto out;
4683  }
4684  locator_set_index = p[0];
4685 
4686  /* XXX treat batch configuration */
4687  a->is_add = mp->is_add;
4688  a->deid = eid;
4689  a->locator_set_index = locator_set_index;
4690  a->local = 1;
4691 
4692  rv = vnet_lisp_add_del_local_mapping(a, &map_index);
4693 
4694 out:
4695  vec_free(name);
4696 
4697  REPLY_MACRO(VL_API_LISP_ADD_DEL_LOCAL_EID_REPLY);
4698 }
4699 
4700 static void
4703  ip_address_t *slocator,
4704  ip_address_t *dlocator,
4705  gid_address_t *eid)
4706 {
4707  ip_address_t *ip_eid = NULL;
4708  ip_prefix_t *prefp = NULL;
4709 
4710  prefp = &gid_address_ippref(eid);
4711  ip_eid = &ip_prefix_addr(prefp);
4712 
4713  if (mp->eid_is_ipv6) {
4714  clib_memcpy(&ip_addr_v6(ip_eid), mp->eid_ip_address,
4715  sizeof(ip_addr_v6(ip_eid)));
4716  ip_addr_version(ip_eid) = IP6;
4717  } else {
4718  clib_memcpy(&ip_addr_v4(ip_eid), mp->eid_ip_address,
4719  sizeof(ip_addr_v4(ip_eid)));
4720  ip_addr_version(ip_eid) = IP4;
4721  }
4722  ip_prefix_len(prefp) = mp->eid_prefix_len;
4723 
4724  if (mp->address_is_ipv6) {
4725  clib_memcpy(&ip_addr_v6(slocator), mp->source_ip_address,
4726  sizeof(ip_addr_v6(slocator)));
4727  ip_addr_version(slocator) = IP6;
4729  sizeof(ip_addr_v6(dlocator)));
4730  ip_addr_version(dlocator) = IP6;
4731  } else {
4732  clib_memcpy(&ip_addr_v4(slocator), mp->source_ip_address,
4733  sizeof(ip_addr_v4(slocator)));
4734  ip_addr_version(slocator) = IP4;
4736  sizeof(ip_addr_v4(dlocator)));
4737  ip_addr_version(dlocator) = IP4;
4738  }
4739 }
4740 
4741 static void
4744 {
4746  int rv = 0;
4747  ip_address_t slocator, dlocator;
4748  gid_address_t eid;
4750 
4751  lisp_gpe_add_del_fwd_entry_set_address(mp, &slocator, &dlocator, &eid);
4752 
4753  memset (&a, 0, sizeof(a));
4754 
4755  a.is_add = mp->is_add;
4756  a.deid = eid;
4757  a.slocator = slocator;
4758  a.dlocator = dlocator;
4759  rv = vnet_lisp_gpe_add_del_fwd_entry (&a, 0);
4760 
4761  REPLY_MACRO(VL_API_LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY);
4762 }
4763 
4764 static void
4767 {
4769  int rv = 0;
4770  ip_address_t *ip_addr = NULL;
4772 
4773  a->is_add = mp->is_add;
4774  ip_addr = &a->address;
4775 
4776  if (mp->is_ipv6) {
4777  clib_memcpy(&ip_addr_v6(ip_addr), mp->ip_address,
4778  sizeof(ip_addr_v6(ip_addr)));
4779  ip_addr_version(ip_addr) = IP6;
4780  } else {
4781  clib_memcpy(&ip_addr_v4(ip_addr), mp->ip_address,
4782  sizeof(ip_addr_v4(ip_addr)));
4783  ip_addr_version(ip_addr) = IP4;
4784  }
4785 
4787 
4788  REPLY_MACRO(VL_API_LISP_ADD_DEL_MAP_RESOLVER_REPLY);
4789 }
4790 
4791 static void
4794 {
4796  int rv = 0;
4798 
4799  a->is_en = mp->is_en;
4801 
4802  REPLY_MACRO(VL_API_LISP_GPE_ENABLE_DISABLE_REPLY);
4803 }
4804 
4805 static void
4808 {
4810  int rv = 0;
4811 
4813  REPLY_MACRO(VL_API_LISP_ENABLE_DISABLE_REPLY);
4814 }
4815 
4816 static void
4819 {
4821  int rv = 0;
4823 
4824  a->is_add = mp->is_add;
4825  a->table_id = mp->table_id;
4826  a->vni = mp->vni;
4828 
4829  REPLY_MACRO(VL_API_LISP_GPE_ADD_DEL_IFACE_REPLY);
4830 }
4831 
4832 /** Used for transferring locators via VPP API */
4833 typedef CLIB_PACKED(struct
4834 {
4835  u8 is_ip4; /**< is locator an IPv4 address */
4836  u8 addr[16]; /**< IPv4/IPv6 address */
4837 }) rloc_t;
4838 
4839 static void
4840 send_lisp_locator_set_details_set_address
4842  gid_address_t *gid_address)
4843 {
4844  ip_prefix_t *ip_addr;
4845 
4846  if (gid_address_type(gid_address) != GID_ADDR_IP_PREFIX) {
4847  return;
4848  }
4849 
4850  ip_addr = &gid_address_ippref(gid_address);
4851  rmp->prefix_len = ip_prefix_len(ip_addr);
4852  rmp->is_ipv6 = ip_prefix_version(ip_addr);
4854 }
4855 
4856 static void
4859 {
4860  u32 i;
4861  ip_address_t rloc, * rlocs = 0;
4863  int rv = 0;
4864  gid_address_t _seid, * seid = &_seid;
4865  gid_address_t _deid, * deid = &_deid;
4866  ip_prefix_t * seid_pref = &gid_address_ippref(seid);
4867  ip_prefix_t * deid_pref = &gid_address_ippref(deid);
4868 
4871  ip_address_t * seid_addr = &ip_prefix_addr(seid_pref);
4872  ip_address_t * deid_addr = &ip_prefix_addr(deid_pref);
4873  ip_prefix_len(seid_pref) = mp->seid_len;
4874  ip_prefix_len(deid_pref) = mp->deid_len;
4875  gid_address_set_vni (seid, ntohl (mp->vni));
4876  gid_address_set_vni (deid, ntohl (mp->vni));
4877 
4878  if (mp->eid_is_ip4) {
4879  ip_prefix_version(seid_pref) = IP4;
4880  ip_prefix_version(deid_pref) = IP4;
4881  clib_memcpy (&ip_addr_v4(seid_addr),
4882  mp->seid, sizeof (ip_addr_v4(seid_addr)));
4883  clib_memcpy (&ip_addr_v4(deid_addr),
4884  mp->deid, sizeof (ip_addr_v4(deid_addr)));
4885  } else {
4886  ip_prefix_version(seid_pref) = IP6;
4887  ip_prefix_version(deid_pref) = IP6;
4888  clib_memcpy (&ip_addr_v6(seid_addr),
4889  mp->seid, sizeof (ip_addr_v6(seid_addr)));
4890  clib_memcpy (&ip_addr_v6(deid_addr),
4891  mp->deid, sizeof (ip_addr_v6(deid_addr)));
4892  }
4893 
4894  for (i = 0; i < mp->rloc_num; i++) {
4895  rloc_t * r = &((rloc_t *) mp->rlocs)[i];
4896  if (r->is_ip4) {
4897  clib_memcpy (&ip_addr_v4(&rloc), &r->addr, sizeof (rloc_t));
4898  ip_addr_version (&rloc) = IP4;
4899  } else {
4900  clib_memcpy (&ip_addr_v6(&rloc), &r->addr, sizeof (rloc_t));
4901  ip_addr_version (&rloc) = IP6;
4902  }
4903  vec_add1 (rlocs, rloc);
4904  }
4905 
4906  rv = vnet_lisp_add_del_remote_mapping (deid, seid, rlocs,
4907  mp->action, mp->is_add);
4908  vec_free (rlocs);
4909  REPLY_MACRO(VL_API_LISP_GPE_ADD_DEL_IFACE_REPLY);
4910 }
4911 
4912 static void
4914  locator_set_t *lsit,
4916  u32 context,
4917  u32 index)
4918 {
4920  locator_t *loc = NULL;
4921  u32 * locit = NULL;
4922  u8 * str = NULL;
4923 
4924  vec_foreach (locit, lsit->locator_indices) {
4925  loc = pool_elt_at_index (lcm->locator_pool, locit[0]);
4926  rmp = vl_msg_api_alloc (sizeof (*rmp));
4927  memset (rmp, 0, sizeof (*rmp));
4928  rmp->_vl_msg_id = ntohs(VL_API_LISP_LOCATOR_SET_DETAILS);
4929  rmp->local = lsit->local;
4930  if (lsit->local) {
4931  ASSERT(lsit->name != NULL);
4932  strncpy((char *) rmp->locator_set_name,
4933  (char *) lsit->name, ARRAY_LEN(rmp->locator_set_name) - 1);
4934  rmp->sw_if_index = htonl(loc->sw_if_index);
4935  } else {
4936  str = format(0, "remote-%d", index);
4937  strncpy((char *) rmp->locator_set_name, (char *) str,
4938  ARRAY_LEN(rmp->locator_set_name) - 1);
4939  send_lisp_locator_set_details_set_address(rmp, &loc->address);
4940 
4941  vec_free(str);
4942  }
4943  rmp->priority = loc->priority;
4944  rmp->weight = loc->weight;
4945  rmp->context = context;
4946 
4947  vl_msg_api_send_shmem (q, (u8 *)&rmp);
4948  }
4949 }
4950 
4951 static void
4953 {
4956  locator_set_t * lsit = NULL;
4957  u32 index;
4958 
4960  if (q == 0) {
4961  return;
4962  }
4963 
4964  index = 0;
4965  pool_foreach (lsit, lcm->locator_set_pool,
4966  ({
4967  send_lisp_locator_set_details(lcm, lsit, q, mp->context, index++);
4968  }));
4969 }
4970 
4971 static void
4974  u32 context)
4975 {
4978  locator_set_t *ls = NULL;
4979  gid_address_t *gid = NULL;
4980  ip_prefix_t *ip_prefix = NULL;
4981  u8 * str = NULL;
4982  u8 type = ~0;
4983 
4985  mapit->locator_set_index);
4986 
4987  gid = &mapit->eid;
4988  type = gid_address_type(gid);
4989 
4990  if (type != GID_ADDR_IP_PREFIX) {
4991  return;
4992  }
4993 
4994  ip_prefix = &gid_address_ippref(gid);
4995 
4996  rmp = vl_msg_api_alloc (sizeof (*rmp));
4997  memset (rmp, 0, sizeof (*rmp));
4998  rmp->_vl_msg_id = ntohs(VL_API_LISP_LOCAL_EID_TABLE_DETAILS);
4999  if (ls->local) {
5000  ASSERT(ls->name != NULL);
5001  strncpy((char *) rmp->locator_set_name,
5002  (char *) ls->name, ARRAY_LEN(rmp->locator_set_name) - 1);
5003  } else {
5004  str = format(0, "remote-%d", mapit->locator_set_index);
5005  strncpy((char *) rmp->locator_set_name, (char *) str,
5006  ARRAY_LEN(rmp->locator_set_name) - 1);
5007  vec_free(str);
5008  }
5009 
5010  switch (ip_prefix_version(ip_prefix)) {
5011  case IP4:
5012  rmp->eid_is_ipv6 = 0;
5013  clib_memcpy(rmp->eid_ip_address, &ip_prefix_v4(ip_prefix),
5014  sizeof(ip_prefix_v4(ip_prefix)));
5015  break;
5016 
5017  case IP6:
5018  rmp->eid_is_ipv6 = 1;
5019  clib_memcpy(rmp->eid_ip_address, &ip_prefix_v6(ip_prefix),
5020  sizeof(ip_prefix_v6(ip_prefix)));
5021  break;
5022 
5023  default:
5024  ASSERT(0);
5025  }
5026  rmp->eid_prefix_len = ip_prefix_len(ip_prefix);
5027  rmp->context = context;
5028 
5029  vl_msg_api_send_shmem (q, (u8 *)&rmp);
5030 }
5031 
5032 static void
5035 {
5038  mapping_t * mapit = NULL;
5039 
5041  if (q == 0) {
5042  return;
5043  }
5044 
5045  pool_foreach (mapit, lcm->mapping_pool,
5046  ({
5047  send_lisp_local_eid_table_details(mapit, q, mp->context);
5048  }));
5049 }
5050 
5051 static void
5054  u32 context)
5055 {
5057  lisp_gpe_main_t * lgm = &lisp_gpe_main;
5058 
5059  rmp = vl_msg_api_alloc (sizeof (*rmp));
5060  memset (rmp, 0, sizeof (*rmp));
5061  rmp->_vl_msg_id = ntohs(VL_API_LISP_GPE_TUNNEL_DETAILS);
5062 
5063  rmp->tunnels = tunnel - lgm->tunnels;
5064 
5065  rmp->is_ipv6 = ip_addr_version(&tunnel->src) == IP6 ? 1 : 0;
5066  ip_address_copy_addr(rmp->source_ip, &tunnel->src);
5067  ip_address_copy_addr(rmp->destination_ip, &tunnel->dst);
5068 
5069  rmp->encap_fib_id = htonl(tunnel->encap_fib_index);
5070  rmp->decap_fib_id = htonl(tunnel->decap_fib_index);
5071  rmp->dcap_next = htonl(tunnel->decap_next_index);
5072  rmp->lisp_ver = tunnel->ver_res;
5073  rmp->next_protocol = tunnel->next_protocol;
5074  rmp->flags = tunnel->flags;
5075  rmp->ver_res = tunnel->ver_res;
5076  rmp->res = tunnel->res;
5077  rmp->iid = htonl(tunnel->vni);
5078  rmp->context = context;
5079 
5080  vl_msg_api_send_shmem (q, (u8 *)&rmp);
5081 }
5082 
5083 static void
5086 {
5088  lisp_gpe_main_t * lgm = &lisp_gpe_main;
5089  lisp_gpe_tunnel_t * tunnel = NULL;
5090 
5091  if (pool_elts(lgm->tunnels) == 0) {
5092  return;
5093  }
5094 
5096  if (q == 0) {
5097  return;
5098  }
5099 
5100  pool_foreach(tunnel, lgm->tunnels,
5101  ({
5102  send_lisp_gpe_tunnel_details(tunnel, q, mp->context);
5103  }));
5104 }
5105 
5106 static void
5109  u32 context)
5110 {
5112 
5113  rmp = vl_msg_api_alloc (sizeof (*rmp));
5114  memset (rmp, 0, sizeof (*rmp));
5115  rmp->_vl_msg_id = ntohs(VL_API_LISP_MAP_RESOLVER_DETAILS);
5116 
5117  switch (ip_addr_version(ip)) {
5118  case IP4:
5119  rmp->is_ipv6 = 0;
5120  clib_memcpy(rmp->ip_address, &ip_addr_v4(ip), sizeof(ip_addr_v4(ip)));
5121  break;
5122 
5123  case IP6:
5124  rmp->is_ipv6 = 1;
5125  clib_memcpy(rmp->ip_address, &ip_addr_v6(ip), sizeof(ip_addr_v6(ip)));
5126  break;
5127 
5128  default:
5129  ASSERT(0);
5130  }
5131  rmp->context = context;
5132 
5133  vl_msg_api_send_shmem (q, (u8 *)&rmp);
5134 }
5135 
5136 static void
5139 {
5142  ip_address_t *ip = NULL;
5143 
5145  if (q == 0) {
5146  return;
5147  }
5148 
5149  vec_foreach(ip, lcm->map_resolvers) {
5151  }
5152 
5153 }
5154 
5155 static void
5157  u32 context)
5158 {
5160 
5161  rmp = vl_msg_api_alloc (sizeof (*rmp));
5162  memset (rmp, 0, sizeof (*rmp));
5163  rmp->_vl_msg_id = ntohs(VL_API_LISP_ENABLE_DISABLE_STATUS_DETAILS);
5164 
5167  rmp->context = context;
5168 
5169  vl_msg_api_send_shmem (q, (u8 *)&rmp);
5170 }
5171 
5172 static void
5175 {
5177 
5179  if (q == 0) {
5180  return;
5181  }
5182 
5184 }
5185 
5186 static void
5188 {
5190  int rv = 0;
5191 
5193 
5195  (ntohl(mp->sw_if_index), ntohl(mp->new_show_dev_instance));
5196 
5198 
5199  REPLY_MACRO(VL_API_INTERFACE_NAME_RENUMBER_REPLY);
5200 }
5201 
5202 static int arp_change_data_callback (u32 pool_index, u8 * new_mac,
5203  u32 sw_if_index, u32 address)
5204 {
5205  vpe_api_main_t * am = &vpe_api_main;
5206  vlib_main_t * vm = am->vlib_main;
5207  vl_api_ip4_arp_event_t * event;
5208  static f64 arp_event_last_time;
5209  f64 now = vlib_time_now (vm);
5210 
5211  if (pool_is_free_index (am->arp_events, pool_index))
5212  return 1;
5213 
5214  event = pool_elt_at_index (am->arp_events, pool_index);
5215  if (memcmp (&event->new_mac, new_mac, sizeof (event->new_mac))) {
5216  clib_memcpy (event->new_mac, new_mac, sizeof(event->new_mac));
5217  } else { /* same mac */
5218  if ((sw_if_index == event->sw_if_index) &&
5219  ((address == 0) ||
5220  /* for BD case, also check IP address with 10 sec timeout */
5221  ((address == event->address) &&
5222  ((now - arp_event_last_time) < 10.0))))
5223  return 1;
5224  }
5225 
5226  arp_event_last_time = now;
5227  event->sw_if_index = sw_if_index;
5228  if (address) event->address = address;
5229  return 0;
5230 }
5231 
5232 static int arp_change_delete_callback (u32 pool_index, u8 * notused)
5233 {
5234  vpe_api_main_t * am = &vpe_api_main;
5235 
5236  if (pool_is_free_index (am->arp_events, pool_index))
5237  return 1;
5238 
5239  pool_put_index (am->arp_events, pool_index);
5240  return 0;
5241 }
5242 
5243 static void
5246 {
5247  vpe_api_main_t * am = &vpe_api_main;
5248  vnet_main_t * vnm = vnet_get_main();
5250  vl_api_ip4_arp_event_t * event;
5251  int rv;
5252 
5253  if (mp->enable_disable) {
5254  pool_get (am->arp_events, event);
5255  memset (event, 0, sizeof (*event));
5256 
5257  event->_vl_msg_id = ntohs(VL_API_IP4_ARP_EVENT);
5258  event->client_index = mp->client_index;
5259  event->context = mp->context;
5260  event->address = mp->address;
5261  event->pid = mp->pid;
5262 
5265  mp->pid,
5266  &mp->address /* addr, in net byte order */,
5267  vpe_resolver_process_node.index,
5268  IP4_ARP_EVENT, event - am->arp_events, 1 /* is_add */);
5269  } else {
5272  mp->pid,
5273  &mp->address /* addr, in net byte order */,
5274  vpe_resolver_process_node.index,
5275  IP4_ARP_EVENT, ~0 /* pool index */, 0 /* is_add */);
5276  }
5277  REPLY_MACRO(VL_API_WANT_IP4_ARP_EVENTS_REPLY);
5278 }
5279 
5282 {
5283  vlib_main_t *vm = vlib_get_main();
5285  int rv;
5286  u32 sw_if_index, ip4_table_index, ip6_table_index, l2_table_index;
5287 
5288  ip4_table_index = ntohl(mp->ip4_table_index);
5289  ip6_table_index = ntohl(mp->ip6_table_index);
5290  l2_table_index = ntohl(mp->l2_table_index);
5291  sw_if_index = ntohl(mp->sw_if_index);
5292 
5294 
5295  rv = vnet_set_input_acl_intfc (vm, sw_if_index, ip4_table_index,
5296  ip6_table_index, l2_table_index,
5297  mp->is_add);
5298 
5300 
5301  REPLY_MACRO(VL_API_INPUT_ACL_SET_INTERFACE_REPLY);
5302 }
5303 
5306 {
5307 #if IPSEC == 0
5308  clib_warning ("unimplemented");
5309 #else
5310 
5311  vlib_main_t *vm __attribute__((unused)) = vlib_get_main();
5313  int rv;
5314 
5315 #if DPDK > 0
5316  rv = ipsec_add_del_spd (vm, ntohl(mp->spd_id), mp->is_add);
5317 #else
5318  rv = VNET_API_ERROR_UNIMPLEMENTED;
5319 #endif
5320 
5321  REPLY_MACRO(VL_API_IPSEC_SPD_ADD_DEL_REPLY);
5322 #endif
5323 }
5324 
5327 {
5328  vlib_main_t *vm __attribute__((unused)) = vlib_get_main();
5330  int rv;
5331  u32 sw_if_index __attribute__((unused));
5332  u32 spd_id __attribute__((unused));
5333 
5334  sw_if_index = ntohl(mp->sw_if_index);
5335  spd_id = ntohl(mp->spd_id);
5336 
5338 
5339 #if IPSEC > 0
5340  rv = ipsec_set_interface_spd(vm, sw_if_index, spd_id, mp->is_add);
5341 #else
5342  rv = VNET_API_ERROR_UNIMPLEMENTED;
5343 #endif
5344 
5346 
5347  REPLY_MACRO(VL_API_IPSEC_INTERFACE_ADD_DEL_SPD_REPLY);
5348 }
5349 
5352 {
5353  vlib_main_t *vm __attribute__((unused)) = vlib_get_main();
5355  int rv;
5356 
5357 #if IPSEC > 0
5358  ipsec_policy_t p;
5359 
5360  memset(&p, 0, sizeof(p));
5361 
5362  p.id = ntohl(mp->spd_id);
5363  p.priority = ntohl(mp->priority);
5364  p.is_outbound = mp->is_outbound;
5365  p.is_ipv6 = mp->is_ipv6;
5366 
5371 
5372  p.protocol = mp->protocol;
5373  p.rport.start = ntohs(mp->remote_port_start);
5374  p.rport.stop = ntohs(mp->remote_port_stop);
5375  p.lport.start = ntohs(mp->local_port_start);
5376  p.lport.stop = ntohs(mp->local_port_stop);
5377  /* policy action resolve unsupported */
5378  if (mp->policy == IPSEC_POLICY_ACTION_RESOLVE) {
5379  clib_warning("unsupported action: 'resolve'");
5380  rv = VNET_API_ERROR_UNIMPLEMENTED;
5381  goto out;
5382  }
5383  p.policy = mp->policy;
5384  p.sa_id = ntohl(mp->sa_id);
5385 
5386  rv = ipsec_add_del_policy(vm, &p, mp->is_add);
5387  if (rv)
5388  goto out;
5389 
5390  if (mp->is_ip_any) {
5391  p.is_ipv6 = 1;
5392  rv = ipsec_add_del_policy(vm, &p, mp->is_add);
5393  }
5394 #else
5395  rv = VNET_API_ERROR_UNIMPLEMENTED;
5396  goto out;
5397 #endif
5398 
5399 out:
5400  REPLY_MACRO(VL_API_IPSEC_SPD_ADD_DEL_ENTRY_REPLY);
5401 }
5402 
5405 {
5406  vlib_main_t *vm __attribute__((unused)) = vlib_get_main();
5408  int rv;
5409 #if IPSEC > 0
5410  ipsec_sa_t sa;
5411 
5412  memset(&sa, 0, sizeof(sa));
5413 
5414  sa.id = ntohl(mp->sad_id);
5415  sa.spi = ntohl(mp->spi);
5416  /* security protocol AH unsupported */
5417  if (mp->protocol == IPSEC_PROTOCOL_AH) {
5418  clib_warning("unsupported security protocol 'AH'");
5419  rv = VNET_API_ERROR_UNIMPLEMENTED;
5420  goto out;
5421  }
5422  sa.protocol = mp->protocol;
5423  /* check for unsupported crypto-alg */
5424  if (mp->crypto_algorithm < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
5425  mp->crypto_algorithm > IPSEC_CRYPTO_ALG_AES_CBC_256) {
5426  clib_warning("unsupported crypto-alg: '%U'", format_ipsec_crypto_alg,
5427  mp->crypto_algorithm);
5428  rv = VNET_API_ERROR_UNIMPLEMENTED;
5429  goto out;
5430  }
5431  sa.crypto_alg = mp->crypto_algorithm;
5433  clib_memcpy(&sa.crypto_key, mp->crypto_key, sizeof(sa.crypto_key));
5434  /* check for unsupported integ-alg */
5435  if (mp->integrity_algorithm < IPSEC_INTEG_ALG_SHA1_96 ||
5436  mp->integrity_algorithm > IPSEC_INTEG_ALG_SHA_512_256) {
5437  clib_warning("unsupported integ-alg: '%U'", format_ipsec_integ_alg,
5438  mp->integrity_algorithm);
5439  rv = VNET_API_ERROR_UNIMPLEMENTED;
5440  goto out;
5441  }
5442  sa.integ_alg = mp->integrity_algorithm;
5444  clib_memcpy(&sa.integ_key, mp->integrity_key, sizeof(sa.integ_key));
5446  sa.is_tunnel = mp->is_tunnel;
5447  sa.is_tunnel_ip6 = mp->is_tunnel_ipv6;
5450 
5451  rv = ipsec_add_del_sa(vm, &sa, mp->is_add);
5452 #else
5453  rv = VNET_API_ERROR_UNIMPLEMENTED;
5454  goto out;
5455 #endif
5456 
5457 out:
5458  REPLY_MACRO(VL_API_IPSEC_SAD_ADD_DEL_ENTRY_REPLY);
5459 }
5460 
5461 static void
5464 {
5466  int rv = 0;
5467 
5468 #if IPSEC > 0
5469  vlib_main_t * vm = vlib_get_main();
5470  clib_error_t * error;
5471  u8 * tmp = format(0, "%s", mp->name);
5472  error = ikev2_add_del_profile(vm, tmp, mp->is_add);
5473  vec_free (tmp);
5474  if (error)
5475  rv = VNET_API_ERROR_UNSPECIFIED;
5476 #else
5477  rv = VNET_API_ERROR_UNIMPLEMENTED;
5478 #endif
5479 
5480  REPLY_MACRO(VL_API_IKEV2_PROFILE_ADD_DEL_REPLY);
5481 }
5482 
5483 static void
5486 {
5488  int rv = 0;
5489 
5490 #if IPSEC > 0
5491  vlib_main_t * vm = vlib_get_main();
5492  clib_error_t * error;
5493  u8 * tmp = format(0, "%s", mp->name);
5494  u8 * data = vec_new (u8, mp->data_len);
5495  clib_memcpy(data, mp->data, mp->data_len);
5496  error = ikev2_set_profile_auth(vm, tmp, mp->auth_method, data, mp->is_hex);
5497  vec_free (tmp);
5498  vec_free (data);
5499  if (error)
5500  rv = VNET_API_ERROR_UNSPECIFIED;
5501 #else
5502  rv = VNET_API_ERROR_UNIMPLEMENTED;
5503 #endif
5504 
5505  REPLY_MACRO(VL_API_IKEV2_PROFILE_SET_AUTH_REPLY);
5506 }
5507 
5508 static void
5511 {
5513  int rv = 0;
5514 
5515 #if IPSEC > 0
5516  vlib_main_t * vm = vlib_get_main();
5517  clib_error_t * error;
5518  u8 * tmp = format(0, "%s", mp->name);
5519  u8 * data = vec_new (u8, mp->data_len);
5520  clib_memcpy(data, mp->data, mp->data_len);
5521  error = ikev2_set_profile_id(vm, tmp, mp->id_type, data, mp->is_local);
5522  vec_free (tmp);
5523  vec_free (data);
5524  if (error)
5525  rv = VNET_API_ERROR_UNSPECIFIED;
5526 #else
5527  rv = VNET_API_ERROR_UNIMPLEMENTED;
5528 #endif
5529 
5530  REPLY_MACRO(VL_API_IKEV2_PROFILE_SET_ID_REPLY);
5531 }
5532 
5533 static void
5536 {
5538  int rv = 0;
5539 
5540 #if IPSEC > 0
5541  vlib_main_t * vm = vlib_get_main();
5542  clib_error_t * error;
5543  u8 * tmp = format(0, "%s", mp->name);
5544  error = ikev2_set_profile_ts(vm, tmp, mp->proto, mp->start_port,
5545  mp->end_port, (ip4_address_t) mp->start_addr,
5546  (ip4_address_t) mp->end_addr, mp->is_local);
5547  vec_free (tmp);
5548  if (error)
5549  rv = VNET_API_ERROR_UNSPECIFIED;
5550 #else
5551  rv = VNET_API_ERROR_UNIMPLEMENTED;
5552 #endif
5553 
5554  REPLY_MACRO(VL_API_IKEV2_PROFILE_SET_TS_REPLY);
5555 }
5556 
5557 static void
5560 {
5562  int rv = 0;
5563 
5564 #if IPSEC > 0
5565  vlib_main_t * vm = vlib_get_main();
5566  clib_error_t * error;
5567 
5568  error = ikev2_set_local_key(vm, mp->key_file);
5569  if (error)
5570  rv = VNET_API_ERROR_UNSPECIFIED;
5571 #else
5572  rv = VNET_API_ERROR_UNIMPLEMENTED;
5573 #endif
5574 
5575  REPLY_MACRO(VL_API_IKEV2_SET_LOCAL_KEY_REPLY);
5576 }
5577 
5578 static void
5581 {
5583  int rv = 0;
5584  u32 index;
5585  u8 flags = mp->is_translation ? MAP_DOMAIN_TRANSLATION : 0;
5589  mp->ea_bits_len, mp->psid_offset, mp->psid_length, &index, ntohs(mp->mtu), flags);
5590 
5591  REPLY_MACRO2(VL_API_MAP_ADD_DOMAIN_REPLY,
5592  ({
5593  rmp->index = ntohl(index);
5594  }));
5595 }
5596 
5597 static void
5600 {
5602  int rv = 0;
5603 
5604  rv = map_delete_domain(ntohl(mp->index));
5605 
5606  REPLY_MACRO(VL_API_MAP_DEL_DOMAIN_REPLY);
5607 }
5608 
5609 static void
5612 {
5614  int rv = 0;
5615 
5616  rv = map_add_del_psid(ntohl(mp->index), ntohs(mp->psid), (ip6_address_t *)mp->ip6_dst, mp->is_add);
5617 
5618  REPLY_MACRO(VL_API_MAP_ADD_DEL_RULE_REPLY);
5619 }
5620 
5621 static void
5624 {
5626  map_main_t *mm = &map_main;
5627  map_domain_t *d;
5629 
5630  if (pool_elts (mm->domains) == 0)
5631  return;
5632 
5634  if (q == 0) {
5635  return;
5636  }
5637 
5638  pool_foreach(d, mm->domains, ({
5639  /* Make sure every field is initiated (or don't skip the memset()) */
5640  rmp = vl_msg_api_alloc (sizeof (*rmp));
5641  rmp->_vl_msg_id = ntohs(VL_API_MAP_DOMAIN_DETAILS);
5642  rmp->domain_index = htonl(d - mm->domains);
5643  rmp->ea_bits_len = d->ea_bits_len;
5644  rmp->psid_offset = d->psid_offset;
5645  rmp->psid_length = d->psid_length;
5646  clib_memcpy(rmp->ip4_prefix, &d->ip4_prefix, sizeof(rmp->ip4_prefix));
5647  rmp->ip4_prefix_len = d->ip4_prefix_len;
5648  clib_memcpy(rmp->ip6_prefix, &d->ip6_prefix, sizeof(rmp->ip6_prefix));
5649  rmp->ip6_prefix_len = d->ip6_prefix_len;
5650  clib_memcpy(rmp->ip6_src, &d->ip6_src, sizeof(rmp->ip6_src));
5651  rmp->ip6_src_len = d->ip6_src_len;
5652  rmp->mtu = htons(d->mtu);
5653  rmp->is_translation = (d->flags & MAP_DOMAIN_TRANSLATION);
5654  rmp->context = mp->context;
5655 
5656  vl_msg_api_send_shmem (q, (u8 *)&rmp);
5657  }));
5658 }
5659 
5660 static void
5663 {
5665  u16 i;
5666  ip6_address_t dst;
5668  map_main_t *mm = &map_main;
5669  u32 domain_index = ntohl(mp->domain_index);
5670  map_domain_t *d;
5671 
5672  if (pool_elts (mm->domains) == 0)
5673  return;
5674 
5675  d = pool_elt_at_index(mm->domains, domain_index);
5676  if (!d || !d->rules) {
5677  return;
5678  }
5679 
5681  if (q == 0) {
5682  return;
5683  }
5684 
5685  for (i = 0; i < (0x1 << d->psid_length); i++) {
5686  dst = d->rules[i];
5687  if (dst.as_u64[0] == 0 && dst.as_u64[1] == 0) {
5688  continue;
5689  }
5690  rmp = vl_msg_api_alloc(sizeof(*rmp));
5691  memset(rmp, 0, sizeof(*rmp));
5692  rmp->_vl_msg_id = ntohs(VL_API_MAP_RULE_DETAILS);
5693  rmp->psid = htons(i);
5694  clib_memcpy(rmp->ip6_dst, &dst, sizeof(rmp->ip6_dst));
5695  rmp->context = mp->context;
5696  vl_msg_api_send_shmem(q, (u8 *)&rmp);
5697  }
5698 }
5699 
5700 static void
5703 {
5706  vlib_counter_t v;
5707  int i, which;
5708  u64 total_pkts[VLIB_N_RX_TX];
5709  u64 total_bytes[VLIB_N_RX_TX];
5710  map_main_t *mm = &map_main;
5713 
5714  if (!q)
5715  return;
5716 
5717  rmp = vl_msg_api_alloc (sizeof (*rmp));
5718  rmp->_vl_msg_id = ntohs(VL_API_MAP_SUMMARY_STATS_REPLY);
5719  rmp->context = mp->context;
5720  rmp->retval = 0;
5721 
5722  memset (total_pkts, 0, sizeof (total_pkts));
5723  memset (total_bytes, 0, sizeof (total_bytes));
5724 
5726  vec_foreach(cm, mm->domain_counters) {
5727  which = cm - mm->domain_counters;
5728 
5729  for (i = 0; i < vec_len(cm->maxi); i++) {
5730  vlib_get_combined_counter (cm, i, &v);
5731  total_pkts[which] += v.packets;
5732  total_bytes[which] += v.bytes;
5733  }
5734  }
5735 
5737 
5738  /* Note: in network byte order! */
5739  rmp->total_pkts[MAP_DOMAIN_COUNTER_RX] = clib_host_to_net_u64(total_pkts[MAP_DOMAIN_COUNTER_RX]);
5740  rmp->total_bytes[MAP_DOMAIN_COUNTER_RX] = clib_host_to_net_u64(total_bytes[MAP_DOMAIN_COUNTER_RX]);
5741  rmp->total_pkts[MAP_DOMAIN_COUNTER_TX] = clib_host_to_net_u64(total_pkts[MAP_DOMAIN_COUNTER_TX]);
5742  rmp->total_bytes[MAP_DOMAIN_COUNTER_TX] = clib_host_to_net_u64(total_bytes[MAP_DOMAIN_COUNTER_TX]);
5743  rmp->total_bindings = clib_host_to_net_u64(pool_elts(mm->domains));
5744  rmp->total_ip4_fragments = 0; // Not yet implemented. Should be a simple counter.
5745  rmp->total_security_check[MAP_DOMAIN_COUNTER_TX] = clib_host_to_net_u64(map_error_counter_get(ip4_map_node.index, MAP_ERROR_ENCAP_SEC_CHECK));
5746  rmp->total_security_check[MAP_DOMAIN_COUNTER_RX] = clib_host_to_net_u64(map_error_counter_get(ip4_map_node.index, MAP_ERROR_DECAP_SEC_CHECK));
5747 
5748  vl_msg_api_send_shmem(q, (u8 *)&rmp);
5749 }
5750 
5753 {
5754  vlib_main_t *vm __attribute__((unused)) = vlib_get_main();
5756  int rv;
5757 #if IPSEC > 0
5758  ipsec_sa_t sa;
5759  sa.id = ntohl(mp->sa_id);
5761  clib_memcpy(&sa.crypto_key, mp->crypto_key, sizeof(sa.crypto_key));
5763  clib_memcpy(&sa.integ_key, mp->integrity_key, sizeof(sa.integ_key));
5764 
5765  rv = ipsec_set_sa_key(vm, &sa);
5766 #else
5767  rv = VNET_API_ERROR_UNIMPLEMENTED;
5768 #endif
5769 
5770  REPLY_MACRO(VL_API_IPSEC_SA_SET_KEY_REPLY);
5771 }
5772 
5775 {
5777  int rv;
5778  u32 sw_if_index = ntohl(mp->sw_if_index);
5779  int enable_disable;
5780 
5782 
5783  enable_disable = (int) mp->enable_disable;
5784 
5785  rv = cop_interface_enable_disable (sw_if_index, enable_disable);
5786 
5788 
5789  REPLY_MACRO(VL_API_COP_INTERFACE_ENABLE_DISABLE_REPLY);
5790 }
5791 
5794 {
5797  u32 sw_if_index = ntohl(mp->sw_if_index);
5798  int rv;
5799 
5801 
5802  a->sw_if_index = sw_if_index;
5803  a->ip4 = mp->ip4;
5804  a->ip6 = mp->ip6;
5805  a->default_cop = mp->default_cop;
5806  a->fib_id = ntohl(mp->fib_id);
5807 
5809 
5811 
5812  REPLY_MACRO(VL_API_COP_WHITELIST_ENABLE_DISABLE_REPLY);
5813 }
5814 
5817 {
5818  int rv = 0;
5819  u8 * vector = 0;
5820  api_main_t * am = &api_main;
5821  vlib_main_t * vm = vlib_get_main();
5822  void * oldheap;
5824 
5825  pthread_mutex_lock (&am->vlib_rp->mutex);
5826  oldheap = svm_push_data_heap (am->vlib_rp);
5827 
5828  /*
5829  * Keep the number of memcpy ops to a minimum (e.g. 1).
5830  * The current size of the serialized vector is
5831  * slightly under 4K.
5832  */
5833  vec_validate (vector, 4095);
5834  vec_reset_length (vector);
5835 
5836  vector = vlib_node_serialize (&vm->node_main, vector);
5837 
5838  svm_pop_heap (oldheap);
5839  pthread_mutex_unlock (&am->vlib_rp->mutex);
5840 
5841  REPLY_MACRO2(VL_API_GET_NODE_GRAPH_REPLY,
5842  rmp->reply_in_shmem = (uword) vector);
5843 }
5844 
5847 {
5848  int rv = 0;
5850  clib_error_t *error;
5851 
5852  /* Ignoring the profile id as currently a single profile
5853  * is supported */
5855  ntohl(mp->node_id), ntohl(mp->trace_app_data),
5856  mp->pow_enable, mp->trace_tsp,
5857  mp->trace_ppc);
5858  if (error) {
5859  clib_error_report(error);
5860  rv = clib_error_get_code(error);
5861  }
5862 
5863  REPLY_MACRO(VL_API_TRACE_PROFILE_ADD_REPLY);
5864 }
5865 
5868 {
5869  int rv = 0;
5871 
5872  if (mp->enable != 0) {
5874  ntohl(mp->prefix_length),
5875  ntohl(mp->vrf_id),
5876  mp->trace_op == IOAM_HBYH_ADD,
5877  mp->trace_op == IOAM_HBYH_POP,
5878  mp->trace_op == IOAM_HBYH_MOD);
5879  } else {
5880  //ip6_ioam_clear_destination(&ip6, mp->prefix_length, mp->vrf_id);
5881  }
5882  REPLY_MACRO(VL_API_TRACE_PROFILE_APPLY_REPLY);
5883 }
5884 
5887 {
5888  int rv = 0;
5890  clib_error_t *error;
5891 
5892  error = clear_ioam_rewrite_fn();
5893  if (error) {
5894  clib_error_report(error);
5895  rv = clib_error_get_code(error);
5896  }
5897 
5898  REPLY_MACRO(VL_API_TRACE_PROFILE_DEL_REPLY);
5899 }
5900 
5901 static void
5904 {
5905  vlib_main_t *vm = vlib_get_main();
5907  int rv = 0;
5908  u8 *host_if_name = NULL;
5909 
5910  host_if_name = format(0, "%s", mp->host_if_name);
5911  vec_add1 (host_if_name, 0);
5912 
5913  rv = af_packet_create_if(vm, host_if_name,
5914  mp->use_random_hw_addr ? 0 : mp->hw_addr);
5915 
5916  vec_free(host_if_name);
5917 
5918  REPLY_MACRO(VL_API_AF_PACKET_CREATE_REPLY);
5919 }
5920 
5921 static void
5924 {
5925  vlib_main_t * vm = vlib_get_main();
5927  int rv = 0;
5928  u8 *host_if_name = NULL;
5929 
5930  host_if_name = format(0, "%s", mp->host_if_name);
5931  vec_add1 (host_if_name, 0);
5932 
5933  rv = af_packet_delete_if(vm, host_if_name);
5934 
5935  vec_free(host_if_name);
5936 
5937  REPLY_MACRO(VL_API_AF_PACKET_DELETE_REPLY);
5938 }
5939 
5940 static void
5943 {
5944  vlib_main_t * vm = vlib_get_main();
5946  int rv = 0;
5947  u8 *name = NULL;
5949  clib_error_t * error;
5950 
5951  name = format(0, "%s", mp->name);
5952 
5953  memset (&cfg, 0, sizeof (cfg));
5954  cfg.rfc = mp->type;
5955  cfg.rnd_type = mp->round_type;
5956  cfg.rate_type = mp->rate_type;
5957  cfg.rb.kbps.cir_kbps = mp->cir;
5958  cfg.rb.kbps.eir_kbps = mp->eir;
5959  cfg.rb.kbps.cb_bytes = mp->cb;
5960  cfg.rb.kbps.eb_bytes = mp->eb;
5961 
5962  error = policer_add_del(vm, name, &cfg, mp->is_add);
5963 
5964  if (error)
5965  rv = VNET_API_ERROR_UNSPECIFIED;
5966 
5967  REPLY_MACRO(VL_API_POLICER_ADD_DEL_REPLY);
5968 }
5969 
5970 #define BOUNCE_HANDLER(nn) \
5971 static void vl_api_##nn##_t_handler ( \
5972  vl_api_##nn##_t *mp) \
5973 { \
5974  vpe_client_registration_t *reg; \
5975  vpe_api_main_t * vam = &vpe_api_main; \
5976  unix_shared_memory_queue_t * q; \
5977  \
5978  /* One registration only... */ \
5979  pool_foreach(reg, vam->nn##_registrations, \
5980  ({ \
5981  q = vl_api_client_index_to_input_queue (reg->client_index); \
5982  if (q) { \
5983  /* \
5984  * If the queue is stuffed, turf the msg and complain \
5985  * It's unlikely that the intended recipient is \
5986  * alive; avoid deadlock at all costs. \
5987  */ \
5988  if (q->cursize == q->maxsize) { \
5989  clib_warning ("ERROR: receiver queue full, drop msg"); \
5990  vl_msg_api_free (mp); \
5991  return; \
5992  } \
5993  vl_msg_api_send_shmem (q, (u8 *)&mp); \
5994  return; \
5995  } \
5996  })); \
5997  vl_msg_api_free (mp); \
5998 }
5999 
6000 /*
6001  * vpe_api_hookup
6002  * Add vpe's API message handlers to the table.
6003  * vlib has alread mapped shared memory and
6004  * added the client registration handlers.
6005  * See .../open-repo/vlib/memclnt_vlib.c:memclnt_process()
6006  */
6007 
6008 static clib_error_t *
6010 {
6011  api_main_t * am = &api_main;
6012 
6013 #define _(N,n) \
6014  vl_msg_api_set_handlers(VL_API_##N, #n, \
6015  vl_api_##n##_t_handler, \
6016  vl_noop_handler, \
6017  vl_api_##n##_t_endian, \
6018  vl_api_##n##_t_print, \
6019  sizeof(vl_api_##n##_t), 1);
6021 #undef _
6022 
6023  /*
6024  * Manually register the sr tunnel add del msg, so we trace
6025  * enough bytes to capture a typical segment list
6026  */
6027  vl_msg_api_set_handlers (VL_API_SR_TUNNEL_ADD_DEL,
6028  "sr_tunnel_add_del",
6031  vl_api_sr_tunnel_add_del_t_endian,
6033  256, 1);
6034 
6035 
6036  /*
6037  * Manually register the sr policy add del msg, so we trace
6038  * enough bytes to capture a typical tunnel name list
6039  */
6040  vl_msg_api_set_handlers (VL_API_SR_POLICY_ADD_DEL,
6041  "sr_policy_add_del",
6044  vl_api_sr_policy_add_del_t_endian,
6046  256, 1);
6047 
6048  /*
6049  * Trace space for 8 MPLS encap labels, classifier mask+match
6050  */
6051  am->api_trace_cfg [VL_API_MPLS_ADD_DEL_ENCAP].size += 8 * sizeof(u32);
6052  am->api_trace_cfg [VL_API_CLASSIFY_ADD_DEL_TABLE].size
6053  += 5 * sizeof (u32x4);
6054  am->api_trace_cfg [VL_API_CLASSIFY_ADD_DEL_SESSION].size
6055  += 5 * sizeof (u32x4);
6056  am->api_trace_cfg [VL_API_VXLAN_ADD_DEL_TUNNEL].size
6057  += 16 * sizeof (u32);
6058 
6059  /*
6060  * Thread-safe API messages
6061  */
6062  am->is_mp_safe [VL_API_IP_ADD_DEL_ROUTE] = 1;
6063 
6064  return 0;
6065 }
6066 
6068 
6069 static clib_error_t *
6071 {
6073 
6074  am->vlib_main = vm;
6075  am->vnet_main = vnet_get_main();
6076  am->interface_events_registration_hash = hash_create (0, sizeof (uword));
6077  am->to_netconf_server_registration_hash = hash_create (0, sizeof (uword));
6078  am->from_netconf_server_registration_hash = hash_create (0, sizeof (uword));
6079  am->to_netconf_client_registration_hash = hash_create (0, sizeof (uword));
6080  am->from_netconf_client_registration_hash = hash_create (0, sizeof (uword));
6081  am->oam_events_registration_hash = hash_create (0, sizeof (uword));
6082 
6083  vl_api_init (vm);
6084  vl_set_memory_region_name ("/vpe-api");
6085  vl_enable_disable_memory_api (vm, 1 /* enable it */);
6086 
6087  return 0;
6088 }
6089 
6091 
6092 
6093 static clib_error_t *
6095 {
6096  u8 * chroot_path;
6097  int uid, gid, rv;
6098  char *s, buf[128];
6099  struct passwd _pw, *pw;
6100  struct group _grp, *grp;
6101  clib_error_t *e;
6102 
6103  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
6104  {
6105  if (unformat (input, "prefix %s", &chroot_path))
6106  {
6107  vec_add1 (chroot_path, 0);
6108  vl_set_memory_root_path ((char *)chroot_path);
6109  }
6110  else if (unformat (input, "uid %d", &uid))
6111  vl_set_memory_uid (uid);
6112  else if (unformat (input, "gid %d", &gid))
6113  vl_set_memory_gid (gid);
6114  else if (unformat (input, "uid %s", &s))
6115  {
6116  /* lookup the username */
6117  pw = NULL;
6118  rv = getpwnam_r(s, &_pw, buf, sizeof(buf), &pw);
6119  if (rv < 0)
6120  {
6121  e = clib_error_return_code(0, rv,
6123  "cannot fetch username %s", s);
6124  vec_free (s);
6125  return e;
6126  }
6127  if (pw == NULL)
6128  {
6129  e = clib_error_return_fatal(0, "username %s does not exist", s);
6130  vec_free (s);
6131  return e;
6132  }
6133  vec_free (s);
6134  vl_set_memory_uid (pw->pw_uid);
6135  }
6136  else if (unformat (input, "gid %s", &s))
6137  {
6138  /* lookup the group name */
6139  grp = NULL;
6140  rv = getgrnam_r(s, &_grp, buf, sizeof(buf), &grp);
6141  if (rv != 0)
6142  {
6143  e = clib_error_return_code(0, rv,
6145  "cannot fetch group %s", s);
6146  vec_free (s);
6147  return e;
6148  }
6149  if (grp == NULL)
6150  {
6151  e = clib_error_return_fatal(0, "group %s does not exist", s);
6152  vec_free (s);
6153  return e;
6154  }
6155  vec_free (s);
6156  vl_set_memory_gid (grp->gr_gid);
6157  }
6158  else
6159  return clib_error_return (0, "unknown input `%U'",
6160  format_unformat_error, input);
6161  }
6162  return 0;
6163 }
6165 
6167 {
6168  return (void *) &unformat_vnet_sw_interface;
6169 }
6170 
6171 #undef vl_api_version
6172 #define vl_api_version(n,v) static u32 vpe_api_version = v;
6173 #include <api/vpe.api.h>
6174 #undef vl_api_version
6175 
6177 {
6178  if (clib_host_to_net_u32(mp->api_versions[0]) != vpe_api_version) {
6179  clib_warning ("vpe API mismatch: 0x%08x instead of 0x%08x",
6180  clib_host_to_net_u32 (mp->api_versions[0]),
6181  vpe_api_version);
6182  return -1;
6183  }
6184  return 0;
6185 }
6186 
6187 static u8 * format_arp_event (u8 * s, va_list * args)
6188 {
6189  vl_api_ip4_arp_event_t * event = va_arg (*args, vl_api_ip4_arp_event_t *);
6190 
6191  s = format (s, "pid %d: %U", event->pid,
6192  format_ip4_address, &event->address);
6193  return s;
6194 }
6195 
6196 static clib_error_t *
6198  unformat_input_t * input,
6199  vlib_cli_command_t * cmd)
6200 {
6201  vpe_api_main_t * am = &vpe_api_main;
6202  vl_api_ip4_arp_event_t * event;
6203 
6204  if (pool_elts (am->arp_events) == 0) {
6205  vlib_cli_output (vm, "No active arp event registrations");
6206  return 0;
6207  }
6208 
6209  pool_foreach (event, am->arp_events,
6210  ({
6211  vlib_cli_output (vm, "%U", format_arp_event, event);
6212  }));
6213 
6214  return 0;
6215 }
6216 
6218  .path = "show arp event registrations",
6219  .function = show_ip4_arp_events_fn,
6220  .short_help = "Show arp event registrations",
6221 };
struct vnet_sub_interface_t::@91 eth
#define ip_prefix_v4(_a)
Definition: lisp_types.h:56
static void vl_api_lisp_add_del_remote_mapping_t_handler(vl_api_lisp_add_del_remote_mapping_t *mp)
Definition: api.c:4857
static void vl_api_sw_interface_set_flags_t_handler(vl_api_sw_interface_set_flags_t *mp)
Definition: api.c:2363
static void vl_api_bridge_flags_t_handler(vl_api_bridge_flags_t *mp)
Definition: api.c:1661
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:394
static void vl_api_af_packet_delete_t_handler(vl_api_af_packet_delete_t *mp)
Definition: api.c:5923
ip46_address_t stop
Definition: ipsec.h:96
#define foreach_ip_interface_address(lm, a, sw_if_index, loop, body)
Definition: lookup.h:534
Reply for IPsec: Add/delete Security Association Database entry.
Definition: vpe.api:2849
static void vl_api_map_rule_dump_t_handler(vl_api_map_rule_dump_t *mp)
Definition: api.c:5662
static_always_inline u8 bd_feature_forward(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:145
#define VNET_SW_INTERFACE_FLAG_UNNUMBERED
Definition: interface.h:380
static void vl_api_proxy_arp_add_del_t_handler(vl_api_proxy_arp_add_del_t *mp)
Definition: api.c:2149
DHCP Proxy config response.
Definition: vpe.api:790
u8 psid_length
Definition: map.h:94
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:98
u64 local_cookie[2]
Definition: l2tp.h:33
vmrglw vmrglh hi
DHCP Proxy set / unset vss request.
Definition: vpe.api:804
void unformat_init_vector(unformat_input_t *input, u8 *vector_string)
Definition: unformat.c:1000
Proxy ARP add / del request.
Definition: vpe.api:484
static void vl_api_lisp_enable_disable_t_handler(vl_api_lisp_enable_disable_t *mp)
Definition: api.c:4806
#define VALIDATE_SW_IF_INDEX(mp)
Definition: api.c:156
u8 crypto_algorithm
Definition: vpe.api:2828
u32 bd_set_flags(vlib_main_t *vm, u32 bd_index, u32 flags, u32 enable)
Definition: l2_bd.c:164
#define vec_foreach_index(var, v)
Iterate over vector indices.
static void send_lisp_gpe_tunnel_details(lisp_gpe_tunnel_t *tunnel, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:5052
static void vl_api_lisp_gpe_add_del_iface_t_handler(vl_api_lisp_gpe_add_del_iface_t *mp)
Definition: api.c:4817
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:4089
L2 interface vlan tag rewrite response.
Definition: vpe.api:1907
LISP local eid table status.
Definition: vpe.api:2398
#define foreach_registration_hash
Definition: api.c:348
L2 FIB add entry request.
Definition: vpe.api:1386
#define clib_error_return_code(e, code, flags, args...)
Definition: error.h:106
u8 use_extended_sequence_number
Definition: vpe.api:2836
cop: enable/disable whitelist filtration features on an interface Note: the supplied fib_id must matc...
Definition: vpe.api:3235
static void * vl_api_sr_tunnel_add_del_t_print(vl_api_sr_tunnel_add_del_t *mp, void *handle)
Definition: custom_dump.c:1006
u32 sa_id
Definition: vpe.api:2773
#define hash_set(h, key, value)
Definition: hash.h:237
l2_input_config_t * configs
Definition: l2_input.h:63
static void vl_api_mpls_add_del_decap_t_handler(vl_api_mpls_add_del_decap_t *mp)
Definition: api.c:2136
Set bridge flags response.
Definition: vpe.api:1452
int vnet_mpls_gre_delete_fib_tunnels(u32 fib_id)
Definition: interface.c:957
Definition: gre.h:60
DHCP Client config response.
Definition: vpe.api:2634
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:267
u8 integrity_key_length
Definition: vpe.api:2833
u32 decap_next_index
Definition: lisp_gpe.h:62
static void vl_api_trace_profile_add_t_handler(vl_api_trace_profile_add_t *mp)
Definition: api.c:5846
static void vl_api_sw_interface_dump_t_handler(vl_api_sw_interface_dump_t *mp)
Definition: api.c:2562
vnet_main_t * vnet_main
Definition: api.c:388
#define gid_address_type(_a)
Definition: lisp_types.h:161
void vl_enable_disable_memory_api(vlib_main_t *vm, int yesno)
Definition: memory_vlib.c:651
Reset fib table request.
Definition: vpe.api:749
u32 * config_index_by_sw_if_index
Definition: lookup.h:345
static void svm_pop_heap(void *oldheap)
Definition: svm.h:179
u16 stop
Definition: ipsec.h:100
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)
Definition: tapcli.c:931
uword unformat(unformat_input_t *i, char *fmt,...)
Definition: unformat.c:942
Add or Delete MAP rule from a domain (Only used for shared IPv4 per subscriber)
Definition: vpe.api:3117
int map_delete_domain(u32 map_domain_index)
Definition: map.c:282
u32 local_adj_index
Definition: lookup.h:380
static int ip6_add_del_route_t_handler(vl_api_ip_add_del_route_t *mp)
Definition: api.c:1017
ip46_address_t tunnel_src_addr
Definition: ipsec.h:84
vpe parser cli string response
Definition: vpe.api:1092
static void vl_api_lisp_add_del_map_resolver_t_handler(vl_api_lisp_add_del_map_resolver_t *mp)
Definition: api.c:4765
always_inline uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Definition: node_funcs.h:410
add or delete lisp gpe maptunel
Definition: vpe.api:2221
static void send_vxlan_tunnel_details(vxlan_tunnel_t *t, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:4363
u8 address_is_ipv6
Definition: vpe.api:2228
static void vl_api_set_arp_neighbor_limit_t_handler(vl_api_set_arp_neighbor_limit_t *mp)
Definition: api.c:3356
static void vl_api_create_loopback_t_handler(vl_api_create_loopback_t *mp)
Definition: api.c:3254
a
Definition: bitmap.h:393
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)
Definition: l2_vtr.c:44
int dpdk_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:1442
u8 vnet_lisp_gpe_enable_disable_status(void)
Definition: lisp_gpe.c:436
void vl_set_memory_gid(int gid)
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:274
u32 id
Definition: ipsec.h:67
format_function_t format_ip6_address
Definition: format.h:87
Reply for IKEv2: Set IKEv2 profile traffic selector parameters.
Definition: vpe.api:3003
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
static void(BVT(clib_bihash)*h, BVT(clib_bihash_value)*v)
clib_error_t * ikev2_add_del_profile(vlib_main_t *vm, u8 *name, int is_add)
Definition: ikev2.c:1956
static void vl_api_sw_interface_set_l2_bridge_t_handler(vl_api_sw_interface_set_l2_bridge_t *mp)
Definition: api.c:1412
static void send_lisp_enable_disable_details(unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:5156
always_inline void * vnet_rewrite_get_data_internal(vnet_rewrite_header_t *rw, int max_size)
Definition: rewrite.h:111
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
Reply for IKEv2: Set IKEv2 profile authentication method.
Definition: vpe.api:2939
int af_packet_create_if(vlib_main_t *vm, u8 *host_if_name, u8 *hw_addr_set)
Definition: af_packet.c:165
Vhost-user interface details structure (fix this)
Definition: vpe.api:2042
u8 tunnel_dst_address[16]
Definition: vpe.api:2841
u32 bvi_sw_if_index
Definition: l2_bd.h:60
ethernet_main_t * ethernet_get_main(vlib_main_t *vm)
Definition: init.c:95
Set flags on the interface.
Definition: vpe.api:127
Reply for locator_set add/del.
Definition: vpe.api:2149
IKEv2: Add/delete profile.
Definition: vpe.api:2897
int vnet_set_ip6_classify_intfc(vlib_main_t *vm, u32 sw_if_index, u32 table_index)
Definition: ip6_forward.c:2758
ip6_address_t * multicast_address
Definition: sr.h:121
vnet_interface_main_t interface_main
Definition: vnet.h:62
static void vl_api_vxlan_add_del_tunnel_t_handler(vl_api_vxlan_add_del_tunnel_t *mp)
Definition: api.c:4313
u16 local_port_start
Definition: vpe.api:2768
Control ping from client to api server request.
Definition: vpe.api:1058
ip_lookup_next_t lookup_next_index
Definition: lookup.h:163
static void vl_api_sw_interface_vhost_user_details_t_handler(vl_api_sw_interface_vhost_user_details_t *mp)
Definition: api.c:3807
i32 priority
Definition: ipsec.h:122
LISP map resolver status.
Definition: vpe.api:2446
u32 table_id
Definition: ip4.h:58
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:2099
int size
Definition: api.h:68
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:214
static void vl_api_control_ping_t_handler(vl_api_control_ping_t *mp)
Definition: api.c:3282
u8 as_u8[16]
Definition: ip6_packet.h:47
u64 as_u64[2]
Definition: ip6_packet.h:50
IPsec: Update Security Association keys.
Definition: vpe.api:2867
OAM event structure.
Definition: vpe.api:690
static void dhcpv4_proxy_config_2(vl_api_dhcp_proxy_config_2_t *mp)
Definition: api.c:2936
#define IOAM_HBYH_MOD
Reply for gpe_iface add/del.
Definition: vpe.api:2323
static void vl_api_lisp_enable_disable_status_dump_t_handler(vl_api_lisp_enable_disable_status_dump_t *mp)
Definition: api.c:5174
static void vl_api_classify_set_interface_l2_tables_t_handler(vl_api_classify_set_interface_l2_tables_t *mp)
Definition: api.c:3634
L2TP tunnel set cookies response.
Definition: vpe.api:1733
int dpdk_vhost_user_delete_if(vnet_main_t *vnm, vlib_main_t *vm, u32 sw_if_index)
Definition: vhost_user.c:1492
#define UNFORMAT_END_OF_INPUT
Definition: format.h:142
u32 miss_adj_index
Definition: lookup.h:380
u8 is_add
Definition: vpe.api:2750
clib_error_t * vnet_lisp_gpe_enable_disable(vnet_lisp_gpe_enable_disable_args_t *a)
Definition: lisp_gpe.c:444
#define NULL
Definition: clib.h:55
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)
u32 index
Definition: node.h:203
vlib_counter_t * maxi
Definition: counter.h:181
always_inline u32 ip4_fib_lookup(ip4_main_t *im, u32 sw_if_index, ip4_address_t *dst)
Definition: ip4.h:191
#define L2_FLOOD
Definition: l2_bd.h:97
Request for a single block of summary stats.
Definition: vpe.api:666
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:2519
Set max allowed ARP or ip6 neighbor entries request.
Definition: vpe.api:1104
static void vl_api_sw_interface_set_vpath_t_handler(vl_api_sw_interface_set_vpath_t *mp)
Definition: api.c:1324
static vlib_node_registration_t vpe_resolver_process_node
(constructor) VLIB_REGISTER_NODE (vpe_resolver_process_node)
Definition: api.c:391
lisp_gpe_tunnel_t * tunnels
Definition: lisp_gpe.h:131
locator_t * locator_pool
Definition: control.h:64
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:1267
L2 bridge domain sw interface operational state response.
Definition: vpe.api:2603
ip6_address_t our_address
Definition: l2tp.h:27
u64 map_error_counter_get(u32 node_index, map_error_t map_error)
Definition: map.c:880
static void vl_api_gre_add_del_tunnel_t_handler(vl_api_gre_add_del_tunnel_t *mp)
Definition: api.c:4422
int ip6_neighbor_ra_config(vlib_main_t *vm, u32 sw_if_index, u8 surpress, 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)
static void vl_api_l2_fib_table_entry_t_handler(vl_api_l2_fib_table_entry_t *mp)
Definition: api.c:4083
#define IP4_ARP_EVENT
Reply for IPsec: Add/delete Security Policy Database entry.
Definition: vpe.api:2781
#define L2_FWD
Definition: l2_bd.h:96
ip46_address_t dst
Definition: vxlan.h:71
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:284
clib_error_t * ip4_set_arp_limit(u32 arp_limit)
Definition: arp.c:1249
Add / del gre tunnel request.
Definition: vpe.api:394
static void vl_api_af_packet_create_t_handler(vl_api_af_packet_create_t *mp)
Definition: api.c:5903
u8 tap_name[64]
Definition: vpe.api:249
ip_config_main_t rx_config_mains[VNET_N_CAST]
Definition: lookup.h:401
ipsec_integ_alg_t integ_alg
Definition: ipsec.h:75
u32 l2fib_del_entry(u64 mac, u32 bd_index)
Definition: l2_fib.c:459
#define REPLY_MACRO(t)
Definition: api.c:122
#define ip_prefix_len(_a)
Definition: lisp_types.h:55
u32 outer_fib_index
Definition: gre.h:55
vlib_main_t * vlib_main
Definition: stats.h:59
static int arp_change_data_callback(u32 pool_index, u8 *new_mac, u32 sw_if_index, u32 address)
Definition: api.c:5202
vnet_main_t ** vnet_mains
Definition: vnet.h:82
IPsec: Add/delete Security Policy Database entry.
Definition: vpe.api:2747
Classify add / del session request.
Definition: vpe.api:1537
add_epi add_epi sub
Definition: vector_sse2.h:217
int ip6_sr_add_del_policy(ip6_sr_add_del_policy_args_t *a)
Definition: sr.c:1287
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:480
static void vl_api_delete_loopback_t_handler(vl_api_delete_loopback_t *mp)
Definition: api.c:3269
int vnet_interface_name_renumber(u32 sw_if_index, u32 new_show_dev_instance)
Definition: interface.c:1028
static void lisp_gpe_add_del_fwd_entry_set_address(vl_api_lisp_gpe_add_del_fwd_entry_t *mp, ip_address_t *slocator, ip_address_t *dlocator, gid_address_t *eid)
Definition: api.c:4701
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 *sw_if_index)
Definition: l2tp.c:292
static void map_domain_counter_unlock(map_main_t *mm)
Definition: map.h:536
LISP locator_set status.
Definition: vpe.api:2371
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
static void vl_api_sw_if_l2tpv3_tunnel_dump_t_handler(vl_api_sw_if_l2tpv3_tunnel_dump_t *mp)
Definition: api.c:3990
u8 is_tunnel
Definition: ipsec.h:82
struct _vlib_node_registration vlib_node_registration_t
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:519
u8 eid_prefix_len
Definition: vpe.api:2227
Dump tap interfaces request.
Definition: vpe.api:287
gid_address_t deid
Definition: lisp_gpe.h:213
l2_flood_member_t * members
Definition: l2_bd.h:66
static void vl_api_lisp_gpe_tunnel_dump_t_handler(vl_api_lisp_local_eid_table_dump_t *mp)
Definition: api.c:5084
always_inline void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
Definition: node_funcs.h:789
ip6_address_t * tags
Definition: sr.h:86
always_inline uword vlib_process_get_events_with_type(vlib_main_t *vm, uword **data_vector, uword with_type_opaque)
Definition: node_funcs.h:462
#define hash_set_mem(h, key, value)
Definition: hash.h:257
static void vl_api_ikev2_profile_add_del_t_handler(vl_api_ikev2_profile_add_del_t *mp)
Definition: api.c:5463
ip_lookup_main_t lookup_main
Definition: ip4.h:129
static void vl_api_l2tpv3_create_tunnel_t_handler(vl_api_l2tpv3_create_tunnel_t *mp)
Definition: api.c:4230
Reply to sw_interface_clear_stats.
Definition: vpe.api:3296
uword * sub_interface_sw_if_index_by_id
Definition: interface.h:316
vlib_main_t * vlib_main
Definition: api.c:387
cop: interface enable/disable junk filtration reply
Definition: vpe.api:3218
u32 * fib_index_by_sw_if_index
Definition: ip4.h:137
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:2446
static void vl_api_vxlan_tunnel_dump_t_handler(vl_api_vxlan_tunnel_dump_t *mp)
Definition: api.c:4392
vlib_node_registration_t ip4_map_node
(constructor) VLIB_REGISTER_NODE (ip4_map_node)
Definition: ip4_map.c:597
union sse2_qos_pol_cfg_params_st_::@153 rb
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:2545
static void vl_api_sw_interface_set_l2_xconnect_t_handler(vl_api_sw_interface_set_l2_xconnect_t *mp)
Definition: api.c:1385
Add/Delete classification table request.
Definition: vpe.api:1498
vl_api_ip4_arp_event_t * arp_events
Definition: api.c:384
unformat_function_t unformat_vnet_sw_interface
Reply for add / del tunnel request.
Definition: vpe.api:411
IPv6 router advertisement config request.
Definition: vpe.api:874
Reply for tap delete request.
Definition: vpe.api:281
static void vl_api_cop_whitelist_enable_disable_t_handler(vl_api_cop_whitelist_enable_disable_t *mp)
Definition: api.c:5793
void * get_unformat_vnet_sw_interface(void)
Definition: api.c:6166
L2 bridge domain request operational state details.
Definition: vpe.api:2571
#define clib_error_report(e)
Definition: error.h:126
Set bridge domain ip to mac entry response.
Definition: vpe.api:1481
static void vl_api_mpls_ethernet_add_del_tunnel_t_handler(vl_api_mpls_ethernet_add_del_tunnel_t *mp)
Definition: api.c:1972
#define VNET_HW_INTERFACE_FLAG_LINK_UP
Definition: interface.h:241
u8 policy
Definition: vpe.api:2772
void ip4_maybe_remap_adjacencies(ip4_main_t *im, u32 table_index_or_table_id, u32 flags)
Definition: ip4_forward.c:522
static void vl_api_bridge_domain_add_del_t_handler(vl_api_bridge_domain_add_del_t *mp)
Definition: api.c:1444
int vnet_vxlan_gpe_add_del_tunnel(vnet_vxlan_gpe_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
Definition: vxlan_gpe.c:180
static uword resolver_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: api.c:635
Definition: l2_fib.h:50
vhost-user interface create request
Definition: vpe.api:1919
static_always_inline u8 bd_feature_uu_flood(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:139
u16 remote_port_stop
Definition: vpe.api:2767
Reply for locator add/del.
Definition: vpe.api:2177
#define pool_get(P, E)
Definition: pool.h:186
format_function_t format_ip4_address
Definition: format.h:71
u8 crypto_key[128]
Definition: vpe.api:2830
Add/del policer response.
Definition: vpe.api:3459
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:4742
vlib_cli_command_t show_ip4_arp_events
(constructor) VLIB_CLI_COMMAND (show_ip4_arp_events)
Definition: api.c:6217
ip_address_t dlocator
Definition: lisp_gpe.h:217
#define ip_prefix_version(_a)
Definition: lisp_types.h:54
u64 remote_cookie
Definition: l2tp.h:34
L2 interface ethernet flow point filtering response.
Definition: vpe.api:1791
void send_oam_event(oam_target_t *t)
Definition: api.c:2601
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:3057
trace_cfg_t * api_trace_cfg
Definition: api.h:121
ip_address_t * map_resolvers
Definition: control.h:95
always_inline vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
add or delete gpe_iface
Definition: vpe.api:2311
#define VNET_HW_INTERFACE_FLAG_DUPLEX_MASK
Definition: interface.h:246
u8 crypto_key[128]
Definition: ipsec.h:73
int vnet_create_loopback_interface(u32 *sw_if_indexp, u8 *mac_address)
Definition: interface.c:349
u32 * tunnel_index_by_sw_if_index
Definition: gre.h:75
u32 custom_dev_instance
Definition: vpe.api:252
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
ip6_address_t client_address
Definition: l2tp.h:28
u8 protocol
Definition: vpe.api:2764
Interface bridge mode response.
Definition: vpe.api:1371
u32 spi
Definition: ipsec.h:68
u32 index
Definition: ip4.h:61
port_range_t lport
Definition: ipsec.h:130
always_inline void * ip_interface_address_get_address(ip_lookup_main_t *lm, ip_interface_address_t *a)
Definition: lookup.h:513
int ip6_sr_add_del_multicastmap(ip6_sr_add_del_multicastmap_args_t *a)
Definition: sr.c:1503
IPv6 segment routing tunnel add / del response.
Definition: vpe.api:1181
static void vl_api_l2_fib_table_dump_t_handler(vl_api_l2_fib_table_dump_t *mp)
Definition: api.c:4114
Get list of map domains.
Definition: vpe.api:3138
ip4_address_t tunnel_dst
Definition: gre.h:54
always_inline uword unformat_check_input(unformat_input_t *i)
Definition: format.h:168
static void vl_api_sw_interface_tap_dump_t_handler(vl_api_sw_interface_tap_dump_t *mp)
Definition: api.c:4027
OAM add / del target response.
Definition: vpe.api:738
static void vl_api_ipsec_interface_add_del_spd_t_handler(vl_api_ipsec_interface_add_del_spd_t *mp)
Definition: api.c:5326
api_main_t api_main
Definition: api.h:162
u8 source_ip_address[16]
Definition: vpe.api:2229
static void vl_api_ip_dump_t_handler(vl_api_ip_dump_t *mp)
Definition: api.c:4052
ip6_address_t * segments
Definition: sr.h:80
#define VNET_HW_INTERFACE_FLAG_SPEED_MASK
Definition: interface.h:258
static void vl_api_map_add_del_rule_t_handler(vl_api_map_add_del_rule_t *mp)
Definition: api.c:5611
u32 bd_id
Definition: vpe.api:2095
Create host-interface response.
Definition: vpe.api:3401
u8 mac_address[6]
Definition: vpe.api:250
u32 spd_id
Definition: vpe.api:2752
vnet_main_t * vnet_get_main(void)
Definition: misc.c:45
L2 bridge domain operational state response.
Definition: vpe.api:2586
u8 local_address_start[16]
Definition: vpe.api:2761
u32 sw_if_index
Definition: gre.h:57
Reply for interface events registration.
Definition: vpe.api:203
u8 integ_key[128]
Definition: ipsec.h:77
Get node index using name request.
Definition: vpe.api:1624
static void vl_api_lisp_add_del_local_eid_t_handler(vl_api_lisp_add_del_local_eid_t *mp)
Definition: api.c:4649
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:80
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:586
Proxy ARP add / del request.
Definition: vpe.api:508
u8 is_tunnel
Definition: vpe.api:2838
clib_error_t * policer_add_del(vlib_main_t *vm, u8 *name, sse2_qos_pol_cfg_params_st *cfg, u8 is_add)
Definition: policer.c:19
#define VNET_SW_INTERFACE_FLAG_PROXY_ARP
Definition: interface.h:378
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:3972
void vlib_clear_combined_counters(vlib_combined_counter_main_t *cm)
Definition: counter.c:65
Clear interface statistics.
Definition: vpe.api:3286
#define pool_foreach(VAR, POOL, BODY)
Definition: pool.h:328
u8 crypto_key_length
Definition: vpe.api:2829
u32 context
Definition: vpe.api:2094
static void vl_api_vnet_get_summary_stats_t_handler(vl_api_vnet_get_summary_stats_t *mp)
Definition: api.c:2636
u32 sad_id
Definition: vpe.api:2822
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:109
static void vl_api_interface_name_renumber_t_handler(vl_api_interface_name_renumber_t *mp)
Definition: api.c:5187
DHCP Proxy config 2 add / del request.
Definition: vpe.api:1665
static void * svm_push_data_heap(svm_region_t *rp)
Definition: svm.h:172
Reply for IPsec: Update Security Association keys.
Definition: vpe.api:2885
#define MODE_L2_BRIDGE
Definition: l2_input.h:209
static void vl_api_map_add_domain_t_handler(vl_api_map_add_domain_t *mp)
Definition: api.c:5580
void vl_set_memory_uid(int uid)
Reply for gpe enable/disable.
Definition: vpe.api:2281
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
Definition: vec.h:268
vlib_combined_counter_main_t * combined_sw_if_counters
Definition: interface.h:458
vlib_combined_counter_main_t * domain_counters
Definition: map.h:190
static void vl_api_dhcp_client_config_t_handler(vl_api_dhcp_client_config_t *mp)
Definition: api.c:3037
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:1986
static void vl_api_map_del_domain_t_handler(vl_api_map_del_domain_t *mp)
Definition: api.c:5599
void vl_api_ip_add_del_route_t_handler(vl_api_ip_add_del_route_t *mp)
Definition: api.c:1190
static void vl_api_l2tpv3_set_lookup_key_t_handler(vl_api_l2tpv3_set_lookup_key_t *mp)
Definition: api.c:4295
Reply for the vlan subinterface create request.
Definition: vpe.api:320
u8 is_add
Definition: lisp_gpe.h:205
static void vl_api_l2_flags_t_handler(vl_api_l2_flags_t *mp)
Definition: api.c:1638
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:79
int mpls_fib_reset_labels(u32 fib_id)
Definition: mpls.c:711
Delete Trace Profile.
Definition: vpe.api:3366
int i32
Definition: types.h:81
u32 feature_bitmap
Definition: vpe.api:1418
#define clib_error_return_fatal(e, args...)
Definition: error.h:118
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
static void set_ip4_flow_hash(vl_api_set_ip_flow_hash_t *mp)
Definition: api.c:3181
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static_always_inline u8 bd_feature_arp_term(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:157
int ip6_interface_enabled(vlib_main_t *vm, u32 sw_if_index)
#define L2_UU_FLOOD
Definition: l2_bd.h:98
u16 start
Definition: ipsec.h:100
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:50
svm_region_t * vlib_rp
Definition: api.h:123
static void vl_api_sw_interface_set_unnumbered_t_handler(vl_api_sw_interface_set_unnumbered_t *mp)
Definition: api.c:3210
int ipsec_add_del_policy(vlib_main_t *vm, ipsec_policy_t *policy, int is_add)
Definition: ipsec.c:161
always_inline uword pool_elts(void *v)
Definition: pool.h:97
static void vl_api_dhcp_proxy_config_t_handler(vl_api_dhcp_proxy_config_t *mp)
Definition: api.c:2994
get_node_graph_reply
Definition: vpe.api:3275
static void vl_api_get_node_graph_t_handler(vl_api_get_node_graph_t *mp)
Definition: api.c:5816
ip6_address_t * rules
Definition: map.h:84
Reply for add / del encapsulation request.
Definition: vpe.api:441
Reply for MPLS Ethernet add / delete tunnel request.
Definition: vpe.api:1282
#define clib_warning(format, args...)
Definition: error.h:59
IPv6 interface enable / disable request.
Definition: vpe.api:948
u32 table_index_or_table_id
Definition: ip6.h:343
Delete host-interface.
Definition: vpe.api:3411
void ip_address_copy_addr(void *dst, ip_address_t *src)
Definition: lisp_types.c:425
unsigned long u64
Definition: types.h:89
clib_error_t * ip6_set_neighbor_limit(u32 neighbor_limit)
Set/unset input ACL interface.
Definition: vpe.api:2650
void vnet_l2_classify_enable_disable(u32 sw_if_index, int enable_disable)
Definition: l2_classify.c:428
static void vl_api_lisp_gpe_enable_disable_t_handler(vl_api_lisp_gpe_enable_disable_t *mp)
Definition: api.c:4792
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
Definition: vec.h:199
static clib_error_t * admin_up_down_function(vnet_main_t *vm, u32 hw_if_index, u32 flags)
Definition: api.c:523
int vnet_arp_unset_ip4_over_ethernet(vnet_main_t *vnm, u32 sw_if_index, u32 fib_index, void *a_arg)
Definition: arp.c:1384
static void vl_api_l2fib_add_del_t_handler(vl_api_l2fib_add_del_t *mp)
Definition: api.c:1587
void vnet_lisp_gpe_add_del_iface(vnet_lisp_gpe_add_del_iface_args_t *a, u32 *hw_if_indexp)
Definition: interface.c:484
#define ip_addr_v4(_a)
Definition: lisp_types.h:49
IKEv2: Set IKEv2 profile local/remote identification.
Definition: vpe.api:2954
u8 * format_ipsec_integ_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:90
Trace profile apply response.
Definition: vpe.api:3356
Initialize a new tap interface with the given paramters.
Definition: vpe.api:215
IKEv2: Set IKEv2 profile traffic selector parameters.
Definition: vpe.api:2986
int l2tpv3_interface_enable_disable(vnet_main_t *vnm, u32 sw_if_index, int enable_disable)
Definition: l2tp.c:570
static void add_routes_in_fib(clib_bihash_kv_24_8_t *kvp, void *arg)
Definition: api.c:2799
int vnet_set_ip4_classify_intfc(vlib_main_t *vm, u32 sw_if_index, u32 table_index)
Definition: ip4_forward.c:3239
ip6_fib_t * fibs
Definition: ip6.h:143
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:2224
uword * bd_index_by_bd_id
Definition: l2_bd.h:26
i32 priority
Definition: vpe.api:2753
Definition: lisp_gpe.h:203
u32 hw_if_index
Definition: l2tp.h:39
Reply for tap connect request.
Definition: vpe.api:230
#define API_ADMIN_UP_DOWN_EVENT
Definition: api.c:427
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)
Definition: l2_input.c:509
clib_error_t * ip6_probe_neighbor(vlib_main_t *vm, ip6_address_t *dst, u32 sw_if_index)
Definition: ip6_forward.c:2129
Classify add / del session response.
Definition: vpe.api:1552
#define ip_addr_version(_a)
Definition: lisp_types.h:51
static void vl_api_l2_interface_efp_filter_t_handler(vl_api_l2_interface_efp_filter_t *mp)
Definition: api.c:3686
int map_add_del_psid(u32 map_domain_index, u16 psid, ip6_address_t *tep, u8 is_add)
Definition: map.c:346
l2tpv3 tunnel interface create response
Definition: vpe.api:1715
Dump l2 fib (aka bridge domain) table.
Definition: vpe.api:2107
Interface set vpath response.
Definition: vpe.api:1251
static void dhcpv6_proxy_config(vl_api_dhcp_proxy_config_t *mp)
Definition: api.c:2921
Delete tap interface.
Definition: vpe.api:271
u8 local_address_stop[16]
Definition: vpe.api:2762
#define BAD_RX_SW_IF_INDEX_LABEL
Definition: api.c:182
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:1239
static_always_inline u8 bd_feature_flood(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:133
clib_error_t * ip4_probe_neighbor(vlib_main_t *vm, ip4_address_t *dst, u32 sw_if_index)
Definition: ip4_forward.c:2383
Delete MAP domain.
Definition: vpe.api:3094
vnet_api_error_t api_errno
Definition: vnet.h:76
void dsunlock(stats_main_t *sm)
Definition: stats.c:85
static void vl_api_is_address_reachable_t_handler(vl_api_is_address_reachable_t *mp)
Definition: api.c:2293
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:3176
Reply for gpe enable/disable.
Definition: vpe.api:2301
static void vl_api_bridge_domain_details_t_handler(vl_api_bridge_domain_details_t *mp)
Definition: api.c:1495
void vl_set_memory_root_path(char *root_path)
ip6_address_t dst_address
Definition: ip6.h:346
#define hash_get(h, key)
Definition: hash.h:231
vl_api_ip_add_del_route_t r
Definition: api.c:365
clib_error_t * ikev2_set_profile_id(vlib_main_t *vm, u8 *name, u8 id_type, u8 *data, int is_local)
Definition: ikev2.c:2016
Set L2 flags request !!! TODO - need more info, feature bits in l2_input.h.
Definition: vpe.api:1413
format_function_t format_vnet_sw_interface_name
#define VNET_HW_INTERFACE_FLAG_DUPLEX_SHIFT
Definition: interface.h:243
#define pool_elt_at_index(p, i)
Definition: pool.h:346
static void vl_api_ipsec_sad_add_del_entry_t_handler(vl_api_ipsec_sad_add_del_entry_t *mp)
Definition: api.c:5404
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:442
#define IOAM_HBYH_POP
vnet_sub_interface_t sub
Definition: interface.h:404
L2 fib clear table request, clear all mac entries in the l2 fib.
Definition: vpe.api:1760
u64 mac
Definition: vpe.api:2096
void ip6_maybe_remap_adjacencies(ip6_main_t *im, u32 table_index_or_table_id, u32 flags)
Definition: ip6_forward.c:601
Set/unset input ACL interface response.
Definition: vpe.api:2664
static void vl_api_input_acl_set_interface_t_handler(vl_api_input_acl_set_interface_t *mp)
Definition: api.c:5281
uword * fib_index_by_table_id
Definition: ip4.h:141
static void vl_api_l2tpv3_set_tunnel_cookies_t_handler(vl_api_l2tpv3_set_tunnel_cookies_t *mp)
Definition: api.c:4260
Status of lisp-gpe protocol, enable or disable.
Definition: vpe.api:2465
#define clib_error_get_code(err)
Definition: error.h:88
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)
#define API_LINK_STATE_EVENT
Definition: api.c:426
u8 is_tunnel_ip6
Definition: ipsec.h:83
static void vl_api_l2tpv3_interface_enable_disable_t_handler(vl_api_l2tpv3_interface_enable_disable_t *mp)
Definition: api.c:4278
static int arp_change_delete_callback(u32 pool_index, u8 *notused)
Definition: api.c:5232
static void vl_api_cop_interface_enable_disable_t_handler(vl_api_cop_interface_enable_disable_t *mp)
Definition: api.c:5774
#define VNET_HW_INTERFACE_FLAG_SPEED_SHIFT
Definition: interface.h:251
Trace profile add / del response.
Definition: vpe.api:3376
int dpdk_vhost_user_dump_ifs(vnet_main_t *vnm, vlib_main_t *vm, vhost_user_intf_details_t **out_vuids)
Definition: vhost_user.c:1525
u32 local_session_id
Definition: l2tp.h:35
Set/unset l2 classification tables for an interface response.
Definition: vpe.api:1603
char * vpe_api_get_version(void)
Definition: version.c:85
IPsec: Add/delete Security Policy Database.
Definition: vpe.api:2676
always_inline uword * vlib_process_wait_for_event(vlib_main_t *vm)
Definition: node_funcs.h:484
#define ip_prefix_v6(_a)
Definition: lisp_types.h:57
IPv6 segment routing tunnel add / del request.
Definition: vpe.api:1160
IPv6 segment routing multicast map to policy add / del request.
Definition: vpe.api:1217
int vnet_lisp_add_del_local_mapping(vnet_lisp_add_del_mapping_args_t *a, u32 *map_index_result)
Definition: control.c:131
L2 FIB add entry response.
Definition: vpe.api:1401
map_domain_t * domains
Definition: map.h:186
static void send_lisp_map_resolver_details(ip_address_t *ip, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:5107
Set/unset l2 classification tables for an interface request.
Definition: vpe.api:1589
int vl_api_memclnt_delete_callback(u32 client_index)
Definition: api.c:405
static clib_error_t * api_segment_config(vlib_main_t *vm, unformat_input_t *input)
Definition: api.c:6094
Add/Delete classification table response.
Definition: vpe.api:1519
ip_adjacency_t * add_adj
Definition: ip6.h:355
Set L2 bits response.
Definition: vpe.api:1425
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:2561
Set bridge domain ip to mac entry request.
Definition: vpe.api:1467
int ipsec_add_del_sa(vlib_main_t *vm, ipsec_sa_t *new_sa, int is_add)
Definition: ipsec.c:405
static void shmem_cli_output(uword arg, u8 *buffer, uword buffer_bytes)
Definition: api.c:3293
always_inline u64 l2fib_make_key(u8 *mac_address, u16 bd_index)
Definition: l2_fib.h:84
#define pool_put(P, E)
Definition: pool.h:200
vhost-user interface create response
Definition: vpe.api:1935
uword * sw_if_index_by_sup_and_sub
Definition: interface.h:452
always_inline f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Definition: node_funcs.h:551
#define VALIDATE_TX_SW_IF_INDEX(mp)
Definition: api.c:188
add or delete lisp eid-table
Definition: vpe.api:2191
IOAM Trace : Set TRACE profile.
Definition: vpe.api:3311
int dpdk_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:1396
static int mpls_ethernet_add_del_tunnel_2_t_handler(vl_api_mpls_ethernet_add_del_tunnel_2_t *mp)
Definition: api.c:2002
always_inline f64 vlib_last_vector_length_per_node(vlib_main_t *vm)
Definition: main.h:267
vxlan_main_t vxlan_main
Definition: vxlan.c:18
static void vlib_get_combined_counter(vlib_combined_counter_main_t *cm, u32 index, vlib_counter_t *result)
Definition: counter.h:248
IPv6 router advertisement prefix config response.
Definition: vpe.api:937
int cop_whitelist_enable_disable(cop_whitelist_enable_disable_args_t *a)
Definition: cop.c:228
struct sse2_qos_pol_cfg_params_st_::@153::@154 kbps
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:1530
u32 index
Definition: ip6.h:67
static vpe_api_main_t vpe_api_main
Definition: api.c:392
static void vl_api_sw_interface_clear_stats_t_handler(vl_api_sw_interface_clear_stats_t *mp)
Definition: api.c:2388
static void send_lisp_local_eid_table_details(mapping_t *mapit, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:4972
vlib_simple_counter_main_t * sw_if_counters
Definition: interface.h:457
static void vl_api_trace_profile_del_t_handler(vl_api_trace_profile_del_t *mp)
Definition: api.c:5886
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:3011
map_main_t map_main
Definition: map.h:297
clib_error_t * vnet_lisp_enable_disable(u8 is_enabled)
Definition: control.c:824
ip46_address_range_t laddr
Definition: ipsec.h:127
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:2525
u8 is_add
Definition: vpe.api:2820
MPLS Ethernet add/ del tunnel 2.
Definition: vpe.api:1300
Set unnumbered interface add / del response.
Definition: vpe.api:1007
static void vl_api_ikev2_set_local_key_t_handler(vl_api_ikev2_set_local_key_t *mp)
Definition: api.c:5559
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:3144
int ip6_sr_add_del_tunnel(ip6_sr_add_del_tunnel_args_t *a)
Definition: sr.c:740
Set or delete one or all ip addresses on a specified interface.
Definition: vpe.api:164
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:538
u16 local_port_stop
Definition: vpe.api:2769
typedef CLIB_PACKED(struct{ip4_address_t address;u32 address_length:6;u32 index:26;})
Definition: api.c:2685
Set/unset interface classification table response.
Definition: vpe.api:1576
static void vl_api_cli_request_t_handler(vl_api_cli_request_t *mp)
Definition: api.c:3320
u32 index
Definition: lookup.c:2053
cop: interface enable/disable junk filtration reply
Definition: vpe.api:3250
#define foreach_vpe_api_msg
Definition: api.c:215
Reply to sw_interface_set_flags.
Definition: vpe.api:141
ip6_to_l2_lookup_t lookup_type
Definition: l2tp.h:62
clib_error_t * ikev2_set_local_key(vlib_main_t *vm, u8 *file)
Definition: ikev2.c:1944
#define ip_addr_v6(_a)
Definition: lisp_types.h:50
ip_adjacency_t * add_adj
Definition: ip4.h:293
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:2053
#define gid_address_ippref(_a)
Definition: lisp_types.h:162
u8 bvi_mac
Definition: vpe.api:2100
ip46_address_t tunnel_dst_addr
Definition: ipsec.h:85
IP Set the next node for a given node response.
Definition: vpe.api:1648
uword * fib_index_by_table_id
Definition: ip6.h:152
ip6_address_t * src_address
Definition: sr.h:67
Get node index using name request.
Definition: vpe.api:1613
Reply for IPsec: Add/delete Security Policy Database entry.
Definition: vpe.api:2688
L2 fib clear table response.
Definition: vpe.api:1769
struct l2fib_entry_key_t::@124::@126 fields
resolve_t
Definition: api.c:356
#define VNET_HW_INTERFACE_BOND_INFO_SLAVE
Definition: interface.h:327
static void vl_api_policer_add_del_t_handler(vl_api_policer_add_del_t *mp)
Definition: api.c:5942
u32 sw_if_index
Definition: lisp_types.h:192
int vnet_vxlan_add_del_tunnel(vnet_vxlan_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
Definition: vxlan.c:196
Delete loopback interface response.
Definition: vpe.api:1049
IPsec: Add/delete SPD from interface.
Definition: vpe.api:2703
static void vl_api_tap_modify_t_handler(vl_api_tap_modify_t *mp, vlib_main_t *vm)
Definition: api.c:1741
int ipsec_set_sa_key(vlib_main_t *vm, ipsec_sa_t *sa_update)
Definition: ipsec.c:443
#define VLIB_EARLY_CONFIG_FUNCTION(x, n,...)
Definition: init.h:137
vl_api_mpls_ethernet_add_del_tunnel_2_t t
Definition: api.c:366
static void vl_api_tap_connect_t_handler(vl_api_tap_connect_t *mp, vlib_main_t *vm)
Definition: api.c:1715
int vnet_lisp_add_del_remote_mapping(gid_address_t *deid, gid_address_t *seid, ip_address_t *rlocs, u8 action, u8 is_add)
Adds/removes/updates static remote mapping.
Definition: control.c:275
Set the ip flow hash config for a fib request.
Definition: vpe.api:835
void * vl_msg_api_alloc(int nbytes)
u16 remote_port_start
Definition: vpe.api:2766
u16 encap_fib_index
Definition: vxlan.h:80
always_inline void * clib_mem_alloc(uword size)
Definition: mem.h:109
Reply for Proxy ARP interface enable / disable request.
Definition: vpe.api:520
enable or disable LISP feature
Definition: vpe.api:2291
Reply for interface events registration.
Definition: vpe.api:2512
Reply for lisp_add_del_remote_mapping.
Definition: vpe.api:2360
void l2fib_clear_table(uint keep_static)
Definition: l2_fib.c:207
Create host-interface.
Definition: vpe.api:3388
vhost-user interface delete response
Definition: vpe.api:1978
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:2217
u8 remote_address_stop[16]
Definition: vpe.api:2760
L2 interface patch add / del response.
Definition: vpe.api:1139
pending_route_t * pending_routes
Definition: api.c:381
static void vl_api_set_ip_flow_hash_t_handler(vl_api_set_ip_flow_hash_t *mp)
Definition: api.c:3201
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:337
static void vl_api_sr_multicast_map_add_del_t_handler(vl_api_sr_multicast_map_add_del_t *mp)
Definition: api.c:3495
Request for local eid table summary status.
Definition: vpe.api:2410
cop: enable/disable junk filtration features on an interface
Definition: vpe.api:3206
u32 bd_add_del_ip_mac(u32 bd_index, u8 *ip_addr, u8 *mac_addr, u8 is_ip6, u8 is_add)
Definition: l2_bd.c:447
IPsec: Add/delete Security Association Database entry.
Definition: vpe.api:2817
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:298
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:134
int vnet_delete_loopback_interface(u32 sw_if_index)
Definition: interface.c:459
VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION(admin_up_down_function)
Definition: ip6.h:62
u8 eid_ip_address[16]
Definition: vpe.api:2226
Set/unset the classification table for an interface request.
Definition: vpe.api:1564
u32 drop_adj_index
Definition: lookup.h:380
static void vl_api_l2_patch_add_del_t_handler(vl_api_l2_patch_add_del_t *mp)
Definition: api.c:4512
Delete host-interface response.
Definition: vpe.api:3422
Definition: ip4.h:47
IPv6 segment routing multicast map to policy add / del response.
Definition: vpe.api:1229
ip46_address_t start
Definition: ipsec.h:96
static_always_inline u8 bd_feature_learn(l2_bridge_domain_t *bd_config)
Definition: l2_input.h:151
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:4009
u32 locator_set_index
Definition: lisp_types.h:221
char * vpe_api_get_build_directory(void)
Definition: version.c:80
IPv6 interface enable / disable response.
Definition: vpe.api:959
#define clib_memcpy(a, b, c)
Definition: string.h:63
Reply for map_summary_stats request.
Definition: vpe.api:3189
always_inline vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
u8 remote_address_start[16]
Definition: vpe.api:2759
int cop_interface_enable_disable(u32 sw_if_index, int enable_disable)
Definition: cop.c:150
ip4_address_t tunnel_src
Definition: gre.h:53
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:328
static void vnet_interface_counter_unlock(vnet_interface_main_t *im)
Definition: interface.h:478
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:2249
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:6197
Reply for IP Neighbor add / delete request.
Definition: vpe.api:553
static void vl_api_vxlan_gpe_add_del_tunnel_t_handler(vl_api_vxlan_gpe_add_del_tunnel_t *mp)
Definition: api.c:4536
#define pool_is_free_index(P, I)
Definition: pool.h:197
u8 tunnel_src_address[16]
Definition: vpe.api:2840
int ipsec_add_del_spd(vlib_main_t *vm, u32 spd_id, int is_add)
Definition: ipsec.c:99
#define ARRAY_LEN(x)
Definition: clib.h:59
u32 decap_next_index
Definition: vxlan.h:77
always_inline vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
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:512
clib_error_t * enable_ip6_interface(vlib_main_t *vm, u32 sw_if_index)
void l2fib_add_entry(u64 mac, u32 bd_index, u32 sw_if_index, u32 static_mac, u32 filter_mac, u32 bvi_mac)
Definition: l2_fib.c:243
static void vl_api_dhcp_proxy_set_vss_t_handler(vl_api_dhcp_proxy_set_vss_t *mp)
Definition: api.c:2974
static clib_error_t * vpe_api_hookup(vlib_main_t *vm)
Definition: api.c:6009
lisp_gpe_main_t lisp_gpe_main
Definition: lisp_gpe.c:18
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:301
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:3903
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:1493
VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION(link_up_down_function)
Delete loopback interface request.
Definition: vpe.api:1039
#define IP4_ROUTE_FLAG_DEL
Definition: ip4.h:265
always_inline vnet_sw_interface_t * vnet_get_sup_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
always_inline lisp_cp_main_t * vnet_lisp_cp_get_main()
Definition: control.h:168
struct l2fib_entry_result_t::@128::@130 fields
port_range_t rport
Definition: ipsec.h:131
static void map_domain_counter_lock(map_main_t *mm)
Definition: map.h:529
Reply for local_eid add/del.
Definition: vpe.api:2205
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:804
vhost-user interface modify request
Definition: vpe.api:1946
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:150
struct _vnet_classify_main vnet_classify_main_t
Definition: vnet_classify.h:50
u8 vnet_lisp_enable_disable_status(void)
Definition: control.c:927
u8 destination_ip_address[16]
Definition: vpe.api:2230
u32 sw_if_index
Definition: vpe.api:2097
#define foreach_flow_hash_bit
Definition: lookup.h:138
ip46_address_range_t raddr
Definition: ipsec.h:128
Set L2 XConnect between two interfaces request.
Definition: vpe.api:1331
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:1507
static void vl_api_want_ip4_arp_events_t_handler(vl_api_want_ip4_arp_events_t *mp)
Definition: api.c:5245
u8 eid_is_ipv6
Definition: vpe.api:2225
static void vnet_interface_counter_lock(vnet_interface_main_t *im)
Definition: interface.h:472
#define hash_create(elts, value_bytes)
Definition: hash.h:615
foreach_registration_hash u8 link_state_process_up
Definition: api.c:378
struct _gid_address_t gid_address_t
DHCP proxy set / unset vss response.
Definition: vpe.api:818
Reset fib response.
Definition: vpe.api:760
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
Definition: interface.h:373
l2 fib table entry structure
Definition: vpe.api:2093
IP neighbor add / del request.
Definition: vpe.api:536
Set L2 XConnect response.
Definition: vpe.api:1343
Reply for tap dump request.
Definition: vpe.api:296
#define pool_put_index(p, i)
Definition: pool.h:214
#define ASSERT(truth)
Trace profile add / del response.
Definition: vpe.api:3328
Reply for vnet_get_summary_stats request.
Definition: vpe.api:678
IPv6 router advertisement config response.
Definition: vpe.api:897
u32 remote_session_id
Definition: l2tp.h:36
unsigned int u32
Definition: types.h:88
static void vl_api_ipsec_spd_add_del_t_handler(vl_api_ipsec_spd_add_del_t *mp)
Definition: api.c:5305
static void vl_api_proxy_arp_intfc_enable_disable_t_handler(vl_api_proxy_arp_intfc_enable_disable_t *mp)
Definition: api.c:2183
ip4_fib_t * fibs
Definition: ip4.h:132
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:87
ip4_address_t dst_address
Definition: ip4.h:284
#define IP4_ROUTE_FLAG_ADD
Definition: ip4.h:264
ip6_main_t ip6_main
Definition: ip6_forward.c:2490
Request for locator_set summary status.
Definition: vpe.api:2387
ip_lookup_main_t lookup_main
Definition: ip6.h:135
static void dhcpv4_proxy_config(vl_api_dhcp_proxy_config_t *mp)
Definition: api.c:2905
u32 spi
Definition: vpe.api:2824
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:62
#define IP6_ROUTE_FLAG_NOT_LAST_IN_GROUP
Definition: ip6.h:333
static void vl_api_lisp_local_eid_table_dump_t_handler(vl_api_lisp_local_eid_table_dump_t *mp)
Definition: api.c:5033
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:3089
static_always_inline l2_bridge_domain_t * l2input_bd_config_from_index(l2input_main_t *l2im, u32 bd_index)
Definition: l2_input.h:78
u8 * format(u8 *s, char *fmt,...)
Definition: format.c:405
Reply for add / del route request.
Definition: vpe.api:376
Definition: l2_fib.h:33
IPv6 router advertisement prefix config request.
Definition: vpe.api:917
static void vl_api_lisp_add_del_locator_t_handler(vl_api_lisp_add_del_locator_t *mp)
Definition: api.c:4614
Reply for IPsec: Add/delete SPD from interface.
Definition: vpe.api:2717
gre_tunnel_t * tunnels
Definition: gre.h:62
Reply for MPLS decap add / del request.
Definition: vpe.api:471
static void vl_api_classify_add_del_table_t_handler(vl_api_classify_add_del_table_t *mp)
Definition: api.c:3545
Reply for tap modify request.
Definition: vpe.api:260
static void vl_api_ipsec_spd_add_del_entry_t_handler(vl_api_ipsec_spd_add_del_entry_t *mp)
Definition: api.c:5351
static void set_ip6_flow_hash(vl_api_set_ip_flow_hash_t *mp)
Definition: api.c:3171
int stats_memclnt_delete_callback(u32 client_index)
Definition: stats.c:883
static void vl_api_sw_interface_vhost_user_dump_t_handler(vl_api_sw_interface_vhost_user_dump_t *mp)
Definition: api.c:3842
Reply for proxy arp add / del request.
Definition: vpe.api:497
static void vl_api_get_node_index_t_handler(vl_api_get_node_index_t *mp)
Definition: api.c:4178
Control ping from the client to the server response.
Definition: vpe.api:1069
locator_set_t * locator_set_pool
Definition: control.h:67
static void vl_api_map_domain_dump_t_handler(vl_api_map_domain_dump_t *mp)
Definition: api.c:5623
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_add_node_next_t_handler(vl_api_add_node_next_t *mp)
Definition: api.c:4200
IKEv2: Set IKEv2 profile authentication method.
Definition: vpe.api:2924
vnet_main_t * vnet_main
Definition: l2tp.h:75
u8 integ_key_len
Definition: ipsec.h:76
Set the next node for a given node request.
Definition: vpe.api:1636
static void vl_api_sw_interface_details_t_handler(vl_api_sw_interface_details_t *mp)
Definition: api.c:2357
ip_address_t slocator
Definition: lisp_gpe.h:216
u32 sw_if_index
Definition: vxlan.h:84
Is Address Reachable request - DISABLED.
Definition: vpe.api:588
show version
Definition: vpe.api:2012
add or delete locator_set
Definition: vpe.api:2138
static void vl_api_modify_vhost_user_if_t_handler(vl_api_modify_vhost_user_if_t *mp)
Definition: api.c:3763
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:233
int vnet_tap_delete(vlib_main_t *vm, u32 sw_if_index)
Definition: tapcli.c:863
vnet_classify_main_t vnet_classify_main
Definition: vnet_classify.c:21
Request for a single block of summary stats.
Definition: vpe.api:3176
static void vl_api_delete_vhost_user_if_t_handler(vl_api_delete_vhost_user_if_t *mp)
Definition: api.c:3782
Set max allowed ARP or ip6 neighbor entries response.
Definition: vpe.api:1115
ipsec_protocol_t protocol
Definition: ipsec.h:69
Reply for MAP domain add.
Definition: vpe.api:3083
#define IP_FLOW_HASH_DEFAULT
Definition: lookup.h:136
void vnet_ip6_fib_init(ip6_main_t *im, u32 fib_index)
Definition: ip6_forward.c:101
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:462
static void vl_api_lisp_locator_set_dump_t_handler(vl_api_lisp_locator_set_dump_t *mp)
Definition: api.c:4952
IPv6 segment routing policy add / del response.
Definition: vpe.api:1205
OAM add / del target request.
Definition: vpe.api:725
static void vl_api_trace_profile_apply_t_handler(vl_api_trace_profile_apply_t *mp)
Definition: api.c:5867
always_inline uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
Definition: node_funcs.h:919
static void send_gre_tunnel_details(gre_tunnel_t *t, unix_shared_memory_queue_t *q, u32 context)
Definition: api.c:4464
#define MODE_L2_XC
Definition: l2_input.h:210
int vnet_classify_add_del_session(vnet_classify_main_t *cm, u32 table_index, u8 *match, u32 hit_next_index, u32 opaque_index, i32 advance, int is_add)
static void vl_api_create_subif_t_handler(vl_api_create_subif_t *mp)
Definition: api.c:1865
#define IP6_ROUTE_FLAG_FIB_INDEX
Definition: ip6.h:330
static void vl_api_sr_tunnel_add_del_t_handler(vl_api_sr_tunnel_add_del_t *mp)
Definition: api.c:3381
always_inline void vlib_zero_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
Definition: counter.h:277
u8 * vlib_node_serialize(vlib_node_main_t *nm, u8 *vector)
always_inline ip_adjacency_t * ip_get_adjacency(ip_lookup_main_t *lm, u32 adj_index)
Definition: lookup.h:423
u64 uword
Definition: types.h:112
Request for lisp-gpe protocol status.
Definition: vpe.api:2475
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:3869
static void vl_api_sw_interface_set_table_t_handler(vl_api_sw_interface_set_table_t *mp)
Definition: api.c:1280
u32 l2input_intf_bitmap_enable(u32 sw_if_index, u32 feature_bitmap, u32 enable)
Definition: l2_input.c:473
void vl_set_memory_region_name(char *name)
Definition: memory_vlib.c:1063
void dslock(stats_main_t *sm, int release_hint, int tag)
Definition: stats.c:61
static u8 * format_arp_event(u8 *s, va_list *args)
Definition: api.c:6187
u8 crypto_key_len
Definition: ipsec.h:72
static void vl_api_classify_set_interface_ip_table_t_handler(vl_api_classify_set_interface_ip_table_t *mp)
Definition: api.c:3611
Add / del route request.
Definition: vpe.api:348
int vnet_lisp_add_del_locator_set(vnet_lisp_add_del_locator_set_args_t *a, u32 *ls_result)
Definition: control.c:705
static int ip4_add_del_route_t_handler(vl_api_ip_add_del_route_t *mp)
Definition: api.c:823
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
Definition: node.c:44
Interface bridge mode request.
Definition: vpe.api:1357
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:46
static void vl_api_oam_add_del_t_handler(vl_api_oam_add_del_t *mp)
Definition: api.c:2622
ip6_route_t ** routep
Definition: lookup.c:2058
u8 static_mac
Definition: vpe.api:2098
unsigned short u16
Definition: types.h:57
l2input_main_t l2input_main
Definition: l2_input.c:72
int vnet_gre_add_del_tunnel(vnet_gre_add_del_tunnel_args_t *a, u32 *sw_if_indexp)
Definition: interface.c:38
clib_error_t * ip6_ioam_trace_profile_set(u32 trace_option_elts, u32 trace_type, u32 node_id, u32 app_data, int has_pow_option, u32 trace_tsp, int has_ppc_option)
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:1077
static void vl_api_bridge_domain_sw_if_details_t_handler(vl_api_bridge_domain_sw_if_details_t *mp)
Definition: api.c:1501
int vnet_proxy_arp_fib_reset(u32 fib_id)
Definition: arp.c:1535
IKEv2: Set IKEv2 local RSA private key.
Definition: vpe.api:3014
static int ip6_reset_fib_t_handler(vl_api_reset_fib_t *mp)
Definition: api.c:2815
u32 bd_find_or_add_bd_index(bd_main_t *bdm, u32 bd_id)
Get or create a bridge domain.
Definition: l2_bd.c:52
static void vl_api_ikev2_profile_set_ts_t_handler(vl_api_ikev2_profile_set_ts_t *mp)
Definition: api.c:5535
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
double f64
Definition: types.h:140
vnet_interface_main_t * interface_main
Definition: stats.h:61
unsigned char u8
Definition: types.h:56
static void dhcpv6_proxy_config_2(vl_api_dhcp_proxy_config_2_t *mp)
Definition: api.c:2953
#define hash_foreach_pair(p, v, body)
Definition: hash.h:311
u8 is_outbound
Definition: ipsec.h:123
vlib_node_main_t node_main
Definition: main.h:115
u32 flags
Definition: vxlan.h:92
Reply for gpe_fwd_entry add/del.
Definition: vpe.api:2237
#define BAD_TX_SW_IF_INDEX_LABEL
Definition: api.c:198
u8 integrity_algorithm
Definition: vpe.api:2832
always_inline vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
static int event_data_cmp(void *a1, void *a2)
Definition: api.c:430
#define L2_ARP_TERM
Definition: l2_bd.h:99
Process a vpe parser cli string request.
Definition: vpe.api:1081
u8 integrity_key[128]
Definition: vpe.api:2834
u8 is_tunnel_ipv6
Definition: vpe.api:2839
#define RESOLUTION_PENDING_EVENT
add or delete locator for locator_set
Definition: vpe.api:2163
static void vl_api_ip_address_dump_t_handler(vl_api_ip_address_dump_t *mp)
Definition: api.c:3929
IOAM Trace enable trace profile for a flow.
Definition: vpe.api:3341
#define VXLAN_TUNNEL_IS_IPV4
Definition: vxlan.h:96
struct vnet_sub_interface_t::@91::@92::@94 flags
L2 interface ethernet flow point filtering enable/disable request.
Definition: vpe.api:1780
static void vl_api_bd_ip_mac_add_del_t_handler(vl_api_bd_ip_mac_add_del_t *mp)
Definition: api.c:1689
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:898
#define IP4_ROUTE_FLAG_FIB_INDEX
Definition: ip4.h:267
int vnet_l2_patch_add_del(u32 rx_sw_if_index, u32 tx_sw_if_index, int is_add)
Definition: l2_patch.c:255
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:449
struct ip_adjacency_t::@112::@115 classify
int vl_msg_api_version_check(vl_api_memclnt_create_t *mp)
Definition: api.c:6176
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:618
static void vl_api_mpls_add_del_encap_t_handler(vl_api_mpls_add_del_encap_t *mp)
Definition: api.c:2111
mapping_t * mapping_pool
Definition: control.h:61
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:1209
Create loopback interface request.
Definition: vpe.api:1017
static void vl_api_l2_interface_vlan_tag_rewrite_t_handler(vl_api_l2_interface_vlan_tag_rewrite_t *mp)
Definition: api.c:3700
Reply for interface events registration.
Definition: vpe.api:179
u32 address_length
Definition: lookup.c:2051
Set unnumbered interface add / del request.
Definition: vpe.api:995
uword * locator_set_index_by_name
Definition: control.h:73
show version response
Definition: vpe.api:2024
add or delete remote static mapping
Definition: vpe.api:2340
l2t_session_t * sessions
Definition: l2tp.h:55
static void vl_api_lisp_map_resolver_dump_t_handler(vl_api_lisp_local_eid_table_dump_t *mp)
Definition: api.c:5137
L2 interface vlan tag rewrite configure request.
Definition: vpe.api:1893
u32 table_index_or_table_id
Definition: ip4.h:281
get_node_graph - get a copy of the vpp node graph including the current set of graph arcs...
Definition: vpe.api:3262
l2_bridge_domain_t * bd_configs
Definition: l2_input.h:66
ip6_address_t * dst_address
Definition: sr.h:68
#define REPLY_MACRO2(t, body)
Definition: api.c:138
Add / del MPLS decapsulation request.
Definition: vpe.api:456
Create a new subinterface with the given vlan id.
Definition: vpe.api:308
Definition: lisp_types.h:24
gid_address_t eid
Definition: lisp_types.h:218
u32 custom_dev_instance
Definition: vpe.api:222
Add MAP domains.
Definition: vpe.api:3062
gid_address_t address
Definition: lisp_types.h:193
Create loopback interface response.
Definition: vpe.api:1028
u32 * tunnel_index_by_sw_if_index
Definition: vxlan.h:137
static clib_error_t * link_up_down_function(vnet_main_t *vm, u32 hw_if_index, u32 flags)
Definition: api.c:509
L2 interface patch add / del request.
Definition: vpe.api:1127
#define hash_get_mem(h, key)
Definition: hash.h:251
void l2fib_table_dump(u32 bd_index, l2fib_entry_key_t **l2fe_key, l2fib_entry_result_t **l2fe_res)
Definition: l2_fib.c:59
u32 client_index
Definition: vpe.api:2080
static void vl_api_map_summary_stats_t_handler(vl_api_map_summary_stats_t *mp)
Definition: api.c:5701
static void vl_api_mpls_gre_add_del_tunnel_t_handler(vl_api_mpls_gre_add_del_tunnel_t *mp)
Definition: api.c:1944
static void vl_api_l2_fib_clear_table_t_handler(vl_api_l2_fib_clear_table_t *mp)
Definition: api.c:3667
#define IP4_ROUTE_FLAG_NOT_LAST_IN_GROUP
Definition: ip4.h:271
static void vl_api_show_version_t_handler(vl_api_show_version_t *mp)
Definition: api.c:4151
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)
Definition: l2_vtr.c:230
Interface set vpath request.
Definition: vpe.api:1240
always_inline void vlib_zero_simple_counter(vlib_simple_counter_main_t *cm, u32 index)
Definition: counter.h:122
Modify a tap interface with the given paramters.
Definition: vpe.api:244
Add/del policer.
Definition: vpe.api:3440
char * vpe_api_get_build_date(void)
Definition: version.c:89
static void vl_api_reset_fib_t_handler(vl_api_reset_fib_t *mp)
Definition: api.c:2890
u8 * is_mp_safe
Definition: api.h:114
ipsec_crypto_alg_t crypto_alg
Definition: ipsec.h:71
void vlib_clear_simple_counters(vlib_simple_counter_main_t *cm)
Definition: counter.c:42
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:140
void vl_noop_handler(void *mp)
Definition: api_shared.c:636
int vnet_lisp_add_del_map_resolver(vnet_lisp_add_del_map_resolver_args_t *a)
Definition: control.c:1057
ip4_main_t ip4_main
Definition: ip4_forward.c:1394
#define IP4_ROUTE_FLAG_TABLE_ID
Definition: ip4.h:266
static void vl_api_classify_add_del_session_t_handler(vl_api_classify_add_del_session_t *mp)
Definition: api.c:3590
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)
Definition: tapcli.c:826
#define gid_address_set_vni(_a, _val)
Definition: lisp_types.h:169
Register for ip4 arp resolution events.
Definition: vpe.api:2500
#define IP6_ROUTE_FLAG_ADD
Definition: ip6.h:327
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 index)
Definition: api.c:4913
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:714
#define vec_foreach(var, vec)
Vector iterator.
static void vl_api_gre_tunnel_dump_t_handler(vl_api_gre_tunnel_dump_t *mp)
Definition: api.c:4482
clib_error_t * clear_ioam_rewrite_fn(void)
static void vl_api_tap_delete_t_handler(vl_api_tap_delete_t *mp, vlib_main_t *vm)
Definition: api.c:1767
Set bridge flags (such as L2_LEARN, L2_FWD, L2_FLOOD, L2_UU_FLOOD, or L2_ARP_TERM) request...
Definition: vpe.api:1439
Reply for map_resolver add/del.
Definition: vpe.api:2261
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:2271
i16 explicit_fib_index
Definition: lookup.h:168
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:3116
u8 is_outbound
Definition: vpe.api:2754
always_inline f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:182
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
Definition: interface.c:462
static void vl_api_create_vlan_subif_t_handler(vl_api_create_vlan_subif_t *mp)
Definition: api.c:1793
u32 sw_if_index
Definition: l2_bd.h:44
u8 is_ipv6
Definition: vpe.api:2757
u8 filter_mac
Definition: vpe.api:2099
u32 table_id
Definition: ip6.h:64
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:1155
#define VALIDATE_RX_SW_IF_INDEX(mp)
Definition: api.c:172
#define pub_sub_handler(lca, UCA)
Definition: api.c:540
#define BAD_SW_IF_INDEX_LABEL
Definition: api.c:166
uword * adj_index_by_dst_address[33]
Definition: ip4.h:49
static void vl_api_sw_interface_add_del_address_t_handler(vl_api_sw_interface_add_del_address_t *mp)
Definition: api.c:1252
#define foreach_classify_add_del_table_field
Definition: api.c:3535
static void vl_api_ipsec_sa_set_key_t_handler(vl_api_ipsec_sa_set_key_t *mp)
Definition: api.c:5752
vhost_vring_addr_t addr
Definition: vhost-user.h:78
#define clib_error_return(e, args...)
Definition: error.h:112
#define IP6_ROUTE_FLAG_TABLE_ID
Definition: ip6.h:329
vhost-user interface delete request
Definition: vpe.api:1968
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:513
Reply for IKEv2: Add/delete profile.
Definition: vpe.api:2909
vhost-user interface modify response
Definition: vpe.api:1960
void ip4_add_del_route(ip4_main_t *im, ip4_add_del_route_args_t *args)
Definition: ip4_forward.c:196
u8 l2_sublayer_present
Definition: l2tp.h:43
static void vl_api_dhcp_proxy_config_2_t_handler(vl_api_dhcp_proxy_config_2_t *mp)
Definition: api.c:3003
Interface details structure (fix this)
Definition: vpe.api:69
static void vl_api_sr_policy_add_del_t_handler(vl_api_sr_policy_add_del_t *mp)
Definition: api.c:3441
u8 resolve_type
Definition: api.c:363
static void vl_api_ikev2_profile_set_id_t_handler(vl_api_ikev2_profile_set_id_t *mp)
Definition: api.c:5510
VLIB_API_INIT_FUNCTION(vpe_api_hookup)
u32 flags
Definition: vhost-user.h:73
Definition: lisp_types.h:25
bd_main_t bd_main
Definition: l2_bd.c:35
MPLS Ethernet add / del tunnel request.
Definition: vpe.api:1266
clib_error_t * disable_ip6_interface(vlib_main_t *vm, u32 sw_if_index)
ethernet_interface_t * interfaces
Definition: ethernet.h:201
l2tpv3 tunnel interface create request
Definition: vpe.api:1697
#define L2_LEARN
Definition: l2_bd.h:95
Associate the specified interface with a fib table.
Definition: vpe.api:191
u8 * format_ipsec_crypto_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:58
vlib_node_registration_t link_state_process_node
(constructor) VLIB_REGISTER_NODE (link_state_process_node)
Definition: api.c:499
Tell client about a DHCP completion event.
Definition: vpe.api:3038
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 clib_error_t * vpe_api_init(vlib_main_t *vm)
Definition: api.c:6070
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:721
Add / del MPLS encapsulation request.
Definition: vpe.api:426
int vnet_tap_dump_ifs(tapcli_interface_details_t **out_tapids)
Definition: tapcli.c:616
int ipsec_set_interface_spd(vlib_main_t *vm, u32 sw_if_index, u32 spd_id, int is_add)
Definition: ipsec.c:28
u32 * fib_index_by_sw_if_index
Definition: ip6.h:148
static void vl_api_bridge_domain_dump_t_handler(vl_api_bridge_domain_dump_t *mp)
Definition: api.c:1550
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:543
DHCP Client config add / del request.
Definition: vpe.api:2620
void vlib_cli_input(vlib_main_t *vm, unformat_input_t *input, vlib_cli_output_function_t *function, uword function_arg)
Definition: cli.c:504
int dhcp_proxy_set_option82_vss(u32 vrf_id, u32 oui, u32 fib_id, int is_del)
Definition: proxy_node.c:960
vxlan_tunnel_t * tunnels
Definition: vxlan.h:120
u32 * locator_indices
Definition: lisp_types.h:212
vnet_config_main_t config_main
Definition: lookup.h:343
static uword link_state_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: api.c:439
uword key
Definition: hash.h:148
static void vl_api_ikev2_profile_set_auth_t_handler(vl_api_ikev2_profile_set_auth_t *mp)
Definition: api.c:5485
#define RESOLUTION_EVENT
void l2_efp_filter_configure(vnet_main_t *vnet_main, u32 sw_if_index, u32 enable)
ip_address_t src
Definition: lisp_gpe.h:65
ip46_address_t src
Definition: vxlan.h:70
clib_error_t * vl_api_init(vlib_main_t *vm)
Definition: api_shared.c:639
Definition: defs.h:45
#define IOAM_HBYH_ADD
static void vl_api_lisp_add_del_locator_set_t_handler(vl_api_lisp_add_del_locator_set_t *mp)
Definition: api.c:4589
DHCP Proxy config add / del request.
Definition: vpe.api:775
pthread_mutex_t mutex
Definition: svm.h:41
#define ip_prefix_addr(_a)
Definition: lisp_types.h:53
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:66
u8 protocol
Definition: vpe.api:2826
Set the ip flow hash config for a fib response.
Definition: vpe.api:852
#define MODE_L3
Definition: l2_input.h:208
int l2tpv3_set_tunnel_cookies(l2t_main_t *lm, u32 sw_if_index, u64 new_local_cookie, u64 new_remote_cookie)
Definition: l2tp.c:490
struct _unix_shared_memory_queue unix_shared_memory_queue_t
u8 is_ip_any
Definition: vpe.api:2758
ip6_address_t address
Definition: lookup.c:2049
always_inline uword vnet_sw_interface_get_flags(vnet_main_t *vnm, u32 sw_if_index)
int af_packet_delete_if(vlib_main_t *vm, u8 *host_if_name)
Definition: af_packet.c:272
always_inline vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)
Reply for MAP domain del.
Definition: vpe.api:3104
static void vl_api_create_vhost_user_if_t_handler(vl_api_create_vhost_user_if_t *mp)
Definition: api.c:3740
L2 bridge domain add or delete request.
Definition: vpe.api:2545
IPv6 segment routing policy add / del request.
Definition: vpe.api:1193