summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorluigi <luigi@FreeBSD.org>2002-03-13 09:23:11 +0000
committerluigi <luigi@FreeBSD.org>2002-03-13 09:23:11 +0000
commitd4a3339ee0407cbcb5011092efa77422dfa52be7 (patch)
tree638cbf2eb69d4c10fc4f6c494720bd7e4c153041 /sys
parente11d2515d54dca98d8c75dba28e6922034531af9 (diff)
downloadFreeBSD-src-d4a3339ee0407cbcb5011092efa77422dfa52be7.zip
FreeBSD-src-d4a3339ee0407cbcb5011092efa77422dfa52be7.tar.gz
Add a readonly sysctl variable of type string, kern.bootp_cookie,
which is initialized with whatever string a dhcp/bootp server passes as vendor tag 134. There is no standard tag that I know with this information, and no vendor-defined tag that applies to FreeBSD that I could find doing the same thing. The intended use is to pass information to userland for run-time configuration of a diskless client without having to run a bootp/dhcp client for the third time (after the one in pxeboot/etherboot, and the one in the kernel bootp), also because these clients generally screwup the interface configuration, which is not exactly what you want when you have your disks nfs-mounted. Manpage update to follow soon. MFC-after: 3 days
Diffstat (limited to 'sys')
-rw-r--r--sys/nfsclient/bootp_subr.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/sys/nfsclient/bootp_subr.c b/sys/nfsclient/bootp_subr.c
index 27a5877..5de53ef 100644
--- a/sys/nfsclient/bootp_subr.c
+++ b/sys/nfsclient/bootp_subr.c
@@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
#include <sys/proc.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
+#include <sys/sysctl.h>
#include <sys/uio.h>
#include <net/if.h>
@@ -197,6 +198,7 @@ struct bootpc_globalcontext {
#define TAG_SWAPSIZE 129
#define TAG_ROOTOPTS 130
#define TAG_SWAPOPTS 131
+#define TAG_COOKIE 134 /* ascii info for userland, via sysctl */
#define TAG_DHCP_MSGTYPE 53
#define TAG_DHCP_REQ_ADDR 50
@@ -209,6 +211,10 @@ struct bootpc_globalcontext {
#define DHCP_REQUEST 3
#define DHCP_ACK 5
+static char bootp_cookie[128];
+SYSCTL_STRING(_kern, OID_AUTO, bootp_cookie, CTLFLAG_RD,
+ bootp_cookie, 0, "Cookie (T134) supplied by bootp server");
+
/* mountd RPC */
static int md_mount(struct sockaddr_in *mdsin, char *path, u_char *fhp,
int *fhsizep, struct nfs_args *args, struct thread *td);
@@ -1607,6 +1613,15 @@ bootpc_decode_reply(struct nfsv3_diskless *nd, struct bootpc_ifcontext *ifctx,
gctx->sethostname = ifctx;
}
}
+ p = bootpc_tag(&gctx->tag, &ifctx->reply, ifctx->replylen,
+ TAG_COOKIE);
+ if (p != NULL) { /* store in a sysctl variable */
+ int i, l = sizeof(bootp_cookie) - 1;
+ for (i = 0; i < l && p[i] != '\0'; i++)
+ bootp_cookie[i] = p[i];
+ p[i] = '\0';
+ }
+
printf("\n");
OpenPOWER on IntegriCloud