Date: Mon, 22 Feb 2016 18:53:55 +0000 (UTC) From: Ian Lepore <ian@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r295895 - head/sys/boot/uboot/lib Message-ID: <201602221853.u1MIrt5V064059@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ian Date: Mon Feb 22 18:53:55 2016 New Revision: 295895 URL: https://svnweb.freebsd.org/changeset/base/295895 Log: 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). Modified: head/sys/boot/uboot/lib/net.c Modified: head/sys/boot/uboot/lib/net.c ============================================================================== --- head/sys/boot/uboot/lib/net.c Mon Feb 22 17:18:36 2016 (r295894) +++ head/sys/boot/uboot/lib/net.c Mon Feb 22 18:53:55 2016 (r295895) @@ -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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201602221853.u1MIrt5V064059>