]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
net: explicitly assign errno to return code in case of network failure
authorThomas RIENOESSL <thomas.rienoessl@bachmann.info>
Wed, 21 Nov 2018 14:56:07 +0000 (15:56 +0100)
committerJoe Hershberger <joe.hershberger@ni.com>
Thu, 24 Jan 2019 17:35:28 +0000 (11:35 -0600)
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: Thomas RIENOESSL <thomas.rienoessl@bachmann.info>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
net/net.c
test/dm/eth.c

index a5a216c3eeec04ca984e2b73ff2e6aa71f15ef4b..e9f7a7d85e7365d574850b8426b18b4df2813e88 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -657,6 +657,7 @@ restart:
                        /* Invalidate the last protocol */
                        eth_set_last_protocol(BOOTP);
                        debug_cond(DEBUG_INT_STATE, "--- net_loop Fail!\n");
+                       ret = -ENONET;
                        goto done;
 
                case NETLOOP_CONTINUE:
index 850eabb9dc56c626d3f8e0b3ce9a889dcd1a8a27..6e002b8dce954dfca681393a0bea9f01d6224ea8 100644 (file)
@@ -237,7 +237,7 @@ static int _dm_test_net_retry(struct unit_test_state *uts)
        env_set("ethact", "eth@10004000");
        env_set("netretry", "no");
        sandbox_eth_skip_timeout();
-       ut_asserteq(-ETIMEDOUT, net_loop(PING));
+       ut_asserteq(-ENONET, net_loop(PING));
        ut_asserteq_str("eth@10004000", env_get("ethact"));
 
        return 0;