Bug 3745

Summary: Wrong sender address for ping to multicast
Product: Busybox Reporter: linus.luessing
Component: NetworkingAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Host: Target:
Build:

Description linus.luessing 2011-05-17 21:29:28 UTC
With a full-blown ping6 the output looks like the following:
----
$ ping6 ff02::1%br0
PING ff02::1%br0(ff02::1) 56 data bytes
64 bytes from fe80::21e:68ff:fee2:da1a: icmp_seq=1 ttl=255 time=0.036 ms
64 bytes from fe80::222:b0ff:fe98:87fa: icmp_seq=1 ttl=64 time=114 ms (DUP!)
----

However, with busybox the from-address is wrongly displayed as the multicast address:
----
$ ping6 ff02::1%br-lan
PING ff02::1%br-lan (ff02::1): 56 data bytes
64 bytes from ff02::1: seq=0 ttl=64 time=2.575 ms
64 bytes from ff02::1: seq=0 ttl=64 time=84.320 ms (DUP!)
----

I usually like to use ping6 ff02::1%ifname to find the addresses of the devices in my network again, when I forgot about them or don't want to look them up :).

So basically the parameters given to unpack4() and unpack6() look wrong:
http://git.busybox.net/busybox/tree/networking/ping.c#n618
http://git.busybox.net/busybox/tree/networking/ping.c#n647

Cheers, Linus
Comment 1 Denys Vlasenko 2011-09-11 18:29:21 UTC
Committed the below patch as commit 5126cf9a15f9e5c3986be0fc2743b63adcc6b1fb

Please confirm that current git works for you. If it doesn't, reopen this bug.


diff -d -urpN busybox.4/networking/ping.c busybox.5/networking/ping.c
--- busybox.4/networking/ping.c	2011-09-11 16:45:32.268689149 +0200
+++ busybox.5/networking/ping.c	2011-09-11 20:24:11.839444987 +0200
@@ -613,7 +613,7 @@ static void unpack4(char *buf, int sz, s
 	}
 }
 #if ENABLE_PING6
-static void unpack6(char *packet, int sz, /*struct sockaddr_in6 *from,*/ int hoplimit)
+static void unpack6(char *packet, int sz, struct sockaddr_in6 *from, int hoplimit)
 {
 	struct icmp6_hdr *icmppkt;
 	char buf[INET6_ADDRSTRLEN];
@@ -633,7 +633,7 @@ static void unpack6(char *packet, int sz
 		if (sz >= sizeof(struct icmp6_hdr) + sizeof(uint32_t))
 			tp = (uint32_t *) &icmppkt->icmp6_data8[4];
 		unpack_tail(sz, tp,
-			inet_ntop(AF_INET6, &pingaddr.sin6.sin6_addr,
+			inet_ntop(AF_INET6, &from->sin6_addr,
 					buf, sizeof(buf)),
 			recv_seq, hoplimit);
 	} else if (icmppkt->icmp6_type != ICMP6_ECHO_REQUEST) {
@@ -783,7 +783,7 @@ static void ping6(len_and_sockaddr *lsa)
 				move_from_unaligned_int(hoplimit, CMSG_DATA(mp));
 			}
 		}
-		unpack6(G.rcv_packet, c, /*&from,*/ hoplimit);
+		unpack6(G.rcv_packet, c, &from, hoplimit);
 		if (pingcount && nreceived >= pingcount)
 			break;
 	}