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

Sascha Hauer sha at pengutronix.de
Tue May 2 02:44:54 PDT 2023


On Wed, Apr 26, 2023 at 10:46:59AM +0200, Michael Olbrich wrote:
> 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(-)

Nice. I didn't know one can pass more parameters with ip=dhcp.

Applied, thanks

Sascha

> 
> 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
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list