Blame SOURCES/dhcp-option97-pxe-client-id.patch

0c2dab
diff -up dhcp-4.2.5/common/options.c.option97 dhcp-4.2.5/common/options.c
0c2dab
--- dhcp-4.2.5/common/options.c.option97	2015-05-20 16:44:34.958765179 +0200
0c2dab
+++ dhcp-4.2.5/common/options.c	2015-05-20 16:44:35.078763436 +0200
0c2dab
@@ -4222,13 +4222,26 @@ int validate_packet(struct packet *packe
0c2dab
 				"a future version of ISC DHCP will reject this");
0c2dab
 		}
0c2dab
 	} else {
0c2dab
-		/* 
0c2dab
-		 * If hlen is 0 we don't have any identifier, we warn the user
0c2dab
-		 * but continue processing the packet as we can.
0c2dab
-		 */
0c2dab
-		if (packet->raw->hlen == 0) {
0c2dab
-			log_debug("Received DHCPv4 packet without client-id"
0c2dab
-				  " option and empty hlen field.");
0c2dab
+		oc = lookup_option (&dhcp_universe, packet->options,
0c2dab
+				    DHO_PXE_CLIENT_ID);
0c2dab
+		if (oc) {
0c2dab
+			/* Let's check if pxe-client-id is sane */
0c2dab
+			if ((oc->data.len < 2) ||
0c2dab
+			    (oc->data.data[0] == '\0' &&
0c2dab
+			     oc->data.len != 17)) {
0c2dab
+				log_debug("Dropped DHCPv4 packet with wrong "
0c2dab
+				    "(len == %d) pxe-client-id", oc->data.len);
0c2dab
+				return (0);
0c2dab
+			}
0c2dab
+		} else {
0c2dab
+			/*
0c2dab
+			 * If hlen is 0 we don't have any identifier, we warn the user
0c2dab
+			 * but continue processing the packet as we can.
0c2dab
+			 */
0c2dab
+			if (packet->raw->hlen == 0) {
0c2dab
+				log_debug("Received DHCPv4 packet without client-id"
0c2dab
+						" option and empty hlen field.");
0c2dab
+			}
0c2dab
 		}
0c2dab
 	}
0c2dab
 
0c2dab
diff -up dhcp-4.2.5/common/tables.c.option97 dhcp-4.2.5/common/tables.c
0c2dab
--- dhcp-4.2.5/common/tables.c.option97	2015-05-20 16:44:35.079763422 +0200
0c2dab
+++ dhcp-4.2.5/common/tables.c	2015-05-20 16:47:50.172931400 +0200
0c2dab
@@ -203,8 +203,9 @@ static struct option dhcp_options[] = {
0c2dab
 	/* Defined by RFC 4578 */
0c2dab
 	{ "pxe-system-type", "S",		&dhcp_universe,  93, 1 },
0c2dab
 	{ "pxe-interface-id", "BBB",		&dhcp_universe,  94, 1 },
0c2dab
-	{ "pxe-client-id", "BX",		&dhcp_universe,  97, 1 },
0c2dab
 #endif
0c2dab
+	{ "pxe-client-id", "BX",		&dhcp_universe,  97, 1 },
0c2dab
+
0c2dab
 	{ "uap-servers", "t",			&dhcp_universe,  98, 1 },
0c2dab
 	{ "netinfo-server-address", "Ia",	&dhcp_universe, 112, 1 },
0c2dab
 	{ "netinfo-server-tag", "t",		&dhcp_universe, 113, 1 },
0c2dab
diff -up dhcp-4.2.5/includes/dhcp.h.option97 dhcp-4.2.5/includes/dhcp.h
0c2dab
--- dhcp-4.2.5/includes/dhcp.h.option97	2015-05-20 16:44:34.975764932 +0200
0c2dab
+++ dhcp-4.2.5/includes/dhcp.h	2015-05-20 16:44:35.079763422 +0200
0c2dab
@@ -163,6 +163,7 @@ struct dhcp_packet {
0c2dab
 #define DHO_AUTHENTICATE			90  /* RFC3118, was 210 */
0c2dab
 #define DHO_CLIENT_LAST_TRANSACTION_TIME	91
0c2dab
 #define DHO_ASSOCIATED_IP			92
0c2dab
+#define DHO_PXE_CLIENT_ID			97  /* RFC4578 */
0c2dab
 #define DHO_SUBNET_SELECTION			118 /* RFC3011! */
0c2dab
 #define DHO_DOMAIN_SEARCH			119 /* RFC3397 */
0c2dab
 #define DHO_CLASSLESS_STATIC_ROUTES		121 /* RFC3442 */
0c2dab
diff -up dhcp-4.2.5/server/dhcp.c.option97 dhcp-4.2.5/server/dhcp.c
0c2dab
--- dhcp-4.2.5/server/dhcp.c.option97	2015-05-20 16:44:35.060763698 +0200
0c2dab
+++ dhcp-4.2.5/server/dhcp.c	2015-05-20 16:51:26.718798033 +0200
0c2dab
@@ -202,6 +205,10 @@ dhcp (struct packet *packet) {
0c2dab
 			oc = lookup_option (&dhcp_universe, packet -> options,
0c2dab
 					    DHO_DHCP_CLIENT_IDENTIFIER);
0c2dab
 			if (!oc)
0c2dab
+				oc = lookup_option (&dhcp_universe,
0c2dab
+						    packet -> options,
0c2dab
+						    DHO_PXE_CLIENT_ID);
0c2dab
+			if (!oc)
0c2dab
 				goto nolease;
0c2dab
 
0c2dab
 			memset (&data, 0, sizeof data);
0c2dab
@@ -770,6 +777,9 @@ void dhcprelease (packet, ms_nulltp)
0c2dab
 
0c2dab
 	oc = lookup_option (&dhcp_universe, packet -> options,
0c2dab
 			    DHO_DHCP_CLIENT_IDENTIFIER);
0c2dab
+	if (!oc)
0c2dab
+		oc = lookup_option (&dhcp_universe, packet -> options,
0c2dab
+				    DHO_PXE_CLIENT_ID);
0c2dab
 	memset (&data, 0, sizeof data);
0c2dab
 	if (oc &&
0c2dab
 	    evaluate_option_cache (&data, packet, (struct lease *)0,
0c2dab
@@ -1841,6 +1851,9 @@ void ack_lease (packet, lease, offer, wh
0c2dab
 		   can be used. */
0c2dab
 		oc = lookup_option (&dhcp_universe, packet -> options,
0c2dab
 				    DHO_DHCP_CLIENT_IDENTIFIER);
0c2dab
+		if (!oc)
0c2dab
+			oc = lookup_option (&dhcp_universe, packet -> options,
0c2dab
+					    DHO_PXE_CLIENT_ID);
0c2dab
 		if (oc &&
0c2dab
 		    evaluate_option_cache (&d1, packet, lease,
0c2dab
 					   (struct client_state *)0,
0c2dab
@@ -2386,6 +2399,9 @@ void ack_lease (packet, lease, offer, wh
0c2dab
 	/* Record the uid, if given... */
0c2dab
 	oc = lookup_option (&dhcp_universe, packet -> options,
0c2dab
 			    DHO_DHCP_CLIENT_IDENTIFIER);
0c2dab
+	if (!oc)
0c2dab
+		oc = lookup_option (&dhcp_universe, packet -> options,
0c2dab
+				    DHO_PXE_CLIENT_ID);
0c2dab
 	if (oc &&
0c2dab
 	    evaluate_option_cache (&d1, packet, lease,
0c2dab
 				   (struct client_state *)0,
0c2dab
@@ -3429,6 +3445,9 @@ int find_lease (struct lease **lp,
0c2dab
 	   specified unique client identifier. */
0c2dab
 	oc = lookup_option (&dhcp_universe, packet -> options,
0c2dab
 			    DHO_DHCP_CLIENT_IDENTIFIER);
0c2dab
+	if (!oc)
0c2dab
+		oc = lookup_option (&dhcp_universe, packet -> options,
0c2dab
+				    DHO_PXE_CLIENT_ID);
0c2dab
 	memset (&client_identifier, 0, sizeof client_identifier);
0c2dab
 	if (oc &&
0c2dab
 	    evaluate_option_cache (&client_identifier,
0c2dab
diff -up dhcp-4.2.5/server/dhcpd.conf.5.option97 dhcp-4.2.5/server/dhcpd.conf.5
0c2dab
--- dhcp-4.2.5/server/dhcpd.conf.5.option97	2015-05-20 16:44:34.908765906 +0200
0c2dab
+++ dhcp-4.2.5/server/dhcpd.conf.5	2015-05-20 16:44:35.081763393 +0200
0c2dab
@@ -1657,10 +1657,12 @@ should be a name identifying the host.
0c2dab
 not specified for the host, \fIhostname\fR is used.
0c2dab
 .PP
0c2dab
 \fIHost\fR declarations are matched to actual DHCP or BOOTP clients
0c2dab
-by matching the \fRdhcp-client-identifier\fR option specified in the
0c2dab
+by matching the \fIdhcp-client-identifier\fR or \fIpxe-client-id\fR
0c2dab
+options specified in the
0c2dab
 \fIhost\fR declaration to the one supplied by the client, or, if the
0c2dab
 \fIhost\fR declaration or the client does not provide a
0c2dab
-\fRdhcp-client-identifier\fR option, by matching the \fIhardware\fR
0c2dab
+\fIdhcp-client-identifier\fR or \fIpxe-client-id\fR options,
0c2dab
+by matching the \fIhardware\fR
0c2dab
 parameter in the \fIhost\fR declaration to the network hardware
0c2dab
 address supplied by the client.  BOOTP clients do not normally
0c2dab
 provide a \fIdhcp-client-identifier\fR, so the hardware address must
0c2dab
@@ -1672,7 +1674,8 @@ to identify hosts.
0c2dab
 .PP
0c2dab
 Please be aware that
0c2dab
 .B only
0c2dab
-the \fIdhcp-client-identifier\fR option and the hardware address can be
0c2dab
+the \fIdhcp-client-identifier\fR and \fIpxe-client-id\fR
0c2dab
+options and the hardware address can be
0c2dab
 used to match a host declaration, or the \fIhost-identifier option\fR
0c2dab
 parameter for DHCPv6 servers.  For example, it is not possible to
0c2dab
 match a host declaration to a \fIhost-name\fR option.  This is
0c2dab
diff -up dhcp-4.2.5/server/dhcpleasequery.c.option97 dhcp-4.2.5/server/dhcpleasequery.c
0c2dab
--- dhcp-4.2.5/server/dhcpleasequery.c.option97	2013-01-03 01:02:25.000000000 +0100
0c2dab
+++ dhcp-4.2.5/server/dhcpleasequery.c	2015-05-20 16:44:35.082763378 +0200
0c2dab
@@ -279,7 +279,7 @@ dhcpleasequery(struct packet *packet, in
0c2dab
 		 */
0c2dab
 
0c2dab
 		memset(&uid, 0, sizeof(uid));
0c2dab
-		if (get_option(&uid, 
0c2dab
+		i = get_option(&uid,
0c2dab
 			       &dhcp_universe,
0c2dab
 			       packet,
0c2dab
 			       NULL,
0c2dab
@@ -289,8 +289,20 @@ dhcpleasequery(struct packet *packet, in
0c2dab
 			       packet->options, 
0c2dab
 			       &global_scope,
0c2dab
 			       DHO_DHCP_CLIENT_IDENTIFIER,
0c2dab
-			       MDL)) {
0c2dab
-
0c2dab
+			       MDL);
0c2dab
+		if (!i)
0c2dab
+			i = get_option(&uid,
0c2dab
+				       &dhcp_universe,
0c2dab
+				       packet,
0c2dab
+				       NULL,
0c2dab
+				       NULL,
0c2dab
+				       packet->options,
0c2dab
+				       NULL,
0c2dab
+				       packet->options,
0c2dab
+				       &global_scope,
0c2dab
+				       DHO_PXE_CLIENT_ID,
0c2dab
+				       MDL);
0c2dab
+		if (i) {
0c2dab
 			snprintf(dbg_info, 
0c2dab
 				 sizeof(dbg_info), 
0c2dab
 				 "client-id %s",
0c2dab
diff -up dhcp-4.2.5/server/failover.c.option97 dhcp-4.2.5/server/failover.c
0c2dab
--- dhcp-4.2.5/server/failover.c.option97	2015-05-20 16:44:35.001764555 +0200
0c2dab
+++ dhcp-4.2.5/server/failover.c	2015-05-20 16:44:35.083763364 +0200
0c2dab
@@ -5875,6 +5875,9 @@ int load_balance_mine (struct packet *pa
0c2dab
 
0c2dab
 	oc = lookup_option(&dhcp_universe, packet->options,
0c2dab
 			   DHO_DHCP_CLIENT_IDENTIFIER);
0c2dab
+	if (!oc)
0c2dab
+		oc = lookup_option(&dhcp_universe, packet -> options,
0c2dab
+				    DHO_PXE_CLIENT_ID);
0c2dab
 	memset(&ds, 0, sizeof ds);
0c2dab
 	if (oc &&
0c2dab
 	    evaluate_option_cache(&ds, packet, NULL, NULL,
0c2dab
diff -up dhcp-4.2.5/server/mdb.c.option97 dhcp-4.2.5/server/mdb.c
0c2dab
--- dhcp-4.2.5/server/mdb.c.option97	2013-01-03 01:02:25.000000000 +0100
0c2dab
+++ dhcp-4.2.5/server/mdb.c	2015-05-20 16:44:35.084763349 +0200
0c2dab
@@ -127,8 +127,9 @@ static int find_uid_statement (struct ex
0c2dab
 	    esp -> data.option &&
0c2dab
 	    (esp -> data.option -> option -> universe ==
0c2dab
 	     &dhcp_universe) &&
0c2dab
-	    (esp -> data.option -> option -> code ==
0c2dab
-	     DHO_DHCP_CLIENT_IDENTIFIER)) {
0c2dab
+	    ((esp -> data.option -> option -> code ==
0c2dab
+						DHO_DHCP_CLIENT_IDENTIFIER) ||
0c2dab
+	     (esp -> data.option -> option -> code == DHO_PXE_CLIENT_ID))) {
0c2dab
 		if (condp) {
0c2dab
 			log_error ("dhcp client identifier may not be %s",
0c2dab
 				   "specified conditionally.");