[PATCH] net: ifup: pass hostname and linuxdevname to linux with DHCP

Michael Olbrich m.olbrich at pengutronix.de
Wed Apr 26 01:46:59 PDT 2023


Barebox always uses the hostname in the DHCP request. To configure
kernel networking, use the long ip= syntax for DHCP and set the hostname
as well. This way, Barebox and Linux use the same hostname in the DHCP
request.
Also set the device if linuxdevname is configured. This is already done
for static configurations. Do the same for DHCP.

Signed-off-by: Michael Olbrich <m.olbrich at pengutronix.de>
---
 net/ifup.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/ifup.c b/net/ifup.c
index 1870f7401714..18ab1363c748 100644
--- a/net/ifup.c
+++ b/net/ifup.c
@@ -159,8 +159,8 @@ out:
 
 static void set_linux_bootarg(struct eth_device *edev)
 {
+	char *bootarg;
 	if (edev->global_mode == ETH_MODE_STATIC) {
-		char *bootarg;
 		IPaddr_t serverip;
 		IPaddr_t gateway;
 
@@ -176,7 +176,11 @@ static void set_linux_bootarg(struct eth_device *edev)
 		dev_set_param(&edev->dev, "linux.bootargs", bootarg);
 		free(bootarg);
 	} else if (edev->global_mode == ETH_MODE_DHCP) {
-		dev_set_param(&edev->dev, "linux.bootargs", "ip=dhcp");
+		bootarg = basprintf("ip=::::%s:%s:dhcp",
+				barebox_get_hostname(),
+				edev->linuxdevname ? edev->linuxdevname : "");
+		dev_set_param(&edev->dev, "linux.bootargs", bootarg);
+		free(bootarg);
 	}
 }
 
-- 
2.39.2




More information about the barebox mailing list