From 51dbbaa7b54d795be777c489586fdd2ebd1ef787 Mon Sep 17 00:00:00 2001 From: Nick Peng Date: Fri, 16 Feb 2024 16:13:26 +0800 Subject: [PATCH] fast_ping: Optimize log output when the kernel does not support IPV6 ping --- src/fast_ping.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/fast_ping.c b/src/fast_ping.c index d111cae214..c103f0f827 100644 --- a/src/fast_ping.c +++ b/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));