From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Lars Schmidt <lsc@pengutronix.de>,
Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] net: dhcp: mention that eth0 is the default
Date: Wed, 16 Apr 2025 10:16:47 +0200 [thread overview]
Message-ID: <20250416081646.2201914-1-a.fatoum@pengutronix.de> (raw)
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
reply other threads:[~2025-04-16 10:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20250416081646.2201914-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=lsc@pengutronix.de \
/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