From 56f6bfb820a61f9aef0964f609b22d0ad73d0bb3 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Wed, 4 Apr 2012 18:04:42 +0200 Subject: [PATCH] net: arp_request: do not retry endlessly Signed-off-by: Wolfram Sang Signed-off-by: Sascha Hauer --- include/net.h | 2 ++ net/net.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/include/net.h b/include/net.h index 0ebe19823..3f2187eca 100644 --- a/include/net.h +++ b/include/net.h @@ -21,6 +21,8 @@ #include #include /* for nton* / ntoh* stuff */ +/* How often do we retry to send packages */ +#define PKT_NUM_RETRIES 4 /* The number of receive packet buffers */ #define PKTBUFSRX 4 diff --git a/net/net.c b/net/net.c index 39db75e7a..046ddd407 100644 --- a/net/net.c +++ b/net/net.c @@ -223,6 +223,7 @@ static int arp_request(IPaddr_t dest, unsigned char *ether) uint64_t arp_start; static char *arp_packet; struct ethernet *et; + unsigned retries = 0; if (!arp_packet) { arp_packet = net_alloc_packet(); @@ -277,8 +278,12 @@ static int arp_request(IPaddr_t dest, unsigned char *ether) printf("T "); arp_start = get_time_ns(); eth_send(arp_packet, ETHER_HDR_SIZE + ARP_HDR_SIZE); + retries++; } + if (retries > PKT_NUM_RETRIES) + return -ETIMEDOUT; + net_poll(); }