net: arp_request: do not retry endlessly
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
f31693eb58
commit
56f6bfb820
|
@ -21,6 +21,8 @@
|
||||||
#include <led.h>
|
#include <led.h>
|
||||||
#include <asm/byteorder.h> /* for nton* / ntoh* stuff */
|
#include <asm/byteorder.h> /* for nton* / ntoh* stuff */
|
||||||
|
|
||||||
|
/* How often do we retry to send packages */
|
||||||
|
#define PKT_NUM_RETRIES 4
|
||||||
|
|
||||||
/* The number of receive packet buffers */
|
/* The number of receive packet buffers */
|
||||||
#define PKTBUFSRX 4
|
#define PKTBUFSRX 4
|
||||||
|
|
|
@ -223,6 +223,7 @@ static int arp_request(IPaddr_t dest, unsigned char *ether)
|
||||||
uint64_t arp_start;
|
uint64_t arp_start;
|
||||||
static char *arp_packet;
|
static char *arp_packet;
|
||||||
struct ethernet *et;
|
struct ethernet *et;
|
||||||
|
unsigned retries = 0;
|
||||||
|
|
||||||
if (!arp_packet) {
|
if (!arp_packet) {
|
||||||
arp_packet = net_alloc_packet();
|
arp_packet = net_alloc_packet();
|
||||||
|
@ -277,8 +278,12 @@ static int arp_request(IPaddr_t dest, unsigned char *ether)
|
||||||
printf("T ");
|
printf("T ");
|
||||||
arp_start = get_time_ns();
|
arp_start = get_time_ns();
|
||||||
eth_send(arp_packet, ETHER_HDR_SIZE + ARP_HDR_SIZE);
|
eth_send(arp_packet, ETHER_HDR_SIZE + ARP_HDR_SIZE);
|
||||||
|
retries++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (retries > PKT_NUM_RETRIES)
|
||||||
|
return -ETIMEDOUT;
|
||||||
|
|
||||||
net_poll();
|
net_poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue