From 0934883fe1455e9e63ad978451bbeba3d37cf9b1 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Wed, 17 Jul 2019 20:17:56 +0100 Subject: [PATCH] mtr-packet: make address-not-available errors less likely 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 Reproeuced-by: Jarred Trainor Signed-off-by: Sami Kerola && --- packet/probe_unix.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packet/probe_unix.c b/packet/probe_unix.c index fec3d47..ac630c7 100644 --- a/packet/probe_unix.c +++ b/packet/probe_unix.c @@ -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) { -- 2.47.2