mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] Configure network device for nfsboot via nv var
@ 2017-11-08 15:05 Gavin Schenk
  2017-11-10  7:00 ` Sascha Hauer
  0 siblings, 1 reply; 5+ messages in thread
From: Gavin Schenk @ 2017-11-08 15:05 UTC (permalink / raw)
  To: barebox; +Cc: Gavin Schenk

When you have a static network environment but more than one network
device on your machine it is necessary to provide the <device> parameter
to the ip parameter at kernel cmd line.

The device name assigned by Linux cannot in general be predicted as it
depends on driver bind order.

This patch introduces a new global variable
"global.linux.nfsroot.device" which when set is feed to the ip=
kernel parameter as device name.

Signed-off-by: Gavin Schenk <g.schenk@eckelmann.de>
---
 net/ifup.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/ifup.c b/net/ifup.c
index 5113d138329a..bdb7cf0e6d0a 100644
--- a/net/ifup.c
+++ b/net/ifup.c
@@ -109,16 +109,19 @@ int ifup(const char *name, unsigned flags)
 		dev_set_param(dev, "linux.bootargs", "ip=dhcp");
 	} else if (!strcmp(ip, "static")) {
 		char *bootarg;
+		const char *env_linux_nfsroot_device = 
+			getenv("global.linux.nfsroot.device");
 		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:::",
+		bootarg = basprintf("ip=%pI4:%pI4:%pI4:%pI4::%s:",
 				&edev->ipaddr,
 				&edev->serverip,
 				&edev->gateway,
-				&edev->netmask);
+				&edev->netmask,
+				env_linux_nfsroot_device ?: "");
 		dev_set_param(dev, "linux.bootargs", bootarg);
 		free(bootarg);
 	} else {
-- 
2.15.0


Eckelmann AG
Vorstand: Dipl.-Ing. Peter Frankenbach (Sprecher) Dipl.-Wi.-Ing. Philipp Eckelmann
Dr.-Ing. Marco Münchhof Dr.-Ing. Frank Uhlemann
Vorsitzender des Aufsichtsrats: Hubertus G. Krossa
Stv. Vorsitzender des Aufsichtsrats: Dr.-Ing. Gerd Eckelmann
Sitz der Gesellschaft: Berliner Str. 161, 65205 Wiesbaden, Amtsgericht Wiesbaden HRB 12636
http://www.eckelmann.de 


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] Configure network device for nfsboot via nv var
  2017-11-08 15:05 [PATCH] Configure network device for nfsboot via nv var Gavin Schenk
@ 2017-11-10  7:00 ` Sascha Hauer
  2017-11-16  7:20   ` AW: " Schenk, Gavin
  0 siblings, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2017-11-10  7:00 UTC (permalink / raw)
  To: Gavin Schenk; +Cc: barebox

On Wed, Nov 08, 2017 at 04:05:17PM +0100, Gavin Schenk wrote:
> When you have a static network environment but more than one network
> device on your machine it is necessary to provide the <device> parameter
> to the ip parameter at kernel cmd line.
> 
> The device name assigned by Linux cannot in general be predicted as it
> depends on driver bind order.
> 
> This patch introduces a new global variable
> "global.linux.nfsroot.device" which when set is feed to the ip=
> kernel parameter as device name.

Maybe we should rather add a linuxname property to the ethernet device
instead. That way we could specify multiple names in case we have
multiple ethernet devices in barebox aswell.

Sascha


> 
> Signed-off-by: Gavin Schenk <g.schenk@eckelmann.de>
> ---
>  net/ifup.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ifup.c b/net/ifup.c
> index 5113d138329a..bdb7cf0e6d0a 100644
> --- a/net/ifup.c
> +++ b/net/ifup.c
> @@ -109,16 +109,19 @@ int ifup(const char *name, unsigned flags)
>  		dev_set_param(dev, "linux.bootargs", "ip=dhcp");
>  	} else if (!strcmp(ip, "static")) {
>  		char *bootarg;
> +		const char *env_linux_nfsroot_device = 
> +			getenv("global.linux.nfsroot.device");
>  		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:::",
> +		bootarg = basprintf("ip=%pI4:%pI4:%pI4:%pI4::%s:",
>  				&edev->ipaddr,
>  				&edev->serverip,
>  				&edev->gateway,
> -				&edev->netmask);
> +				&edev->netmask,
> +				env_linux_nfsroot_device ?: "");
>  		dev_set_param(dev, "linux.bootargs", bootarg);
>  		free(bootarg);
>  	} else {
> -- 
> 2.15.0
> 
> 
> Eckelmann AG
> Vorstand: Dipl.-Ing. Peter Frankenbach (Sprecher) Dipl.-Wi.-Ing. Philipp Eckelmann
> Dr.-Ing. Marco Münchhof Dr.-Ing. Frank Uhlemann
> Vorsitzender des Aufsichtsrats: Hubertus G. Krossa
> Stv. Vorsitzender des Aufsichtsrats: Dr.-Ing. Gerd Eckelmann
> Sitz der Gesellschaft: Berliner Str. 161, 65205 Wiesbaden, Amtsgericht Wiesbaden HRB 12636
> http://www.eckelmann.de 
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* AW: [PATCH] Configure network device for nfsboot via nv var
  2017-11-10  7:00 ` Sascha Hauer
