mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] net: dhcp: mention that eth0 is the default
@ 2025-04-16  8:16 Ahmad Fatoum
  2025-04-22  9:56 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages 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] 2+ messages in thread

* Re: [PATCH] net: dhcp: mention that eth0 is the default
  2025-04-16  8:16 [PATCH] net: dhcp: mention that eth0 is the default Ahmad Fatoum
@ 2025-04-22  9:56 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2025-04-22  9:56 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum; +Cc: Lars Schmidt


On Wed, 16 Apr 2025 10:16:47 +0200, Ahmad Fatoum wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] net: dhcp: mention that eth0 is the default
      https://git.pengutronix.de/cgit/barebox/commit/?id=538fd22b9255 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




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

end of thread, other threads:[~2025-04-22 10:29 UTC | newest]

Thread overview: 2+ messages (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
2025-04-22  9:56 ` Sascha Hauer

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