From: Matt Kimball Date: Tue, 11 Jul 2017 01:01:25 +0000 (-0700) Subject: mtr-packet: report ICMP destination unreachable probes as "no route to host" X-Git-Tag: v0.93~45^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6cc8183d94ca347c0553b8ccb57c04c94f174169;p=thirdparty%2Fmtr.git mtr-packet: report ICMP destination unreachable probes as "no route to host" When an ICMP reply of type destination unreachable is received, report the probe status as "no-route". The exception is the port unreacable subtype of destination unreachable, which may occur normally when using a non-ICMP probe type. --- diff --git a/packet/deconstruct_unix.c b/packet/deconstruct_unix.c index ce889ca..c09dd64 100644 --- a/packet/deconstruct_unix.c +++ b/packet/deconstruct_unix.c @@ -394,6 +394,15 @@ void handle_received_icmp4_packet( handle_inner_ip4_packet(net_state, remote_addr, ICMP_ECHOREPLY, inner_ip, inner_size, timestamp, mpls_count, mpls); + } else { + /* + ICMP_DEST_UNREACH subtypes other than port unreachable + indicate an exceptional condition, and will be reported + as a "no route to host" probe response. + */ + handle_inner_ip4_packet(net_state, remote_addr, + ICMP_DEST_UNREACH, inner_ip, inner_size, + timestamp, mpls_count, mpls); } } } @@ -443,6 +452,10 @@ void handle_received_icmp6_packet( handle_inner_ip6_packet(net_state, remote_addr, ICMP_ECHOREPLY, inner_ip, inner_size, timestamp, mpls_count, mpls); + } else { + handle_inner_ip6_packet(net_state, remote_addr, + ICMP_DEST_UNREACH, inner_ip, inner_size, + timestamp, mpls_count, mpls); } } } diff --git a/packet/probe.c b/packet/probe.c index 34ff368..de85b16 100644 --- a/packet/probe.c +++ b/packet/probe.c @@ -248,6 +248,8 @@ void respond_to_probe( if (icmp_type == ICMP_TIME_EXCEEDED) { result = "ttl-expired"; + } else if (icmp_type == ICMP_DEST_UNREACH) { + result = "no-route"; } else { assert(icmp_type == ICMP_ECHOREPLY); result = "reply"; diff --git a/packet/probe_cygwin.c b/packet/probe_cygwin.c index a37c5c6..c62cee1 100644 --- a/packet/probe_cygwin.c +++ b/packet/probe_cygwin.c @@ -102,14 +102,6 @@ void report_win_error( /* It could be that we got no reply because of timeout */ if (err == IP_REQ_TIMED_OUT || err == IP_SOURCE_QUENCH) { printf("%d no-reply\n", command_token); - } else if (err == IP_DEST_HOST_UNREACHABLE - || err == IP_DEST_PORT_UNREACHABLE - || err == IP_DEST_PROT_UNREACHABLE - || err == IP_DEST_NET_UNREACHABLE - || err == IP_DEST_UNREACHABLE - || err == IP_DEST_NO_ROUTE - || err == IP_BAD_ROUTE || err == IP_BAD_DESTINATION) { - printf("%d no-route\n", command_token); } else if (err == ERROR_INVALID_NETNAME) { printf("%d address-not-available\n", command_token); } else if (err == ERROR_INVALID_PARAMETER) { @@ -186,7 +178,18 @@ void WINAPI on_icmp_reply( icmp_type = ICMP_ECHOREPLY; } else if (reply_status == IP_TTL_EXPIRED_TRANSIT || reply_status == IP_TTL_EXPIRED_REASSEM) { + icmp_type = ICMP_TIME_EXCEEDED; + } else if (reply_status == IP_DEST_HOST_UNREACHABLE + || reply_status == IP_DEST_PORT_UNREACHABLE + || reply_status == IP_DEST_PROT_UNREACHABLE + || reply_status == IP_DEST_NET_UNREACHABLE + || reply_status == IP_DEST_UNREACHABLE + || reply_status == IP_DEST_NO_ROUTE + || reply_status == IP_BAD_ROUTE + || reply_status == IP_BAD_DESTINATION) { + + icmp_type = ICMP_DEST_UNREACH; } if (icmp_type != -1) {