diff options
author | brian <brian@FreeBSD.org> | 2004-07-08 22:35:36 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 2004-07-08 22:35:36 +0000 |
commit | aae31dbf3205a16e99cdd85918abc0a16b13a7c4 (patch) | |
tree | 20232a5e4a3c9e6b2610bd5b43c7e935d7896f38 | |
parent | eeb3c914453162ca5f06e82aeddf24e35a8c86ad (diff) | |
download | FreeBSD-src-aae31dbf3205a16e99cdd85918abc0a16b13a7c4.zip FreeBSD-src-aae31dbf3205a16e99cdd85918abc0a16b13a7c4.tar.gz |
Change the following environment variables to kernel options:
bootp -> BOOTP
bootp.nfsroot -> BOOTP_NFSROOT
bootp.nfsv3 -> BOOTP_NFSV3
bootp.compat -> BOOTP_COMPAT
bootp.wired_to -> BOOTP_WIRED_TO
- i.e. back out the previous commit. It's already possible to
pxeboot(8) with a GENERIC kernel.
Pointed out by: dwmalone
-rw-r--r-- | sys/alpha/alpha/autoconf.c | 12 | ||||
-rw-r--r-- | sys/amd64/amd64/autoconf.c | 19 | ||||
-rw-r--r-- | sys/boot/common/dev_net.c | 2 | ||||
-rw-r--r-- | sys/boot/common/loader.8 | 23 | ||||
-rw-r--r-- | sys/boot/forth/loader.conf | 5 | ||||
-rw-r--r-- | sys/conf/NOTES | 9 | ||||
-rw-r--r-- | sys/conf/files | 4 | ||||
-rw-r--r-- | sys/conf/options | 5 | ||||
-rw-r--r-- | sys/i386/i386/autoconf.c | 19 | ||||
-rw-r--r-- | sys/i386/i386/locore.s | 3 | ||||
-rw-r--r-- | sys/ia64/ia64/autoconf.c | 23 | ||||
-rw-r--r-- | sys/modules/nfs4client/Makefile | 2 | ||||
-rw-r--r-- | sys/modules/nfsclient/Makefile | 2 | ||||
-rw-r--r-- | sys/netinet/ip_input.c | 11 | ||||
-rw-r--r-- | sys/nfs4client/nfs4_vfsops.c | 1 | ||||
-rw-r--r-- | sys/nfsclient/bootp_subr.c | 156 | ||||
-rw-r--r-- | sys/nfsclient/nfs_vfsops.c | 16 |
17 files changed, 143 insertions, 169 deletions
diff --git a/sys/alpha/alpha/autoconf.c b/sys/alpha/alpha/autoconf.c index 0cf7e65..d3ffb23 100644 --- a/sys/alpha/alpha/autoconf.c +++ b/sys/alpha/alpha/autoconf.c @@ -27,6 +27,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "opt_bootp.h" #include "opt_isa.h" #include "opt_nfs.h" #include "opt_nfsroot.h" @@ -202,12 +203,11 @@ void cpu_rootconf() { #if defined(NFSCLIENT) && defined(NFS_ROOT) - char *cp = NULL; - - if (nfs_diskless_valid || (cp = getenv("bootp.nfsroot")) != NULL) - rootdevnames[0] = "nfs:"; - if (cp != NULL) - freeenv(cp); + int order = 0; +#if !defined(BOOTP_NFSROOT) + if (nfs_diskless_valid) +#endif + rootdevnames[order++] = "nfs:"; #endif } SYSINIT(cpu_rootconf, SI_SUB_ROOT_CONF, SI_ORDER_FIRST, cpu_rootconf, NULL) diff --git a/sys/amd64/amd64/autoconf.c b/sys/amd64/amd64/autoconf.c index f5a4164..c646741 100644 --- a/sys/amd64/amd64/autoconf.c +++ b/sys/amd64/amd64/autoconf.c @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); * devices are determined (from possibilities mentioned in ioconf.c), * and the drivers are initialized. */ +#include "opt_bootp.h" #include "opt_isa.h" #include "opt_nfs.h" #include "opt_nfsroot.h" @@ -142,19 +143,15 @@ configure_final(dummy) void cpu_rootconf() { - char *cp; - - if ((cp = getenv("bootp")) != NULL) { - bootpc_init(); - freeenv(cp); - } +#ifdef BOOTP + bootpc_init(); +#endif #if defined(NFSCLIENT) && defined(NFS_ROOT) - if ((cp = getenv("bootp.nfsroot")) == NULL) - nfs_setup_diskless(); - if (cp != NULL || nfs_diskless_valid) +#if !defined(BOOTP_NFSROOT) + nfs_setup_diskless(); + if (nfs_diskless_valid) +#endif rootdevnames[0] = "nfs:"; - if (cp != NULL) - freeenv(cp); #endif } SYSINIT(cpu_rootconf, SI_SUB_ROOT_CONF, SI_ORDER_FIRST, cpu_rootconf, NULL) diff --git a/sys/boot/common/dev_net.c b/sys/boot/common/dev_net.c index 2e136c4..b7ccbca 100644 --- a/sys/boot/common/dev_net.c +++ b/sys/boot/common/dev_net.c @@ -273,7 +273,7 @@ net_getparams(sock) /* * If present, strip the server's address off of the rootpath * before passing it along. This allows us to be compatible with - * the kernel's diskless (kenv bootp.nfsroot=1) booting conventions + * the kernel's diskless (BOOTP_NFSROOT) booting conventions */ for (i = 0; rootpath[i] != '\0' && i < FNAME_SIZE; i++) if (rootpath[i] == ':') diff --git a/sys/boot/common/loader.8 b/sys/boot/common/loader.8 index 958b33b..a77a828 100644 --- a/sys/boot/common/loader.8 +++ b/sys/boot/common/loader.8 @@ -352,29 +352,6 @@ by the kernel during the boot phase. List of semicolon-separated search path for bootable kernels. The default is .Dq Li kernel;kernel.old . -.It Va bootp -Setting this variable tells the kernel to use BOOTP to obtain an IP address -and hostname at boot time. -The kernel must be built with -.Dv NFSCLIENT -and -.Dv NFS_ROOT -defined. -.It Va bootp.compat -Setting this variable enables a workaround for broken BOOTP daemons. -.It Va bootp.nfsroot -Setting this variable tells the kernel to NFS mount the root filesystem using -BOOTP information. -.It Va bootp.nfsv3 -Setting this variable tells the kernel to use NFS version 3 to mount the root -filesystem. -.It Va bootp.wired_to -This variable may be set to the name of the interface that is to be used to -boot from when -.Va bootp -is set. -If it is not set, the system will attempt to boot from all available -interfaces, using the first one found. .It Va console Defines the current console. .It Va currdev diff --git a/sys/boot/forth/loader.conf b/sys/boot/forth/loader.conf index db43699..992ab06 100644 --- a/sys/boot/forth/loader.conf +++ b/sys/boot/forth/loader.conf @@ -67,11 +67,6 @@ module_path="/boot/kernel;/boot/modules" # Set the module search path #boot_single="" # Start system in single-user mode #boot_userconfig="" # Run kernel's interactive device configuration program #boot_verbose="" # Causes extra debugging information to be printed -#bootp="" # Use BOOTP to obtain an IP address at boot time -#bootp.compat="" # Enable a workaround for broken bootp daemons -#bootp.nfsroot="" # NFS mount the root filesystem using BOOTP info -#bootp.nfsv3="" # Use NFS v3 to mount the root filesystem -#bootp.wired_to="fxp0" # Use this interface only when bootp is enabled #init_path="/sbin/init:/sbin/oinit:/sbin/init.bak:/stand/sysinstall" # Sets the list of init candidates #dumpdev="ad0s1b" # Set device for crash dumps diff --git a/sys/conf/NOTES b/sys/conf/NOTES index e1cbcad..fd1b42a 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -2124,7 +2124,14 @@ device pps device lpbb device pcfclock -# Kernel BOOTP support - see loader(8) +# Kernel BOOTP support + +options BOOTP # Use BOOTP to obtain IP address/hostname + # Requires NFSCLIENT and NFS_ROOT +options BOOTP_NFSROOT # NFS mount root filesystem using BOOTP info +options BOOTP_NFSV3 # Use NFS v3 to NFS mount root +options BOOTP_COMPAT # Workaround for broken bootp daemons. +options BOOTP_WIRED_TO=fxp0 # Use interface fxp0 for BOOTP # # Add tie-ins for a hardware watchdog. This only enables the hooks; diff --git a/sys/conf/files b/sys/conf/files index 1638778..7237d64 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1573,8 +1573,8 @@ netsmb/smb_trantcp.c optional netsmb netsmb/smb_usr.c optional netsmb nfs/nfs_common.c optional nfsclient nfs/nfs_common.c optional nfsserver -nfsclient/bootp_subr.c standard -nfsclient/krpc_subr.c optional nfsclient +nfsclient/bootp_subr.c optional bootp nfsclient +nfsclient/krpc_subr.c optional bootp nfsclient nfsclient/nfs_bio.c optional nfsclient nfsclient/nfs_diskless.c optional nfsclient nfs_root nfsclient/nfs_node.c optional nfsclient diff --git a/sys/conf/options b/sys/conf/options index 71cf0fe..b593318 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -310,6 +310,11 @@ ALTQ_CDNR opt_altq.h ALTQ_PRIQ opt_altq.h ALTQ_NOPCC opt_altq.h ALTQ_DEBUG opt_altq.h +BOOTP opt_bootp.h +BOOTP_COMPAT opt_bootp.h +BOOTP_NFSROOT opt_bootp.h +BOOTP_NFSV3 opt_bootp.h +BOOTP_WIRED_TO opt_bootp.h BRIDGE opt_bdg.h DEV_PF opt_pf.h DEV_PFLOG opt_pf.h diff --git a/sys/i386/i386/autoconf.c b/sys/i386/i386/autoconf.c index 3239c1d..c213a68 100644 --- a/sys/i386/i386/autoconf.c +++ b/sys/i386/i386/autoconf.c @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); * devices are determined (from possibilities mentioned in ioconf.c), * and the drivers are initialized. */ +#include "opt_bootp.h" #include "opt_isa.h" #include "opt_nfs.h" #include "opt_nfsroot.h" @@ -180,19 +181,15 @@ configure_final(dummy) void cpu_rootconf() { - char *cp; - - if ((cp = getenv("bootp")) != NULL) { - bootpc_init(); - freeenv(cp); - } +#ifdef BOOTP + bootpc_init(); +#endif #if defined(NFSCLIENT) && defined(NFS_ROOT) - if ((cp = getenv("bootp.nfsroot")) == NULL) - nfs_setup_diskless(); - if (cp != NULL || nfs_diskless_valid) +#if !defined(BOOTP_NFSROOT) + nfs_setup_diskless(); + if (nfs_diskless_valid) +#endif rootdevnames[0] = "nfs:"; - if (cp != NULL) - freeenv(cp); #endif } SYSINIT(cpu_rootconf, SI_SUB_ROOT_CONF, SI_ORDER_FIRST, cpu_rootconf, NULL) diff --git a/sys/i386/i386/locore.s b/sys/i386/i386/locore.s index 50f32d4..72ef2bf 100644 --- a/sys/i386/i386/locore.s +++ b/sys/i386/i386/locore.s @@ -39,6 +39,7 @@ * and many others. */ +#include "opt_bootp.h" #include "opt_compat.h" #include "opt_nfsroot.h" #include "opt_pmap.h" @@ -541,6 +542,7 @@ got_common_bi_size: movsb #ifdef NFS_ROOT +#ifndef BOOTP_NFSV3 /* * If we have a nfs_diskless structure copy it in */ @@ -555,6 +557,7 @@ got_common_bi_size: movl $R(nfs_diskless_valid),%edi movl $1,(%edi) #endif +#endif /* * The old style disk boot. diff --git a/sys/ia64/ia64/autoconf.c b/sys/ia64/ia64/autoconf.c index df2e03b..dcfd1b0 100644 --- a/sys/ia64/ia64/autoconf.c +++ b/sys/ia64/ia64/autoconf.c @@ -26,6 +26,7 @@ * $FreeBSD$ */ +#include "opt_bootp.h" #include "opt_isa.h" #include "opt_nfs.h" #include "opt_nfsroot.h" @@ -53,7 +54,9 @@ static void configure(void *); SYSINIT(configure, SI_SUB_CONFIGURE, SI_ORDER_THIRD, configure, NULL) +#ifdef BOOTP void bootpc_init(void); +#endif #ifdef DEV_ISA #include <isa/isavar.h> @@ -96,18 +99,18 @@ configure(void *dummy) void cpu_rootconf() { - char *cp; +#if defined(NFSCLIENT) && defined(NFS_ROOT) + int order = 0; +#endif - if ((cp = getenv("bootp")) != NULL) { - bootpc_init(); - freeenv(cp); - cp = NULL; - } +#ifdef BOOTP + bootpc_init(); +#endif #if defined(NFSCLIENT) && defined(NFS_ROOT) - if (nfs_diskless_valid || (cp = getenv("bootp.nfsroot")) != NULL) - rootdevnames[0] = "nfs:"; - if (cp != NULL) - freeenv(cp); +#if !defined(BOOTP_NFSROOT) + if (nfs_diskless_valid) +#endif + rootdevnames[order++] = "nfs:"; #endif } SYSINIT(cpu_rootconf, SI_SUB_ROOT_CONF, SI_ORDER_FIRST, cpu_rootconf, NULL) diff --git a/sys/modules/nfs4client/Makefile b/sys/modules/nfs4client/Makefile index 0259817..723f571 100644 --- a/sys/modules/nfs4client/Makefile +++ b/sys/modules/nfs4client/Makefile @@ -6,7 +6,7 @@ KMOD= nfs4client SRCS= vnode_if.h \ nfs_bio.c nfs_lock.c nfs_node.c nfs_nfsiod.c \ nfs_common.c \ - opt_inet.h opt_nfs.h opt_nfsroot.h \ + opt_inet.h opt_nfs.h opt_bootp.h opt_nfsroot.h \ nfs4_dev.c nfs4_idmap.c nfs4_socket.c nfs4_subs.c \ nfs4_vfs_subs.c nfs4_vfsops.c nfs4_vn_subs.c nfs4_vnops.c SRCS+= opt_inet6.h diff --git a/sys/modules/nfsclient/Makefile b/sys/modules/nfsclient/Makefile index 688bd37..11b83eb 100644 --- a/sys/modules/nfsclient/Makefile +++ b/sys/modules/nfsclient/Makefile @@ -7,7 +7,7 @@ KMOD= nfsclient SRCS= vnode_if.h \ nfs_bio.c nfs_lock.c nfs_node.c nfs_socket.c nfs_subs.c nfs_nfsiod.c \ nfs_vfsops.c nfs_vnops.c nfs_common.c \ - opt_inet.h opt_nfs.h opt_nfsroot.h + opt_inet.h opt_nfs.h opt_bootp.h opt_nfsroot.h SRCS+= nfs4_dev.c nfs4_idmap.c nfs4_socket.c nfs4_subs.c \ nfs4_vfs_subs.c nfs4_vfsops.c nfs4_vn_subs.c nfs4_vnops.c SRCS+= opt_inet6.h diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 77c8c79..048f613 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -30,6 +30,7 @@ * $FreeBSD$ */ +#include "opt_bootp.h" #include "opt_ipfw.h" #include "opt_ipdn.h" #include "opt_ipdivert.h" @@ -298,7 +299,6 @@ ip_input(struct mbuf *m) struct ipq *fp; struct in_ifaddr *ia = NULL; struct ifaddr *ifa; - char *cp; int i, checkif, hlen = 0; u_short sum; struct in_addr pkt_dst; @@ -598,11 +598,10 @@ pass: goto ours; if (ia->ia_netbroadcast.s_addr == pkt_dst.s_addr) goto ours; - if ((cp = getenv("bootp.compat")) != NULL) { - freeenv(cp); - if (IA_SIN(ia)->sin_addr.s_addr == INADDR_ANY) - goto ours; - } +#ifdef BOOTP_COMPAT + if (IA_SIN(ia)->sin_addr.s_addr == INADDR_ANY) + goto ours; +#endif } } if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { diff --git a/sys/nfs4client/nfs4_vfsops.c b/sys/nfs4client/nfs4_vfsops.c index c9b3e3c..e20d176 100644 --- a/sys/nfs4client/nfs4_vfsops.c +++ b/sys/nfs4client/nfs4_vfsops.c @@ -62,6 +62,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "opt_bootp.h" #include "opt_nfsroot.h" #include <sys/param.h> diff --git a/sys/nfsclient/bootp_subr.c b/sys/nfsclient/bootp_subr.c index d68a94f..2132ef5 100644 --- a/sys/nfsclient/bootp_subr.c +++ b/sys/nfsclient/bootp_subr.c @@ -43,6 +43,8 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "opt_bootp.h" + #include <sys/param.h> #include <sys/systm.h> #include <sys/kernel.h> @@ -588,7 +590,6 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct thread *td) int gotrootpath; int retry; const char *s; - char *cp; NET_ASSERT_GIANT(); @@ -953,19 +954,14 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct thread *td) error = 0; goto out; } - - if ((cp = getenv("bootp.nfsroot")) != NULL) - freeenv(cp); - else { - for (ifctx = gctx->interfaces; ifctx != NULL; - ifctx = ifctx->next) { - if (bootpc_ifctx_isresolved(ifctx) != 0) { - error = 0; - goto out; - } +#ifndef BOOTP_NFSROOT + for (ifctx = gctx->interfaces; ifctx != NULL; ifctx = ifctx->next) { + if (bootpc_ifctx_isresolved(ifctx) != 0) { + error = 0; + goto out; } } - +#endif error = ETIMEDOUT; goto out; @@ -1645,9 +1641,10 @@ bootpc_init(void) struct bootpc_ifcontext *ifctx, *nctx; /* Interface BOOTP contexts */ struct bootpc_globalcontext *gctx; /* Global BOOTP context */ struct ifnet *ifp; - char *cp, *bootp_wired_to; - int bootp_nfsroot, error; + int error; +#ifndef BOOTP_WIRED_TO int ifcnt; +#endif struct nfsv3_diskless *nd; struct thread *td; @@ -1670,31 +1667,31 @@ bootpc_init(void) /* * Find a network interface. */ - if ((bootp_wired_to = getenv("bootp.wired_to")) != NULL) { - printf("bootpc_init: wired to interface '%s'\n", - bootp_wired_to); - allocifctx(gctx); - } else { - /* - * Preallocate interface context storage, if another interface - * attaches and wins the race, it won't be eligible for bootp. - */ - IFNET_RLOCK(); - for (ifp = TAILQ_FIRST(&ifnet), ifcnt = 0; - ifp != NULL; - ifp = TAILQ_NEXT(ifp, if_link)) { - if ((ifp->if_flags & - (IFF_LOOPBACK | IFF_POINTOPOINT | IFF_BROADCAST)) != - IFF_BROADCAST) - continue; - ifcnt++; - } - IFNET_RUNLOCK(); - if (ifcnt == 0) - panic("bootpc_init: no eligible interfaces"); - for (; ifcnt > 0; ifcnt--) - allocifctx(gctx); +#ifdef BOOTP_WIRED_TO + printf("bootpc_init: wired to interface '%s'\n", + __XSTRING(BOOTP_WIRED_TO)); + allocifctx(gctx); +#else + /* + * Preallocate interface context storage, if another interface + * attaches and wins the race, it won't be eligible for bootp. + */ + IFNET_RLOCK(); + for (ifp = TAILQ_FIRST(&ifnet), ifcnt = 0; + ifp != NULL; + ifp = TAILQ_NEXT(ifp, if_link)) { + if ((ifp->if_flags & + (IFF_LOOPBACK | IFF_POINTOPOINT | IFF_BROADCAST)) != + IFF_BROADCAST) + continue; + ifcnt++; } + IFNET_RUNLOCK(); + if (ifcnt == 0) + panic("bootpc_init: no eligible interfaces"); + for (; ifcnt > 0; ifcnt--) + allocifctx(gctx); +#endif IFNET_RLOCK(); for (ifp = TAILQ_FIRST(&ifnet), ifctx = gctx->interfaces; @@ -1702,24 +1699,29 @@ bootpc_init(void) ifp = TAILQ_NEXT(ifp, if_link)) { strlcpy(ifctx->ireq.ifr_name, ifp->if_xname, sizeof(ifctx->ireq.ifr_name)); - if (bootp_wired_to) { - if (strcmp(ifctx->ireq.ifr_name, bootp_wired_to) != 0) - continue; - } else if ((ifp->if_flags & - (IFF_LOOPBACK | IFF_POINTOPOINT | IFF_BROADCAST)) != +#ifdef BOOTP_WIRED_TO + if (strcmp(ifctx->ireq.ifr_name, + __XSTRING(BOOTP_WIRED_TO)) != 0) + continue; +#else + if ((ifp->if_flags & + (IFF_LOOPBACK | IFF_POINTOPOINT | IFF_BROADCAST)) != IFF_BROADCAST) continue; +#endif ifctx->ifp = ifp; ifctx = ifctx->next; } IFNET_RUNLOCK(); if (gctx->interfaces == NULL || gctx->interfaces->ifp == NULL) { - if (bootp_wired_to) - panic("bootpc_init: Could not find interface specified " - "by bootp.wired_to: %s", bootp_wired_to); - else - panic("bootpc_init: no suitable interface"); +#ifdef BOOTP_WIRED_TO + panic("bootpc_init: Could not find interface specified " + "by BOOTP_WIRED_TO: " + __XSTRING(BOOTP_WIRED_TO)); +#else + panic("bootpc_init: no suitable interface"); +#endif } for (ifctx = gctx->interfaces; ifctx != NULL; ifctx = ifctx->next) @@ -1730,17 +1732,12 @@ bootpc_init(void) error = bootpc_call(gctx, td); - if ((cp = getenv("bootp.nfsroot")) != NULL) { - freeenv(cp); - bootp_nfsroot = 1; - } else - bootp_nfsroot = 0; - if (error != 0) { - if (bootp_nfsroot) - panic("BOOTP call failed"); - else - printf("BOOTP call failed\n"); +#ifdef BOOTP_NFSROOT + panic("BOOTP call failed"); +#else + printf("BOOTP call failed\n"); +#endif } mountopts(&nd->root_args, NULL); @@ -1749,8 +1746,10 @@ bootpc_init(void) if (bootpc_ifctx_isresolved(ifctx) != 0) bootpc_decode_reply(nd, ifctx, gctx); - if (bootp_nfsroot && gctx->gotrootpath == 0) +#ifdef BOOTP_NFSROOT + if (gctx->gotrootpath == 0) panic("bootpc: No root path offered"); +#endif for (ifctx = gctx->interfaces; ifctx != NULL; ifctx = ifctx->next) { bootpc_adjust_interface(ifctx, gctx, td); @@ -1796,8 +1795,6 @@ out: free(ifctx, M_TEMP); } free(gctx, M_TEMP); - if (bootp_wired_to) - freeenv(bootp_wired_to); } /* @@ -1810,31 +1807,27 @@ md_mount(struct sockaddr_in *mdsin, char *path, u_char *fhp, int *fhsizep, struct nfs_args *args, struct thread *td) { struct mbuf *m; - char *cp; int error; int authunixok; int authcount; int authver; - if ((cp = getenv("bootp.nfsv3")) != NULL) { - /* First try NFS v3 */ - /* Get port number for MOUNTD. */ - freeenv(cp); - error = krpc_portmap(mdsin, RPCPROG_MNT, RPCMNT_VER3, - &mdsin->sin_port, td); - if (error == 0) { - m = xdr_string_encode(path, strlen(path)); - - /* Do RPC to mountd. */ - error = krpc_call(mdsin, RPCPROG_MNT, RPCMNT_VER3, - RPCMNT_MOUNT, &m, NULL, td); - } - if (error == 0) - args->flags |= NFSMNT_NFSV3; - } else - error = 1; /* Need to try NFS v2 */ +#ifdef BOOTP_NFSV3 + /* First try NFS v3 */ + /* Get port number for MOUNTD. */ + error = krpc_portmap(mdsin, RPCPROG_MNT, RPCMNT_VER3, + &mdsin->sin_port, td); + if (error == 0) { + m = xdr_string_encode(path, strlen(path)); - if (error) { + /* Do RPC to mountd. */ + error = krpc_call(mdsin, RPCPROG_MNT, RPCMNT_VER3, + RPCMNT_MOUNT, &m, NULL, td); + } + if (error == 0) { + args->flags |= NFSMNT_NFSV3; + } else { +#endif /* Fallback to NFS v2 */ /* Get port number for MOUNTD. */ @@ -1850,7 +1843,10 @@ md_mount(struct sockaddr_in *mdsin, char *path, u_char *fhp, int *fhsizep, RPCMNT_MOUNT, &m, NULL, td); if (error != 0) return error; /* message already freed */ + +#ifdef BOOTP_NFSV3 } +#endif if (xdr_int_decode(&m, &error) != 0 || error != 0) goto bad; diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c index ec63a7a..9674628 100644 --- a/sys/nfsclient/nfs_vfsops.c +++ b/sys/nfsclient/nfs_vfsops.c @@ -35,6 +35,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "opt_bootp.h" #include "opt_nfsroot.h" #include <sys/param.h> @@ -388,23 +389,16 @@ nfs_mountroot(struct mount *mp, struct thread *td) struct nfsv3_diskless *nd = &nfsv3_diskless; struct socket *so; struct vnode *vp; - char *cp; int error, i; u_long l; char buf[128]; GIANT_REQUIRED; /* XXX until socket locking done */ - if ((cp = getenv("bootp")) != NULL) { - freeenv(cp); - if ((cp = getenv("bootp.nfsroot")) != NULL) { - freeenv(cp); - bootpc_init(); /* get nfs_diskless filled in */ - } - } -#if defined(NFS_ROOT) - if (cp == NULL) - nfs_setup_diskless(); +#if defined(BOOTP_NFSROOT) && defined(BOOTP) + bootpc_init(); /* use bootp to get nfs_diskless filled in */ +#elif defined(NFS_ROOT) + nfs_setup_diskless(); #endif if (nfs_diskless_valid == 0) |