[PATCH 04/11] batctl: ping/traceroute: don't restart RTT timer on stray replies
Sven Eckelmann <[email protected]> Tue, 07 Jul 2026 20:46:46 +0200
| Newsgroups | org.open-mesh.lists.batman |
|---|---|
| Message-ID | <[email protected]> |
When a reply with an unexpected seqno arrives (for example a late answer to
an already timed out request), ping and traceroute jump back to read_packet
to keep waiting for the real answer. The jump target also re-runs
start_timer(), so the reported round trip time only measures from the
arrival of the stray packet instead of from the transmission of the
request, underreporting the RTT and polluting the min/avg/max statistics.
Start the timer (and initialize the timeout in traceroute) once per
transmitted request. At the same time, let select in icmp_interface_read()
the wait time instead of restarting it each time.
Fixes: 2ecb2c8b060b ("batctl: tr / ping - ignore packets with wrong sequence number")
Signed-off-by: Sven Eckelmann <[email protected]>
---
ping.c | 2 +-
traceroute.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/ping.c b/ping.c
index 5eafdad..fcb8d5e 100644
--- a/ping.c
+++ b/ping.c
@@ -215,9 +215,9 @@ static int ping(struct state *state, int argc, char **argv)
packets_out++;
-read_packet:
start_timer();
+read_packet:
read_len = icmp_interface_read((struct batadv_icmp_header *)&icmp_packet_in,
packet_len, &tv);
diff --git a/traceroute.c b/traceroute.c
index 94443d7..975c9ff 100644
--- a/traceroute.c
+++ b/traceroute.c
@@ -142,12 +142,12 @@ static int traceroute(struct state *state, int argc, char **argv)
continue;
}
-read_packet:
start_timer();
tv.tv_sec = 2;
tv.tv_usec = 0;
+read_packet:
read_len = icmp_interface_read((struct batadv_icmp_header *)&icmp_packet_in,
sizeof(icmp_packet_in), &tv);
if (read_len <= 0)
--
2.47.3