Module Name: src
Committed By: roy
Date: Fri Jul 10 01:29:55 UTC 2009
Modified Files:
src/sys/nfs: nfs_bootdhcp.c
Log Message:
When using DHCP, request the parameters that we need. Fixes PR kern/38830.
Thanks to Tim McIntosh.
To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/nfs/nfs_bootdhcp.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/nfs/nfs_bootdhcp.c
diff -u src/sys/nfs/nfs_bootdhcp.c:1.48 src/sys/nfs/nfs_bootdhcp.c:1.49
--- src/sys/nfs/nfs_bootdhcp.c:1.48 Wed May 6 05:34:12 2009
+++ src/sys/nfs/nfs_bootdhcp.c Fri Jul 10 01:29:54 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: nfs_bootdhcp.c,v 1.48 2009/05/06 05:34:12 cegger Exp $ */
+/* $NetBSD: nfs_bootdhcp.c,v 1.49 2009/07/10 01:29:54 roy Exp $ */
/*-
* Copyright (c) 1995, 1997 The NetBSD Foundation, Inc.
@@ -44,7 +44,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_bootdhcp.c,v 1.48 2009/05/06 05:34:12 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_bootdhcp.c,v 1.49 2009/07/10 01:29:54 roy Exp $");
#ifdef _KERNEL_OPT
#include "opt_nfs_boot.h"
@@ -461,6 +461,7 @@
#ifdef NFS_BOOT_DHCP
char vci[64];
int vcilen;
+ unsigned int index;
#endif
error = socreate(AF_INET, &so, SOCK_DGRAM, 0, lwp, NULL);
@@ -586,21 +587,32 @@
/* Fill-in the vendor data. */
memcpy(bootp->bp_vend, vm_rfc1048, 4);
#ifdef NFS_BOOT_DHCP
- bootp->bp_vend[4] = TAG_DHCP_MSGTYPE;
- bootp->bp_vend[5] = 1;
- bootp->bp_vend[6] = DHCPDISCOVER;
+ index = 4;
+ bootp->bp_vend[index++] = TAG_DHCP_MSGTYPE;
+ bootp->bp_vend[index++] = 1;
+ bootp->bp_vend[index++] = DHCPDISCOVER;
+ /* Request the paramters we need. */
+ bootp->bp_vend[index++] = TAG_PARAM_REQ;
+ bootp->bp_vend[index++] = 6;
+ bootp->bp_vend[index++] = TAG_SUBNET_MASK;
+ bootp->bp_vend[index++] = TAG_GATEWAY;
+ bootp->bp_vend[index++] = TAG_HOST_NAME;
+ bootp->bp_vend[index++] = TAG_DOMAIN_NAME;
+ bootp->bp_vend[index++] = TAG_ROOT_PATH;
+ bootp->bp_vend[index++] = TAG_SWAP_SERVER;
/*
* Insert a NetBSD Vendor Class Identifier option.
*/
snprintf(vci, sizeof(vci), "%s:%s:kernel:%s", ostype, MACHINE,
osrelease);
vcilen = strlen(vci);
- bootp->bp_vend[7] = TAG_CLASSID;
- bootp->bp_vend[8] = vcilen;
- memcpy(&bootp->bp_vend[9], vci, vcilen);
- bootp->bp_vend[9 + vcilen] = TAG_END;
+ bootp->bp_vend[index++] = TAG_CLASSID;
+ bootp->bp_vend[index++] = vcilen;
+ memcpy(&bootp->bp_vend[index], vci, vcilen);
+ index += vcilen;
+ bootp->bp_vend[index] = TAG_END;
#else
- bootp->bp_vend[4] = TAG_END;
+ bootp->bp_vend[index] = TAG_END;
#endif
bpc.xid = xid;
@@ -622,21 +634,38 @@
#ifdef NFS_BOOT_DHCP
if (bpc.dhcp_ok) {
u_int32_t leasetime;
- bootp->bp_vend[6] = DHCPREQUEST;
- bootp->bp_vend[7] = TAG_REQ_ADDR;
- bootp->bp_vend[8] = 4;
- memcpy(&bootp->bp_vend[9], &bpc.replybuf->bp_yiaddr, 4);
- bootp->bp_vend[13] = TAG_SERVERID;
- bootp->bp_vend[14] = 4;
- memcpy(&bootp->bp_vend[15], &bpc.dhcp_serverip.s_addr, 4);
- bootp->bp_vend[19] = TAG_LEASETIME;
- bootp->bp_vend[20] = 4;
+ index = 6;
+ bootp->bp_vend[index++] = DHCPREQUEST;
+ bootp->bp_vend[index++] = TAG_REQ_ADDR;
+ bootp->bp_vend[index++] = 4;
+ memcpy(&bootp->bp_vend[index], &bpc.replybuf->bp_yiaddr, 4);
+ index += 4;
+ bootp->bp_vend[index++] = TAG_SERVERID;
+ bootp->bp_vend[index++] = 4;
+ memcpy(&bootp->bp_vend[index], &bpc.dhcp_serverip.s_addr, 4);
+ index += 4;
+ bootp->bp_vend[index++] = TAG_LEASETIME;
+ bootp->bp_vend[index++] = 4;
leasetime = htonl(300);
- memcpy(&bootp->bp_vend[21], &leasetime, 4);
- bootp->bp_vend[25] = TAG_CLASSID;
- bootp->bp_vend[26] = vcilen;
- memcpy(&bootp->bp_vend[27], vci, vcilen);
- bootp->bp_vend[27 + vcilen] = TAG_END;
+ memcpy(&bootp->bp_vend[index], &leasetime, 4);
+ index += 4;
+ /* Request the paramters we need. */
+ bootp->bp_vend[index++] = TAG_PARAM_REQ;
+ bootp->bp_vend[index++] = 6;
+ bootp->bp_vend[index++] = TAG_SUBNET_MASK;
+ bootp->bp_vend[index++] = TAG_GATEWAY;
+ bootp->bp_vend[index++] = TAG_HOST_NAME;
+ bootp->bp_vend[index++] = TAG_DOMAIN_NAME;
+ bootp->bp_vend[index++] = TAG_ROOT_PATH;
+ bootp->bp_vend[index++] = TAG_SWAP_SERVER;
+ /*
+ * Insert a NetBSD Vendor Class Identifier option.
+ */
+ bootp->bp_vend[index++] = TAG_CLASSID;
+ bootp->bp_vend[index++] = vcilen;
+ memcpy(&bootp->bp_vend[index], vci, vcilen);
+ index += vcilen;
+ bootp->bp_vend[index] = TAG_END;
bpc.expected_dhcpmsgtype = DHCPACK;