Commit a735e6e9 authored by Thomas RIENOESSL's avatar Thomas RIENOESSL Committed by Joe Hershberger

net: explicitly assign errno to return code in case of network failure

When dealing with two ethernet ports and having "netretry" set
to "once", it could occur that the connection (e.g. an ARP
request) failed, hence the status of the netloop was
"NETLOOP_FAIL". Due to the setting of "netretry", the network
logic would then switch to the other network interface,
assigning "ret" with the return value of "net_start_again()".
If this call succeeded we would return 0 (i.e. success) to
the caller when in reality the network action failed.
Signed-off-by: default avatarThomas RIENOESSL <thomas.rienoessl@bachmann.info>
Reviewed-by: default avatarChristian Gmeiner <christian.gmeiner@gmail.com>
Acked-by: Joe Hershberger's avatarJoe Hershberger <joe.hershberger@ni.com>
parent 21586cdd
...@@ -657,6 +657,7 @@ restart: ...@@ -657,6 +657,7 @@ restart:
/* Invalidate the last protocol */ /* Invalidate the last protocol */
eth_set_last_protocol(BOOTP); eth_set_last_protocol(BOOTP);
debug_cond(DEBUG_INT_STATE, "--- net_loop Fail!\n"); debug_cond(DEBUG_INT_STATE, "--- net_loop Fail!\n");
ret = -ENONET;
goto done; goto done;
case NETLOOP_CONTINUE: case NETLOOP_CONTINUE:
......
...@@ -237,7 +237,7 @@ static int _dm_test_net_retry(struct unit_test_state *uts) ...@@ -237,7 +237,7 @@ static int _dm_test_net_retry(struct unit_test_state *uts)
env_set("ethact", "eth@10004000"); env_set("ethact", "eth@10004000");
env_set("netretry", "no"); env_set("netretry", "no");
sandbox_eth_skip_timeout(); sandbox_eth_skip_timeout();
ut_asserteq(-ETIMEDOUT, net_loop(PING)); ut_asserteq(-ENONET, net_loop(PING));
ut_asserteq_str("eth@10004000", env_get("ethact")); ut_asserteq_str("eth@10004000", env_get("ethact"));
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment