summaryrefslogtreecommitdiffstats
path: root/sys/nfsclient/bootp_subr.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2004-07-08 22:35:36 +0000
committerbrian <brian@FreeBSD.org>2004-07-08 22:35:36 +0000
commitaae31dbf3205a16e99cdd85918abc0a16b13a7c4 (patch)
tree20232a5e4a3c9e6b2610bd5b43c7e935d7896f38 /sys/nfsclient/bootp_subr.c
parenteeb3c914453162ca5f06e82aeddf24e35a8c86ad (diff)
downloadFreeBSD-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
Diffstat (limited to 'sys/nfsclient/bootp_subr.c')
-rw-r--r--sys/nfsclient/bootp_subr.c156
1 files changed, 76 insertions, 80 deletions
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;
OpenPOWER on IntegriCloud