summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Brüns <stefan.bruens@rwth-aachen.de>2015-08-30 17:46:54 +0200
committerJoe Hershberger <joe.hershberger@ni.com>2015-10-28 14:57:37 -0500
commit45b47734a0788721c76e3bb621a5133554e0a640 (patch)
treefb8b5ce5c47435ff1683d918c563e48436809e5b
parent943231119f3caaaca7db4c588e4f3e9a6cec426a (diff)
downloadu-boot-imx-45b47734a0788721c76e3bb621a5133554e0a640.zip
u-boot-imx-45b47734a0788721c76e3bb621a5133554e0a640.tar.gz
u-boot-imx-45b47734a0788721c76e3bb621a5133554e0a640.tar.bz2
net/arp: account for ARP delay, avoid duplicate packets on timeout
eth_rx() in the main reception loop may trigger sending a packet which is already timed out (or will immediately) upon reception of an ARP reply. As long as the ARP reply is pending, the timeout handler of a packet should be postponed. Happens on TFTP with bad network (e.g. WLAN). Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
-rw-r--r--net/arp.c5
-rw-r--r--net/arp.h2
-rw-r--r--net/net.c4
3 files changed, 7 insertions, 4 deletions
diff --git a/net/arp.c b/net/arp.c
index b1f12bf..824d2e9 100644
--- a/net/arp.c
+++ b/net/arp.c
@@ -96,12 +96,12 @@ void arp_request(void)
arp_raw_request(net_ip, net_null_ethaddr, net_arp_wait_reply_ip);
}
-void arp_timeout_check(void)
+int arp_timeout_check(void)
{
ulong t;
if (!net_arp_wait_packet_ip.s_addr)
- return;
+ return 0;
t = get_timer(0);
@@ -118,6 +118,7 @@ void arp_timeout_check(void)
arp_request();
}
}
+ return 1;
}
void arp_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)
diff --git a/net/arp.h b/net/arp.h
index 43c6296..a288d61 100644
--- a/net/arp.h
+++ b/net/arp.h
@@ -25,7 +25,7 @@ void arp_init(void);
void arp_request(void);
void arp_raw_request(struct in_addr source_ip, const uchar *targetEther,
struct in_addr target_ip);
-void arp_timeout_check(void);
+int arp_timeout_check(void);
void arp_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len);
#endif /* __ARP_H__ */
diff --git a/net/net.c b/net/net.c
index a115ce2..6f75e3c 100644
--- a/net/net.c
+++ b/net/net.c
@@ -569,7 +569,9 @@ restart:
goto done;
}
- arp_timeout_check();
+ if (arp_timeout_check() > 0) {
+ time_start = get_timer(0);
+ }
/*
* Check for a timeout, and run the timeout handler