[PATCH 06/28] batctl: traceroute: handle fast replies
Sven Eckelmann <[email protected]> Sun, 21 Jun 2026 16:23:56 +0200
| Newsgroups | org.open-mesh.lists.batman |
|---|---|
| Message-ID | <[email protected]> |
If a reply for a traceroute is received faster than the CLOCK_MONOTONIC
precision or (in the rather unlikely scenario) the double precision,
time_delta[i] would be 0. In this case, the packet would be counted as
lost. Introduce a new array "received" to only track whether the packet was
received or not.
Fixes: 0641511400dc ("batctl: traceroute - use all received packets to retrieve neighbor mac")
Signed-off-by: Sven Eckelmann <[email protected]>
---
traceroute.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/traceroute.c b/traceroute.c
index 8f23128..d9db618 100644
--- a/traceroute.c
+++ b/traceroute.c
@@ -42,6 +42,7 @@ static int traceroute(struct state *state, int argc, char **argv)
struct batadv_icmp_packet icmp_packet_in;
struct ether_addr *dst_mac = NULL;
double time_delta[NUM_PACKETS];
+ uint8_t received[NUM_PACKETS];
int disable_translate_mac = 0;
int read_opt = USE_BAT_HOSTS;
struct bat_host *bat_host;
@@ -125,6 +126,7 @@ static int traceroute(struct state *state, int argc, char **argv)
for (i = 0; i < NUM_PACKETS; i++) {
icmp_packet_out.seqno = htons(++seq_counter);
time_delta[i] = 0.0;
+ received[i] = 0;
res = icmp_interface_write(state,
(struct batadv_icmp_header *)&icmp_packet_out,
@@ -162,6 +164,7 @@ static int traceroute(struct state *state, int argc, char **argv)
/* fall through */
case BATADV_TTL_EXCEEDED:
time_delta[i] = end_timer();
+ received[i] = 1;
if (!return_mac) {
return_mac = ether_ntoa_long((struct ether_addr *)&icmp_packet_in.orig);
@@ -195,7 +198,7 @@ static int traceroute(struct state *state, int argc, char **argv)
bat_host->name, return_mac);
for (i = 0; i < NUM_PACKETS; i++) {
- if (time_delta[i])
+ if (received[i])
printf(" %.3f ms", time_delta[i]);
else
printf(" *");
--
2.47.3