[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [PATCH] - Fixes traceroute in presence of external ICMP traffic
From:       "Michael Birmingham" <michael.birmingham () cantab ! net>
Date:       2011-04-19 15:39:07
Message-ID: 48701.10.0.7.178.1303227547.squirrel () webmail ! cantab ! net
[Download RAW message or body]

Package: busybox
Version: v1.18.4
Severity: wishlist

Attached is a patch to fix traceroute (when using ICMP packets) in the
presence of other ICMP traffic. This removes the problem where during the
time we wait to declare a target as unresponsive we receive an unrelated
ICMP packet. If there is enough traffic, this can make traceroute hang as
it never declares the target as unresponsive.

Could you please consider taking this patch into the busybox source?

Thanks,
Mike
["traceroutepatch.patch" (application/octet-stream)]

diff --git a/networking/traceroute.c b/networking/traceroute.c
index 96f9d34..0f2db40 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -398,14 +398,17 @@ static len_and_sockaddr* dup_sockaddr(const len_and_sockaddr *lsa)
 
 
 static int
-wait_for_reply(len_and_sockaddr *from_lsa, struct sockaddr *to)
+wait_for_reply(len_and_sockaddr *from_lsa, struct sockaddr *to, unsigned t1)
 {
 	struct pollfd pfd[1];
+	signed delta_us = t1 - monotonic_us() + waittime * 1000000;
 	int read_len = 0;
 
 	pfd[0].fd = rcvsock;
 	pfd[0].events = POLLIN;
-	if (safe_poll(pfd, 1, waittime * 1000) > 0) {
+	if ((delta_us > 0)
+	 && (safe_poll(pfd, 1, delta_us / 1000) > 0)
+	) {
 		read_len = recv_from_to(rcvsock,
 				recv_pkt, sizeof(recv_pkt),
 				/*flags:*/ 0,
@@ -1120,7 +1123,7 @@ common_traceroute_main(int op, char **argv)
 			send_probe(++seq, ttl);
 
 			first = 0;
-			while ((read_len = wait_for_reply(from_lsa, to)) != 0) {
+			while ((read_len = wait_for_reply(from_lsa, to, t1)) != 0) {
 				t2 = monotonic_us();
 				i = packet_ok(read_len, from_lsa, to, seq);
 				/* Skip short packet */


_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic