]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
mtr-packet: report ICMP destination unreachable probes as "no route to host"
authorMatt Kimball <matt.kimball@gmail.com>
Tue, 11 Jul 2017 01:01:25 +0000 (18:01 -0700)
committerMatt Kimball <matt.kimball@gmail.com>
Tue, 11 Jul 2017 20:49:08 +0000 (13:49 -0700)
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.

packet/deconstruct_unix.c
packet/probe.c
packet/probe_cygwin.c

index ce889ca4add8fb54950f5139181374f2d4c8595d..c09dd6440c804c26791dae6f2364c88069bf9aac 100644 (file)
@@ -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);
         }
     }
 }
index 34ff368467f78722e8bcfa06ecbc3da98356bab7..de85b161c01f61c7d543c6c8b500a9113d8a0d7c 100644 (file)
@@ -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";
index a37c5c6a0e3bf6880b2b7ed43516ec2e46e2db9d..c62cee118bad3a892b50d36af471b7f1082500a6 100644 (file)
@@ -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) {