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
This commit is contained in:
Luigi Rizzo 2002-03-13 09:23:11 +00:00
parent 64f24fd5b8
commit 49b144f286
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=92219

View File

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