From: florian Date: Fri, 18 Apr 2014 16:26:47 +0000 (+0000) Subject: Structure wait_for_reply() loop like traceroute, thereby moving the X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9569ae34933405d3cb49df11d4057f84f4d43b4a;p=openbsd Structure wait_for_reply() loop like traceroute, thereby moving the loop body one indent layer up. OK benno@ --- diff --git a/usr.sbin/traceroute6/traceroute6.c b/usr.sbin/traceroute6/traceroute6.c index 6af5ccf9e12..9e84c840e90 100644 --- a/usr.sbin/traceroute6/traceroute6.c +++ b/usr.sbin/traceroute6/traceroute6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: traceroute6.c,v 1.76 2014/04/18 16:23:00 florian Exp $ */ +/* $OpenBSD: traceroute6.c,v 1.77 2014/04/18 16:26:47 florian Exp $ */ /* $KAME: traceroute6.c,v 1.63 2002/10/24 12:53:25 itojun Exp $ */ /* @@ -713,29 +713,28 @@ main(int argc, char *argv[]) send_probe(++seq, hops, incflag, (struct sockaddr*)&to); while ((cc = wait_for_reply(rcvsock, &rcvmhdr))) { (void) gettimeofday(&t2, NULL); - if ((i = packet_ok(&rcvmhdr, cc, seq, - incflag))) { - if (!IN6_ARE_ADDR_EQUAL(&from.sin6_addr, - &lastaddr)) { - print((struct sockaddr *) - rcvmhdr.msg_name, cc, - rcvpktinfo ? inet_ntop( - AF_INET6, &rcvpktinfo-> - ipi6_addr, hbuf, - sizeof(hbuf)) : "?"); - lastaddr = from.sin6_addr; - } - printf(" %g ms", deltaT(&t1, &t2)); - if (ttl_flag) - printf(" (%u)", rcvhlim); - - /* time exceeded in transit */ - if (i == -1) - break; - icmp6_code(i - 1, &got_there, - &unreachable); - break; + i = packet_ok(&rcvmhdr, cc, seq, incflag); + /* Skip short packet */ + if (i == 0) + continue; + if (!IN6_ARE_ADDR_EQUAL(&from.sin6_addr, + &lastaddr)) { + print((struct sockaddr *) + rcvmhdr.msg_name, cc, + rcvpktinfo ? inet_ntop(AF_INET6, + &rcvpktinfo->ipi6_addr, hbuf, + sizeof(hbuf)) : "?"); + lastaddr = from.sin6_addr; } + printf(" %g ms", deltaT(&t1, &t2)); + if (ttl_flag) + printf(" (%u)", rcvhlim); + + /* time exceeded in transit */ + if (i == -1) + break; + icmp6_code(i - 1, &got_there, &unreachable); + break; } if (cc == 0) { printf(" *");