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 @@ 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..dac2400 100644 --- a/net/eth.c +++ b/net/eth.c @@ -384,6 +384,8 @@ 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 30ac3f5..5113d13 100644 --- a/net/ifup.c +++ b/net/ifup.c @@ -106,12 +106,21 @@ 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;