Răsfoiți Sursa

fast_ping: Optimize log output when the kernel does not support IPV6 ping

Nick Peng 1 an în urmă
părinte
comite
2c9ca2e5d5
2 a modificat fișierele cu 6 adăugiri și 2 ștergeri
  1. 0 1
      etc/smartdns/smartdns.conf
  2. 6 1
      src/fast_ping.c

+ 0 - 1
etc/smartdns/smartdns.conf

@@ -406,4 +406,3 @@ log-level info
 # load plugin
 # plugin [path/to/file] [args]
 # plugin /usr/lib/smartdns/libsmartdns-ui.so --p 8080 -i 0.0.0.0 -r /usr/share/smartdns/wwwroot
-

+ 6 - 1
src/fast_ping.c

@@ -710,6 +710,11 @@ static int _fast_ping_sendping_v6(struct ping_host_struct *ping_host)
 	struct icmp6_hdr *icmp6 = &packet->icmp6;
 	int len = 0;
 
+	if (ping.fd_icmp6 <= 0) {
+		errno = EADDRNOTAVAIL;
+		goto errout;
+	}
+
 	ping_host->seq++;
 	memset(icmp6, 0, sizeof(*icmp6));
 	icmp6->icmp6_type = ICMP6_ECHO_REQUEST;
@@ -1031,7 +1036,7 @@ static int _fast_ping_create_icmp_sock(FAST_PING_TYPE type)
 				}
 				bool_print_log = 0;
 			}
-			tlog(TLOG_ERROR, "create icmp socket failed, %s\n", strerror(errno));
+			tlog(TLOG_INFO, "create icmpv6 socket failed, %s\n", strerror(errno));
 			goto errout;
 		}
 		setsockopt(fd, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &on, sizeof(on));