From 9bdf4ccd68026c2cc90c9c751615d95f8a32e330 Mon Sep 17 00:00:00 2001 From: "chao.an" Date: Mon, 22 Feb 2021 10:35:18 +0800 Subject: [PATCH] net/arp: add timeout to avoid infinite send wait add timeout to avoid infinite send wait if the network device is unreachable Signed-off-by: chao.an --- net/arp/arp_send.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/net/arp/arp_send.c b/net/arp/arp_send.c index 698ec55d5f..65f5cf8050 100644 --- a/net/arp/arp_send.c +++ b/net/arp/arp_send.c @@ -337,7 +337,12 @@ int arp_send(in_addr_t ipaddr) do { - net_lockedwait(&state.snd_sem); + ret = net_timedwait_uninterruptible(&state.snd_sem, + CONFIG_ARP_SEND_DELAYMSEC); + if (ret == -ETIMEDOUT) + { + goto timeout; + } } while (!state.snd_sent); @@ -367,6 +372,8 @@ int arp_send(in_addr_t ipaddr) break; } +timeout: + /* Increment the retry count */ state.snd_retries++;