Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Sep 2001 16:37:33 +0100
From:      Ian Dowse <iedowse@maths.tcd.ie>
To:        freebsd-net@freebsd.org
Subject:   bootpd and "Maximum DHCP Message Size" option.
Message-ID:   <200109241637.aa38673@salmon.maths.tcd.ie>

next in thread | raw e-mail | index | archive | help

I came across a problem recently when using Etherboot with FreeBSD's
bootpd. Etherboot was specifying a "Maximum DHCP Message Size" of
1500, which caused bootpd to generate a reply larger than the MTU,
and Etherboot can't handle fragments.

As pointed out by Ken Yap on the Etherboot mailing list, the
description in RFC2132 of the Maximum DHCP Message Size option is
slightly ambiguous:

	9.10. Maximum DHCP Message Size

	This option specifies the maximum length DHCP message that it is
	willing to accept.  The length is specified as an unsigned 16-bit
	integer.  A client may use the maximum DHCP message size option in
	DHCPDISCOVER or DHCPREQUEST messages, but should not use the option
	in DHCPDECLINE messages.

	The code for this option is 57, and its length is 2.  The minimum
	legal value is 576 octets.

The problem is that it doesn't seem to specify whether this size
refers to the length of the DHCP message in the UDP payload, or
the full length of the packet. Etherboot assumes the latter, but
FreeBSD's bootpd assumes the former.

The isc-dhcpd code takes the safest option, and ensures that the
full Ethernet packet is no longer than the client-specified maximum
message length. Below is a patch that makes bootpd do the same.

Any objections if I commit this?

Ian

Index: bootp.h
===================================================================
RCS file: /dump/FreeBSD-CVS/src/libexec/bootpd/bootp.h,v
retrieving revision 1.5
diff -u -r1.5 bootp.h
--- bootp.h	12 Nov 1999 10:11:48 -0000	1.5
+++ bootp.h	24 Sep 2001 15:05:37 -0000
@@ -38,6 +38,8 @@
 #define BP_FILE_LEN	128
 #define BP_VEND_LEN	 64
 #define BP_MINPKTSZ	300	/* to check sizeof(struct bootp) */
+/* Overhead to fit a bootp message into an Ethernet packet. */
+#define BP_MSG_OVERHEAD	(14 + 20 + 8)	/* Ethernet + IP + UDP headers */
 
 struct bootp {
     unsigned char    bp_op;			/* packet opcode type */
Index: bootpd.c
===================================================================
RCS file: /dump/FreeBSD-CVS/src/libexec/bootpd/bootpd.c,v
retrieving revision 1.14
diff -u -r1.14 bootpd.c
--- bootpd.c	9 Dec 2000 09:35:33 -0000	1.14
+++ bootpd.c	24 Sep 2001 15:04:51 -0000
@@ -1292,10 +1292,10 @@
 				p += len;
 			}
 
-			if (msgsz > sizeof(*bp)) {
+			if (msgsz > sizeof(*bp) + BP_MSG_OVERHEAD) {
 				if (debug > 1)
 					report(LOG_INFO, "request has DHCP msglen=%d", msgsz);
-				pktlen = msgsz;
+				pktlen = msgsz - BP_MSG_OVERHEAD;
 			}
 		}
 	}


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi? <200109241637.aa38673>