]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
mtr-packet: make address-not-available errors less likely 306/head
authorSami Kerola <kerolasa@iki.fi>
Wed, 17 Jul 2019 19:17:56 +0000 (20:17 +0100)
committerSami Kerola <kerolasa@iki.fi>
Wed, 17 Jul 2019 19:17:56 +0000 (20:17 +0100)
Use MIN_PORT to MAX_PORT port range to avoid getting EADDRNOTAVAIL caused by
sockets in FIN-WAIT-1 state.  This issue is easy to reproduce with following
loop (as root).

    src="$(ip route | awk '/default/ {print $9}')"
    while true; do
      echo "6000 send-probe ip-4 1.1.1.1 local-ip-4 $src port 443 protocol tcp" |
      ./mtr-packet
    done | head -n 10
    6000 reply ip-4 1.1.1.1 round-trip-time 11306
    6000 address-not-available
    6000 address-not-available
    [...]

Reported-by: Scott Pearson <scott@cloudflare.com>
Reproeuced-by: Jarred Trainor <jarred@cloudflare.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi> && <kerolasa@cloudflare.com>
packet/probe_unix.c

index fec3d472c76dc087fb5c65a75e643bea36b25cab..ac630c7a8c50459a963011c25d72909ec2f7eb19 100644 (file)
@@ -583,8 +583,11 @@ void send_probe(
 
         if ((param->protocol != IPPROTO_TCP) && 
             (param->protocol != IPPROTO_SCTP)) break; // no retry if not TCP/SCTP
-        if (errno != EADDRINUSE) break; // no retry if not addrinuse.
-               
+
+        if (errno != EADDRINUSE && errno != EADDRNOTAVAIL) {
+            break; // no retry
+        }
+
        probe->sequence = net_state->platform.next_sequence++;
                
                if (net_state->platform.next_sequence > MAX_PORT) {