From ac3f26cc15ad7e3e9efc2b0b0e18c6e84d93af77 Mon Sep 17 00:00:00 2001 From: Joe Hershberger Date: Wed, 26 Sep 2018 16:49:02 -0500 Subject: net: Don't overwrite waiting packets with asynchronous replies Peter originally sent a fix, but it breaks a number of other things. This addresses the original reported issue in a different way. That report was: > U-Boot has 1 common buffer to send Ethernet frames, pointed to by > net_tx_packet. When sending to an IP address without knowing the MAC > address, U-Boot makes an ARP request (using the arp_tx_packet buffer) > to find out the MAC address of the IP addressr. When a matching ARP > reply is received, U-Boot continues sending the frame stored in the > net_tx_packet buffer. > > However, in the mean time, if U-Boot needs to send out any network > packets (e.g. replying ping packets or ARP requests for its own IP > address etc.), it will use the net_tx_packet buffer to prepare the > new packet. Thus this buffer is no longer the original packet meant > to be transmitted after the ARP reply. The original packet will be > lost. This instead uses the ARP tx buffer to send async replies in the case where we are actively waiting for an ARP reply. Signed-off-by: Joe Hershberger Reported-by: Tran Tien Dat Reviewed-by: Simon Glass Reviewed-by: Bin Meng Tested-by: Bin Meng --- include/net.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include/net.h') diff --git a/include/net.h b/include/net.h index 40e895316e..e5cd52b726 100644 --- a/include/net.h +++ b/include/net.h @@ -655,6 +655,14 @@ static inline void net_set_state(enum net_loop_state state) net_state = state; } +/* + * net_get_async_tx_pkt_buf - Get a packet buffer that is not in use for + * sending an asynchronous reply + * + * returns - ptr to packet buffer + */ +uchar * net_get_async_tx_pkt_buf(void); + /* Transmit a packet */ static inline void net_send_packet(uchar *pkt, int len) { -- cgit v1.2.3