From a7cffe03b548dff6e6702da852f723da7b4f4950 Mon Sep 17 00:00:00 2001 From: meijian Date: Thu, 29 Feb 2024 15:01:05 +0800 Subject: [PATCH] [ping] fix ping early return when ping is interrupted by ifdown During a long ping, the tester will repeatedly switch the dev interface on and off. When the interface is down and ping is in sendto sem_wait state,ifdown will trigger event of sendto and post sem. in func of sendto_eventhandler: if ((flags & NETDEV_DOWN) != 0) { nerr("ERROR: Interface is down\n"); pstate->snd_result = -ENETUNREACH; goto end_wait; } Signed-off-by: meijian --- netutils/ping/icmp_ping.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/netutils/ping/icmp_ping.c b/netutils/ping/icmp_ping.c index d7e85ec35..1f7045072 100644 --- a/netutils/ping/icmp_ping.c +++ b/netutils/ping/icmp_ping.c @@ -270,22 +270,21 @@ void icmp_ping(FAR const struct ping_info_s *info) } priv->start = clock(); + result.nrequests++; priv->nsent = sendto(priv->sockfd, iobuffer, result.outsize, 0, (FAR struct sockaddr *)&priv->destaddr, sizeof(struct sockaddr_in)); if (priv->nsent < 0) { icmp_callback(&result, ICMP_E_SENDTO, errno); - goto done; + continue; } else if (priv->nsent != result.outsize) { icmp_callback(&result, ICMP_E_SENDSMALL, priv->nsent); - goto done; + continue; } - result.nrequests++; - priv->elapsed = 0; do {