mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Enrico Jorns <ejo@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Michael Olbrich <m.olbrich@pengutronix.de>,
	Gavin Schenk <g.schenk@eckelmann.de>,
	Enrico Jorns <ejo@pengutronix.de>,
	u.kleine-koenig@pengutronix.de
Subject: [PATCH 1/2] net: add linux.bootarg parameter from ifup call
Date: Mon, 19 Sep 2016 18:03:48 +0200	[thread overview]
Message-ID: <1474301029-22877-2-git-send-email-ejo@pengutronix.de> (raw)
In-Reply-To: <1474301029-22877-1-git-send-email-ejo@pengutronix.de>

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

  reply	other threads:[~2016-09-19 16:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2016-09-21  8:33   ` [PATCH 1/2] net: add linux.bootarg parameter from ifup call 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

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=1474301029-22877-2-git-send-email-ejo@pengutronix.de \
    --to=ejo@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=g.schenk@eckelmann.de \
    --cc=m.olbrich@pengutronix.de \
    --cc=u.kleine-koenig@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