Skip to content

Commit

Permalink
fast_ping: Optimize log output when the kernel does not support IPV6 …
Browse files Browse the repository at this point in the history
…ping
  • Loading branch information
pymumu committed Feb 16, 2024
1 parent 9ee27e7 commit 51dbbaa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/fast_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 51dbbaa

Please sign in to comment.