summaryrefslogtreecommitdiffstats
path: root/sys/boot
diff options
context:
space:
mode:
authorbapt <bapt@FreeBSD.org>2016-10-19 13:26:07 +0000
committerbapt <bapt@FreeBSD.org>2016-10-19 13:26:07 +0000
commit83fbe0035b4271799832a877abf0806f2602c9ab (patch)
treeade1d093d4a0180e46b2e308fdf6692b7d2aa464 /sys/boot
parent9837f2846a73d054cd7637ec275baa49506a0216 (diff)
downloadFreeBSD-src-83fbe0035b4271799832a877abf0806f2602c9ab.zip
FreeBSD-src-83fbe0035b4271799832a877abf0806f2602c9ab.tar.gz
MFC: 304677, 304680, 305125, 305770, 305769
r304677: Add tftpfs support for the EFI loader Allow netbooting on efi without having to setup any NFS server by rebuilding the loader with LOADER_TFTP_SUPPORT like for the i386 pxeloader r305125: Netboot: allow both tftpfs and nfs in both pxeboot and loader.efi Add a new 'netproto' variable which can be set for now to NET_TFTP or NET_NFS (default to NET_NONE) From the dhcp options if one sets the root-path option to: "ip:path", the loader will consider it is booting over NFS (meaning same behaviour as the default current behaviour) if the dhcp option "tftp server address" is set (option 150) the loader will consider it is booting over tftpfs, it will then consider the root-path options with 2 possible case 1. "path" then the IP of the tftp server will be the one passed by the option 150, and the files will be retrieved under "path" on the tftp server 2. "ip:path" then the IP of the tftp server will be the one passed in the option "overwritting the IP from the option 150. We could not "abuse" the rootpath option in the form or tftp://ip:path because this is already used for other purpose by iPXE preventing any chainload from iPXE to the FreeBSD loader. Given at each open(), the loader loops over all available filesystems and keep the "best" error, we needed to prevent tftpfs to fallback on nfs and vice versa. the tftpfs and nfs implementation in libstand now return EINVAL early if 'netproto' for that purpose. Relnotes: yes Sponsored by: Gandi.net
Diffstat (limited to 'sys/boot')
-rw-r--r--sys/boot/common/dev_net.c18
-rw-r--r--sys/boot/efi/loader/conf.c1
-rw-r--r--sys/boot/i386/libi386/pxe.c35
-rw-r--r--sys/boot/i386/loader/conf.c4
-rw-r--r--sys/boot/pc98/loader/conf.c4
5 files changed, 36 insertions, 26 deletions
diff --git a/sys/boot/common/dev_net.c b/sys/boot/common/dev_net.c
index ed07a2c..09583d0 100644
--- a/sys/boot/common/dev_net.c
+++ b/sys/boot/common/dev_net.c
@@ -167,8 +167,14 @@ net_open(struct open_file *f, ...)
setenv("boot.netif.ip", inet_ntoa(myip), 1);
setenv("boot.netif.netmask", intoa(netmask), 1);
setenv("boot.netif.gateway", inet_ntoa(gateip), 1);
- setenv("boot.nfsroot.server", inet_ntoa(rootip), 1);
- setenv("boot.nfsroot.path", rootpath, 1);
+ setenv("boot.netif.server", inet_ntoa(rootip), 1);
+ if (netproto == NET_TFTP) {
+ setenv("boot.tftproot.server", inet_ntoa(rootip), 1);
+ setenv("boot.tftproot.path", rootpath, 1);
+ } else if (netproto == NET_NFS) {
+ setenv("boot.nfsroot.server", inet_ntoa(rootip), 1);
+ setenv("boot.nfsroot.path", rootpath, 1);
+ }
if (intf_mtu != 0) {
char mtu[16];
sprintf(mtu, "%u", intf_mtu);
@@ -365,6 +371,13 @@ net_parse_rootpath()
int i;
n_long addr = INADDR_NONE;
+ netproto = NET_NFS;
+
+ if (tftpip.s_addr != 0) {
+ netproto = NET_TFTP;
+ addr = tftpip.s_addr;
+ }
+
for (i = 0; rootpath[i] != '\0' && i < FNAME_SIZE; i++)
if (rootpath[i] == ':')
break;
@@ -373,5 +386,6 @@ net_parse_rootpath()
addr = inet_addr(&rootpath[0]);
bcopy(&rootpath[i], rootpath, strlen(&rootpath[i])+1);
}
+
return (addr);
}
diff --git a/sys/boot/efi/loader/conf.c b/sys/boot/efi/loader/conf.c
index ecbf8b0..3596a63 100644
--- a/sys/boot/efi/loader/conf.c
+++ b/sys/boot/efi/loader/conf.c
@@ -51,6 +51,7 @@ struct fs_ops *file_system[] = {
&dosfs_fsops,
&ufs_fsops,
&cd9660_fsops,
+ &tftp_fsops,
&nfs_fsops,
&gzipfs_fsops,
&bzipfs_fsops,
diff --git a/sys/boot/i386/libi386/pxe.c b/sys/boot/i386/libi386/pxe.c
index 096ebc4..28046f3 100644
--- a/sys/boot/i386/libi386/pxe.c
+++ b/sys/boot/i386/libi386/pxe.c
@@ -288,10 +288,15 @@ pxe_open(struct open_file *f, ...)
bootp(pxe_sock, BOOTP_PXE);
if (rootip.s_addr == 0)
rootip.s_addr = bootplayer.sip;
-#ifdef LOADER_NFS_SUPPORT
- if (!rootpath[0])
+
+ netproto = NET_NFS;
+ if (tftpip.s_addr != 0) {
+ netproto = NET_TFTP;
+ rootip.s_addr = tftpip.s_addr;
+ }
+
+ if (netproto == NET_NFS && !rootpath[0])
strcpy(rootpath, PXENFSROOTPATH);
-#endif
for (i = 0; rootpath[i] != '\0' && i < FNAME_SIZE; i++)
if (rootpath[i] == ':')
@@ -315,17 +320,17 @@ pxe_open(struct open_file *f, ...)
sprintf(mtu, "%u", intf_mtu);
setenv("boot.netif.mtu", mtu, 1);
}
-#ifdef LOADER_NFS_SUPPORT
printf("pxe_open: server addr: %s\n", inet_ntoa(rootip));
printf("pxe_open: server path: %s\n", rootpath);
printf("pxe_open: gateway ip: %s\n", inet_ntoa(gateip));
- setenv("boot.nfsroot.server", inet_ntoa(rootip), 1);
- setenv("boot.nfsroot.path", rootpath, 1);
-#else
- setenv("boot.netif.server", inet_ntoa(rootip), 1);
- setenv("boot.tftproot.path", rootpath, 1);
-#endif
+ if (netproto == NET_NFS) {
+ setenv("boot.nfsroot.server", inet_ntoa(rootip), 1);
+ setenv("boot.nfsroot.path", rootpath, 1);
+ } else if (netproto == NET_TFTP) {
+ setenv("boot.netif.server", inet_ntoa(rootip), 1);
+ setenv("boot.tftproot.path", rootpath, 1);
+ }
setenv("dhcp.host-name", hostname, 1);
setenv("pxeboot.ip", inet_ntoa(myip), 1);
@@ -359,10 +364,10 @@ pxe_close(struct open_file *f)
if (pxe_opens > 0)
return(0);
-#ifdef LOADER_NFS_SUPPORT
- /* get an NFS filehandle for our root filesystem */
- pxe_setnfshandle(rootpath);
-#endif
+ if (netproto == NET_NFS) {
+ /* get an NFS filehandle for our root filesystem */
+ pxe_setnfshandle(rootpath);
+ }
if (pxe_sock >= 0) {
@@ -422,7 +427,6 @@ pxe_perror(int err)
return;
}
-#ifdef LOADER_NFS_SUPPORT
/*
* Reach inside the libstand NFS code and dig out an NFS handle
* for the root filesystem.
@@ -533,7 +537,6 @@ pxe_setnfshandle(char *rootpath)
setenv("boot.nfsroot.nfshandlelen", buf, 1);
}
#endif /* OLD_NFSV2 */
-#endif /* LOADER_NFS_SUPPORT */
void
pxenv_call(int func)
diff --git a/sys/boot/i386/loader/conf.c b/sys/boot/i386/loader/conf.c
index 38df74d..29ce1e3 100644
--- a/sys/boot/i386/loader/conf.c
+++ b/sys/boot/i386/loader/conf.c
@@ -45,10 +45,6 @@ __FBSDID("$FreeBSD$");
* XXX as libi386 and biosboot merge, some of these can become linker sets.
*/
-#if defined(LOADER_NFS_SUPPORT) && defined(LOADER_TFTP_SUPPORT)
-#error "Cannot have both tftp and nfs support yet."
-#endif
-
#if defined(LOADER_FIREWIRE_SUPPORT)
extern struct devsw fwohci;
#endif
diff --git a/sys/boot/pc98/loader/conf.c b/sys/boot/pc98/loader/conf.c
index d05cd13..695c260 100644
--- a/sys/boot/pc98/loader/conf.c
+++ b/sys/boot/pc98/loader/conf.c
@@ -42,10 +42,6 @@ __FBSDID("$FreeBSD$");
* XXX as libi386 and biosboot merge, some of these can become linker sets.
*/
-#if defined(LOADER_NFS_SUPPORT) && defined(LOADER_TFTP_SUPPORT)
-#error "Cannot have both tftp and nfs support yet."
-#endif
-
/* Exported for libstand */
struct devsw *devsw[] = {
&bioscd,
OpenPOWER on IntegriCloud