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
This commit is contained in:
Brian Somers 2004-07-08 22:35:36 +00:00
parent 63fcce68f1
commit 0ac4013324
17 changed files with 144 additions and 170 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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] == ':')

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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
*/
@ -554,6 +556,7 @@ got_common_bi_size:
movsb
movl $R(nfs_diskless_valid),%edi
movl $1,(%edi)
#endif
#endif
/*

View File

@ -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 ((cp = getenv("bootp")) != NULL) {
bootpc_init();
freeenv(cp);
cp = NULL;
}
#if defined(NFSCLIENT) && defined(NFS_ROOT)
if (nfs_diskless_valid || (cp = getenv("bootp.nfsroot")) != NULL)
rootdevnames[0] = "nfs:";
if (cp != NULL)
freeenv(cp);
int order = 0;
#endif
#ifdef BOOTP
bootpc_init();
#endif
#if defined(NFSCLIENT) && defined(NFS_ROOT)
#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)

View File

@ -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

View File

@ -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

View File

@ -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 @@ ip_input(struct mbuf *m)
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))) {

View File

@ -62,6 +62,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "opt_bootp.h"
#include "opt_nfsroot.h"
#include <sys/param.h>

View File

@ -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 @@ bootpc_init(void)
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));
#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));
/* 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 */
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;

View File

@ -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)