aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/vnet/ip/ping.c38
-rw-r--r--src/vnet/ip/ping.h15
2 files changed, 39 insertions, 14 deletions
diff --git a/src/vnet/ip/ping.c b/src/vnet/ip/ping.c
index 096b2ebfbda..029e06c5e51 100755
--- a/src/vnet/ip/ping.c
+++ b/src/vnet/ip/ping.c
@@ -46,6 +46,21 @@ format_icmp_echo_trace (u8 * s, va_list * va)
return s;
}
+static u8 *
+format_ip46_ping_result (u8 * s, va_list * args)
+{
+ send_ip46_ping_result_t res = va_arg (*args, send_ip46_ping_result_t);
+
+ switch (res)
+ {
+#define _(v, n) case SEND_PING_##v: s = format(s, "%s", n);
+ foreach_ip46_ping_result
+#undef _
+ }
+
+ return (s);
+}
+
/*
* If we can find the ping run by an ICMP ID, then we send the signal
* to the CLI process referenced by that ping run, alongside with
@@ -582,25 +597,30 @@ run_ping_ip46_address (vlib_main_t * vm, u32 table_id, ip4_address_t * pa4,
hash_set (pm->ping_run_by_icmp_id, icmp_id, ping_run_index);
for (i = 1; i <= ping_repeat; i++)
{
+ send_ip46_ping_result_t res = SEND_PING_OK;
f64 sleep_interval;
f64 time_ping_sent = vlib_time_now (vm);
/* Reset pr: running ping in other process could have changed pm->ping_runs */
pr = vec_elt_at_index (pm->ping_runs, ping_run_index);
pr->curr_seq = i;
- if (pa6 &&
- (SEND_PING_OK ==
- send_ip6_ping (vm, ping_main.ip6_main, table_id, pa6, sw_if_index,
- i, icmp_id, data_len, ping_burst, verbose)))
+ if (pa6)
{
- n_requests += ping_burst;
+ res = send_ip6_ping (vm, ping_main.ip6_main, table_id,
+ pa6, sw_if_index, i, icmp_id,
+ data_len, ping_burst, verbose);
}
- if (pa4 &&
- (SEND_PING_OK ==
- send_ip4_ping (vm, ping_main.ip4_main, table_id, pa4, sw_if_index,
- i, icmp_id, data_len, ping_burst, verbose)))
+ if (pa4)
+ {
+ res = send_ip4_ping (vm, ping_main.ip4_main, table_id, pa4,
+ sw_if_index, i, icmp_id, data_len,
+ ping_burst, verbose);
+ }
+ if (SEND_PING_OK == res)
{
n_requests += ping_burst;
}
+ else
+ vlib_cli_output (vm, "Failed: %U", format_ip46_ping_result, res);
while ((i <= ping_repeat)
&&
((sleep_interval =
diff --git a/src/vnet/ip/ping.h b/src/vnet/ip/ping.h
index 3f7488fbeac..442ba732dda 100644
--- a/src/vnet/ip/ping.h
+++ b/src/vnet/ip/ping.h
@@ -26,13 +26,18 @@ typedef enum
PING_RESPONSE_IP4,
} ping_response_type_t;
+#define foreach_ip46_ping_result \
+ _ (OK, "OK") \
+ _ (ALLOC_FAIL, "packet allocation failed") \
+ _ (NO_INTERFACE, "no egress interface") \
+ _ (NO_TABLE, "no IPv6 Table for lookup") \
+ _ (NO_SRC_ADDRESS, "no source address for egress interface") \
+
typedef enum
{
- SEND_PING_OK = 0,
- SEND_PING_ALLOC_FAIL,
- SEND_PING_NO_INTERFACE,
- SEND_PING_NO_TABLE,
- SEND_PING_NO_SRC_ADDRESS,
+#define _(v, s) SEND_PING_##v,
+ foreach_ip46_ping_result
+#undef _
} send_ip46_ping_result_t;
/*