diff options
author | ian <ian@FreeBSD.org> | 2016-02-22 18:53:55 +0000 |
---|---|---|
committer | ian <ian@FreeBSD.org> | 2016-02-22 18:53:55 +0000 |
commit | f52f52309988edc8b7766212f900ed5b40ff341c (patch) | |
tree | 45f7342eac77605cf994a2df740c5d1cec31d8cc | |
parent | eccec115f860cf9d4515aa74b37c2a2f7370606a (diff) | |
download | FreeBSD-src-f52f52309988edc8b7766212f900ed5b40ff341c.zip FreeBSD-src-f52f52309988edc8b7766212f900ed5b40ff341c.tar.gz |
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).
-rw-r--r-- | sys/boot/uboot/lib/net.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/sys/boot/uboot/lib/net.c b/sys/boot/uboot/lib/net.c index 20a26b7..9bc0c07 100644 --- a/sys/boot/uboot/lib/net.c +++ b/sys/boot/uboot/lib/net.c @@ -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; |