@ 2017-11-16  7:20   ` Schenk, Gavin
  2017-11-17  9:26     ` Uwe Kleine-König
  2017-11-17  9:32     ` s.hauer
  0 siblings, 2 replies; 5+ messages in thread
From: Schenk, Gavin @ 2017-11-16  7:20 UTC (permalink / raw)
  To: s.hauer; +Cc: barebox

Hi,

> On Wed, Nov 08, 2017 at 04:05:17PM +0100, Gavin Schenk wrote:
> > When you have a static network environment but more than one
> > network
> > device on your machine it is necessary to provide the <device>
> > parameter to the ip parameter at kernel cmd line.
> > 
> > The device name assigned by Linux cannot in general be predicted as
> > it
> > depends on driver bind order.
> > 
> > This patch introduces a new global variable
> > "global.linux.nfsroot.device" which when set is feed to the ip=
> > kernel
> > parameter as device name.
> 
> Maybe we should rather add a linuxname property to the ethernet
> device
> instead. That way we could specify multiple names in case we have
> multiple ethernet devices in barebox aswell.
> 

maybe I am missing something important, but is this useful for anything
besides nfsboot?

If linuxname is a property of the device, how do we decide between
eth0.linuxname and eth1.linuxname when doing a "boot /mnt/nfs"? 
In this case we need additionally a global variable like nfsboot-
device=eth0 to switch between nfsboot devices and to make the decision
when filling the ip parameter?

Best regards
Gavin

Eckelmann AG
Vorstand: Dipl.-Ing. Peter Frankenbach (Sprecher) Dipl.-Wi.-Ing. Philipp Eckelmann
Dr.-Ing. Marco Münchhof Dr.-Ing. Frank Uhlemann
Vorsitzender des Aufsichtsrats: Hubertus G. Krossa
Stv. Vorsitzender des Aufsichtsrats: Dr.-Ing. Gerd Eckelmann
Sitz der Gesellschaft: Berliner Str. 161, 65205 Wiesbaden, Amtsgericht Wiesbaden HRB 12636
http://www.eckelmann.de 

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] Configure network device for nfsboot via nv var
  2017-11-16  7:20   ` AW: " Schenk, Gavin
@ 2017-11-17  9:26     ` Uwe Kleine-König
  2017-11-17  9:32     ` s.hauer
  1 sibling, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2017-11-17  9:26 UTC (permalink / raw)
  To: Schenk, Gavin; +Cc: barebox

