From 841d83ff0a30dfdb58ae94f497097b52aecacf67 Mon Sep 17 00:00:00 2001 From: Enrico Jorns Date: Mon, 19 Sep 2016 18:03:48 +0200 Subject: net: add linux.bootarg parameter from ifup call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This sets a `ip=dhcp` or `ip=::::::` 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 Acked-by: Uwe Kleine-König Signed-off-by: Sascha Hauer --- net/eth.c | 2 ++ net/ifup.c | 9 +++++++++ 2 files changed, 11 insertions(+) (limited to 'net') diff --git a/net/eth.c b/net/eth.c index 6f8e78d8d3..dac2400b81 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->bootarg = xstrdup(""); + 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 30ac3f5861..5113d13832 100644 --- a/net/ifup.c +++ b/net/ifup.c @@ -106,12 +106,21 @@ 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:::", + &edev->ipaddr, + &edev->serverip, + &edev->gateway, + &edev->netmask); + dev_set_param(dev, "linux.bootargs", bootarg); + free(bootarg); } else { pr_err("unknown ip type: %s\n", ip); ret = -EINVAL; -- cgit v1.2.3