[U-Boot] [PATCH] eth_receive(): Do not assume that caller always wants full packet.

Piotr Ziecik kosmo at semihalf.com
Tue Jul 14 10:08:35 CEST 2009


When packets arrive on the interface that are larger than the buffer
being passed to U-Boot from a standalone application, then the eth_receive()
returns -1 and leaves the packet saved. The next call to eth_receive()
will find that same packet and can fail for the exact same reason.
A typical scenario is the loader doing ARP with a buffer of 66 bytes.
The end result is that the ARP will fail and the loader panics.

This patch fixes above problem by allowing partial packet read.

Signed-off-by: Marcel Moolenaar <xcllnt at mac.com>
Signed-off-by: Piotr Ziecik <kosmo at semihalf.com>
---
 net/eth.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/net/eth.c b/net/eth.c
index 3d93966..f0124f8 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -416,10 +416,7 @@ int eth_receive(volatile void *packet, int length)
 			return -1;
 	}
 
-	if (length < eth_rcv_bufs[eth_rcv_current].length)
-		return -1;
-
-	length = eth_rcv_bufs[eth_rcv_current].length;
+	length = min(length, eth_rcv_bufs[eth_rcv_current].length);
 
 	for (i = 0; i < length; i++)
 		p[i] = eth_rcv_bufs[eth_rcv_current].data[i];
-- 
1.5.2.2



More information about the U-Boot mailing list