When global.net.server is set, barebox will attempt to bring up all interfaces on ifup -a1 to see which interface can resolve it. That can take a while and there's no way to abort that, so stick in a ctrlc(), so user can change their mind (and e.g. remove global.net.server, so ifup -a1 takes first interface that has link up). Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- net/ifup.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/net/ifup.c b/net/ifup.c index 64298b44ebf3..993d2a115fda 100644 --- a/net/ifup.c +++ b/net/ifup.c @@ -276,7 +276,7 @@ static bool ifup_edev_need_conf(struct eth_device *edev) edev->global_mode != ETH_MODE_DISABLED; } -static void __ifup_all_parallel(unsigned flags) +static int __ifup_all_parallel(unsigned flags) { struct eth_device *edev; unsigned netdev_count = 0; @@ -292,6 +292,9 @@ static void __ifup_all_parallel(unsigned flags) start = get_time_ns(); while (netdev_count && !is_timeout(start, PHY_AN_TIMEOUT * SECOND)) { for_each_netdev(edev) { + if (ctrlc()) + return -EINTR; + if (!ifup_edev_need_conf(edev)) continue; @@ -306,21 +309,28 @@ static void __ifup_all_parallel(unsigned flags) netdev_count--; if ((flags & IFUP_FLAG_UNTIL_NET_SERVER) && net_get_server()) - return; + return 0; } } + + return 0; } -static void __ifup_all_sequence(unsigned flags) +static int __ifup_all_sequence(unsigned flags) { struct eth_device *edev; for_each_netdev(edev) { + if (ctrlc()) + return -EINTR; + ifup_edev(edev, flags); if ((flags & IFUP_FLAG_UNTIL_NET_SERVER) && net_get_server()) - return; + return 0; } + + return 0; } int ifup_all(unsigned flags) @@ -358,11 +368,9 @@ int ifup_all(unsigned flags) flags &= ~IFUP_FLAG_UNTIL_NET_SERVER; if (flags & IFUP_FLAG_PARALLEL) - __ifup_all_parallel(flags); + return __ifup_all_parallel(flags); else - __ifup_all_sequence(flags); - - return 0; + return __ifup_all_sequence(flags); } void ifdown_all(void) -- 2.39.2