Package: mtr
Version: 0.85-3
Followup-For: Bug #321144

With the attached patch, the mtr compiled for IPv6 support fallbacks to IPv4
resolution when IPV6 isn't available on the host machine (the kernel lacks
IPv6 or have it disabled).

-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1, 
'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.2.3 (SMP w/4 CPU cores; PREEMPT)
Locale: LANG=pt_BR.UTF-8, LC_CTYPE=pt_BR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Init: systemd (via /run/systemd/system)

Versions of packages mtr depends on:
ii  libatk1.0-0          2.18.0-1
ii  libc6                2.19-22
ii  libcairo2            1.14.2-2
ii  libfontconfig1       2.11.0-6.3
ii  libfreetype6         2.6-2
ii  libgdk-pixbuf2.0-0   2.32.1-1
ii  libglib2.0-0         2.46.1-1
ii  libgtk2.0-0          2.24.28-1
ii  libncurses5          6.0+20150810-1
ii  libpango-1.0-0       1.38.0-3
ii  libpangocairo-1.0-0  1.38.0-3
ii  libpangoft2-1.0-0    1.38.0-3
ii  libtinfo5            6.0+20150810-1

mtr recommends no packages.

mtr suggests no packages.

-- no debconf information
diff -pru mtr-0.85/dns.c mtr-0.85-new/dns.c
--- mtr-0.85/dns.c	2013-06-26 05:25:56.000000000 -0300
+++ mtr-0.85-new/dns.c	2015-10-26 12:07:49.843979465 -0200
@@ -532,7 +532,6 @@ void dns_open(void)
     fprintf(stderr,
             "Unable to allocate IPv6 socket for nameserver communication: %s\n",
 	    strerror(errno));
-    exit(-1);
   }
 #endif
   option = 1;
@@ -543,7 +542,7 @@ void dns_open(void)
     exit(-1);
   }
 #ifdef ENABLE_IPV6
-  if (setsockopt(resfd6,SOL_SOCKET,SO_BROADCAST,(char *)&option,sizeof(option))) {
+  if (resfd6 != -1 && setsockopt(resfd6,SOL_SOCKET,SO_BROADCAST,(char *)&option,sizeof(option))) {
     fprintf(stderr,
             "Unable to setsockopt() on IPv6 nameserver communication socket: %s\n",
 	    strerror(errno));
@@ -936,7 +935,7 @@ void dorequest(char *s,int type,word id)
   for (i = 0;i < NSCOUNT6;i++) {
     if (!NSSOCKADDR6(i))
       continue;
-    if (NSSOCKADDR6(i)->sin6_family == AF_INET6)
+    if (NSSOCKADDR6(i)->sin6_family == AF_INET6 && resfd6 != -1)
       (void)sendto(resfd6,buf,r,0,(struct sockaddr *) NSSOCKADDR6(i),
 		   sizeof(struct sockaddr_in6));
   }
Somente em mtr-0.85: dns.o
Somente em mtr-0.85: getopt1.o
Somente em mtr-0.85: getopt.o
diff -pru mtr-0.85/gtk.c mtr-0.85-new/gtk.c
--- mtr-0.85/gtk.c	2013-04-29 15:22:05.000000000 -0300
+++ mtr-0.85-new/gtk.c	2015-10-26 12:48:57.651852406 -0200
@@ -609,14 +609,17 @@ gboolean gtk_dns_data6(UNUSED GIOChannel
 void gtk_loop(void) 
 {
   GIOChannel *net_iochannel, *dns_iochannel;
-
+  int fd = -1;
   gtk_add_ping_timeout ();
   
   net_iochannel = g_io_channel_unix_new(net_waitfd());
   g_io_add_watch(net_iochannel, G_IO_IN, gtk_net_data, NULL);
 #ifdef ENABLE_IPV6
-  dns_iochannel = g_io_channel_unix_new(dns_waitfd6());
-  g_io_add_watch(dns_iochannel, G_IO_IN, gtk_dns_data6, NULL);
+  fd = dns_waitfd6();
+  if (fd != -1) {
+     dns_iochannel = g_io_channel_unix_new(fd);
+     g_io_add_watch(dns_iochannel, G_IO_IN, gtk_dns_data6, NULL);
+  }
 #endif
   dns_iochannel = g_io_channel_unix_new(dns_waitfd());
   g_io_add_watch(dns_iochannel, G_IO_IN, gtk_dns_data, NULL);
diff -pru mtr-0.85/select.c mtr-0.85-new/select.c
--- mtr-0.85/select.c	2013-04-29 15:22:05.000000000 -0300
+++ mtr-0.85-new/select.c	2015-10-26 12:59:22.511668698 -0200
@@ -82,17 +82,19 @@ void select_loop(void) {
 #ifdef ENABLE_IPV6
     if (dns) {
       dnsfd6 = dns_waitfd6();
-      FD_SET(dnsfd6, &readfd);
-      if(dnsfd6 >= maxfd) maxfd = dnsfd6 + 1;
+      if (dnsfd6 != -1) {
+          FD_SET(dnsfd6, &readfd);
+          if(dnsfd6 >= maxfd) maxfd = dnsfd6 + 1;
+      }
     } else
-      dnsfd6 = 0;
+      dnsfd6 = -1;
 #endif
     if (dns) {
       dnsfd = dns_waitfd();
       FD_SET(dnsfd, &readfd);
       if(dnsfd >= maxfd) maxfd = dnsfd + 1;
     } else
-      dnsfd = 0;
+      dnsfd = -1;
 
     netfd = net_waitfd();
     FD_SET(netfd, &readfd);

Reply via email to