X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvat%2Fapi_format.c;h=0e2fec32218afe9e0aedd4baa9b381966efe4a65;hb=712dde9cec41beef3b4252a8cf14f98b674a8d79;hp=cef60e05725968c698f55293f955062f5589cbf9;hpb=7c44d78ef2e7bf0c8714be4184511ed8f23ff239;p=vpp.git diff --git a/src/vat/api_format.c b/src/vat/api_format.c index cef60e05725..0e2fec32218 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -712,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) { @@ -5030,8 +5049,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); @@ -5048,8 +5067,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; @@ -5550,7 +5569,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) \ @@ -15028,13 +15047,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) @@ -15043,15 +15064,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)) ; @@ -15093,65 +15118,123 @@ api_ipsec_tunnel_if_add_del (vat_main_t * vam) } } - M (IPSEC_TUNNEL_IF_ADD_DEL, mp); + if (count > 1) + { + /* Turn on async mode */ + vam->async_mode = 1; + vam->async_errors = 0; + before = vat_time_now (vam); + } - mp->is_add = is_add; - mp->esn = esn; - mp->anti_replay = anti_replay; + for (jj = 0; jj < count; jj++) + { + M (IPSEC_TUNNEL_IF_ADD_DEL, mp); - clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t)); - clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t)); + mp->is_add = is_add; + mp->esn = esn; + mp->anti_replay = anti_replay; - mp->local_spi = htonl (local_spi); - mp->remote_spi = htonl (remote_spi); - mp->crypto_alg = (u8) crypto_alg; + if (jj > 0) + increment_vl_address (&remote_ip); - 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); - } + clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip)); + clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip)); - 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); - } + mp->local_spi = htonl (local_spi + jj); + mp->remote_spi = htonl (remote_spi + jj); + mp->crypto_alg = (u8) crypto_alg; + + 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); + } + + 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); + } - mp->integ_alg = (u8) integ_alg; + mp->integ_alg = (u8) integ_alg; - 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); + 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); + } + + 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 (renumber) + { + mp->renumber = renumber; + mp->show_instance = ntohl (instance); + } + S (mp); } - mp->remote_integ_key_len = 0; - if (rik) + /* When testing multiple add/del ops, use a control-ping to sync */ + if (count > 1) { - 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); - } + vl_api_control_ping_t *mp_ping; + f64 after; + f64 timeout; + + /* Shut off async mode */ + vam->async_mode = 0; + + MPING (CONTROL_PING, mp_ping); + S (mp_ping); + + timeout = vat_time_now (vam) + 1.0; + while (vat_time_now (vam) < timeout) + if (vam->result_ready == 1) + goto out; + vam->retval = -99; + + out: + if (vam->retval == -99) + errmsg ("timeout"); + + if (vam->async_errors > 0) + { + errmsg ("%d asynchronous errors", vam->async_errors); + vam->retval = -98; + } + vam->async_errors = 0; + after = vat_time_now (vam); - if (renumber) + /* slim chance, but we might have eaten SIGTERM on the first iteration */ + if (jj > 0) + count = jj; + + print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec", + count, after - before, count / (after - before)); + } + else { - mp->renumber = renumber; - mp->show_instance = ntohl (instance); + /* Wait for a reply... */ + W (ret); + return ret; } - S (mp); - W (ret); return ret; } @@ -15229,8 +15312,7 @@ static void vl_api_ipsec_sa_details_t_handler_json ntohl (mp->entry.integrity_algorithm)); flags = ntohl (mp->entry.flags); vat_json_object_add_uint (node, "use_esn", - ! !(flags & - IPSEC_API_SAD_FLAG_USE_EXTENDED_SEQ_NUM)); + ! !(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", @@ -20345,14 +20427,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; @@ -20362,9 +20444,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; @@ -20375,12 +20459,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); @@ -20434,10 +20518,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 @@ -20455,13 +20550,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 @@ -22656,7 +22752,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 ") \