Hello,

On Thu, Nov 16, 2017 at 07:20:14AM +0000, Schenk, Gavin wrote:
> > On Wed, Nov 08, 2017 at 04:05:17PM +0100, Gavin Schenk wrote:
> > > When you have a static network environment but more than one
> > > network
> > > device on your machine it is necessary to provide the <device>
> > > parameter to the ip parameter at kernel cmd line.
> > > 
> > > The device name assigned by Linux cannot in general be predicted as
> > > it
> > > depends on driver bind order.
> > > 
> > > This patch introduces a new global variable
> > > "global.linux.nfsroot.device" which when set is feed to the ip=
> > > kernel
> > > parameter as device name.
> > 
> > Maybe we should rather add a linuxname property to the ethernet
> > device
> > instead. That way we could specify multiple names in case we have
> > multiple ethernet devices in barebox aswell.
> > 
> 
> maybe I am missing something important, but is this useful for anything
> besides nfsboot?
> 
> If linuxname is a property of the device, how do we decide between
> eth0.linuxname and eth1.linuxname when doing a "boot /mnt/nfs"? 
> In this case we need additionally a global variable like nfsboot-
> device=eth0 to switch between nfsboot devices and to make the decision
> when filling the ip parameter?

IMHO this is unnecessary complicated and the suggested patch is fine.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] Configure network device for nfsboot via nv var
  2017-11-16  7:20   ` AW: " Schenk, Gavin
  2017-11-17  9:26     ` Uwe Kleine-König
@ 2017-11-17  9:32     ` s.hauer
  1 sibling, 0 replies; 5+ messages in thread
From: s.hauer @ 2017-11-17  9:32 UTC (permalink / raw)
  To: Schenk, Gavin; +Cc: barebox

On Thu, Nov 16, 2017 at 07:20:14AM +0000, Schenk, Gavin wrote:
> Hi,
> 
> > On Wed, Nov 08, 2017 at 04:05:17PM +0100, Gavin Schenk wrote:
> > > When you have a static network environment but more than one
> > > network
> > > device on your machine it is necessary to provide the <device>
> > > parameter to the ip parameter at kernel cmd line.
> > > 
> > > The device name assigned by Linux cannot in general be predicted as
> > > it
> > > depends on driver bind order.
> > > 
> > > This patch introduces a new global variable
> > > "global.linux.nfsroot.device" which when set is feed to the ip=
> > > kernel
> > > parameter as device name.
> > 
> > Maybe we should rather add a linuxname property to the ethernet
> > device
> > instead. That way we could specify multiple names in case we have
> > multiple ethernet devices in barebox aswell.
> > 
> 
> maybe I am missing something important, but is this useful for anything
> besides nfsboot?
> 
> If linuxname is a property of the device, how do we decide between
> eth0.linuxname and eth1.linuxname when doing a "boot /mnt/nfs"? 
> In this case we need additionally a global variable like nfsboot-
> device=eth0 to switch between nfsboot devices and to make the decision
> when filling the ip parameter?

Look again at the code. The code you patched in your patch does not
add anything directly to the kernel commandline. Instead, it fills the
network device specific variable ethx.linux.bootargs with a kernel
commandline snippet needed to boot from this particular device. So
during boot barebox will add the snippet from the actual boot device
to the commandline.
With eth0.linuxname and eth1.linuxname you will get two
eth[01].linux.bootargs variables containing the corresponding linuxname.
Depending on the ethernet device being active during boot barebox will
pick the correct string.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2017-11-17  9:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-08 15:05 [PATCH] Configure network device for nfsboot via nv var Gavin Schenk
2017-11-10  7:00 ` Sascha Hauer
2017-11-16  7:20   ` AW: " Schenk, Gavin
2017-11-17  9:26     ` Uwe Kleine-König
2017-11-17  9:32     ` s.hauer

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