If the user has set a u-boot env var named rootpath, automatically
import it into the loader(8) env as dhcp.root-path, so that it overrides any dhcp/bootp server-provided path. Now if you have a dhcp server available you can easily net-boot a u-boot system even if you don't control the dhcp server config, by setting just two variables in the u-boot env: loaderdev=net rootpath=<nfsserverip>:<pathname> Previously you had to either accept all the dhcp parameters from the server without the ability to locally provide the rootpath, or you had to forego dhcp and set more vars (ipaddr, netmask, serverip, rootpath).
This commit is contained in:
parent
e1b6d4a9f4
commit
0d2550a169
@ -108,9 +108,19 @@ get_env_net_params()
|
||||
char *envstr;
|
||||
in_addr_t rootaddr, serveraddr;
|
||||
|
||||
/* Silently get out right away if we don't have rootpath. */
|
||||
if (ub_env_get("rootpath") == NULL)
|
||||
/*
|
||||
* Silently get out right away if we don't have rootpath, because none
|
||||
* of the other info we obtain below is sufficient to boot without it.
|
||||
*
|
||||
* If we do have rootpath, copy it into the global var and also set
|
||||
* dhcp.root-path in the env. If we don't get all the other info from
|
||||
* the u-boot env below, we will still try dhcp/bootp, but the server-
|
||||
* provided path will not replace the user-provided value we set here.
|
||||
*/
|
||||
if ((envstr = ub_env_get("rootpath")) == NULL)
|
||||
return;
|
||||
strlcpy(rootpath, envstr, sizeof(rootpath));
|
||||
setenv("dhcp.root-path", rootpath, 0);
|
||||
|
||||
/*
|
||||
* Our own IP address must be valid. Silently get out if it's not set,
|
||||
@ -154,9 +164,6 @@ get_env_net_params()
|
||||
* There must be a rootpath. It may be ip:/path or it may be just the
|
||||
* path in which case the ip needs to be in serverip.
|
||||
*/
|
||||
if ((envstr = ub_env_get("rootpath")) == NULL)
|
||||
return;
|
||||
strncpy(rootpath, envstr, sizeof(rootpath) - 1);
|
||||
rootaddr = net_parse_rootpath();
|
||||
if (rootaddr == INADDR_NONE)
|
||||
rootaddr = serveraddr;
|
||||
|
Loading…
Reference in New Issue
Block a user