From 924d84dc7aa9fc64a9236547607679645a139d85 Mon Sep 17 00:00:00 2001 From: Andy Fiddaman Date: Thu, 10 May 2018 21:26:18 +0000 Subject: [PATCH] 9469 pxeboot should default to TFTP in absence of root-path 9470 pxeboot should assume / if no path provided in root-path 9471 pxeboot.5 example ISC DHCP daemon syntax does not work Reviewed by: Dominik Hassler Reviewed by: Toomas Soome Approved by: Dan McDonald --- usr/src/boot/sys/boot/common/dev_net.c | 25 ++++++++++++++++++++----- usr/src/man/man5/pxeboot.5 | 13 ++++++++++--- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/usr/src/boot/sys/boot/common/dev_net.c b/usr/src/boot/sys/boot/common/dev_net.c index 46b5481222..1814d3e682 100644 --- a/usr/src/boot/sys/boot/common/dev_net.c +++ b/usr/src/boot/sys/boot/common/dev_net.c @@ -27,6 +27,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ +/* + * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. + */ + #include /* @@ -362,6 +366,8 @@ net_print(int verbose) * 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 @@ net_parse_rootpath(void) 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 @@ net_parse_rootpath(void) * 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), diff --git a/usr/src/man/man5/pxeboot.5 b/usr/src/man/man5/pxeboot.5 index 5e0a820420..0954d585bc 100644 --- a/usr/src/man/man5/pxeboot.5 +++ b/usr/src/man/man5/pxeboot.5 @@ -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 @@ The .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 @@ max-lease-time 120; 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 @@ defaults to using NFS if the 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. -- 2.11.4.GIT