Skip to content

Commit 2c9ca2e

Browse files
committed
fast_ping: Optimize log output when the kernel does not support IPV6 ping
1 parent 9ee27e7 commit 2c9ca2e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

etc/smartdns/smartdns.conf

-1
Original file line numberDiff line numberDiff line change
@@ -406,4 +406,3 @@ log-level info
406406
# load plugin
407407
# plugin [path/to/file] [args]
408408
# plugin /usr/lib/smartdns/libsmartdns-ui.so --p 8080 -i 0.0.0.0 -r /usr/share/smartdns/wwwroot
409-

src/fast_ping.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,11 @@ static int _fast_ping_sendping_v6(struct ping_host_struct *ping_host)
710710
struct icmp6_hdr *icmp6 = &packet->icmp6;
711711
int len = 0;
712712

713+
if (ping.fd_icmp6 <= 0) {
714+
errno = EADDRNOTAVAIL;
715+
goto errout;
716+
}
717+
713718
ping_host->seq++;
714719
memset(icmp6, 0, sizeof(*icmp6));
715720
icmp6->icmp6_type = ICMP6_ECHO_REQUEST;
@@ -1031,7 +1036,7 @@ static int _fast_ping_create_icmp_sock(FAST_PING_TYPE type)
10311036
}
10321037
bool_print_log = 0;
10331038
}
1034-
tlog(TLOG_ERROR, "create icmp socket failed, %s\n", strerror(errno));
1039+
tlog(TLOG_INFO, "create icmpv6 socket failed, %s\n", strerror(errno));
10351040
goto errout;
10361041
}
10371042
setsockopt(fd, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &on, sizeof(on));

0 commit comments

Comments
 (0)