X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvat%2Fapi_format.c;h=fb0f3fdbf1d1ba0a97dd86a51ab07df772d7465f;hb=56bc738dc;hp=1b61af6226ab88abed61aeef88f2992aa19c5f2d;hpb=754f24b35946021bb5e648c2bbf772791afe6e20;p=vpp.git diff --git a/src/vat/api_format.c b/src/vat/api_format.c index 1b61af6226a..fb0f3fdbf1d 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -40,7 +41,6 @@ #include #include #include -#include #include #include #include @@ -53,6 +53,8 @@ #include #include #include +#include +#include #include "vat/json_format.h" #include #include @@ -358,20 +360,6 @@ unformat_ipsec_policy_action (unformat_input_t * input, va_list * args) return 1; } -uword -unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args) -{ - u32 *r = va_arg (*args, u32 *); - - if (0); -#define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f; - foreach_ipsec_crypto_alg -#undef _ - else - return 0; - return 1; -} - u8 * format_ipsec_crypto_alg (u8 * s, va_list * args) { @@ -389,20 +377,6 @@ format_ipsec_crypto_alg (u8 * s, va_list * args) return format (s, "%s", t); } -uword -unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args) -{ - u32 *r = va_arg (*args, u32 *); - - if (0); -#define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f; - foreach_ipsec_integ_alg -#undef _ - else - return 0; - return 1; -} - u8 * format_ipsec_integ_alg (u8 * s, va_list * args) { @@ -420,33 +394,6 @@ format_ipsec_integ_alg (u8 * s, va_list * args) return format (s, "%s", t); } -uword -unformat_ikev2_auth_method (unformat_input_t * input, va_list * args) -{ - u32 *r = va_arg (*args, u32 *); - - if (0); -#define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f; - foreach_ikev2_auth_method -#undef _ - else - return 0; - return 1; -} - -uword -unformat_ikev2_id_type (unformat_input_t * input, va_list * args) -{ - u32 *r = va_arg (*args, u32 *); - - if (0); -#define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f; - foreach_ikev2_id_type -#undef _ - else - return 0; - return 1; -} #else /* VPP_API_TEST_BUILTIN == 1 */ static uword api_unformat_sw_if_index (unformat_input_t * input, va_list * args) @@ -470,6 +417,34 @@ api_unformat_hw_if_index (unformat_input_t * input, va_list * args) #endif /* VPP_API_TEST_BUILTIN */ +uword +unformat_ipsec_api_crypto_alg (unformat_input_t * input, va_list * args) +{ + u32 *r = va_arg (*args, u32 *); + + if (0); +#define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_CRYPTO_ALG_##f; + foreach_ipsec_crypto_alg +#undef _ + else + return 0; + return 1; +} + +uword +unformat_ipsec_api_integ_alg (unformat_input_t * input, va_list * args) +{ + u32 *r = va_arg (*args, u32 *); + + if (0); +#define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_INTEG_ALG_##f; + foreach_ipsec_integ_alg +#undef _ + else + return 0; + return 1; +} + static uword unformat_policer_rate_type (unformat_input_t * input, va_list * args) { @@ -737,6 +712,25 @@ increment_v4_address (ip4_address_t * a) a->as_u32 = ntohl (v); } +static void +increment_vl_v4_address (vl_api_ip4_address_t * a) +{ + u32 v; + + v = *(u32 *) a; + v = ntohl (v); + v++; + v = ntohl (v); + clib_memcpy (a, &v, sizeof (v)); +} + +static void +increment_vl_address (vl_api_address_t * a) +{ + if (ADDRESS_IP4 == a->af) + increment_vl_v4_address (&a->un.ip4); +} + static void increment_v6_address (ip6_address_t * a) { @@ -1441,8 +1435,8 @@ vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp) u32 sw_if_index = ntohl (mp->sw_if_index); errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n", mp->mac_ip ? "mac/ip binding" : "address resolution", - ntohl (mp->pid), format_ip4_address, &mp->address, - format_ethernet_address, mp->new_mac, sw_if_index); + ntohl (mp->pid), format_ip4_address, mp->ip, + format_vl_api_mac_address, &mp->mac, sw_if_index); } static void @@ -1457,8 +1451,8 @@ vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp) u32 sw_if_index = ntohl (mp->sw_if_index); errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n", mp->mac_ip ? "mac/ip binding" : "address resolution", - ntohl (mp->pid), format_ip6_address, mp->address, - format_ethernet_address, mp->new_mac, sw_if_index); + ntohl (mp->pid), format_vl_api_ip6_address, mp->ip, + format_vl_api_mac_address, mp->mac, sw_if_index); } static void @@ -1735,8 +1729,8 @@ static void vl_api_bridge_flags_reply_t_handler_json vam->result_ready = 1; } -static void vl_api_tap_connect_reply_t_handler - (vl_api_tap_connect_reply_t * mp) +static void +vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp) { vat_main_t *vam = &vat_main; i32 retval = ntohl (mp->retval); @@ -1753,8 +1747,8 @@ static void vl_api_tap_connect_reply_t_handler } -static void vl_api_tap_connect_reply_t_handler_json - (vl_api_tap_connect_reply_t * mp) +static void vl_api_tap_create_v2_reply_t_handler_json + (vl_api_tap_create_v2_reply_t * mp) { vat_main_t *vam = &vat_main; vat_json_node_t node; @@ -1772,41 +1766,7 @@ static void vl_api_tap_connect_reply_t_handler_json } static void -vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - i32 retval = ntohl (mp->retval); - if (vam->async_mode) - { - vam->async_errors += (retval < 0); - } - else - { - vam->retval = retval; - vam->sw_if_index = ntohl (mp->sw_if_index); - vam->result_ready = 1; - } -} - -static void vl_api_tap_modify_reply_t_handler_json - (vl_api_tap_modify_reply_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t node; - - vat_json_init_object (&node); - vat_json_object_add_int (&node, "retval", ntohl (mp->retval)); - vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index)); - - vat_json_print (vam->ofp, &node); - vat_json_free (&node); - - vam->retval = ntohl (mp->retval); - vam->result_ready = 1; -} - -static void -vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp) +vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp) { vat_main_t *vam = &vat_main; i32 retval = ntohl (mp->retval); @@ -1821,8 +1781,8 @@ vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp) } } -static void vl_api_tap_delete_reply_t_handler_json - (vl_api_tap_delete_reply_t * mp) +static void vl_api_tap_delete_v2_reply_t_handler_json + (vl_api_tap_delete_v2_reply_t * mp) { vat_main_t *vam = &vat_main; vat_json_node_t node; @@ -1838,7 +1798,8 @@ static void vl_api_tap_delete_reply_t_handler_json } static void -vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp) +vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t * + mp) { vat_main_t *vam = &vat_main; i32 retval = ntohl (mp->retval); @@ -1852,11 +1813,10 @@ vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp) vam->sw_if_index = ntohl (mp->sw_if_index); vam->result_ready = 1; } - } -static void vl_api_tap_create_v2_reply_t_handler_json - (vl_api_tap_create_v2_reply_t * mp) +static void vl_api_virtio_pci_create_reply_t_handler_json + (vl_api_virtio_pci_create_reply_t * mp) { vat_main_t *vam = &vat_main; vat_json_node_t node; @@ -1874,7 +1834,8 @@ static void vl_api_tap_create_v2_reply_t_handler_json } static void -vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp) +vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t * + mp) { vat_main_t *vam = &vat_main; i32 retval = ntohl (mp->retval); @@ -1889,8 +1850,8 @@ vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp) } } -static void vl_api_tap_delete_v2_reply_t_handler_json - (vl_api_tap_delete_v2_reply_t * mp) +static void vl_api_virtio_pci_delete_reply_t_handler_json + (vl_api_virtio_pci_delete_reply_t * mp) { vat_main_t *vam = &vat_main; vat_json_node_t node; @@ -2505,8 +2466,8 @@ static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json vam->result_ready = 1; } -static void vl_api_gre_add_del_tunnel_reply_t_handler - (vl_api_gre_add_del_tunnel_reply_t * mp) +static void vl_api_gre_tunnel_add_del_reply_t_handler + (vl_api_gre_tunnel_add_del_reply_t * mp) { vat_main_t *vam = &vat_main; i32 retval = ntohl (mp->retval); @@ -2522,8 +2483,8 @@ static void vl_api_gre_add_del_tunnel_reply_t_handler } } -static void vl_api_gre_add_del_tunnel_reply_t_handler_json - (vl_api_gre_add_del_tunnel_reply_t * mp) +static void vl_api_gre_tunnel_add_del_reply_t_handler_json + (vl_api_gre_tunnel_add_del_reply_t * mp) { vat_main_t *vam = &vat_main; vat_json_node_t node; @@ -2736,13 +2697,22 @@ vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp) static void vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp) { - errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U " - "router_addr %U host_mac %U", - ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4", - mp->lease.hostname, - format_ip4_address, &mp->lease.host_address, - format_ip4_address, &mp->lease.router_address, - format_ethernet_address, mp->lease.host_mac); + u8 *s, i; + + s = format (s, "DHCP compl event: pid %d %s hostname %s host_addr %U " + "host_mac %U router_addr %U", + ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4", + mp->lease.hostname, + format_ip4_address, mp->lease.host_address, + format_ethernet_address, mp->lease.host_mac, + format_ip4_address, mp->lease.router_address); + + for (i = 0; i < mp->lease.count; i++) + s = + format (s, " domain_server_addr %U", format_ip4_address, + mp->lease.domain_server[i].address); + + errmsg ((char *) s); } static void vl_api_dhcp_compl_event_t_handler_json @@ -5088,8 +5058,8 @@ static void vl_api_policer_classify_details_t_handler_json vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index)); } -static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler - (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp) +static void vl_api_ipsec_gre_tunnel_add_del_reply_t_handler + (vl_api_ipsec_gre_tunnel_add_del_reply_t * mp) { vat_main_t *vam = &vat_main; i32 retval = ntohl (mp->retval); @@ -5106,8 +5076,8 @@ static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler vam->regenerate_interface_table = 1; } -static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json - (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp) +static void vl_api_ipsec_gre_tunnel_add_del_reply_t_handler_json + (vl_api_ipsec_gre_tunnel_add_del_reply_t * mp) { vat_main_t *vam = &vat_main; vat_json_node_t node; @@ -5238,25 +5208,12 @@ _(want_l2_macs_events_reply) \ _(input_acl_set_interface_reply) \ _(ipsec_spd_add_del_reply) \ _(ipsec_interface_add_del_spd_reply) \ -_(ipsec_spd_add_del_entry_reply) \ -_(ipsec_sad_add_del_entry_reply) \ +_(ipsec_spd_entry_add_del_reply) \ +_(ipsec_sad_entry_add_del_reply) \ _(ipsec_sa_set_key_reply) \ _(ipsec_tunnel_if_add_del_reply) \ _(ipsec_tunnel_if_set_key_reply) \ _(ipsec_tunnel_if_set_sa_reply) \ -_(ikev2_profile_add_del_reply) \ -_(ikev2_profile_set_auth_reply) \ -_(ikev2_profile_set_id_reply) \ -_(ikev2_profile_set_ts_reply) \ -_(ikev2_set_local_key_reply) \ -_(ikev2_set_responder_reply) \ -_(ikev2_set_ike_transforms_reply) \ -_(ikev2_set_esp_transforms_reply) \ -_(ikev2_set_sa_lifetime_reply) \ -_(ikev2_initiate_sa_init_reply) \ -_(ikev2_initiate_del_ike_sa_reply) \ -_(ikev2_initiate_del_child_sa_reply) \ -_(ikev2_initiate_rekey_child_sa_reply) \ _(delete_loopback_reply) \ _(bd_ip_mac_add_del_reply) \ _(bd_ip_mac_flush_reply) \ @@ -5392,13 +5349,12 @@ _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \ _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \ _(L2_FLAGS_REPLY, l2_flags_reply) \ _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \ -_(TAP_CONNECT_REPLY, tap_connect_reply) \ -_(TAP_MODIFY_REPLY, tap_modify_reply) \ -_(TAP_DELETE_REPLY, tap_delete_reply) \ -_(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \ _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \ _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \ _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \ +_(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \ +_(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \ +_(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \ _(BOND_CREATE_REPLY, bond_create_reply) \ _(BOND_DELETE_REPLY, bond_delete_reply) \ _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \ @@ -5466,7 +5422,7 @@ _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \ _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \ _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \ _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \ -_(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \ +_(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \ _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \ _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \ _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \ @@ -5494,26 +5450,13 @@ _(IP_ADDRESS_DETAILS, ip_address_details) \ _(IP_DETAILS, ip_details) \ _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \ _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \ -_(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \ -_(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \ +_(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \ +_(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \ _(IPSEC_SA_DETAILS, ipsec_sa_details) \ _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \ _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \ _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \ _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \ -_(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \ -_(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \ -_(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \ -_(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \ -_(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \ -_(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \ -_(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \ -_(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \ -_(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \ -_(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \ -_(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \ -_(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \ -_(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \ _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \ _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \ _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \ @@ -5635,7 +5578,7 @@ _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \ ip_source_and_port_range_check_add_del_reply) \ _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \ ip_source_and_port_range_check_interface_add_del_reply) \ -_(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \ +_(IPSEC_GRE_TUNNEL_ADD_DEL_REPLY, ipsec_gre_tunnel_add_del_reply) \ _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \ _(DELETE_SUBIF_REPLY, delete_subif_reply) \ _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \ @@ -7516,171 +7459,164 @@ api_bd_ip_mac_dump (vat_main_t * vam) } static int -api_tap_connect (vat_main_t * vam) +api_tap_create_v2 (vat_main_t * vam) { unformat_input_t *i = vam->input; - vl_api_tap_connect_t *mp; + vl_api_tap_create_v2_t *mp; u8 mac_address[6]; u8 random_mac = 1; - u8 name_set = 0; - u8 *tap_name; - u8 *tag = 0; - ip4_address_t ip4_address; - u32 ip4_mask_width; - int ip4_address_set = 0; - ip6_address_t ip6_address; - u32 ip6_mask_width; - int ip6_address_set = 0; + u32 id = ~0; + u8 *host_if_name = 0; + u8 *host_ns = 0; + u8 host_mac_addr[6]; + u8 host_mac_addr_set = 0; + u8 *host_bridge = 0; + ip4_address_t host_ip4_addr; + ip4_address_t host_ip4_gw; + u8 host_ip4_gw_set = 0; + u32 host_ip4_prefix_len = 0; + ip6_address_t host_ip6_addr; + ip6_address_t host_ip6_gw; + u8 host_ip6_gw_set = 0; + u32 host_ip6_prefix_len = 0; int ret; + u32 rx_ring_sz = 0, tx_ring_sz = 0; clib_memset (mac_address, 0, sizeof (mac_address)); /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { - if (unformat (i, "mac %U", unformat_ethernet_address, mac_address)) + if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address)) { random_mac = 0; } - else if (unformat (i, "random-mac")) - random_mac = 1; - else if (unformat (i, "tapname %s", &tap_name)) - name_set = 1; - else if (unformat (i, "tag %s", &tag)) + else if (unformat (i, "id %u", &id)) + ; + else if (unformat (i, "host-if-name %s", &host_if_name)) + ; + else if (unformat (i, "host-ns %s", &host_ns)) + ; + else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address, + host_mac_addr)) + host_mac_addr_set = 1; + else if (unformat (i, "host-bridge %s", &host_bridge)) + ; + else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address, + &host_ip4_addr, &host_ip4_prefix_len)) + ; + else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address, + &host_ip6_addr, &host_ip6_prefix_len)) + ; + else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address, + &host_ip4_gw)) + host_ip4_gw_set = 1; + else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address, + &host_ip6_gw)) + host_ip6_gw_set = 1; + else if (unformat (i, "rx-ring-size %d", &rx_ring_sz)) + ; + else if (unformat (i, "tx-ring-size %d", &tx_ring_sz)) ; - else if (unformat (i, "address %U/%d", - unformat_ip4_address, &ip4_address, &ip4_mask_width)) - ip4_address_set = 1; - else if (unformat (i, "address %U/%d", - unformat_ip6_address, &ip6_address, &ip6_mask_width)) - ip6_address_set = 1; else break; } - if (name_set == 0) + if (vec_len (host_if_name) > 63) { - errmsg ("missing tap name"); + errmsg ("tap name too long. "); return -99; } - if (vec_len (tap_name) > 63) + if (vec_len (host_ns) > 63) { - errmsg ("tap name too long"); + errmsg ("host name space too long. "); return -99; } - vec_add1 (tap_name, 0); - - if (vec_len (tag) > 63) + if (vec_len (host_bridge) > 63) { - errmsg ("tag too long"); + errmsg ("host bridge name too long. "); return -99; } - - /* Construct the API message */ - M (TAP_CONNECT, mp); - - mp->use_random_mac = random_mac; - clib_memcpy (mp->mac_address, mac_address, 6); - clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name)); - if (tag) - clib_memcpy (mp->tag, tag, vec_len (tag)); - - if (ip4_address_set) + if (host_ip4_prefix_len > 32) { - mp->ip4_address_set = 1; - clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address)); - mp->ip4_mask_width = ip4_mask_width; + errmsg ("host ip4 prefix length not valid. "); + return -99; } - if (ip6_address_set) + if (host_ip6_prefix_len > 128) { - mp->ip6_address_set = 1; - clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address)); - mp->ip6_mask_width = ip6_mask_width; + errmsg ("host ip6 prefix length not valid. "); + return -99; } - - vec_free (tap_name); - vec_free (tag); - - /* send it... */ - S (mp); - - /* Wait for a reply... */ - W (ret); - return ret; -} - -static int -api_tap_modify (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_tap_modify_t *mp; - u8 mac_address[6]; - u8 random_mac = 1; - u8 name_set = 0; - u8 *tap_name; - u32 sw_if_index = ~0; - u8 sw_if_index_set = 0; - int ret; - - clib_memset (mac_address, 0, sizeof (mac_address)); - - /* Parse args required to build the message */ - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + if (!is_pow2 (rx_ring_sz)) { - if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) - sw_if_index_set = 1; - else if (unformat (i, "sw_if_index %d", &sw_if_index)) - sw_if_index_set = 1; - else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address)) - { - random_mac = 0; - } - else if (unformat (i, "random-mac")) - random_mac = 1; - else if (unformat (i, "tapname %s", &tap_name)) - name_set = 1; - else - break; + errmsg ("rx ring size must be power of 2. "); + return -99; } - - if (sw_if_index_set == 0) + if (rx_ring_sz > 32768) { - errmsg ("missing vpp interface name"); + errmsg ("rx ring size must be 32768 or lower. "); return -99; } - if (name_set == 0) + if (!is_pow2 (tx_ring_sz)) { - errmsg ("missing tap name"); + errmsg ("tx ring size must be power of 2. "); return -99; } - if (vec_len (tap_name) > 63) + if (tx_ring_sz > 32768) { - errmsg ("tap name too long"); + errmsg ("tx ring size must be 32768 or lower. "); + return -99; } - vec_add1 (tap_name, 0); /* Construct the API message */ - M (TAP_MODIFY, mp); + M (TAP_CREATE_V2, mp); mp->use_random_mac = random_mac; - mp->sw_if_index = ntohl (sw_if_index); - clib_memcpy (mp->mac_address, mac_address, 6); - clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name)); - vec_free (tap_name); - - /* send it... */ - S (mp); - /* Wait for a reply... */ - W (ret); + mp->id = ntohl (id); + mp->host_namespace_set = host_ns != 0; + mp->host_bridge_set = host_bridge != 0; + mp->host_ip4_addr_set = host_ip4_prefix_len != 0; + mp->host_ip6_addr_set = host_ip6_prefix_len != 0; + mp->rx_ring_sz = ntohs (rx_ring_sz); + mp->tx_ring_sz = ntohs (tx_ring_sz); + + if (random_mac == 0) + clib_memcpy (mp->mac_address, mac_address, 6); + if (host_mac_addr_set) + clib_memcpy (mp->host_mac_addr, host_mac_addr, 6); + if (host_if_name) + clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name)); + if (host_ns) + clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns)); + if (host_bridge) + clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge)); + if (host_ip4_prefix_len) + clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4); + if (host_ip6_prefix_len) + clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16); + if (host_ip4_gw_set) + clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4); + if (host_ip6_gw_set) + clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16); + + vec_free (host_ns); + vec_free (host_if_name); + vec_free (host_bridge); + + /* send it... */ + S (mp); + + /* Wait for a reply... */ + W (ret); return ret; } static int -api_tap_delete (vat_main_t * vam) +api_tap_delete_v2 (vat_main_t * vam) { unformat_input_t *i = vam->input; - vl_api_tap_delete_t *mp; + vl_api_tap_delete_v2_t *mp; u32 sw_if_index = ~0; u8 sw_if_index_set = 0; int ret; @@ -7698,12 +7634,12 @@ api_tap_delete (vat_main_t * vam) if (sw_if_index_set == 0) { - errmsg ("missing vpp interface name"); + errmsg ("missing vpp interface name. "); return -99; } /* Construct the API message */ - M (TAP_DELETE, mp); + M (TAP_DELETE_V2, mp); mp->sw_if_index = ntohl (sw_if_index); @@ -7715,29 +7651,41 @@ api_tap_delete (vat_main_t * vam) return ret; } +uword +unformat_pci_addr (unformat_input_t * input, va_list * args) +{ + struct pci_addr_t + { + u16 domain; + u8 bus; + u8 slot:5; + u8 function:3; + } *addr; + addr = va_arg (*args, struct pci_addr_t *); + u32 x[4]; + + if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3])) + return 0; + + addr->domain = x[0]; + addr->bus = x[1]; + addr->slot = x[2]; + addr->function = x[3]; + + return 1; +} + static int -api_tap_create_v2 (vat_main_t * vam) +api_virtio_pci_create (vat_main_t * vam) { unformat_input_t *i = vam->input; - vl_api_tap_create_v2_t *mp; + vl_api_virtio_pci_create_t *mp; u8 mac_address[6]; u8 random_mac = 1; - u32 id = ~0; - u8 *host_if_name = 0; - u8 *host_ns = 0; - u8 host_mac_addr[6]; - u8 host_mac_addr_set = 0; - u8 *host_bridge = 0; - ip4_address_t host_ip4_addr; - ip4_address_t host_ip4_gw; - u8 host_ip4_gw_set = 0; - u32 host_ip4_prefix_len = 0; - ip6_address_t host_ip6_addr; - ip6_address_t host_ip6_gw; - u8 host_ip6_gw_set = 0; - u32 host_ip6_prefix_len = 0; - int ret; + u32 pci_addr = 0; + u64 features = (u64) ~ (0ULL); u32 rx_ring_sz = 0, tx_ring_sz = 0; + int ret; clib_memset (mac_address, 0, sizeof (mac_address)); @@ -7748,60 +7696,21 @@ api_tap_create_v2 (vat_main_t * vam) { random_mac = 0; } - else if (unformat (i, "id %u", &id)) - ; - else if (unformat (i, "host-if-name %s", &host_if_name)) - ; - else if (unformat (i, "host-ns %s", &host_ns)) - ; - else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address, - host_mac_addr)) - host_mac_addr_set = 1; - else if (unformat (i, "host-bridge %s", &host_bridge)) - ; - else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address, - &host_ip4_addr, &host_ip4_prefix_len)) + else if (unformat (i, "pci-addr %U", unformat_pci_addr, &pci_addr)) ; - else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address, - &host_ip6_addr, &host_ip6_prefix_len)) + else if (unformat (i, "features 0x%llx", &features)) ; - else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address, - &host_ip4_gw)) - host_ip4_gw_set = 1; - else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address, - &host_ip6_gw)) - host_ip6_gw_set = 1; - else if (unformat (i, "rx-ring-size %d", &rx_ring_sz)) + else if (unformat (i, "rx-ring-size %u", &rx_ring_sz)) ; - else if (unformat (i, "tx-ring-size %d", &tx_ring_sz)) + else if (unformat (i, "tx-ring-size %u", &tx_ring_sz)) ; else break; } - if (vec_len (host_if_name) > 63) - { - errmsg ("tap name too long. "); - return -99; - } - if (vec_len (host_ns) > 63) + if (pci_addr == 0) { - errmsg ("host name space too long. "); - return -99; - } - if (vec_len (host_bridge) > 63) - { - errmsg ("host bridge name too long. "); - return -99; - } - if (host_ip4_prefix_len > 32) - { - errmsg ("host ip4 prefix length not valid. "); - return -99; - } - if (host_ip6_prefix_len > 128) - { - errmsg ("host ip6 prefix length not valid. "); + errmsg ("pci address must be non zero. "); return -99; } if (!is_pow2 (rx_ring_sz)) @@ -7826,40 +7735,15 @@ api_tap_create_v2 (vat_main_t * vam) } /* Construct the API message */ - M (TAP_CREATE_V2, mp); + M (VIRTIO_PCI_CREATE, mp); mp->use_random_mac = random_mac; - mp->id = ntohl (id); - mp->host_namespace_set = host_ns != 0; - mp->host_bridge_set = host_bridge != 0; - mp->host_ip4_addr_set = host_ip4_prefix_len != 0; - mp->host_ip6_addr_set = host_ip6_prefix_len != 0; - mp->rx_ring_sz = ntohs (rx_ring_sz); - mp->tx_ring_sz = ntohs (tx_ring_sz); + mp->pci_addr = htonl (pci_addr); + mp->features = clib_host_to_net_u64 (features); if (random_mac == 0) clib_memcpy (mp->mac_address, mac_address, 6); - if (host_mac_addr_set) - clib_memcpy (mp->host_mac_addr, host_mac_addr, 6); - if (host_if_name) - clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name)); - if (host_ns) - clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns)); - if (host_bridge) - clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge)); - if (host_ip4_prefix_len) - clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4); - if (host_ip6_prefix_len) - clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16); - if (host_ip4_gw_set) - clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4); - if (host_ip6_gw_set) - clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16); - - vec_free (host_ns); - vec_free (host_if_name); - vec_free (host_bridge); /* send it... */ S (mp); @@ -7870,10 +7754,10 @@ api_tap_create_v2 (vat_main_t * vam) } static int -api_tap_delete_v2 (vat_main_t * vam) +api_virtio_pci_delete (vat_main_t * vam) { unformat_input_t *i = vam->input; - vl_api_tap_delete_v2_t *mp; + vl_api_virtio_pci_delete_t *mp; u32 sw_if_index = ~0; u8 sw_if_index_set = 0; int ret; @@ -7896,9 +7780,9 @@ api_tap_delete_v2 (vat_main_t * vam) } /* Construct the API message */ - M (TAP_DELETE_V2, mp); + M (VIRTIO_PCI_DELETE, mp); - mp->sw_if_index = ntohl (sw_if_index); + mp->sw_if_index = htonl (sw_if_index); /* send it... */ S (mp); @@ -7919,6 +7803,7 @@ api_bond_create (vat_main_t * vam) u8 mode; u8 lb; u8 mode_is_set = 0; + u32 id = ~0; clib_memset (mac_address, 0, sizeof (mac_address)); lb = BOND_LB_L2; @@ -7934,6 +7819,8 @@ api_bond_create (vat_main_t * vam) else if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address)) custom_mac = 1; + else if (unformat (i, "id %u", &id)) + ; else break; } @@ -7951,6 +7838,7 @@ api_bond_create (vat_main_t * vam) mp->mode = mode; mp->lb = lb; + mp->id = htonl (id); if (custom_mac) clib_memcpy (mp->mac_address, mac_address, 6); @@ -9204,7 +9092,7 @@ api_proxy_arp_add_del (vat_main_t * vam) vl_api_proxy_arp_add_del_t *mp; u32 vrf_id = 0; u8 is_add = 1; - ip4_address_t lo, hi; + vl_api_ip4_address_t lo, hi; u8 range_set = 0; int ret; @@ -9212,8 +9100,8 @@ api_proxy_arp_add_del (vat_main_t * vam) { if (unformat (i, "vrf %d", &vrf_id)) ; - else if (unformat (i, "%U - %U", unformat_ip4_address, &lo, - unformat_ip4_address, &hi)) + else if (unformat (i, "%U - %U", unformat_vl_api_ip4_address, &lo, + unformat_vl_api_ip4_address, &hi)) range_set = 1; else if (unformat (i, "del")) is_add = 0; @@ -9232,10 +9120,10 @@ api_proxy_arp_add_del (vat_main_t * vam) M (PROXY_ARP_ADD_DEL, mp); - mp->proxy.vrf_id = ntohl (vrf_id); + mp->proxy.table_id = ntohl (vrf_id); mp->is_add = is_add; - clib_memcpy (mp->proxy.low_address, &lo, sizeof (mp->proxy.low_address)); - clib_memcpy (mp->proxy.hi_address, &hi, sizeof (mp->proxy.hi_address)); + clib_memcpy (mp->proxy.low, &lo, sizeof (lo)); + clib_memcpy (mp->proxy.hi, &hi, sizeof (hi)); S (mp); W (ret); @@ -9443,27 +9331,25 @@ api_sw_interface_set_unnumbered (vat_main_t * vam) static int api_ip_neighbor_add_del (vat_main_t * vam) { + vl_api_mac_address_t mac_address; unformat_input_t *i = vam->input; vl_api_ip_neighbor_add_del_t *mp; + vl_api_address_t ip_address; u32 sw_if_index; u8 sw_if_index_set = 0; u8 is_add = 1; - u8 is_static = 0; - u8 is_no_fib_entry = 0; - u8 mac_address[6]; u8 mac_set = 0; - u8 v4_address_set = 0; - u8 v6_address_set = 0; - ip4_address_t v4address; - ip6_address_t v6address; + u8 address_set = 0; int ret; + ip_neighbor_flags_t flags; - clib_memset (mac_address, 0, sizeof (mac_address)); - + flags = IP_NEIGHBOR_FLAG_NONE; + clib_memset (&ip_address, 0, sizeof (ip_address)); + clib_memset (&mac_address, 0, sizeof (mac_address)); /* Parse args required to build the message */ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { - if (unformat (i, "mac %U", unformat_ethernet_address, mac_address)) + if (unformat (i, "mac %U", unformat_vl_api_mac_address, &mac_address)) { mac_set = 1; } @@ -9474,14 +9360,12 @@ api_ip_neighbor_add_del (vat_main_t * vam) sw_if_index_set = 1; else if (unformat (i, "sw_if_index %d", &sw_if_index)) sw_if_index_set = 1; - else if (unformat (i, "is_static")) - is_static = 1; + else if (unformat (i, "static")) + flags |= IP_NEIGHBOR_FLAG_STATIC; else if (unformat (i, "no-fib-entry")) - is_no_fib_entry = 1; - else if (unformat (i, "dst %U", unformat_ip4_address, &v4address)) - v4_address_set = 1; - else if (unformat (i, "dst %U", unformat_ip6_address, &v6address)) - v6_address_set = 1; + flags |= IP_NEIGHBOR_FLAG_NO_FIB_ENTRY; + else if (unformat (i, "dst %U", unformat_vl_api_address, &ip_address)) + address_set = 1; else { clib_warning ("parse error '%U'", format_unformat_error, i); @@ -9494,12 +9378,7 @@ api_ip_neighbor_add_del (vat_main_t * vam) errmsg ("missing interface name or sw_if_index"); return -99; } - if (v4_address_set && v6_address_set) - { - errmsg ("both v4 and v6 addresses set"); - return -99; - } - if (!v4_address_set && !v6_address_set) + if (!address_set) { errmsg ("no address set"); return -99; @@ -9508,22 +9387,14 @@ api_ip_neighbor_add_del (vat_main_t * vam) /* Construct the API message */ M (IP_NEIGHBOR_ADD_DEL, mp); - mp->sw_if_index = ntohl (sw_if_index); + mp->neighbor.sw_if_index = ntohl (sw_if_index); mp->is_add = is_add; - mp->is_static = is_static; - mp->is_no_adj_fib = is_no_fib_entry; + mp->neighbor.flags = htonl (flags); if (mac_set) - clib_memcpy (mp->mac_address, mac_address, 6); - if (v6_address_set) - { - mp->is_ipv6 = 1; - clib_memcpy (mp->dst_address, &v6address, sizeof (v6address)); - } - else - { - /* mp->is_ipv6 = 0; via clib_memset in M macro above */ - clib_memcpy (mp->dst_address, &v4address, sizeof (v4address)); - } + clib_memcpy (&mp->neighbor.mac_address, &mac_address, + sizeof (mac_address)); + if (address_set) + clib_memcpy (&mp->neighbor.ip_address, &ip_address, sizeof (ip_address)); /* send it... */ S (mp); @@ -10222,7 +10093,7 @@ api_ip6nd_proxy_add_del (vat_main_t * vam) vl_api_ip6nd_proxy_add_del_t *mp; u32 sw_if_index = ~0; u8 v6_address_set = 0; - ip6_address_t v6address; + vl_api_ip6_address_t v6address; u8 is_del = 0; int ret; @@ -10233,7 +10104,7 @@ api_ip6nd_proxy_add_del (vat_main_t * vam) ; else if (unformat (i, "sw_if_index %d", &sw_if_index)) ; - else if (unformat (i, "%U", unformat_ip6_address, &v6address)) + else if (unformat (i, "%U", unformat_vl_api_ip6_address, &v6address)) v6_address_set = 1; if (unformat (i, "del")) is_del = 1; @@ -10260,7 +10131,7 @@ api_ip6nd_proxy_add_del (vat_main_t * vam) mp->is_del = is_del; mp->sw_if_index = ntohl (sw_if_index); - clib_memcpy (mp->address, &v6address, sizeof (v6address)); + clib_memcpy (mp->ip, v6address, sizeof (v6address)); /* send it... */ S (mp); @@ -10295,7 +10166,7 @@ static void vl_api_ip6nd_proxy_details_t_handler vat_main_t *vam = &vat_main; print (vam->ofp, "host %U sw_if_index %d", - format_ip6_address, mp->address, ntohl (mp->sw_if_index)); + format_vl_api_ip6_address, mp->ip, ntohl (mp->sw_if_index)); } static void vl_api_ip6nd_proxy_details_t_handler_json @@ -10315,7 +10186,7 @@ static void vl_api_ip6nd_proxy_details_t_handler_json vat_json_init_object (node); vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index)); - clib_memcpy (&ip6, mp->address, sizeof (ip6)); + clib_memcpy (&ip6, mp->ip, sizeof (ip6)); vat_json_object_add_ip6 (node, "host", ip6); } @@ -10328,7 +10199,7 @@ api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam) u8 sw_if_index_set = 0; u32 address_length = 0; u8 v6_address_set = 0; - ip6_address_t v6address; + vl_api_prefix_t pfx; u8 use_default = 0; u8 no_advertise = 0; u8 off_link = 0; @@ -10346,8 +10217,7 @@ api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam) sw_if_index_set = 1; else if (unformat (i, "sw_if_index %d", &sw_if_index)) sw_if_index_set = 1; - else if (unformat (i, "%U/%d", - unformat_ip6_address, &v6address, &address_length)) + else if (unformat (i, "%U", unformat_vl_api_prefix, &pfx)) v6_address_set = 1; else if (unformat (i, "val_life %d", &val_lifetime)) ; @@ -10387,8 +10257,7 @@ api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam) M (SW_INTERFACE_IP6ND_RA_PREFIX, mp); mp->sw_if_index = ntohl (sw_if_index); - clib_memcpy (mp->address, &v6address, sizeof (v6address)); - mp->address_length = address_length; + clib_memcpy (&mp->prefix, &pfx, sizeof (pfx)); mp->use_default = use_default; mp->no_advertise = no_advertise; mp->off_link = off_link; @@ -12655,53 +12524,6 @@ api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam) } -static void vl_api_sw_interface_tap_details_t_handler - (vl_api_sw_interface_tap_details_t * mp) -{ - vat_main_t *vam = &vat_main; - - print (vam->ofp, "%-16s %d", - mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index)); -} - -static void vl_api_sw_interface_tap_details_t_handler_json - (vl_api_sw_interface_tap_details_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t *node = NULL; - - if (VAT_JSON_ARRAY != vam->json_tree.type) - { - ASSERT (VAT_JSON_NONE == vam->json_tree.type); - vat_json_init_array (&vam->json_tree); - } - node = vat_json_array_add (&vam->json_tree); - - vat_json_init_object (node); - vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index)); - vat_json_object_add_string_copy (node, "dev_name", mp->dev_name); -} - -static int -api_sw_interface_tap_dump (vat_main_t * vam) -{ - vl_api_sw_interface_tap_dump_t *mp; - vl_api_control_ping_t *mp_ping; - int ret; - - print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index"); - /* Get list of tap interfaces */ - M (SW_INTERFACE_TAP_DUMP, mp); - S (mp); - - /* Use a control ping for synchronization */ - MPING (CONTROL_PING, mp_ping); - S (mp_ping); - - W (ret); - return ret; -} - static void vl_api_sw_interface_tap_v2_details_t_handler (vl_api_sw_interface_tap_v2_details_t * mp) { @@ -12785,13 +12607,92 @@ api_sw_interface_tap_v2_dump (vat_main_t * vam) return ret; } +static void vl_api_sw_interface_virtio_pci_details_t_handler + (vl_api_sw_interface_virtio_pci_details_t * mp) +{ + vat_main_t *vam = &vat_main; + + typedef union + { + struct + { + u16 domain; + u8 bus; + u8 slot:5; + u8 function:3; + }; + u32 as_u32; + } pci_addr_t; + pci_addr_t addr; + addr.as_u32 = ntohl (mp->pci_addr); + u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus, + addr.slot, addr.function); + + print (vam->ofp, + "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx", + pci_addr, ntohl (mp->sw_if_index), + ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz), + format_ethernet_address, mp->mac_addr, + clib_net_to_host_u64 (mp->features)); + vec_free (pci_addr); +} + +static void vl_api_sw_interface_virtio_pci_details_t_handler_json + (vl_api_sw_interface_virtio_pci_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + + if (VAT_JSON_ARRAY != vam->json_tree.type) + { + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); + } + node = vat_json_array_add (&vam->json_tree); + + vat_json_init_object (node); + vat_json_object_add_uint (node, "pci-addr", ntohl (mp->pci_addr)); + vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index)); + vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz)); + vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz)); + vat_json_object_add_uint (node, "features", + clib_net_to_host_u64 (mp->features)); + vat_json_object_add_string_copy (node, "mac_addr", + format (0, "%U", format_ethernet_address, + &mp->mac_addr)); +} + static int -api_vxlan_offload_rx (vat_main_t * vam) +api_sw_interface_virtio_pci_dump (vat_main_t * vam) { - unformat_input_t *line_input = vam->input; - vl_api_vxlan_offload_rx_t *mp; - u32 hw_if_index = ~0, rx_if_index = ~0; - u8 is_add = 1; + vl_api_sw_interface_virtio_pci_dump_t *mp; + vl_api_control_ping_t *mp_ping; + int ret; + + print (vam->ofp, + "\n%-12s %-12s %-12s %-12s %-17s %-08s", + "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz", + "mac_addr", "features"); + + /* Get list of tap interfaces */ + M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp); + S (mp); + + /* Use a control ping for synchronization */ + MPING (CONTROL_PING, mp_ping); + S (mp_ping); + + W (ret); + return ret; +} + +static int +api_vxlan_offload_rx (vat_main_t * vam) +{ + unformat_input_t *line_input = vam->input; + vl_api_vxlan_offload_rx_t *mp; + u32 hw_if_index = ~0, rx_if_index = ~0; + u8 is_add = 1; int ret; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) @@ -13398,16 +13299,17 @@ api_geneve_tunnel_dump (vat_main_t * vam) } static int -api_gre_add_del_tunnel (vat_main_t * vam) +api_gre_tunnel_add_del (vat_main_t * vam) { unformat_input_t *line_input = vam->input; - vl_api_gre_add_del_tunnel_t *mp; - ip4_address_t src4, dst4; - ip6_address_t src6, dst6; + vl_api_address_t src = { }, dst = + { + }; + vl_api_gre_tunnel_add_del_t *mp; + vl_api_gre_tunnel_type_t t_type; u8 is_add = 1; u8 ipv4_set = 0; u8 ipv6_set = 0; - u8 t_type = GRE_TUNNEL_TYPE_L3; u8 src_set = 0; u8 dst_set = 0; u32 outer_fib_id = 0; @@ -13415,10 +13317,7 @@ api_gre_add_del_tunnel (vat_main_t * vam) u32 instance = ~0; int ret; - clib_memset (&src4, 0, sizeof src4); - clib_memset (&dst4, 0, sizeof dst4); - clib_memset (&src6, 0, sizeof src6); - clib_memset (&dst6, 0, sizeof dst6); + t_type = GRE_API_TUNNEL_TYPE_L3; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { @@ -13426,32 +13325,20 @@ api_gre_add_del_tunnel (vat_main_t * vam) is_add = 0; else if (unformat (line_input, "instance %d", &instance)) ; - else if (unformat (line_input, "src %U", unformat_ip4_address, &src4)) - { - src_set = 1; - ipv4_set = 1; - } - else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4)) - { - dst_set = 1; - ipv4_set = 1; - } - else if (unformat (line_input, "src %U", unformat_ip6_address, &src6)) + else if (unformat (line_input, "src %U", unformat_vl_api_address, &src)) { src_set = 1; - ipv6_set = 1; } - else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6)) + else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst)) { dst_set = 1; - ipv6_set = 1; } else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id)) ; else if (unformat (line_input, "teb")) - t_type = GRE_TUNNEL_TYPE_TEB; + t_type = GRE_API_TUNNEL_TYPE_TEB; else if (unformat (line_input, "erspan %d", &session_id)) - t_type = GRE_TUNNEL_TYPE_ERSPAN; + t_type = GRE_API_TUNNEL_TYPE_ERSPAN; else { errmsg ("parse error '%U'", format_unformat_error, line_input); @@ -13469,31 +13356,17 @@ api_gre_add_del_tunnel (vat_main_t * vam) errmsg ("tunnel dst address not specified"); return -99; } - if (ipv4_set && ipv6_set) - { - errmsg ("both IPv4 and IPv6 addresses specified"); - return -99; - } + M (GRE_TUNNEL_ADD_DEL, mp); - M (GRE_ADD_DEL_TUNNEL, mp); + clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src)); + clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst)); - if (ipv4_set) - { - clib_memcpy (&mp->src_address, &src4, 4); - clib_memcpy (&mp->dst_address, &dst4, 4); - } - else - { - clib_memcpy (&mp->src_address, &src6, 16); - clib_memcpy (&mp->dst_address, &dst6, 16); - } - mp->instance = htonl (instance); - mp->outer_fib_id = htonl (outer_fib_id); + mp->tunnel.instance = htonl (instance); + mp->tunnel.outer_fib_id = htonl (outer_fib_id); mp->is_add = is_add; - mp->session_id = htons ((u16) session_id); - mp->tunnel_type = t_type; - mp->is_ipv6 = ipv6_set; + mp->tunnel.session_id = htons ((u16) session_id); + mp->tunnel.type = htonl (t_type); S (mp); W (ret); @@ -13504,15 +13377,34 @@ static void vl_api_gre_tunnel_details_t_handler (vl_api_gre_tunnel_details_t * mp) { vat_main_t *vam = &vat_main; - ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address); - ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address); print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d", - ntohl (mp->sw_if_index), - ntohl (mp->instance), - format_ip46_address, &src, IP46_TYPE_ANY, - format_ip46_address, &dst, IP46_TYPE_ANY, - mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id)); + ntohl (mp->tunnel.sw_if_index), + ntohl (mp->tunnel.instance), + format_vl_api_address, &mp->tunnel.src, + format_vl_api_address, &mp->tunnel.dst, + mp->tunnel.type, ntohl (mp->tunnel.outer_fib_id), + ntohl (mp->tunnel.session_id)); +} + +static void +vat_json_object_add_address (vat_json_node_t * node, + const char *str, const vl_api_address_t * addr) +{ + if (ADDRESS_IP6 == addr->af) + { + struct in6_addr ip6; + + clib_memcpy (&ip6, &addr->un.ip6, sizeof (ip6)); + vat_json_object_add_ip6 (node, str, ip6); + } + else + { + struct in_addr ip4; + + clib_memcpy (&ip4, &addr->un.ip4, sizeof (ip4)); + vat_json_object_add_ip4 (node, str, ip4); + } } static void vl_api_gre_tunnel_details_t_handler_json @@ -13531,26 +13423,16 @@ static void vl_api_gre_tunnel_details_t_handler_json node = vat_json_array_add (&vam->json_tree); vat_json_init_object (node); - vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index)); - vat_json_object_add_uint (node, "instance", ntohl (mp->instance)); - if (!mp->is_ipv6) - { - clib_memcpy (&ip4, &mp->src_address, sizeof (ip4)); - vat_json_object_add_ip4 (node, "src_address", ip4); - clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4)); - vat_json_object_add_ip4 (node, "dst_address", ip4); - } - else - { - clib_memcpy (&ip6, &mp->src_address, sizeof (ip6)); - vat_json_object_add_ip6 (node, "src_address", ip6); - clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6)); - vat_json_object_add_ip6 (node, "dst_address", ip6); - } - vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type); - vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id)); - vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6); - vat_json_object_add_uint (node, "session_id", mp->session_id); + vat_json_object_add_uint (node, "sw_if_index", + ntohl (mp->tunnel.sw_if_index)); + vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance)); + + vat_json_object_add_address (node, "src", &mp->tunnel.src); + vat_json_object_add_address (node, "dst", &mp->tunnel.dst); + vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type); + vat_json_object_add_uint (node, "outer_fib_id", + ntohl (mp->tunnel.outer_fib_id)); + vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id); } static int @@ -14365,10 +14247,9 @@ api_ip_probe_neighbor (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_ip_probe_neighbor_t *mp; + vl_api_address_t dst_adr; u8 int_set = 0; u8 adr_set = 0; - u8 is_ipv6 = 0; - u8 dst_adr[16]; u32 sw_if_index; int ret; @@ -14378,13 +14259,8 @@ api_ip_probe_neighbor (vat_main_t * vam) int_set = 1; else if (unformat (i, "sw_if_index %d", &sw_if_index)) int_set = 1; - else if (unformat (i, "address %U", unformat_ip4_address, dst_adr)) + else if (unformat (i, "address %U", unformat_vl_api_address, dst_adr)) adr_set = 1; - else if (unformat (i, "address %U", unformat_ip6_address, dst_adr)) - { - adr_set = 1; - is_ipv6 = 1; - } else break; } @@ -14404,8 +14280,7 @@ api_ip_probe_neighbor (vat_main_t * vam) M (IP_PROBE_NEIGHBOR, mp); mp->sw_if_index = ntohl (sw_if_index); - mp->is_ipv6 = is_ipv6; - clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr)); + clib_memcpy (&mp->dst, &dst_adr, sizeof (dst_adr)); S (mp); W (ret); @@ -14513,7 +14388,7 @@ api_want_ip4_arp_events (vat_main_t * vam) M (WANT_IP4_ARP_EVENTS, mp); mp->enable_disable = enable_disable; mp->pid = htonl (getpid ()); - mp->address = address.as_u32; + clib_memcpy (mp->ip, &address, sizeof (address)); S (mp); W (ret); @@ -14525,14 +14400,15 @@ api_want_ip6_nd_events (vat_main_t * vam) { unformat_input_t *line_input = vam->input; vl_api_want_ip6_nd_events_t *mp; - ip6_address_t address; + vl_api_ip6_address_t address; int address_set = 0; u32 enable_disable = 1; int ret; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { - if (unformat (line_input, "address %U", unformat_ip6_address, &address)) + if (unformat + (line_input, "address %U", unformat_vl_api_ip6_address, &address)) address_set = 1; else if (unformat (line_input, "del")) enable_disable = 0; @@ -14549,7 +14425,7 @@ api_want_ip6_nd_events (vat_main_t * vam) M (WANT_IP6_ND_EVENTS, mp); mp->enable_disable = enable_disable; mp->pid = htonl (getpid ()); - clib_memcpy (mp->address, &address, sizeof (ip6_address_t)); + clib_memcpy (&mp->ip, &address, sizeof (address)); S (mp); W (ret); @@ -14906,26 +14782,24 @@ api_ipsec_interface_add_del_spd (vat_main_t * vam) } static int -api_ipsec_spd_add_del_entry (vat_main_t * vam) +api_ipsec_spd_entry_add_del (vat_main_t * vam) { unformat_input_t *i = vam->input; - vl_api_ipsec_spd_add_del_entry_t *mp; + vl_api_ipsec_spd_entry_add_del_t *mp; u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1; u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0; i32 priority = 0; u32 rport_start = 0, rport_stop = (u32) ~ 0; u32 lport_start = 0, lport_stop = (u32) ~ 0; - ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop; - ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop; + vl_api_address_t laddr_start = { }, laddr_stop = + { + }, raddr_start = + { + }, raddr_stop = + { + }; int ret; - laddr4_start.as_u32 = raddr4_start.as_u32 = 0; - laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0; - laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0; - laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0; - laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0; - laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0; - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { if (unformat (i, "del")) @@ -14950,58 +14824,18 @@ api_ipsec_spd_add_del_entry (vat_main_t * vam) ; else if (unformat (i, "rport_stop %d", &rport_stop)) ; - else - if (unformat - (i, "laddr_start %U", unformat_ip4_address, &laddr4_start)) - { - is_ipv6 = 0; - is_ip_any = 0; - } - else - if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop)) - { - is_ipv6 = 0; - is_ip_any = 0; - } - else - if (unformat - (i, "raddr_start %U", unformat_ip4_address, &raddr4_start)) - { - is_ipv6 = 0; - is_ip_any = 0; - } - else - if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop)) - { - is_ipv6 = 0; - is_ip_any = 0; - } - else - if (unformat - (i, "laddr_start %U", unformat_ip6_address, &laddr6_start)) - { - is_ipv6 = 1; - is_ip_any = 0; - } - else - if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop)) - { - is_ipv6 = 1; - is_ip_any = 0; - } - else - if (unformat - (i, "raddr_start %U", unformat_ip6_address, &raddr6_start)) - { - is_ipv6 = 1; - is_ip_any = 0; - } - else - if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop)) - { - is_ipv6 = 1; - is_ip_any = 0; - } + else if (unformat (i, "laddr_start %U", + unformat_vl_api_address, &laddr_start)) + is_ip_any = 0; + else if (unformat (i, "laddr_stop %U", unformat_vl_api_address, + &laddr_stop)) + is_ip_any = 0; + else if (unformat (i, "raddr_start %U", unformat_vl_api_address, + &raddr_start)) + is_ip_any = 0; + else if (unformat (i, "raddr_stop %U", unformat_vl_api_address, + &raddr_stop)) + is_ip_any = 0; else if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy)) { @@ -15019,65 +14853,50 @@ api_ipsec_spd_add_del_entry (vat_main_t * vam) } - M (IPSEC_SPD_ADD_DEL_ENTRY, mp); + M (IPSEC_SPD_ENTRY_ADD_DEL, mp); - mp->spd_id = ntohl (spd_id); - mp->priority = ntohl (priority); - mp->is_outbound = is_outbound; - - mp->is_ipv6 = is_ipv6; - if (is_ipv6 || is_ip_any) - { - clib_memcpy (mp->remote_address_start, &raddr6_start, - sizeof (ip6_address_t)); - clib_memcpy (mp->remote_address_stop, &raddr6_stop, - sizeof (ip6_address_t)); - clib_memcpy (mp->local_address_start, &laddr6_start, - sizeof (ip6_address_t)); - clib_memcpy (mp->local_address_stop, &laddr6_stop, - sizeof (ip6_address_t)); - } - else - { - clib_memcpy (mp->remote_address_start, &raddr4_start, - sizeof (ip4_address_t)); - clib_memcpy (mp->remote_address_stop, &raddr4_stop, - sizeof (ip4_address_t)); - clib_memcpy (mp->local_address_start, &laddr4_start, - sizeof (ip4_address_t)); - clib_memcpy (mp->local_address_stop, &laddr4_stop, - sizeof (ip4_address_t)); - } - mp->protocol = (u8) protocol; - mp->local_port_start = ntohs ((u16) lport_start); - mp->local_port_stop = ntohs ((u16) lport_stop); - mp->remote_port_start = ntohs ((u16) rport_start); - mp->remote_port_stop = ntohs ((u16) rport_stop); - mp->policy = (u8) policy; - mp->sa_id = ntohl (sa_id); mp->is_add = is_add; - mp->is_ip_any = is_ip_any; + + mp->entry.spd_id = ntohl (spd_id); + mp->entry.priority = ntohl (priority); + mp->entry.is_outbound = is_outbound; + + clib_memcpy (&mp->entry.remote_address_start, &raddr_start, + sizeof (vl_api_address_t)); + clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop, + sizeof (vl_api_address_t)); + clib_memcpy (&mp->entry.local_address_start, &laddr_start, + sizeof (vl_api_address_t)); + clib_memcpy (&mp->entry.local_address_stop, &laddr_stop, + sizeof (vl_api_address_t)); + + mp->entry.protocol = (u8) protocol; + mp->entry.local_port_start = ntohs ((u16) lport_start); + mp->entry.local_port_stop = ntohs ((u16) lport_stop); + mp->entry.remote_port_start = ntohs ((u16) rport_start); + mp->entry.remote_port_stop = ntohs ((u16) rport_stop); + mp->entry.policy = (u8) policy; + mp->entry.sa_id = ntohl (sa_id); + S (mp); W (ret); return ret; } static int -api_ipsec_sad_add_del_entry (vat_main_t * vam) +api_ipsec_sad_entry_add_del (vat_main_t * vam) { unformat_input_t *i = vam->input; - vl_api_ipsec_sad_add_del_entry_t *mp; + vl_api_ipsec_sad_entry_add_del_t *mp; u32 sad_id = 0, spi = 0; u8 *ck = 0, *ik = 0; u8 is_add = 1; - u8 protocol = IPSEC_PROTOCOL_AH; - u8 is_tunnel = 0, is_tunnel_ipv6 = 0; - u32 crypto_alg = 0, integ_alg = 0; - ip4_address_t tun_src4; - ip4_address_t tun_dst4; - ip6_address_t tun_src6; - ip6_address_t tun_dst6; + vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE; + vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE; + vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE; + vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH; + vl_api_address_t tun_src, tun_dst; int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -15089,51 +14908,30 @@ api_ipsec_sad_add_del_entry (vat_main_t * vam) else if (unformat (i, "spi %d", &spi)) ; else if (unformat (i, "esp")) - protocol = IPSEC_PROTOCOL_ESP; - else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4)) - { - is_tunnel = 1; - is_tunnel_ipv6 = 0; - } - else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4)) - { - is_tunnel = 1; - is_tunnel_ipv6 = 0; - } - else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6)) - { - is_tunnel = 1; - is_tunnel_ipv6 = 1; - } - else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6)) + protocol = IPSEC_API_PROTO_ESP; + else + if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src)) { - is_tunnel = 1; - is_tunnel_ipv6 = 1; + flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL; + if (ADDRESS_IP6 == tun_src.af) + flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6; } else - if (unformat - (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg)) + if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst)) { - if (crypto_alg >= IPSEC_CRYPTO_N_ALG) - { - clib_warning ("unsupported crypto-alg: '%U'", - format_ipsec_crypto_alg, crypto_alg); - return -99; - } + flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL; + if (ADDRESS_IP6 == tun_src.af) + flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6; } + else + if (unformat (i, "crypto_alg %U", + unformat_ipsec_api_crypto_alg, &crypto_alg)) + ; else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck)) ; - else - if (unformat - (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg)) - { - if (integ_alg >= IPSEC_INTEG_N_ALG) - { - clib_warning ("unsupported integ-alg: '%U'", - format_ipsec_integ_alg, integ_alg); - return -99; - } - } + else if (unformat (i, "integ_alg %U", + unformat_ipsec_api_integ_alg, &integ_alg)) + ; else if (unformat (i, "integ_key %U", unformat_hex_string, &ik)) ; else @@ -15144,46 +14942,37 @@ api_ipsec_sad_add_del_entry (vat_main_t * vam) } - M (IPSEC_SAD_ADD_DEL_ENTRY, mp); + M (IPSEC_SAD_ENTRY_ADD_DEL, mp); - mp->sad_id = ntohl (sad_id); mp->is_add = is_add; - mp->protocol = protocol; - mp->spi = ntohl (spi); - mp->is_tunnel = is_tunnel; - mp->is_tunnel_ipv6 = is_tunnel_ipv6; - mp->crypto_algorithm = crypto_alg; - mp->integrity_algorithm = integ_alg; - mp->crypto_key_length = vec_len (ck); - mp->integrity_key_length = vec_len (ik); + mp->entry.sad_id = ntohl (sad_id); + mp->entry.protocol = protocol; + mp->entry.spi = ntohl (spi); + mp->entry.flags = flags; - if (mp->crypto_key_length > sizeof (mp->crypto_key)) - mp->crypto_key_length = sizeof (mp->crypto_key); + mp->entry.crypto_algorithm = crypto_alg; + mp->entry.integrity_algorithm = integ_alg; + mp->entry.crypto_key.length = vec_len (ck); + mp->entry.integrity_key.length = vec_len (ik); - if (mp->integrity_key_length > sizeof (mp->integrity_key)) - mp->integrity_key_length = sizeof (mp->integrity_key); + if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data)) + mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data); + + if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data)) + mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data); if (ck) - clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length); + clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length); if (ik) - clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length); + clib_memcpy (mp->entry.integrity_key.data, ik, + mp->entry.integrity_key.length); - if (is_tunnel) + if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL) { - if (is_tunnel_ipv6) - { - clib_memcpy (mp->tunnel_src_address, &tun_src6, - sizeof (ip6_address_t)); - clib_memcpy (mp->tunnel_dst_address, &tun_dst6, - sizeof (ip6_address_t)); - } - else - { - clib_memcpy (mp->tunnel_src_address, &tun_src4, - sizeof (ip4_address_t)); - clib_memcpy (mp->tunnel_dst_address, &tun_dst4, - sizeof (ip4_address_t)); - } + clib_memcpy (&mp->entry.tunnel_src, &tun_src, + sizeof (mp->entry.tunnel_src)); + clib_memcpy (&mp->entry.tunnel_dst, &tun_dst, + sizeof (mp->entry.tunnel_dst)); } S (mp); @@ -15218,19 +15007,19 @@ api_ipsec_sa_set_key (vat_main_t * vam) M (IPSEC_SA_SET_KEY, mp); mp->sa_id = ntohl (sa_id); - mp->crypto_key_length = vec_len (ck); - mp->integrity_key_length = vec_len (ik); + mp->crypto_key.length = vec_len (ck); + mp->integrity_key.length = vec_len (ik); - if (mp->crypto_key_length > sizeof (mp->crypto_key)) - mp->crypto_key_length = sizeof (mp->crypto_key); + if (mp->crypto_key.length > sizeof (mp->crypto_key.data)) + mp->crypto_key.length = sizeof (mp->crypto_key.data); - if (mp->integrity_key_length > sizeof (mp->integrity_key)) - mp->integrity_key_length = sizeof (mp->integrity_key); + if (mp->integrity_key.length > sizeof (mp->integrity_key.data)) + mp->integrity_key.length = sizeof (mp->integrity_key.data); if (ck) - clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length); + clib_memcpy (mp->crypto_key.data, ck, mp->crypto_key.length); if (ik) - clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length); + clib_memcpy (mp->integrity_key.data, ik, mp->integrity_key.length); S (mp); W (ret); @@ -15246,13 +15035,15 @@ api_ipsec_tunnel_if_add_del (vat_main_t * vam) u32 crypto_alg = 0, integ_alg = 0; u8 *lck = NULL, *rck = NULL; u8 *lik = NULL, *rik = NULL; - ip4_address_t local_ip = { {0} }; - ip4_address_t remote_ip = { {0} }; + vl_api_address_t local_ip = { 0 }; + vl_api_address_t remote_ip = { 0 }; + f64 before = 0; u8 is_add = 1; u8 esn = 0; u8 anti_replay = 0; u8 renumber = 0; u32 instance = ~0; + u32 count = 1, jj; int ret; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) @@ -15261,15 +15052,19 @@ api_ipsec_tunnel_if_add_del (vat_main_t * vam) is_add = 0; else if (unformat (i, "esn")) esn = 1; - else if (unformat (i, "anti_replay")) + else if (unformat (i, "anti-replay")) anti_replay = 1; + else if (unformat (i, "count %d", &count)) + ; else if (unformat (i, "local_spi %d", &local_spi)) ; else if (unformat (i, "remote_spi %d", &remote_spi)) ; - else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip)) + else + if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip)) ; - else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip)) + else + if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip)) ; else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck)) ; @@ -15282,7 +15077,7 @@ api_ipsec_tunnel_if_add_del (vat_main_t * vam) ; else if (unformat - (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg)) + (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg)) { if (crypto_alg >= IPSEC_CRYPTO_N_ALG) { @@ -15293,7 +15088,7 @@ api_ipsec_tunnel_if_add_del (vat_main_t * vam) } else if (unformat - (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg)) + (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg)) { if (integ_alg >= IPSEC_INTEG_N_ALG) { @@ -15311,941 +15106,359 @@ api_ipsec_tunnel_if_add_del (vat_main_t * vam) } } - M (IPSEC_TUNNEL_IF_ADD_DEL, mp); - - mp->is_add = is_add; - mp->esn = esn; - mp->anti_replay = anti_replay; - - clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t)); - clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t)); - - mp->local_spi = htonl (local_spi); - mp->remote_spi = htonl (remote_spi); - mp->crypto_alg = (u8) crypto_alg; - - mp->local_crypto_key_len = 0; - if (lck) + if (count > 1) { - mp->local_crypto_key_len = vec_len (lck); - if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key)) - mp->local_crypto_key_len = sizeof (mp->local_crypto_key); - clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len); + /* Turn on async mode */ + vam->async_mode = 1; + vam->async_errors = 0; + before = vat_time_now (vam); } - mp->remote_crypto_key_len = 0; - if (rck) + for (jj = 0; jj < count; jj++) { - mp->remote_crypto_key_len = vec_len (rck); - if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key)) - mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key); - clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len); - } + M (IPSEC_TUNNEL_IF_ADD_DEL, mp); - mp->integ_alg = (u8) integ_alg; + mp->is_add = is_add; + mp->esn = esn; + mp->anti_replay = anti_replay; - mp->local_integ_key_len = 0; - if (lik) - { - mp->local_integ_key_len = vec_len (lik); - if (mp->local_integ_key_len > sizeof (mp->local_integ_key)) - mp->local_integ_key_len = sizeof (mp->local_integ_key); - clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len); - } + if (jj > 0) + increment_vl_address (&remote_ip); - mp->remote_integ_key_len = 0; - if (rik) - { - mp->remote_integ_key_len = vec_len (rik); - if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key)) - mp->remote_integ_key_len = sizeof (mp->remote_integ_key); - clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len); - } + clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip)); + clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip)); - if (renumber) - { - mp->renumber = renumber; - mp->show_instance = ntohl (instance); - } + mp->local_spi = htonl (local_spi + jj); + mp->remote_spi = htonl (remote_spi + jj); + mp->crypto_alg = (u8) crypto_alg; - S (mp); - W (ret); - return ret; -} + mp->local_crypto_key_len = 0; + if (lck) + { + mp->local_crypto_key_len = vec_len (lck); + if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key)) + mp->local_crypto_key_len = sizeof (mp->local_crypto_key); + clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len); + } -static void -vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp) -{ - vat_main_t *vam = &vat_main; + mp->remote_crypto_key_len = 0; + if (rck) + { + mp->remote_crypto_key_len = vec_len (rck); + if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key)) + mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key); + clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len); + } - print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u " - "crypto_key %U integ_alg %u integ_key %U use_esn %u " - "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u " - "tunnel_src_addr %U tunnel_dst_addr %U " - "salt %u seq_outbound %lu last_seq_inbound %lu " - "replay_window %lu total_data_size %lu\n", - ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi), - mp->protocol, - mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len, - mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len, - mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6, - (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address, - mp->tunnel_src_addr, - (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address, - mp->tunnel_dst_addr, - ntohl (mp->salt), - clib_net_to_host_u64 (mp->seq_outbound), - clib_net_to_host_u64 (mp->last_seq_inbound), - clib_net_to_host_u64 (mp->replay_window), - clib_net_to_host_u64 (mp->total_data_size)); -} + mp->integ_alg = (u8) integ_alg; -#define vl_api_ipsec_sa_details_t_endian vl_noop_handler -#define vl_api_ipsec_sa_details_t_print vl_noop_handler + mp->local_integ_key_len = 0; + if (lik) + { + mp->local_integ_key_len = vec_len (lik); + if (mp->local_integ_key_len > sizeof (mp->local_integ_key)) + mp->local_integ_key_len = sizeof (mp->local_integ_key); + clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len); + } -static void vl_api_ipsec_sa_details_t_handler_json - (vl_api_ipsec_sa_details_t * mp) -{ - vat_main_t *vam = &vat_main; - vat_json_node_t *node = NULL; - struct in_addr src_ip4, dst_ip4; - struct in6_addr src_ip6, dst_ip6; + mp->remote_integ_key_len = 0; + if (rik) + { + mp->remote_integ_key_len = vec_len (rik); + if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key)) + mp->remote_integ_key_len = sizeof (mp->remote_integ_key); + clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len); + } - if (VAT_JSON_ARRAY != vam->json_tree.type) - { - ASSERT (VAT_JSON_NONE == vam->json_tree.type); - vat_json_init_array (&vam->json_tree); + if (renumber) + { + mp->renumber = renumber; + mp->show_instance = ntohl (instance); + } + S (mp); } - node = vat_json_array_add (&vam->json_tree); - vat_json_init_object (node); - vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id)); - vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index)); - vat_json_object_add_uint (node, "spi", ntohl (mp->spi)); - vat_json_object_add_uint (node, "proto", mp->protocol); - vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg); - vat_json_object_add_uint (node, "integ_alg", mp->integ_alg); - vat_json_object_add_uint (node, "use_esn", mp->use_esn); - vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay); - vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel); - vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6); - vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key, - mp->crypto_key_len); - vat_json_object_add_bytes (node, "integ_key", mp->integ_key, - mp->integ_key_len); - if (mp->is_tunnel_ip6) - { - clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6)); - vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6); - clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6)); - vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6); - } - else + /* When testing multiple add/del ops, use a control-ping to sync */ + if (count > 1) { - clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4)); - vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4); - clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4)); - vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4); - } - vat_json_object_add_uint (node, "replay_window", - clib_net_to_host_u64 (mp->replay_window)); - vat_json_object_add_uint (node, "total_data_size", - clib_net_to_host_u64 (mp->total_data_size)); + vl_api_control_ping_t *mp_ping; + f64 after; + f64 timeout; -} + /* Shut off async mode */ + vam->async_mode = 0; -static int -api_ipsec_sa_dump (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_ipsec_sa_dump_t *mp; - vl_api_control_ping_t *mp_ping; - u32 sa_id = ~0; - int ret; + MPING (CONTROL_PING, mp_ping); + S (mp_ping); - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "sa_id %d", &sa_id)) - ; - else - { - clib_warning ("parse error '%U'", format_unformat_error, i); - return -99; - } - } - - M (IPSEC_SA_DUMP, mp); - - mp->sa_id = ntohl (sa_id); - - S (mp); - - /* Use a control ping for synchronization */ - M (CONTROL_PING, mp_ping); - S (mp_ping); - - W (ret); - return ret; -} - -static int -api_ipsec_tunnel_if_set_key (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_ipsec_tunnel_if_set_key_t *mp; - u32 sw_if_index = ~0; - u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE; - u8 *key = 0; - u32 alg = ~0; - int ret; - - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) - ; - else - if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg)) - key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO; - else - if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg)) - key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO; - else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg)) - key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG; - else - if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg)) - key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG; - else if (unformat (i, "%U", unformat_hex_string, &key)) - ; - else - { - clib_warning ("parse error '%U'", format_unformat_error, i); - return -99; - } - } - - if (sw_if_index == ~0) - { - errmsg ("interface must be specified"); - return -99; - } - - if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE) - { - errmsg ("key type must be specified"); - return -99; - } - - if (alg == ~0) - { - errmsg ("algorithm must be specified"); - return -99; - } - - if (vec_len (key) == 0) - { - errmsg ("key must be specified"); - return -99; - } - - M (IPSEC_TUNNEL_IF_SET_KEY, mp); - - mp->sw_if_index = htonl (sw_if_index); - mp->alg = alg; - mp->key_type = key_type; - mp->key_len = vec_len (key); - clib_memcpy (mp->key, key, vec_len (key)); - - S (mp); - W (ret); - - return ret; -} - -static int -api_ipsec_tunnel_if_set_sa (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_ipsec_tunnel_if_set_sa_t *mp; - u32 sw_if_index = ~0; - u32 sa_id = ~0; - u8 is_outbound = (u8) ~ 0; - int ret; - - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) - ; - else if (unformat (i, "sa_id %d", &sa_id)) - ; - else if (unformat (i, "outbound")) - is_outbound = 1; - else if (unformat (i, "inbound")) - is_outbound = 0; - else - { - clib_warning ("parse error '%U'", format_unformat_error, i); - return -99; - } - } - - if (sw_if_index == ~0) - { - errmsg ("interface must be specified"); - return -99; - } - - if (sa_id == ~0) - { - errmsg ("SA ID must be specified"); - return -99; - } - - M (IPSEC_TUNNEL_IF_SET_SA, mp); - - mp->sw_if_index = htonl (sw_if_index); - mp->sa_id = htonl (sa_id); - mp->is_outbound = is_outbound; - - S (mp); - W (ret); - - return ret; -} - -static int -api_ikev2_profile_add_del (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_ikev2_profile_add_del_t *mp; - u8 is_add = 1; - u8 *name = 0; - int ret; - - const char *valid_chars = "a-zA-Z0-9_"; - - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "del")) - is_add = 0; - else if (unformat (i, "name %U", unformat_token, valid_chars, &name)) - vec_add1 (name, 0); - else - { - errmsg ("parse error '%U'", format_unformat_error, i); - return -99; - } - } - - if (!vec_len (name)) - { - errmsg ("profile name must be specified"); - return -99; - } - - if (vec_len (name) > 64) - { - errmsg ("profile name too long"); - return -99; - } - - M (IKEV2_PROFILE_ADD_DEL, mp); - - clib_memcpy (mp->name, name, vec_len (name)); - mp->is_add = is_add; - vec_free (name); - - S (mp); - W (ret); - return ret; -} - -static int -api_ikev2_profile_set_auth (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_ikev2_profile_set_auth_t *mp; - u8 *name = 0; - u8 *data = 0; - u32 auth_method = 0; - u8 is_hex = 0; - int ret; - - const char *valid_chars = "a-zA-Z0-9_"; - - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "name %U", unformat_token, valid_chars, &name)) - vec_add1 (name, 0); - else if (unformat (i, "auth_method %U", - unformat_ikev2_auth_method, &auth_method)) - ; - else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data)) - is_hex = 1; - else if (unformat (i, "auth_data %v", &data)) - ; - else - { - errmsg ("parse error '%U'", format_unformat_error, i); - return -99; - } - } - - if (!vec_len (name)) - { - errmsg ("profile name must be specified"); - return -99; - } - - if (vec_len (name) > 64) - { - errmsg ("profile name too long"); - return -99; - } - - if (!vec_len (data)) - { - errmsg ("auth_data must be specified"); - return -99; - } - - if (!auth_method) - { - errmsg ("auth_method must be specified"); - return -99; - } - - M (IKEV2_PROFILE_SET_AUTH, mp); - - mp->is_hex = is_hex; - mp->auth_method = (u8) auth_method; - mp->data_len = vec_len (data); - clib_memcpy (mp->name, name, vec_len (name)); - clib_memcpy (mp->data, data, vec_len (data)); - vec_free (name); - vec_free (data); - - S (mp); - W (ret); - return ret; -} - -static int -api_ikev2_profile_set_id (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_ikev2_profile_set_id_t *mp; - u8 *name = 0; - u8 *data = 0; - u8 is_local = 0; - u32 id_type = 0; - ip4_address_t ip4; - int ret; - - const char *valid_chars = "a-zA-Z0-9_"; - - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "name %U", unformat_token, valid_chars, &name)) - vec_add1 (name, 0); - else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type)) - ; - else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4)) - { - data = vec_new (u8, 4); - clib_memcpy (data, ip4.as_u8, 4); - } - else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data)) - ; - else if (unformat (i, "id_data %v", &data)) - ; - else if (unformat (i, "local")) - is_local = 1; - else if (unformat (i, "remote")) - is_local = 0; - else - { - errmsg ("parse error '%U'", format_unformat_error, i); - return -99; - } - } - - if (!vec_len (name)) - { - errmsg ("profile name must be specified"); - return -99; - } - - if (vec_len (name) > 64) - { - errmsg ("profile name too long"); - return -99; - } - - if (!vec_len (data)) - { - errmsg ("id_data must be specified"); - return -99; - } - - if (!id_type) - { - errmsg ("id_type must be specified"); - return -99; - } - - M (IKEV2_PROFILE_SET_ID, mp); - - mp->is_local = is_local; - mp->id_type = (u8) id_type; - mp->data_len = vec_len (data); - clib_memcpy (mp->name, name, vec_len (name)); - clib_memcpy (mp->data, data, vec_len (data)); - vec_free (name); - vec_free (data); - - S (mp); - W (ret); - return ret; -} - -static int -api_ikev2_profile_set_ts (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_ikev2_profile_set_ts_t *mp; - u8 *name = 0; - u8 is_local = 0; - u32 proto = 0, start_port = 0, end_port = (u32) ~ 0; - ip4_address_t start_addr, end_addr; - - const char *valid_chars = "a-zA-Z0-9_"; - int ret; - - start_addr.as_u32 = 0; - end_addr.as_u32 = (u32) ~ 0; - - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "name %U", unformat_token, valid_chars, &name)) - vec_add1 (name, 0); - else if (unformat (i, "protocol %d", &proto)) - ; - else if (unformat (i, "start_port %d", &start_port)) - ; - else if (unformat (i, "end_port %d", &end_port)) - ; - else - if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr)) - ; - else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr)) - ; - else if (unformat (i, "local")) - is_local = 1; - else if (unformat (i, "remote")) - is_local = 0; - else - { - errmsg ("parse error '%U'", format_unformat_error, i); - return -99; - } - } - - if (!vec_len (name)) - { - errmsg ("profile name must be specified"); - return -99; - } - - if (vec_len (name) > 64) - { - errmsg ("profile name too long"); - return -99; - } - - M (IKEV2_PROFILE_SET_TS, mp); - - mp->is_local = is_local; - mp->proto = (u8) proto; - mp->start_port = (u16) start_port; - mp->end_port = (u16) end_port; - mp->start_addr = start_addr.as_u32; - mp->end_addr = end_addr.as_u32; - clib_memcpy (mp->name, name, vec_len (name)); - vec_free (name); - - S (mp); - W (ret); - return ret; -} - -static int -api_ikev2_set_local_key (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_ikev2_set_local_key_t *mp; - u8 *file = 0; - int ret; - - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "file %v", &file)) - vec_add1 (file, 0); - else - { - errmsg ("parse error '%U'", format_unformat_error, i); - return -99; - } - } - - if (!vec_len (file)) - { - errmsg ("RSA key file must be specified"); - return -99; - } - - if (vec_len (file) > 256) - { - errmsg ("file name too long"); - return -99; - } - - M (IKEV2_SET_LOCAL_KEY, mp); - - clib_memcpy (mp->key_file, file, vec_len (file)); - vec_free (file); - - S (mp); - W (ret); - return ret; -} - -static int -api_ikev2_set_responder (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_ikev2_set_responder_t *mp; - int ret; - u8 *name = 0; - u32 sw_if_index = ~0; - ip4_address_t address; + timeout = vat_time_now (vam) + 1.0; + while (vat_time_now (vam) < timeout) + if (vam->result_ready == 1) + goto out; + vam->retval = -99; - const char *valid_chars = "a-zA-Z0-9_"; + out: + if (vam->retval == -99) + errmsg ("timeout"); - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat - (i, "%U interface %d address %U", unformat_token, valid_chars, - &name, &sw_if_index, unformat_ip4_address, &address)) - vec_add1 (name, 0); - else + if (vam->async_errors > 0) { - errmsg ("parse error '%U'", format_unformat_error, i); - return -99; + errmsg ("%d asynchronous errors", vam->async_errors); + vam->retval = -98; } - } - - if (!vec_len (name)) - { - errmsg ("profile name must be specified"); - return -99; - } - - if (vec_len (name) > 64) - { - errmsg ("profile name too long"); - return -99; - } - - M (IKEV2_SET_RESPONDER, mp); - - clib_memcpy (mp->name, name, vec_len (name)); - vec_free (name); - - mp->sw_if_index = sw_if_index; - clib_memcpy (mp->address, &address, sizeof (address)); - - S (mp); - W (ret); - return ret; -} - -static int -api_ikev2_set_ike_transforms (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_ikev2_set_ike_transforms_t *mp; - int ret; - u8 *name = 0; - u32 crypto_alg, crypto_key_size, integ_alg, dh_group; - - const char *valid_chars = "a-zA-Z0-9_"; + vam->async_errors = 0; + after = vat_time_now (vam); - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name, - &crypto_alg, &crypto_key_size, &integ_alg, &dh_group)) - vec_add1 (name, 0); - else - { - errmsg ("parse error '%U'", format_unformat_error, i); - return -99; - } - } + /* slim chance, but we might have eaten SIGTERM on the first iteration */ + if (jj > 0) + count = jj; - if (!vec_len (name)) - { - errmsg ("profile name must be specified"); - return -99; + print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec", + count, after - before, count / (after - before)); } - - if (vec_len (name) > 64) + else { - errmsg ("profile name too long"); - return -99; + /* Wait for a reply... */ + W (ret); + return ret; } - M (IKEV2_SET_IKE_TRANSFORMS, mp); - - clib_memcpy (mp->name, name, vec_len (name)); - vec_free (name); - mp->crypto_alg = crypto_alg; - mp->crypto_key_size = crypto_key_size; - mp->integ_alg = integ_alg; - mp->dh_group = dh_group; - - S (mp); - W (ret); return ret; } - -static int -api_ikev2_set_esp_transforms (vat_main_t * vam) +static void +vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp) { - unformat_input_t *i = vam->input; - vl_api_ikev2_set_esp_transforms_t *mp; - int ret; - u8 *name = 0; - u32 crypto_alg, crypto_key_size, integ_alg, dh_group; + vat_main_t *vam = &vat_main; - const char *valid_chars = "a-zA-Z0-9_"; + print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u " + "crypto_key %U integ_alg %u integ_key %U flags %x " + "tunnel_src_addr %U tunnel_dst_addr %U " + "salt %u seq_outbound %lu last_seq_inbound %lu " + "replay_window %lu\n", + ntohl (mp->entry.sad_id), + ntohl (mp->sw_if_index), + ntohl (mp->entry.spi), + ntohl (mp->entry.protocol), + ntohl (mp->entry.crypto_algorithm), + format_hex_bytes, mp->entry.crypto_key.data, + mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm), + format_hex_bytes, mp->entry.integrity_key.data, + mp->entry.integrity_key.length, ntohl (mp->entry.flags), + format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address, + &mp->entry.tunnel_dst, ntohl (mp->salt), + clib_net_to_host_u64 (mp->seq_outbound), + clib_net_to_host_u64 (mp->last_seq_inbound), + clib_net_to_host_u64 (mp->replay_window)); +} - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) - { - if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name, - &crypto_alg, &crypto_key_size, &integ_alg, &dh_group)) - vec_add1 (name, 0); - else - { - errmsg ("parse error '%U'", format_unformat_error, i); - return -99; - } - } +#define vl_api_ipsec_sa_details_t_endian vl_noop_handler +#define vl_api_ipsec_sa_details_t_print vl_noop_handler - if (!vec_len (name)) - { - errmsg ("profile name must be specified"); - return -99; - } +static void vl_api_ipsec_sa_details_t_handler_json + (vl_api_ipsec_sa_details_t * mp) +{ + vat_main_t *vam = &vat_main; + vat_json_node_t *node = NULL; + vl_api_ipsec_sad_flags_t flags; - if (vec_len (name) > 64) + if (VAT_JSON_ARRAY != vam->json_tree.type) { - errmsg ("profile name too long"); - return -99; + ASSERT (VAT_JSON_NONE == vam->json_tree.type); + vat_json_init_array (&vam->json_tree); } + node = vat_json_array_add (&vam->json_tree); - M (IKEV2_SET_ESP_TRANSFORMS, mp); - - clib_memcpy (mp->name, name, vec_len (name)); - vec_free (name); - mp->crypto_alg = crypto_alg; - mp->crypto_key_size = crypto_key_size; - mp->integ_alg = integ_alg; - mp->dh_group = dh_group; - - S (mp); - W (ret); - return ret; + vat_json_init_object (node); + vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id)); + vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index)); + vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi)); + vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol)); + vat_json_object_add_uint (node, "crypto_alg", + ntohl (mp->entry.crypto_algorithm)); + vat_json_object_add_uint (node, "integ_alg", + ntohl (mp->entry.integrity_algorithm)); + flags = ntohl (mp->entry.flags); + vat_json_object_add_uint (node, "use_esn", + ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN)); + vat_json_object_add_uint (node, "use_anti_replay", + ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY)); + vat_json_object_add_uint (node, "is_tunnel", + ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)); + vat_json_object_add_uint (node, "is_tunnel_ip6", + ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6)); + vat_json_object_add_uint (node, "udp_encap", + ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP)); + vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data, + mp->entry.crypto_key.length); + vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data, + mp->entry.integrity_key.length); + vat_json_object_add_address (node, "src", &mp->entry.tunnel_src); + vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst); + vat_json_object_add_uint (node, "replay_window", + clib_net_to_host_u64 (mp->replay_window)); } static int -api_ikev2_set_sa_lifetime (vat_main_t * vam) +api_ipsec_sa_dump (vat_main_t * vam) { unformat_input_t *i = vam->input; - vl_api_ikev2_set_sa_lifetime_t *mp; + vl_api_ipsec_sa_dump_t *mp; + vl_api_control_ping_t *mp_ping; + u32 sa_id = ~0; int ret; - u8 *name = 0; - u64 lifetime, lifetime_maxdata; - u32 lifetime_jitter, handover; - - const char *valid_chars = "a-zA-Z0-9_"; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { - if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name, - &lifetime, &lifetime_jitter, &handover, - &lifetime_maxdata)) - vec_add1 (name, 0); + if (unformat (i, "sa_id %d", &sa_id)) + ; else { - errmsg ("parse error '%U'", format_unformat_error, i); + clib_warning ("parse error '%U'", format_unformat_error, i); return -99; } } - if (!vec_len (name)) - { - errmsg ("profile name must be specified"); - return -99; - } + M (IPSEC_SA_DUMP, mp); - if (vec_len (name) > 64) - { - errmsg ("profile name too long"); - return -99; - } + mp->sa_id = ntohl (sa_id); - M (IKEV2_SET_SA_LIFETIME, mp); + S (mp); - clib_memcpy (mp->name, name, vec_len (name)); - vec_free (name); - mp->lifetime = lifetime; - mp->lifetime_jitter = lifetime_jitter; - mp->handover = handover; - mp->lifetime_maxdata = lifetime_maxdata; + /* Use a control ping for synchronization */ + M (CONTROL_PING, mp_ping); + S (mp_ping); - S (mp); W (ret); return ret; } static int -api_ikev2_initiate_sa_init (vat_main_t * vam) +api_ipsec_tunnel_if_set_key (vat_main_t * vam) { unformat_input_t *i = vam->input; - vl_api_ikev2_initiate_sa_init_t *mp; + vl_api_ipsec_tunnel_if_set_key_t *mp; + u32 sw_if_index = ~0; + u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE; + u8 *key = 0; + u32 alg = ~0; int ret; - u8 *name = 0; - - const char *valid_chars = "a-zA-Z0-9_"; while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { - if (unformat (i, "%U", unformat_token, valid_chars, &name)) - vec_add1 (name, 0); + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + ; + else + if (unformat + (i, "local crypto %U", unformat_ipsec_api_crypto_alg, &alg)) + key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO; + else + if (unformat + (i, "remote crypto %U", unformat_ipsec_api_crypto_alg, &alg)) + key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO; + else + if (unformat + (i, "local integ %U", unformat_ipsec_api_integ_alg, &alg)) + key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG; + else + if (unformat + (i, "remote integ %U", unformat_ipsec_api_integ_alg, &alg)) + key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG; + else if (unformat (i, "%U", unformat_hex_string, &key)) + ; else { - errmsg ("parse error '%U'", format_unformat_error, i); + clib_warning ("parse error '%U'", format_unformat_error, i); return -99; } } - if (!vec_len (name)) + if (sw_if_index == ~0) { - errmsg ("profile name must be specified"); + errmsg ("interface must be specified"); return -99; } - if (vec_len (name) > 64) + if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE) { - errmsg ("profile name too long"); + errmsg ("key type must be specified"); return -99; } - M (IKEV2_INITIATE_SA_INIT, mp); - - clib_memcpy (mp->name, name, vec_len (name)); - vec_free (name); - - S (mp); - W (ret); - return ret; -} - -static int -api_ikev2_initiate_del_ike_sa (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_ikev2_initiate_del_ike_sa_t *mp; - int ret; - u64 ispi; - + if (alg == ~0) + { + errmsg ("algorithm must be specified"); + return -99; + } - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + if (vec_len (key) == 0) { - if (unformat (i, "%lx", &ispi)) - ; - else - { - errmsg ("parse error '%U'", format_unformat_error, i); - return -99; - } + errmsg ("key must be specified"); + return -99; } - M (IKEV2_INITIATE_DEL_IKE_SA, mp); + M (IPSEC_TUNNEL_IF_SET_KEY, mp); - mp->ispi = ispi; + mp->sw_if_index = htonl (sw_if_index); + mp->alg = alg; + mp->key_type = key_type; + mp->key_len = vec_len (key); + clib_memcpy (mp->key, key, vec_len (key)); S (mp); W (ret); + return ret; } static int -api_ikev2_initiate_del_child_sa (vat_main_t * vam) +api_ipsec_tunnel_if_set_sa (vat_main_t * vam) { unformat_input_t *i = vam->input; - vl_api_ikev2_initiate_del_child_sa_t *mp; + vl_api_ipsec_tunnel_if_set_sa_t *mp; + u32 sw_if_index = ~0; + u32 sa_id = ~0; + u8 is_outbound = (u8) ~ 0; int ret; - u32 ispi; - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) { - if (unformat (i, "%x", &ispi)) + if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index)) + ; + else if (unformat (i, "sa_id %d", &sa_id)) ; + else if (unformat (i, "outbound")) + is_outbound = 1; + else if (unformat (i, "inbound")) + is_outbound = 0; else { - errmsg ("parse error '%U'", format_unformat_error, i); + clib_warning ("parse error '%U'", format_unformat_error, i); return -99; } } - M (IKEV2_INITIATE_DEL_CHILD_SA, mp); - - mp->ispi = ispi; - - S (mp); - W (ret); - return ret; -} - -static int -api_ikev2_initiate_rekey_child_sa (vat_main_t * vam) -{ - unformat_input_t *i = vam->input; - vl_api_ikev2_initiate_rekey_child_sa_t *mp; - int ret; - u32 ispi; - + if (sw_if_index == ~0) + { + errmsg ("interface must be specified"); + return -99; + } - while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT) + if (sa_id == ~0) { - if (unformat (i, "%x", &ispi)) - ; - else - { - errmsg ("parse error '%U'", format_unformat_error, i); - return -99; - } + errmsg ("SA ID must be specified"); + return -99; } - M (IKEV2_INITIATE_REKEY_CHILD_SA, mp); + M (IPSEC_TUNNEL_IF_SET_SA, mp); - mp->ispi = ispi; + mp->sw_if_index = htonl (sw_if_index); + mp->sa_id = htonl (sa_id); + mp->is_outbound = is_outbound; S (mp); W (ret); + return ret; } @@ -20233,10 +19446,9 @@ static void vl_api_ip_neighbor_details_t_handler vat_main_t *vam = &vat_main; print (vam->ofp, "%c %U %U", - (mp->is_static) ? 'S' : 'D', - format_ethernet_address, &mp->mac_address, - (mp->is_ipv6) ? format_ip6_address : format_ip4_address, - &mp->ip_address); + (ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ? 'S' : 'D', + format_vl_api_mac_address, &mp->neighbor.mac_address, + format_vl_api_address, &mp->neighbor.ip_address); } static void vl_api_ip_neighbor_details_t_handler_json @@ -20245,8 +19457,6 @@ static void vl_api_ip_neighbor_details_t_handler_json vat_main_t *vam = &vat_main; vat_json_node_t *node; - struct in_addr ip4; - struct in6_addr ip6; if (VAT_JSON_ARRAY != vam->json_tree.type) { @@ -20256,24 +19466,15 @@ static void vl_api_ip_neighbor_details_t_handler_json node = vat_json_array_add (&vam->json_tree); vat_json_init_object (node); - vat_json_object_add_string_copy (node, "flag", - (mp->is_static) ? (u8 *) "static" : (u8 *) - "dynamic"); + vat_json_object_add_string_copy + (node, "flag", + ((ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ? + (u8 *) "static" : (u8 *) "dynamic")); vat_json_object_add_string_copy (node, "link_layer", - format (0, "%U", format_ethernet_address, - &mp->mac_address)); - - if (mp->is_ipv6) - { - clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6)); - vat_json_object_add_ip6 (node, "ip_address", ip6); - } - else - { - clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4)); - vat_json_object_add_ip4 (node, "ip_address", ip4); - } + format (0, "%U", format_vl_api_mac_address, + &mp->neighbor.mac_address)); + vat_json_object_add_address (node, "ip", &mp->neighbor.ip_address); } static int @@ -21024,9 +20225,7 @@ api_ip_source_and_port_range_check_add_del (vat_main_t * vam) u16 *high_ports = 0; u16 this_low; u16 this_hi; - ip4_address_t ip4_addr; - ip6_address_t ip6_addr; - u32 length; + vl_api_prefix_t prefix; u32 tmp, tmp2; u8 prefix_set = 0; u32 vrf_id = ~0; @@ -21036,17 +20235,8 @@ api_ip_source_and_port_range_check_add_del (vat_main_t * vam) while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { - if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length)) - { - prefix_set = 1; - } - else - if (unformat - (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length)) - { - prefix_set = 1; - is_ipv6 = 1; - } + if (unformat (input, "%U", unformat_vl_api_prefix, &prefix)) + prefix_set = 1; else if (unformat (input, "vrf %d", &vrf_id)) ; else if (unformat (input, "del")) @@ -21117,18 +20307,8 @@ api_ip_source_and_port_range_check_add_del (vat_main_t * vam) mp->is_add = is_add; - if (is_ipv6) - { - mp->is_ipv6 = 1; - clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr)); - } - else - { - mp->is_ipv6 = 0; - clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr)); - } + clib_memcpy (&mp->prefix, &prefix, sizeof (prefix)); - mp->mask_length = length; mp->number_of_ranges = vec_len (low_ports); clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports)); @@ -21215,14 +20395,14 @@ api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam) } static int -api_ipsec_gre_add_del_tunnel (vat_main_t * vam) +api_ipsec_gre_tunnel_add_del (vat_main_t * vam) { unformat_input_t *i = vam->input; - vl_api_ipsec_gre_add_del_tunnel_t *mp; + vl_api_ipsec_gre_tunnel_add_del_t *mp; u32 local_sa_id = 0; u32 remote_sa_id = 0; - ip4_address_t src_address; - ip4_address_t dst_address; + vl_api_ip4_address_t src_address; + vl_api_ip4_address_t dst_address; u8 is_add = 1; int ret; @@ -21232,9 +20412,11 @@ api_ipsec_gre_add_del_tunnel (vat_main_t * vam) ; else if (unformat (i, "remote_sa %d", &remote_sa_id)) ; - else if (unformat (i, "src %U", unformat_ip4_address, &src_address)) + else + if (unformat (i, "src %U", unformat_vl_api_ip4_address, &src_address)) ; - else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address)) + else + if (unformat (i, "dst %U", unformat_vl_api_ip4_address, &dst_address)) ; else if (unformat (i, "del")) is_add = 0; @@ -21245,12 +20427,12 @@ api_ipsec_gre_add_del_tunnel (vat_main_t * vam) } } - M (IPSEC_GRE_ADD_DEL_TUNNEL, mp); + M (IPSEC_GRE_TUNNEL_ADD_DEL, mp); - mp->local_sa_id = ntohl (local_sa_id); - mp->remote_sa_id = ntohl (remote_sa_id); - clib_memcpy (mp->src_address, &src_address, sizeof (src_address)); - clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address)); + mp->tunnel.local_sa_id = ntohl (local_sa_id); + mp->tunnel.remote_sa_id = ntohl (remote_sa_id); + clib_memcpy (mp->tunnel.src, &src_address, sizeof (src_address)); + clib_memcpy (mp->tunnel.dst, &dst_address, sizeof (dst_address)); mp->is_add = is_add; S (mp); @@ -21304,10 +20486,21 @@ static void vl_api_ipsec_gre_tunnel_details_t_handler vat_main_t *vam = &vat_main; print (vam->ofp, "%11d%15U%15U%14d%14d", - ntohl (mp->sw_if_index), - format_ip4_address, &mp->src_address, - format_ip4_address, &mp->dst_address, - ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id)); + ntohl (mp->tunnel.sw_if_index), + format_vl_api_ip4_address, mp->tunnel.src, + format_vl_api_ip4_address, mp->tunnel.dst, + ntohl (mp->tunnel.local_sa_id), ntohl (mp->tunnel.remote_sa_id)); +} + +static void +vat_json_object_add_vl_api_ip4 (vat_json_node_t * node, + const char *name, + const vl_api_ip4_address_t addr) +{ + struct in_addr ip4; + + clib_memcpy (&ip4, addr, sizeof (ip4)); + vat_json_object_add_ip4 (node, name, ip4); } static void vl_api_ipsec_gre_tunnel_details_t_handler_json @@ -21325,13 +20518,14 @@ static void vl_api_ipsec_gre_tunnel_details_t_handler_json node = vat_json_array_add (&vam->json_tree); vat_json_init_object (node); - vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index)); - clib_memcpy (&ip4, &mp->src_address, sizeof (ip4)); - vat_json_object_add_ip4 (node, "src_address", ip4); - clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4)); - vat_json_object_add_ip4 (node, "dst_address", ip4); - vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id)); - vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id)); + vat_json_object_add_uint (node, "sw_if_index", + ntohl (mp->tunnel.sw_if_index)); + vat_json_object_add_vl_api_ip4 (node, "src", mp->tunnel.src); + vat_json_object_add_vl_api_ip4 (node, "src", mp->tunnel.dst); + vat_json_object_add_uint (node, "local_sa_id", + ntohl (mp->tunnel.local_sa_id)); + vat_json_object_add_uint (node, "remote_sa_id", + ntohl (mp->tunnel.remote_sa_id)); } static int @@ -22205,7 +21399,7 @@ api_sock_init_shm (vat_main_t * vam) config[6].count = 128; config[6].size = sizeof (uword); - rv = vl_socket_client_init_shm (config); + rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ ); if (!rv) vam->client_index_invalid = 1; return rv; @@ -22581,10 +21775,8 @@ api_ip_container_proxy_add_del (vat_main_t * vam) { vl_api_ip_container_proxy_add_del_t *mp; unformat_input_t *i = vam->input; - u32 plen = ~0, sw_if_index = ~0; - ip4_address_t ip4; - ip6_address_t ip6; - u8 is_ip4 = 1; + u32 sw_if_index = ~0; + vl_api_prefix_t pfx = { }; u8 is_add = 1; int ret; @@ -22594,22 +21786,14 @@ api_ip_container_proxy_add_del (vat_main_t * vam) is_add = 0; else if (unformat (i, "add")) ; - if (unformat (i, "%U", unformat_ip4_address, &ip4)) - { - is_ip4 = 1; - plen = 32; - } - else if (unformat (i, "%U", unformat_ip6_address, &ip6)) - { - is_ip4 = 0; - plen = 128; - } + if (unformat (i, "%U", unformat_vl_api_prefix, &pfx)) + ; else if (unformat (i, "sw_if_index %u", &sw_if_index)) ; else break; } - if (sw_if_index == ~0 || plen == ~0) + if (sw_if_index == ~0 || pfx.address_length == 0) { errmsg ("address and sw_if_index must be set"); return -99; @@ -22617,14 +21801,9 @@ api_ip_container_proxy_add_del (vat_main_t * vam) M (IP_CONTAINER_PROXY_ADD_DEL, mp); - mp->is_ip4 = is_ip4; mp->sw_if_index = clib_host_to_net_u32 (sw_if_index); - mp->plen = plen; mp->is_add = is_add; - if (is_ip4) - clib_memcpy (mp->ip, &ip4, sizeof (ip4)); - else - clib_memcpy (mp->ip, &ip6, sizeof (ip6)); + clib_memcpy (&mp->pfx, &pfx, sizeof (pfx)); S (mp); W (ret); @@ -23162,21 +22341,20 @@ _(l2_flags, \ "sw_if | sw_if_index [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \ _(bridge_flags, \ "bd_id [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \ -_(tap_connect, \ - "tapname mac | random-mac [tag ]") \ -_(tap_modify, \ - " | sw_if_index tapname mac | random-mac") \ -_(tap_delete, \ - " | sw_if_index ") \ -_(sw_interface_tap_dump, "") \ _(tap_create_v2, \ "id [hw-addr ] [host-ns ] [rx-ring-size [tx-ring-size ]") \ _(tap_delete_v2, \ " | sw_if_index ") \ _(sw_interface_tap_v2_dump, "") \ +_(virtio_pci_create, \ + "pci-addr [use_random_mac | hw-addr ] [tx-ring-size [rx-ring-size ] [features ]") \ +_(virtio_pci_delete, \ + " | sw_if_index ") \ +_(sw_interface_virtio_pci_dump, "") \ _(bond_create, \ "[hw-addr ] {round-robin | active-backup | " \ - "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]}") \ + "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \ + "[id ]") \ _(bond_delete, \ " | sw_if_index ") \ _(bond_enslave, \ @@ -23309,7 +22487,7 @@ _(geneve_add_del_tunnel, \ "vni [encap-vrf-id ] [decap-next ] [del]") \ _(vxlan_tunnel_dump, "[ | sw_if_index ]") \ _(geneve_tunnel_dump, "[ | sw_if_index ]") \ -_(gre_add_del_tunnel, \ +_(gre_tunnel_add_del, \ "src dst [outer-fib-id ] [instance ]\n" \ "[teb | erspan ] [del]") \ _(gre_tunnel_dump, "[ | sw_if_index ]") \ @@ -23353,10 +22531,10 @@ _(ip_dump, "ipv4 | ipv6") \ _(ipsec_spd_add_del, "spd_id [del]") \ _(ipsec_interface_add_del_spd, "( | sw_if_index )\n" \ " spid_id ") \ -_(ipsec_sad_add_del_entry, "sad_id spi crypto_alg \n" \ +_(ipsec_sad_entry_add_del, "sad_id spi crypto_alg \n" \ " crypto_key tunnel_src tunnel_dst \n" \ " integ_alg integ_key ") \ -_(ipsec_spd_add_del_entry, "spd_id priority action \n" \ +_(ipsec_spd_entry_add_del, "spd_id priority action \n" \ " (inbound|outbound) [sa_id ] laddr_start \n" \ " laddr_stop raddr_start raddr_stop \n" \ " [lport_start lport_stop ] [rport_start rport_stop ]" ) \ @@ -23370,23 +22548,6 @@ _(ipsec_sa_dump, "[sa_id ]") \ _(ipsec_tunnel_if_set_key, " \n" \ " \n") \ _(ipsec_tunnel_if_set_sa, " sa_id \n") \ -_(ikev2_profile_add_del, "name [del]") \ -_(ikev2_profile_set_auth, "name auth_method \n" \ - "(auth_data 0x | auth_data )") \ -_(ikev2_profile_set_id, "name id_type \n" \ - "(id_data 0x | id_data ) (local|remote)") \ -_(ikev2_profile_set_ts, "name protocol \n" \ - "start_port end_port start_addr end_addr \n" \ - "(local|remote)") \ -_(ikev2_set_local_key, "file ") \ -_(ikev2_set_responder, " interface address ") \ -_(ikev2_set_ike_transforms, " ") \ -_(ikev2_set_esp_transforms, " ") \ -_(ikev2_set_sa_lifetime, " ") \ -_(ikev2_initiate_sa_init, "") \ -_(ikev2_initiate_del_ike_sa, "") \ -_(ikev2_initiate_del_child_sa, "") \ -_(ikev2_initiate_rekey_child_sa, "") \ _(delete_loopback,"sw_if_index ") \ _(bd_ip_mac_add_del, "bd_id [del]") \ _(bd_ip_mac_flush, "bd_id ") \ @@ -23559,7 +22720,7 @@ _(ip_source_and_port_range_check_add_del, \ _(ip_source_and_port_range_check_interface_add_del, \ " | sw_if_index [tcp-out-vrf ] [tcp-in-vrf ]" \ "[udp-in-vrf ] [udp-out-vrf ]") \ -_(ipsec_gre_add_del_tunnel, \ +_(ipsec_gre_tunnel_add_del, \ "src dst local_sa remote_sa [del]") \ _(ipsec_gre_tunnel_dump, "[sw_if_index ]") \ _(delete_subif," | sw_if_index ") \