From b9429e04d2be2fdd8a096fcf92c65606bea7395c Mon Sep 17 00:00:00 2001 From: Nick Peng Date: Sun, 20 Nov 2022 11:43:59 +0800 Subject: [PATCH] fast_ping: make debug log happy --- src/fast_ping.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/fast_ping.c b/src/fast_ping.c index 5e7c810..d371799 100644 --- a/src/fast_ping.c +++ b/src/fast_ping.c @@ -1279,7 +1279,7 @@ static struct fast_ping_packet *_fast_ping_icmp6_packet(struct ping_host_struct packet->ttl = hops; if (icmp6->icmp6_type != ICMP6_ECHO_REPLY) { - tlog(TLOG_DEBUG, "icmp6 type faild, %d:%d", icmp6->icmp6_type, ICMP6_ECHO_REPLY); + errno = ENETUNREACH; return NULL; } @@ -1320,7 +1320,7 @@ static struct fast_ping_packet *_fast_ping_icmp_packet(struct ping_host_struct * } if (icmp->icmp_type != ICMP_ECHOREPLY) { - tlog(TLOG_DEBUG, "icmp type faild, %d:%d", icmp->icmp_type, ICMP_ECHOREPLY); + errno = ENETUNREACH; return NULL; } @@ -1402,6 +1402,10 @@ static int _fast_ping_process_icmp(struct ping_host_struct *ping_host, struct ti packet = _fast_ping_recv_packet(ping_host, &msg, inpacket, len, now); if (packet == NULL) { char name[PING_MAX_HOSTLEN]; + if (errno == ENETUNREACH) { + goto errout; + } + tlog(TLOG_DEBUG, "recv ping packet from %s failed.", gethost_by_addr(name, sizeof(name), (struct sockaddr *)&from)); goto errout;