svn commit: r252506 - head/sbin/dhclient

Bruce M Simpson bms at FreeBSD.org
Tue Jul 2 13:24:38 UTC 2013


Author: bms
Date: Tue Jul  2 13:24:37 2013
New Revision: 252506
URL: http://svnweb.freebsd.org/changeset/base/252506

Log:
  When acquiring a lease, record the value of the BOOTP siaddr field
  contained in the DHCP offer, and write it out to the lease file
  as an unquoted value of the "next-server" keyword. The value is ignored
  when the lease is read back by dhclient, however other applications
  are free to parse it.
  
  The intent behind this change is to allow easier interoperability
  with automated installation systems e.g. Cobbler, Foreman, Razor;
  FreeBSD installation kernels can automatically probe the network
  to discover deployment servers.  There are no plans to MFC this
  change unless a backport is specifically requested.
  
  The syntax of the "next-server <ip>" lease keyword is intended to be
  identical to that used by the ISC DHCPD server in its configuration files.
  The required defines are already present in dhclient but were unused before
  this change. (Note: This is NOT the same as Option 66, tftp-server-name).
  
  It has been exercised in a university protocol testbed environment, with
  Cobbler and an mfsBSD image containing pc-sysinstall (driven by Cobbler
  Cheetah templates). The SYSLINUX memdisk driver is used to boot mfsBSD.
  Currently this approach requires that a dedicated system profile has
  been created for the node where FreeBSD is to be deployed. If this
  is not present, the pc-sysinstall wrapper will be unable to obtain
  a node configuration. There is code in progress to allow mfsBSD images
  to obtain the required hints from the memdisk environment by parsing
  the MBFT ACPI chunk.  This is non-standard as it is not linked into
  the platform's ACPI RSDT.
  
  Reviewed by:	des

Modified:
  head/sbin/dhclient/clparse.c
  head/sbin/dhclient/dhclient.c
  head/sbin/dhclient/dhcpd.h

Modified: head/sbin/dhclient/clparse.c
==============================================================================
--- head/sbin/dhclient/clparse.c	Tue Jul  2 10:36:57 2013	(r252505)
+++ head/sbin/dhclient/clparse.c	Tue Jul  2 13:24:37 2013	(r252506)
@@ -642,6 +642,10 @@ parse_client_lease_declaration(FILE *cfi
 	case FILENAME:
 		lease->filename = parse_string(cfile);
 		return;
+	case NEXT_SERVER:
+		if (!parse_ip_addr(cfile, &lease->nextserver))
+			return;
+		break;
 	case SERVER_NAME:
 		lease->server_name = parse_string(cfile);
 		return;

Modified: head/sbin/dhclient/dhclient.c
==============================================================================
--- head/sbin/dhclient/dhclient.c	Tue Jul  2 10:36:57 2013	(r252505)
+++ head/sbin/dhclient/dhclient.c	Tue Jul  2 13:24:37 2013	(r252506)
@@ -1063,6 +1063,9 @@ packet_to_lease(struct packet *packet)
 	lease->address.len = sizeof(packet->raw->yiaddr);
 	memcpy(lease->address.iabuf, &packet->raw->yiaddr, lease->address.len);
 
+	lease->nextserver.len = sizeof(packet->raw->siaddr);
+	memcpy(lease->nextserver.iabuf, &packet->raw->siaddr, lease->nextserver.len);
+
 	/* If the server name was filled out, copy it.
 	   Do not attempt to validate the server name as a host name.
 	   RFC 2131 merely states that sname is NUL-terminated (which do
@@ -1874,6 +1877,11 @@ write_client_lease(struct interface_info
 		fprintf(leaseFile, "  bootp;\n");
 	fprintf(leaseFile, "  interface \"%s\";\n", ip->name);
 	fprintf(leaseFile, "  fixed-address %s;\n", piaddr(lease->address));
+	if (lease->nextserver.len == sizeof(inaddr_any) &&
+	    0 != memcmp(lease->nextserver.iabuf, &inaddr_any,
+	    sizeof(inaddr_any)))
+		fprintf(leaseFile, "  next-server %s;\n",
+		    piaddr(lease->nextserver));
 	if (lease->filename)
 		fprintf(leaseFile, "  filename \"%s\";\n", lease->filename);
 	if (lease->server_name)

Modified: head/sbin/dhclient/dhcpd.h
==============================================================================
--- head/sbin/dhclient/dhcpd.h	Tue Jul  2 10:36:57 2013	(r252505)
+++ head/sbin/dhclient/dhcpd.h	Tue Jul  2 13:24:37 2013	(r252506)
@@ -121,6 +121,7 @@ struct client_lease {
 	struct client_lease	*next;
 	time_t			 expiry, renewal, rebind;
 	struct iaddr		 address;
+	struct iaddr		 nextserver;
 	char			*server_name;
 	char			*filename;
 	struct string_list	*medium;


More information about the svn-src-head mailing list