summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJoe Hershberger <joe.hershberger@ni.com>2018-09-26 16:49:02 -0500
committerJoe Hershberger <joe.hershberger@ni.com>2018-10-10 12:29:01 -0500
commitac3f26cc15ad7e3e9efc2b0b0e18c6e84d93af77 (patch)
tree1bc636d01766693ddfceda55311ee2f72908a1f8 /test
parent72ff0042585bedab4364afbd7ecc935e48324ade (diff)
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 <joe.hershberger@ni.com> Reported-by: Tran Tien Dat <peter.trantiendat@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/dm/eth.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/test/dm/eth.c b/test/dm/eth.c
index 86482e9755..850eabb9dc 100644
--- a/test/dm/eth.c
+++ b/test/dm/eth.c
@@ -332,10 +332,9 @@ static int dm_test_eth_async_arp_reply(struct unit_test_state *uts)
sandbox_eth_set_tx_handler(0, sb_with_async_arp_handler);
/* Used by all of the ut_assert macros in the tx_handler */
sandbox_eth_set_priv(0, uts);
- sandbox_eth_skip_timeout();
env_set("ethact", "eth@10002000");
- ut_assert(net_loop(PING) == -ETIMEDOUT);
+ ut_assertok(net_loop(PING));
ut_asserteq_str("eth@10002000", env_get("ethact"));
sandbox_eth_set_tx_handler(0, NULL);
@@ -418,10 +417,9 @@ static int dm_test_eth_async_ping_reply(struct unit_test_state *uts)
sandbox_eth_set_tx_handler(0, sb_with_async_ping_handler);
/* Used by all of the ut_assert macros in the tx_handler */
sandbox_eth_set_priv(0, uts);
- sandbox_eth_skip_timeout();
env_set("ethact", "eth@10002000");
- ut_assert(net_loop(PING) == -ETIMEDOUT);
+ ut_assertok(net_loop(PING));
ut_asserteq_str("eth@10002000", env_get("ethact"));
sandbox_eth_set_tx_handler(0, NULL);