From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/2] net: ifup: don't redo ifup -a1 if we have a gateway
Date: Fri, 21 Jul 2023 13:07:44 +0200 [thread overview]
Message-ID: <20230721110744.3699054-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20230721110744.3699054-1-a.fatoum@pengutronix.de>
ifup -a -1 is an optimization for switches that have only one port
connected: ifup will poll link on all ports in parallel and early
exit once any port got an IP address. This doesn't work when
global.net.server is set, as the first port to get link up is not
necessary one that is in a network that can resolve global.net.server.
This is needlessly restrictive: Even if global.net.server is set,
it's only a problem if no gateway was set. If there's a gateway, barebox
already knows how to resolve global.net.server, so there's no need to
try to bring up all interfaces when -1 is supplied.
This fixes the delay when using ifup -a1 multiple times in a row.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
net/ifup.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/net/ifup.c b/net/ifup.c
index 993d2a115fda..6866150d93bc 100644
--- a/net/ifup.c
+++ b/net/ifup.c
@@ -292,6 +292,9 @@ static int __ifup_all_parallel(unsigned flags)
start = get_time_ns();
while (netdev_count && !is_timeout(start, PHY_AN_TIMEOUT * SECOND)) {
for_each_netdev(edev) {
+ if ((flags & IFUP_FLAG_UNTIL_NET_SERVER) && net_get_server())
+ return 0;
+
if (ctrlc())
return -EINTR;
@@ -307,9 +310,6 @@ static int __ifup_all_parallel(unsigned flags)
continue;
netdev_count--;
-
- if ((flags & IFUP_FLAG_UNTIL_NET_SERVER) && net_get_server())
- return 0;
}
}
@@ -321,13 +321,13 @@ static int __ifup_all_sequence(unsigned flags)
struct eth_device *edev;
for_each_netdev(edev) {
+ if ((flags & IFUP_FLAG_UNTIL_NET_SERVER) && net_get_server())
+ return 0;
+
if (ctrlc())
return -EINTR;
ifup_edev(edev, flags);
-
- if ((flags & IFUP_FLAG_UNTIL_NET_SERVER) && net_get_server())
- return 0;
}
return 0;
@@ -364,7 +364,7 @@ int ifup_all(unsigned flags)
* empty, i.e. the first DHCP lease setting $global.net.server
* will be what we're going with.
*/
- if (net_get_server())
+ if (net_get_server() && !net_get_gateway())
flags &= ~IFUP_FLAG_UNTIL_NET_SERVER;
if (flags & IFUP_FLAG_PARALLEL)
--
2.39.2
next prev parent reply other threads:[~2023-07-21 11:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-21 11:07 [PATCH 1/2] net: ifup: check for ctrl+c during ifup Ahmad Fatoum
2023-07-21 11:07 ` Ahmad Fatoum [this message]
2023-07-26 10:08 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230721110744.3699054-2-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox