X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fip%2Fping.c;h=f438ce960606ba9aeb27e6ef7426f4274a2e821b;hb=71612d61930e57e7c8ebf9e5647b15a4b23720b2;hp=4131bd710a3f290200e60701166cf7ce44c91623;hpb=864b25d0777d3226f475ef7d0232cacec7127770;p=vpp.git diff --git a/src/vnet/ip/ping.c b/src/vnet/ip/ping.c old mode 100644 new mode 100755 index 4131bd710a3..f438ce96060 --- a/src/vnet/ip/ping.c +++ b/src/vnet/ip/ping.c @@ -18,6 +18,9 @@ #include #include #include +#include + +ping_main_t ping_main; /** * @file @@ -53,8 +56,7 @@ format_icmp_echo_trace (u8 * s, va_list * va) */ static int -signal_ip46_icmp_reply_event (vlib_main_t * vm, - u8 event_type, vlib_buffer_t * b0) +signal_ip46_icmp_reply_event (u8 event_type, vlib_buffer_t * b0) { ping_main_t *pm = &ping_main; u16 net_icmp_id = 0; @@ -84,14 +86,20 @@ signal_ip46_icmp_reply_event (vlib_main_t * vm, return 0; ping_run_t *pr = vec_elt_at_index (pm->ping_runs, p[0]); + vlib_main_t *vm = vlib_mains[pr->cli_thread_index]; if (vlib_buffer_alloc (vm, &bi0_copy, 1) == 1) { - void *dst = vlib_buffer_get_current (vlib_get_buffer (vm, bi0_copy)); + void *dst = vlib_buffer_get_current (vlib_get_buffer (vm, + bi0_copy)); clib_memcpy (dst, vlib_buffer_get_current (b0), b0->current_length); } /* If buffer_alloc failed, bi0_copy == 0 - just signaling an event. */ - - vlib_process_signal_event (vm, pr->cli_process_id, event_type, bi0_copy); + f64 nowts = vlib_time_now (vm); + /* Pass the timestamp to the cli_process thanks to the vnet_buffer unused metadata field */ + clib_memcpy (vnet_buffer + (vlib_get_buffer + (vm, bi0_copy))->unused, &nowts, sizeof (nowts)); + vlib_process_signal_event_mt (vm, pr->cli_process_id, event_type, bi0_copy); return 1; } @@ -116,7 +124,7 @@ ip6_icmp_echo_reply_node_fn (vlib_main_t * vm, bi0 = from[0]; b0 = vlib_get_buffer (vm, bi0); - next0 = signal_ip46_icmp_reply_event (vm, PING_RESPONSE_IP6, b0) ? + next0 = signal_ip46_icmp_reply_event (PING_RESPONSE_IP6, b0) ? ICMP6_ECHO_REPLY_NEXT_DROP : ICMP6_ECHO_REPLY_NEXT_PUNT; if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED)) @@ -174,7 +182,7 @@ ip4_icmp_echo_reply_node_fn (vlib_main_t * vm, bi0 = from[0]; b0 = vlib_get_buffer (vm, bi0); - next0 = signal_ip46_icmp_reply_event (vm, PING_RESPONSE_IP4, b0) ? + next0 = signal_ip46_icmp_reply_event (PING_RESPONSE_IP4, b0) ? ICMP4_ECHO_REPLY_NEXT_DROP : ICMP4_ECHO_REPLY_NEXT_PUNT; if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED)) @@ -497,8 +505,9 @@ print_ip6_icmp_reply (vlib_main_t * vm, u32 bi0) { vlib_buffer_t *b0 = vlib_get_buffer (vm, bi0); icmp6_echo_request_header_t *h0 = vlib_buffer_get_current (b0); - f64 rtt = vlib_time_now (vm) - h0->icmp_echo.time_sent; - + f64 rtt = 0; + clib_memcpy (&rtt, vnet_buffer (b0)->unused, sizeof (rtt)); + rtt -= h0->icmp_echo.time_sent; vlib_cli_output (vm, "%d bytes from %U: icmp_seq=%d ttl=%d time=%.4f ms", clib_host_to_net_u16 (h0->ip6.payload_length), @@ -513,7 +522,9 @@ print_ip4_icmp_reply (vlib_main_t * vm, u32 bi0) { vlib_buffer_t *b0 = vlib_get_buffer (vm, bi0); icmp4_echo_request_header_t *h0 = vlib_buffer_get_current (b0); - f64 rtt = vlib_time_now (vm) - h0->icmp_echo.time_sent; + f64 rtt = 0; + clib_memcpy (&rtt, vnet_buffer (b0)->unused, sizeof (rtt)); + rtt -= h0->icmp_echo.time_sent; u32 rcvd_icmp_len = clib_host_to_net_u16 (h0->ip4.length) - (4 * (0xF & h0->ip4.ip_version_and_header_length)); @@ -565,6 +576,7 @@ run_ping_ip46_address (vlib_main_t * vm, u32 table_id, ip4_address_t * pa4, pool_get (pm->ping_runs, pr); ping_run_index = pr - pm->ping_runs; pr->cli_process_id = curr_proc; + pr->cli_thread_index = vlib_get_thread_index (); pr->icmp_id = icmp_id; hash_set (pm->ping_run_by_icmp_id, icmp_id, ping_run_index); for (i = 1; i <= ping_repeat; i++) @@ -636,6 +648,7 @@ run_ping_ip46_address (vlib_main_t * vm, u32 table_id, ip4_address_t * pa4, i = 1 + ping_repeat; break; } + vec_free (event_data); } } vlib_cli_output (vm, "\n"); @@ -775,7 +788,7 @@ ping_ip_address (vlib_main_t * vm, } else if (unformat (input, "table-id")) { - if (!unformat (input, "du", &table_id)) + if (!unformat (input, "%u", &table_id)) { error = clib_error_return (0, @@ -835,7 +848,7 @@ ping_ip_address (vlib_main_t * vm, run_ping_ip46_address (vm, table_id, ping_ip4 ? &a4 : NULL, ping_ip6 ? &a6 : NULL, sw_if_index, ping_interval, - ping_repeat, ping_burst, data_len, verbose); + ping_repeat, data_len, ping_burst, verbose); done: return error; } @@ -890,6 +903,7 @@ VLIB_CLI_COMMAND (ping_command, static) = " [ipv4 | ipv6 ] [source ]" " [size ] [interval ] [repeat ] [table-id ]" " [verbose]", + .is_mp_safe = 1, }; /* *INDENT-ON* */