[PATCH 6/9] batctl: tcpdump: skip partial line for oversized ICMPv6 errors

Sven Eckelmann <[email protected]> Sun, 05 Jul 2026 19:30:09 +0200
Newsgroups org.open-mesh.lists.batman
Message-ID <[email protected]>
dump_ipv6() prints the "IP6 <src> > <dst> " line prefix before it checks
whether an ICMPv6 error message exceeds IPV6_MIN_MTU. The length check
might just stop the processing and causes some truncated output on stdout.
Which is then also not terminated by a newline.

Move the size check ahead of the printf to avoid this partial line.

Fixes: 35b37756f4a3 ("add IPv6 support to tcpdump parser")
Signed-off-by: Sven Eckelmann <[email protected]>
---
 tcpdump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tcpdump.c b/tcpdump.c
index c532ad1..1094069 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -624,7 +624,6 @@ static void dump_ipv6(unsigned char *packet_buff, ssize_t buff_len,
 		icmphdr = (struct icmp6_hdr *)(packet_buff +
 					       sizeof(struct ip6_hdr));
 
-		printf("%s %s > %s ", ip_string, ipsrc, ipdst);
 		if (icmphdr->icmp6_type < ICMP6_INFOMSG_MASK &&
 		    (size_t)(buff_len) > IPV6_MIN_MTU) {
 			fprintf(stderr,
@@ -633,6 +632,7 @@ static void dump_ipv6(unsigned char *packet_buff, ssize_t buff_len,
 			return;
 		}
 
+		printf("%s %s > %s ", ip_string, ipsrc, ipdst);
 		printf("ICMP6");
 		switch (icmphdr->icmp6_type) {
 		case ICMP6_DST_UNREACH:

-- 
2.47.3