From 9a155c269dd0284dde283e75939ac9713b1f34e8 Mon Sep 17 00:00:00 2001 From: dmiller Date: Mon, 15 Sep 2014 17:27:10 +0000 Subject: [PATCH] Actually use reply ttl for distance guessing in traceroute This chunk of code in read_replies was generating valgrind errors because reply.ttl was uninitialized: if (host->state == HostState::COUNTING_DOWN) { /* If this probe was past the target, skip ahead to what we think the actual distance is. */ int distance = get_initial_ttl_guess(reply.ttl) - reply.ttl + 1; if (distance > 0 && distance < host->current_ttl) host->current_ttl = MIN(distance, MAX_TTL); } My compiler was setting the initial value to 0, which meant that distance was always 33, clearly wrong. Setting reply.ttl in decode_reply silences the error and causes distance to be more accurate. --- traceroute.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/traceroute.cc b/traceroute.cc index d0710e5f9..3508266af 100644 --- a/traceroute.cc +++ b/traceroute.cc @@ -1207,6 +1207,7 @@ static bool decode_reply(const void *ip, unsigned int len, Reply *reply) { return false; reply->from_addr = hdr.src; + reply->ttl = hdr.ttl; if (hdr.version == 4 && hdr.proto == IPPROTO_ICMP) { /* ICMP responses comprise all the TTL exceeded messages we expect from all