]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
net: implement addrcmp for AF_UNSPEC 534/head
authorJames Lu <james@overdrivenetworks.com>
Sat, 14 Jun 2025 02:06:21 +0000 (19:06 -0700)
committerJames Lu <james@overdrivenetworks.com>
Sat, 14 Jun 2025 02:24:10 +0000 (19:24 -0700)
When mtr is compiled with IPv6 enabled, the GTK frontend sets the address family to AF_UNSPEC when changing destinations. However, addrcomp does not support this AF type, which causes all comparisons to not match. For the GTK frontend, this leads to a cascading failure when setting the destination to a host that does not resolve:

1. Upon setting ctl->af = AF_UNSPEC, net_max() will report that all hops have data, as no hops can match the previous remote address.
2. The GTK frontend tries to render a row for every hop, including its IP / hostname.
3. The guard in the GTK frontend to avoid looking up unknown addresses also fails, causing mtr to flood DNS packets and effectively hang.

Fixes https://github.com/traviscross/mtr/issues/533

ui/net.c

index 4df7b74276cd53188ff37b7f24e25e3c13225b45..ce2c2c98b17c82efd8a029dec57ec93334d2971e 100644 (file)
--- a/ui/net.c
+++ b/ui/net.c
@@ -895,6 +895,7 @@ int addrcmp(
         break;
 #ifdef ENABLE_IPV6
     case AF_INET6:
+    case AF_UNSPEC:
         rc = memcmp(a, b, sizeof(struct in6_addr));
         break;
 #endif