From: Gavin Schenk <g.schenk@eckelmann.de>
To: barebox@lists.infradead.org
Cc: Gavin Schenk <g.schenk@eckelmann.de>
Subject: [PATCH] Add linux.devname property to eth device
Date: Tue, 21 Nov 2017 16:40:47 +0100 [thread overview]
Message-ID: <20171121154047.27334-1-g.schenk@eckelmann.de> (raw)
When you have a static network environment but more than one network
device on your machine it is necessary to provide the <device> parameter
to the ip parameter at kernel cmd line.
The device name assigned by Linux cannot in general be predicted as it
depends on driver bind order.
This patch introduces a new property linux.devname to eth devices.
The value is added to bootargs per interface and can be changed in
env/network/INTF
Note that the device name is also used when dhcp is in use.
Signed-off-by: Gavin Schenk <g.schenk@eckelmann.de>
---
This is V2 of "[PATCH] Configure network device for nfsboot via nv var"
include/net.h | 1 +
net/eth.c | 2 ++
net/ifup.c | 19 +++++++++++++++----
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/include/net.h b/include/net.h
index 632b6d541..0aa5569e0 100644
--- a/include/net.h
+++ b/include/net.h
@@ -62,6 +62,7 @@ struct eth_device {
IPaddr_t netmask;
IPaddr_t gateway;
char ethaddr[6];
+ char *linuxdevname;
char *bootarg;
};
diff --git a/net/eth.c b/net/eth.c
index dac2400b8..fe661c832 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -384,6 +384,8 @@ int eth_register(struct eth_device *edev)
dev_add_param_ip(dev, "netmask", NULL, NULL, &edev->netmask, edev);
dev_add_param_mac(dev, "ethaddr", eth_param_set_ethaddr, NULL,
edev->ethaddr, edev);
+ edev->linuxdevname = xstrdup("");
+ dev_add_param_string(dev, "linux.devname", NULL, NULL, &edev->linuxdevname, NULL);
edev->bootarg = xstrdup("");
dev_add_param_string(dev, "linux.bootargs", NULL, NULL, &edev->bootarg, NULL);
diff --git a/net/ifup.c b/net/ifup.c
index 5113d1383..106700e2e 100644
--- a/net/ifup.c
+++ b/net/ifup.c
@@ -50,6 +50,7 @@ int ifup(const char *name, unsigned flags)
int ret;
char *cmd, *cmd_discover;
const char *ip;
+ const char *linuxdevname;
struct stat s;
int i;
struct device_d *dev;
@@ -63,6 +64,7 @@ int ifup(const char *name, unsigned flags)
env_push_context();
setenv("ip", "");
+ setenv("linuxdevname", "");
for (i = 0; i < ARRAY_SIZE(vars); i++)
setenv(vars[i], "");
@@ -95,6 +97,13 @@ int ifup(const char *name, unsigned flags)
if (ret)
goto out;
+ linuxdevname = getenv("linuxdevname");
+ if (!linuxdevname)
+ linuxdevname = "";
+ ret = dev_set_param(dev, "linux.devname", linuxdevname);
+ if (ret)
+ goto out;
+
ip = getenv("ip");
if (!ip)
ip = "";
@@ -114,11 +123,12 @@ int ifup(const char *name, unsigned flags)
if (ret)
goto out;
}
- bootarg = basprintf("ip=%pI4:%pI4:%pI4:%pI4:::",
+ bootarg = basprintf("ip=%pI4:%pI4:%pI4:%pI4::%s:",
&edev->ipaddr,
&edev->serverip,
&edev->gateway,
- &edev->netmask);
+ &edev->netmask,
+ edev->linuxdevname);
dev_set_param(dev, "linux.bootargs", bootarg);
free(bootarg);
} else {
@@ -194,8 +204,9 @@ static int do_ifup(int argc, char *argv[])
BAREBOX_CMD_HELP_START(ifup)
BAREBOX_CMD_HELP_TEXT("Each INTF must have a script /env/network/INTF that set the variables")
BAREBOX_CMD_HELP_TEXT("ip (to 'static' or 'dynamic'), ipaddr, netmask, gateway, serverip and/or")
-BAREBOX_CMD_HELP_TEXT("ethaddr. A script /env/network/INTF-discover can contains for discovering")
-BAREBOX_CMD_HELP_TEXT("the ethernet device, e.g. 'usb'.")
+BAREBOX_CMD_HELP_TEXT("ethaddr, linuxdevname. A script /env/network/INTF-discover can contains")
+BAREBOX_CMD_HELP_TEXT("for discovering the ethernet device, e.g. 'usb'. If set, linuxdevname is")
+BAREBOX_CMD_HELP_TEXT("added to bootargs as device parameter.")
BAREBOX_CMD_HELP_TEXT("")
BAREBOX_CMD_HELP_TEXT("Options:")
BAREBOX_CMD_HELP_OPT ("-a", "bring up all interfaces")
--
2.15.0
Eckelmann AG
Vorstand: Dipl.-Ing. Peter Frankenbach (Sprecher) Dipl.-Wi.-Ing. Philipp Eckelmann
Dr.-Ing. Marco Münchhof Dr.-Ing. Frank Uhlemann
Vorsitzender des Aufsichtsrats: Hubertus G. Krossa
Stv. Vorsitzender des Aufsichtsrats: Dr.-Ing. Gerd Eckelmann
Sitz der Gesellschaft: Berliner Str. 161, 65205 Wiesbaden, Amtsgericht Wiesbaden HRB 12636
http://www.eckelmann.de
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next reply other threads:[~2017-11-21 15:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-21 15:40 Gavin Schenk [this message]
2017-11-23 7:51 ` Uwe Kleine-König
2017-11-24 8:15 ` 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=20171121154047.27334-1-g.schenk@eckelmann.de \
--to=g.schenk@eckelmann.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