[PATCH 03/11] batctl: ping: count sent and not received pings

Sven Eckelmann <[email protected]> Tue, 07 Jul 2026 20:46:45 +0200
Newsgroups org.open-mesh.lists.batman
Message-ID <[email protected]>
packets_out was increased whenever a read of a packet was started. But the
read was repeated whenever the sequence number of a received packet was
incorrect. The packets_out would then be higher then the actual sent ones.

Fixes: 2474249a6312 ("[batctl] ping utility updated to latest batman adv")
Fixes: 2ecb2c8b060b ("batctl: tr / ping - ignore packets with wrong sequence number")
Signed-off-by: Sven Eckelmann <[email protected]>
---
 ping.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ping.c b/ping.c
index 9eb73c1..5eafdad 100644
--- a/ping.c
+++ b/ping.c
@@ -213,6 +213,8 @@ static int ping(struct state *state, int argc, char **argv)
 			goto sleep;
 		}
 
+		packets_out++;
+
 read_packet:
 		start_timer();
 
@@ -222,8 +224,6 @@ static int ping(struct state *state, int argc, char **argv)
 		if (is_aborted)
 			break;
 
-		packets_out++;
-
 		if (read_len == 0) {
 			printf("Reply from host %s timed out\n", dst_string);
 			goto sleep;

-- 
2.47.3