bin/127076: [patch] teach dhclient to recognize options 66 and 67

Eygene Ryabinkin rea-fbsd at codelabs.ru
Wed Sep 3 21:20:03 UTC 2008


>Number:         127076
>Category:       bin
>Synopsis:       [patch] teach dhclient to recognize options 66 and 67
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Sep 03 21:20:02 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Eygene Ryabinkin
>Release:        FreeBSD 7.1-PRERELEASE i386
>Organization:
Code Labs
>Environment:

System: FreeBSD XXX 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE #7: Wed Sep 3 16:42:27 MSD 2008 root at XXX:/usr/src/sys/i386/compile/XXX i386

>Description:

Dhclient does not pass option 66, TFTP server name, and option 67,
bootfile name, to the dhclient-script, because these options are not
validated in the check_option().

These options are used for PXE/diskless environments.  I am using them
to discover TFTP server and sysinstall configuration file template
during automated PXE installation of FreeBSD.

>How-To-Repeat:

Set up DHCP server to give away tftp-server-name and bootfile-name.
For ISC dhcpd it will look like
-----
host XXX {
  ...
  option tftp-server-name "172.16.0.254";
  option bootfile-name "machine.img";
}
-----

Then spawn dhclient and watch for output entries like
-----
unknown dhcp option value 0x42
unknown dhcp option value 0x43
-----

Also try to get the values of environment variables 'new-tftp-server-name'
and 'new-bootfile-name' in /sbin/dhclient-script -- they will be unset.

>Fix:

The following patch adds recognition for the mentioned options.  There
is no real validation, since both options are strings and may have
arbitrary structure.

I had tested this patch with dhclient from 7-STABLE and ISC dhcpd 3.x.
Works as expected.

--- dhclient-options-66-and-67.patch begins here ---
>From 9e60cf5c6f86ef6dfe4fa02cf5b0388f8e11004c Mon Sep 17 00:00:00 2001
From: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
Date: Wed, 3 Sep 2008 23:31:12 +0400

Option 66, TFTP server name, and option 67, bootfile name, are often
used when one wants to retrieve TFTP server name and boot file via DHCP
in PXE or diskless environments.  Teach dhclient to recognize these
options and pass them to the dhclient-script.

Signed-off-by: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
---
 sbin/dhclient/dhclient.c |    2 ++
 sbin/dhclient/dhcp.h     |    2 ++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index a18e17c..88f0030 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -2390,6 +2390,8 @@ check_option(struct client_lease *l, int option)
 	case DHO_DHCP_CLIENT_IDENTIFIER:
 	case DHO_DHCP_USER_CLASS_ID:
 	case DHO_END:
+	case DHO_TFTP_SERVER_NAME:
+	case DHO_BOOTFILE_NAME:
 		return (1);
 	case DHO_CLASSLESS_ROUTES:
 		return (check_classless_option(l->options[option].data,
diff --git a/sbin/dhclient/dhcp.h b/sbin/dhclient/dhcp.h
index aa69930..22d698d 100644
--- a/sbin/dhclient/dhcp.h
+++ b/sbin/dhclient/dhcp.h
@@ -155,6 +155,8 @@ struct dhcp_packet {
 #define DHO_DHCP_REBINDING_TIME		59
 #define DHO_DHCP_CLASS_IDENTIFIER	60
 #define DHO_DHCP_CLIENT_IDENTIFIER	61
+#define DHO_TFTP_SERVER_NAME		66
+#define DHO_BOOTFILE_NAME		67
 #define DHO_SMTP_SERVER			69
 #define DHO_POP_SERVER			70
 #define DHO_NNTP_SERVER			71
-- 
1.5.6.4
--- dhclient-options-66-and-67.patch ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list