mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] net: ifup: check for ctrl+c during ifup
@ 2023-07-21 11:07 Ahmad Fatoum
  2023-07-21 11:07 ` [PATCH 2/2] net: ifup: don't redo ifup -a1 if we have a gateway Ahmad Fatoum
  2023-07-26 10:08 ` [PATCH 1/2] net: ifup: check for ctrl+c during ifup Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2023-07-21 11:07 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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@pengutronix.de>
---
 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




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-26 10:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-21 11:07 [PATCH 1/2] net: ifup: check for ctrl+c during ifup Ahmad Fatoum
2023-07-21 11:07 ` [PATCH 2/2] net: ifup: don't redo ifup -a1 if we have a gateway Ahmad Fatoum
2023-07-26 10:08 ` [PATCH 1/2] net: ifup: check for ctrl+c during ifup Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox