[PATCH 2/2] net: ifup: don't redo ifup -a1 if we have a gateway
Ahmad Fatoum
a.fatoum at pengutronix.de
Fri Jul 21 04:07:44 PDT 2023
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 at 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
More information about the barebox
mailing list