mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] net: ifup: pass hostname and linuxdevname to linux with DHCP
@ 2023-04-26  8:46 Michael Olbrich
  2023-05-02  9:44 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Olbrich @ 2023-04-26  8:46 UTC (permalink / raw)
  To: barebox; +Cc: Michael Olbrich

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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: ifup: pass hostname and linuxdevname to linux with DHCP
  2023-04-26  8:46 [PATCH] net: ifup: pass hostname and linuxdevname to linux with DHCP Michael Olbrich
@ 2023-05-02  9:44 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2023-05-02  9:44 UTC (permalink / raw)
  To: Michael Olbrich; +Cc: barebox

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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-02  9:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-26  8:46 [PATCH] net: ifup: pass hostname and linuxdevname to linux with DHCP Michael Olbrich
2023-05-02  9:44 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox