* [PATCH 0/2] Auto-append ip= option for NFS boot with appendrot
@ 2016-09-19 16:03 Enrico Jorns
2016-09-19 16:03 ` [PATCH 1/2] net: add linux.bootarg parameter from ifup call Enrico Jorns
2016-09-19 16:03 ` [PATCH 2/2] fs: nfs: pick up network interface bootargs parameter Enrico Jorns
0 siblings, 2 replies; 5+ messages in thread
From: Enrico Jorns @ 2016-09-19 16:03 UTC (permalink / raw)
To: barebox; +Cc: Michael Olbrich, Gavin Schenk, Enrico Jorns, u.kleine-koenig
This patches allow booting from nfs without the need to additionally provide an
extra ip= option, such as ip=dhcp to the kernel commandline.
This is solved by adding a bootargs property to the network device of the
connection used for the NFS boot and appending this to the nfs bootarg string.
Note that these patches are based on the 'vsprintf: Add support for printing
ipv4 addresses with %pI4' series posted by Sascha.
Enrico Jorns (2):
net: add linux.bootarg parameter from ifup call
fs: nfs: pick up network interface bootargs parameter
fs/nfs.c | 8 ++++++++
include/net.h | 1 +
net/eth.c | 1 +
net/ifup.c | 10 ++++++++++
4 files changed, 20 insertions(+)
--
2.8.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] net: add linux.bootarg parameter from ifup call
2016-09-19 16:03 [PATCH 0/2] Auto-append ip= option for NFS boot with appendrot Enrico Jorns
@ 2016-09-19 16:03 ` Enrico Jorns
2016-09-21 8:33 ` Sascha Hauer
2016-09-19 16:03 ` [PATCH 2/2] fs: nfs: pick up network interface bootargs parameter Enrico Jorns
1 sibling, 1 reply; 5+ messages in thread
From: Enrico Jorns @ 2016-09-19 16:03 UTC (permalink / raw)
To: barebox; +Cc: Michael Olbrich, Gavin Schenk, Enrico Jorns, u.kleine-koenig
This sets a `ip=dhcp` or
`ip=<clientip>:<serverip>:<gatewayip>:<netmaskip>::<iface>:` bootarg for
the network device upon execution of 'ifup'. This is the only point
where we can distinguish between a static ip and a dhcp-based network
setup and thus set a valid bootarg options as it will be required for
nfs boot, for example.
Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
---
include/net.h | 1 +
net/eth.c | 1 +
net/ifup.c | 10 ++++++++++
3 files changed, 12 insertions(+)
diff --git a/include/net.h b/include/net.h
index fd1c412..632b6d5 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 *bootarg;
};
#define dev_to_edev(d) container_of(d, struct eth_device, dev)
diff --git a/net/eth.c b/net/eth.c
index 6f8e78d..e056826 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -384,6 +384,7 @@ 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);
+ dev_add_param_string(dev, "linux.bootargs", NULL, NULL, &edev->bootarg, NULL);
if (edev->init)
edev->init(edev);
diff --git a/net/ifup.c b/net/ifup.c
index 30ac3f5..618eb8a 100644
--- a/net/ifup.c
+++ b/net/ifup.c
@@ -106,12 +106,22 @@ int ifup(const char *name, unsigned flags)
ret = eth_set_param(dev, "serverip");
if (ret)
goto out;
+ dev_set_param(dev, "linux.bootargs", "ip=dhcp");
} else if (!strcmp(ip, "static")) {
+ char *bootarg;
for (i = 0; i < ARRAY_SIZE(vars); i++) {
ret = eth_set_param(dev, vars[i]);
if (ret)
goto out;
}
+ bootarg = basprintf("ip=%pI4:%pI4:%pI4:%pI4::%s:",
+ &edev->ipaddr,
+ &edev->serverip,
+ &edev->gateway,
+ &edev->netmask,
+ edev->devname);
+ dev_set_param(dev, "linux.bootargs", bootarg);
+ free(bootarg);
} else {
pr_err("unknown ip type: %s\n", ip);
ret = -EINVAL;
--
2.8.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] fs: nfs: pick up network interface bootargs parameter
2016-09-19 16:03 [PATCH 0/2] Auto-append ip= option for NFS boot with appendrot Enrico Jorns
2016-09-19 16:03 ` [PATCH 1/2] net: add linux.bootarg parameter from ifup call Enrico Jorns
@ 2016-09-19 16:03 ` Enrico Jorns
2016-09-19 16:19 ` Uwe Kleine-König
1 sibling, 1 reply; 5+ messages in thread
From: Enrico Jorns @ 2016-09-19 16:03 UTC (permalink / raw)
To: barebox; +Cc: Michael Olbrich, Gavin Schenk, Enrico Jorns, u.kleine-koenig
This adds the linux.bootarg device parameter from the network device of
the current nfs connection and adds it to the nfs bootargs line.
This allows booting from nfs without manually setting a ip=dhcp or
ip=<ipaddr> option.
Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
---
fs/nfs.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/fs/nfs.c b/fs/nfs.c
index a0a9dfc..97f01cf 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -1314,6 +1314,7 @@ static char *rootnfsopts;
static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device_d *fsdev)
{
char *str, *tmp;
+ const char *bootargs;
str = basprintf("root=/dev/nfs nfsroot=%pI4:%s%s%s", &npriv->server, npriv->path,
rootnfsopts[0] ? "," : "", rootnfsopts);
@@ -1331,6 +1332,13 @@ static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device_d *fsdev)
str = tmp;
}
+ bootargs = dev_get_param(&npriv->con->edev->dev, "linux.bootargs");
+ if (bootargs) {
+ tmp = basprintf("%s %s", str, bootargs);
+ free(str);
+ str = tmp;
+ }
+
fsdev_set_linux_rootarg(fsdev, str);
free(str);
--
2.8.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] fs: nfs: pick up network interface bootargs parameter
2016-09-19 16:03 ` [PATCH 2/2] fs: nfs: pick up network interface bootargs parameter Enrico Jorns
@ 2016-09-19 16:19 ` Uwe Kleine-König
0 siblings, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2016-09-19 16:19 UTC (permalink / raw)
To: Enrico Jorns; +Cc: barebox, Michael Olbrich, Gavin Schenk
On Mon, Sep 19, 2016 at 06:03:49PM +0200, Enrico Jorns wrote:
> This adds the linux.bootarg device parameter from the network device of
s/bootarg/bootargs/
> the current nfs connection and adds it to the nfs bootargs line.
s/and adds it//
> This allows booting from nfs without manually setting a ip=dhcp or
> ip=<ipaddr> option.
Otherwise: \o/
(i.e.: Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> for
both patches)
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] net: add linux.bootarg parameter from ifup call
2016-09-19 16:03 ` [PATCH 1/2] net: add linux.bootarg parameter from ifup call Enrico Jorns
@ 2016-09-21 8:33 ` Sascha Hauer
0 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2016-09-21 8:33 UTC (permalink / raw)
To: Enrico Jorns; +Cc: barebox, Michael Olbrich, Gavin Schenk, u.kleine-koenig
On Mon, Sep 19, 2016 at 06:03:48PM +0200, Enrico Jorns wrote:
> This sets a `ip=dhcp` or
> `ip=<clientip>:<serverip>:<gatewayip>:<netmaskip>::<iface>:` bootarg for
> the network device upon execution of 'ifup'. This is the only point
> where we can distinguish between a static ip and a dhcp-based network
> setup and thus set a valid bootarg options as it will be required for
> nfs boot, for example.
>
> Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
Applied both with two little adjustments
> --- a/net/eth.c
> +++ b/net/eth.c
> @@ -384,6 +384,7 @@ 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);
> + dev_add_param_string(dev, "linux.bootargs", NULL, NULL, &edev->bootarg, NULL);
Added a edev->bootarg = xstrdup(""); here to not have a <NULL> string in
the variable when not initialized.
>
> if (edev->init)
> edev->init(edev);
> diff --git a/net/ifup.c b/net/ifup.c
> index 30ac3f5..618eb8a 100644
> --- a/net/ifup.c
> +++ b/net/ifup.c
> @@ -106,12 +106,22 @@ int ifup(const char *name, unsigned flags)
> ret = eth_set_param(dev, "serverip");
> if (ret)
> goto out;
> + dev_set_param(dev, "linux.bootargs", "ip=dhcp");
> } else if (!strcmp(ip, "static")) {
> + char *bootarg;
> for (i = 0; i < ARRAY_SIZE(vars); i++) {
> ret = eth_set_param(dev, vars[i]);
> if (ret)
> goto out;
> }
> + bootarg = basprintf("ip=%pI4:%pI4:%pI4:%pI4::%s:",
> + &edev->ipaddr,
> + &edev->serverip,
> + &edev->gateway,
> + &edev->netmask,
> + edev->devname);
I dropped setting the devname here since we do not know if it's the same
under Linux. If there are multiple interfaces in Linux we can only hope
that the right one is used anyway.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-09-21 8:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-19 16:03 [PATCH 0/2] Auto-append ip= option for NFS boot with appendrot Enrico Jorns
2016-09-19 16:03 ` [PATCH 1/2] net: add linux.bootarg parameter from ifup call Enrico Jorns
2016-09-21 8:33 ` Sascha Hauer
2016-09-19 16:03 ` [PATCH 2/2] fs: nfs: pick up network interface bootargs parameter Enrico Jorns
2016-09-19 16:19 ` Uwe Kleine-König
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox