* [PATCH] net: dhcp: mention that eth0 is the default
@ 2025-04-16 8:16 Ahmad Fatoum
0 siblings, 0 replies; only message in thread
From: Ahmad Fatoum @ 2025-04-16 8:16 UTC (permalink / raw)
To: barebox; +Cc: Lars Schmidt, Ahmad Fatoum
dhcp has always defaulted to eth0 when called without arguments, which
is not a good default for systems where eth0 is the management port of a
DSA switch.
Point out that eth0 is used by default when dhcp is called without
arguments and while at it make ignored positional arguments an error.
In general, users probably should use ifup -a (or -a1) instead.
Cc: Lars Schmidt <lsc@pengutronix.de>
Cc: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
commands/dhcp.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/commands/dhcp.c b/commands/dhcp.c
index 97e9b03e4adf..79ab546fc7a9 100644
--- a/commands/dhcp.c
+++ b/commands/dhcp.c
@@ -49,10 +49,17 @@ static int do_dhcp(int argc, char *argv[])
}
}
- if (optind == argc)
+ switch (argc - optind) {
+ case 0:
edevname = "eth0";
- else
+ puts("Defaulting to eth0\n");
+ break;
+ case 1:
edevname = argv[optind];
+ break;
+ default:
+ return COMMAND_ERROR_USAGE;
+ }
edev = eth_get_byname(edevname);
if (!edev) {
--
2.39.5
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-04-16 10:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-16 8:16 [PATCH] net: dhcp: mention that eth0 is the default Ahmad Fatoum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox