Commit 45b47734a0788721c76e3bb621a5133554e0a640

Authored by Stefan Brüns
Committed by Joe Hershberger
1 parent 943231119f

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>

Showing 3 changed files with 7 additions and 4 deletions Side-by-side Diff

... ... @@ -96,12 +96,12 @@
96 96 arp_raw_request(net_ip, net_null_ethaddr, net_arp_wait_reply_ip);
97 97 }
98 98  
99   -void arp_timeout_check(void)
  99 +int arp_timeout_check(void)
100 100 {
101 101 ulong t;
102 102  
103 103 if (!net_arp_wait_packet_ip.s_addr)
104   - return;
  104 + return 0;
105 105  
106 106 t = get_timer(0);
107 107  
... ... @@ -118,6 +118,7 @@
118 118 arp_request();
119 119 }
120 120 }
  121 + return 1;
121 122 }
122 123  
123 124 void arp_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)
... ... @@ -25,7 +25,7 @@
25 25 void arp_request(void);
26 26 void arp_raw_request(struct in_addr source_ip, const uchar *targetEther,
27 27 struct in_addr target_ip);
28   -void arp_timeout_check(void);
  28 +int arp_timeout_check(void);
29 29 void arp_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len);
30 30  
31 31 #endif /* __ARP_H__ */
... ... @@ -569,7 +569,9 @@
569 569 goto done;
570 570 }
571 571  
572   - arp_timeout_check();
  572 + if (arp_timeout_check() > 0) {
  573 + time_start = get_timer(0);
  574 + }
573 575  
574 576 /*
575 577 * Check for a timeout, and run the timeout handler