changeset 18826:50e32dd26136

pxeboot should default to TFTP in absence of root-path pxeboot should assume / if no path provided in root-path pxeboot.5 example ISC DHCP daemon syntax does not work illumos issues #9469 9470, 9471 Ported by Toomas Soome
author Andy Fiddaman <omnios@citrus-it.co.uk>
date Thu, 10 May 2018 21:26:18 +0000
parents 2ed7ea649fe9
children b9131745b637
files share/man/man5/pxeboot.5 usr/src/boot/sys/boot/common/dev_net.c
diffstat 2 files changed, 30 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/share/man/man5/pxeboot.5	Thu Mar 29 16:11:54 2018 +0300
+++ b/share/man/man5/pxeboot.5	Thu May 10 21:26:18 2018 +0000
@@ -22,7 +22,9 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd May 28, 2017
+.\" Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
+.\"
+.Dd Apr 13, 2018
 .Dt PXEBOOT 5
 .Os
 .Sh NAME
@@ -52,7 +54,7 @@
 .Nm
 binary is loaded just like any other boot file,
 by specifying it in the DHCP server's configuration file.
-Below is a sample configuration for the ISC DHCP v2 server:
+Below is a sample configuration for the ISC DHCP server:
 .Bd -literal -offset indent
 option domain-name "example.com";
 option routers 10.0.0.1;
@@ -68,7 +70,7 @@
 subnet 10.0.0.0 netmask 255.255.255.0 {
        filename "pxeboot";
        range 10.0.0.10 10.0.0.254;
-       if exists user-class and option user-class = "illumos" {
+       if exists user-class and option user-class ~~ "illumos" {
             option root-path "tftp://10.0.0.1/illumos";
        }
 }
@@ -114,6 +116,11 @@
 variable is in the
 .Qq Pa ip-address Ns :/ Ns Pa path
 form, otherwise TFTP is used.
+If no
+.Va root-path
+option is set in the DHCP response,
+.Nm
+defaults to using TFTP.
 .Pp
 .Nm
 defaults to a conservative 1024 byte NFS data packet size.
--- a/usr/src/boot/sys/boot/common/dev_net.c	Thu Mar 29 16:11:54 2018 +0300
+++ b/usr/src/boot/sys/boot/common/dev_net.c	Thu May 10 21:26:18 2018 +0000
@@ -27,6 +27,10 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+/*
+ * Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
+ */
+
 #include <sys/cdefs.h>
 
 /*
@@ -362,6 +366,8 @@
  * If an IPv4 address has been specified, it will be stripped out and passed
  * out as the return value of this function in network byte order.
  *
+ * If no rootpath is present then we will default to TFTP.
+ *
  * If no global default scheme has been specified and no scheme has been
  * specified, we will assume that this is an NFS URL.
  *
@@ -388,11 +394,15 @@
 	ptr = rootpath;
 	/* Fallback for compatibility mode */
 	if (netproto == NET_NONE) {
-		netproto = NET_NFS;
-		(void) strsep(&ptr, ":");
-		if (ptr != NULL) {
-			addr = inet_addr(rootpath);
-			bcopy(ptr, rootpath, strlen(ptr) + 1);
+		if (strcmp(rootpath, "/") == 0) {
+			netproto = NET_TFTP;
+		} else {
+			netproto = NET_NFS;
+			(void) strsep(&ptr, ":");
+			if (ptr != NULL) {
+				addr = inet_addr(rootpath);
+				bcopy(ptr, rootpath, strlen(ptr) + 1);
+			}
 		}
 	} else {
 		ptr += strlen(uri_schemes[i].scheme);
@@ -405,6 +415,11 @@
 			 * Also will need rework for IPv6.
 			 */
 			val = strchr(ptr, '/');
+			if (val == NULL) {
+				/* If no pathname component, default to / */
+				strlcat(rootpath, "/", sizeof (rootpath));
+				val = strchr(ptr, '/');
+			}
 			if (val != NULL) {
 				snprintf(ip, sizeof (ip), "%.*s",
 				    (int)((uintptr_t)val - (uintptr_t)ptr),