#include <vnet/fib/ip6_fib.h>
#include <vnet/fib/ip4_fib.h>
#include <vnet/fib/fib_entry.h>
+#include <vlib/vlib.h>
+
+ping_main_t ping_main;
/**
* @file
*/
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;
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;
}
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))
.format_trace = format_icmp_echo_trace,
.n_next_nodes = ICMP6_ECHO_REPLY_N_NEXT,
.next_nodes = {
- [ICMP6_ECHO_REPLY_NEXT_DROP] = "error-drop",
- [ICMP6_ECHO_REPLY_NEXT_PUNT] = "error-punt",
+ [ICMP6_ECHO_REPLY_NEXT_DROP] = "ip6-drop",
+ [ICMP6_ECHO_REPLY_NEXT_PUNT] = "ip6-punt",
},
};
/* *INDENT-ON* */
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))
.format_trace = format_icmp_echo_trace,
.n_next_nodes = ICMP4_ECHO_REPLY_N_NEXT,
.next_nodes = {
- [ICMP4_ECHO_REPLY_NEXT_DROP] = "error-drop",
- [ICMP4_ECHO_REPLY_NEXT_PUNT] = "error-punt",
+ [ICMP4_ECHO_REPLY_NEXT_DROP] = "ip4-drop",
+ [ICMP4_ECHO_REPLY_NEXT_PUNT] = "ip4-punt",
},
};
/* *INDENT-ON* */
h0->ip6.src_address = *pa6;
/* Fill in the correct source now */
- ip6_address_t *a = ip6_interface_first_address (im, sw_if_index);
- if (!a)
+ if (!ip6_src_address_for_packet (&im->lookup_main,
+ sw_if_index,
+ &h0->ip6.dst_address,
+ &h0->ip6.src_address))
{
vlib_buffer_free (vm, &bi0, 1);
return SEND_PING_NO_SRC_ADDRESS;
}
- h0->ip6.src_address = a[0];
/* Fill in icmp fields */
h0->icmp.type = ICMP6_echo_request;
{
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),
{
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));
pool_get (pm->ping_runs, pr);
ping_run_index = pr - pm->ping_runs;
pr->cli_process_id = curr_proc;
+ pr->cli_thread_index = vm->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++)
i = 1 + ping_repeat;
break;
}
+ vec_free (event_data);
}
}
vlib_cli_output (vm, "\n");
}
else if (unformat (input, "table-id"))
{
- if (!unformat (input, "du", &table_id))
+ if (!unformat (input, "%u", &table_id))
{
error =
clib_error_return (0,
" [ipv4 <ip4-addr> | ipv6 <ip6-addr>] [source <interface>]"
" [size <pktsize>] [interval <sec>] [repeat <cnt>] [table-id <id>]"
" [verbose]",
+ .is_mp_safe = 1,
};
/* *INDENT-ON* */