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

324fcf
diff -up dhcp-4.3.5b1/common/options.c.option97 dhcp-4.3.5b1/common/options.c
324fcf
--- dhcp-4.3.5b1/common/options.c.option97	2016-09-12 17:17:13.972691041 +0200
324fcf
+++ dhcp-4.3.5b1/common/options.c	2016-09-12 17:19:17.706790276 +0200
324fcf
@@ -4434,13 +4434,26 @@ int validate_packet(struct packet *packe
324fcf
 				"a future version of ISC DHCP will reject this");
324fcf
 		}
324fcf
 	} else {
324fcf
-		/*
324fcf
-		 * If hlen is 0 we don't have any identifier, we warn the user
324fcf
-		 * but continue processing the packet as we can.
324fcf
-		 */
324fcf
-		if (packet->raw->hlen == 0) {
324fcf
-			log_debug("Received DHCPv4 packet without client-id"
324fcf
-				  " option and empty hlen field.");
324fcf
+		oc = lookup_option (&dhcp_universe, packet->options,
324fcf
+				    DHO_PXE_CLIENT_ID);
324fcf
+		if (oc) {
324fcf
+			/* Let's check if pxe-client-id is sane */
324fcf
+			if ((oc->data.len < 2) ||
324fcf
+			    (oc->data.data[0] == '\0' &&
324fcf
+			     oc->data.len != 17)) {
324fcf
+				log_debug("Dropped DHCPv4 packet with wrong "
324fcf
+				    "(len == %d) pxe-client-id", oc->data.len);
324fcf
+				return (0);
324fcf
+			}
324fcf
+		} else {
324fcf
+			/*
324fcf
+			 * If hlen is 0 we don't have any identifier, we warn the user
324fcf
+			 * but continue processing the packet as we can.
324fcf
+			 */
324fcf
+			if (packet->raw->hlen == 0) {
324fcf
+				log_debug("Received DHCPv4 packet without client-id"
324fcf
+						" option and empty hlen field.");
324fcf
+			}
324fcf
 		}
324fcf
 	}
324fcf
 
324fcf
diff -up dhcp-4.3.5b1/common/tables.c.option97 dhcp-4.3.5b1/common/tables.c
324fcf
--- dhcp-4.3.5b1/common/tables.c.option97	2016-09-12 17:17:13.927691005 +0200
324fcf
+++ dhcp-4.3.5b1/common/tables.c	2016-09-12 17:17:13.972691041 +0200
324fcf
@@ -196,8 +196,9 @@ static struct option dhcp_options[] = {
324fcf
 	/* Defined by RFC 4578 */
324fcf
 	{ "pxe-system-type", "S",		&dhcp_universe,  93, 1 },
324fcf
 	{ "pxe-interface-id", "BBB",		&dhcp_universe,  94, 1 },
324fcf
-	{ "pxe-client-id", "BX",		&dhcp_universe,  97, 1 },
324fcf
 #endif
324fcf
+	{ "pxe-client-id", "BX",		&dhcp_universe,  97, 1 },
324fcf
+
324fcf
 	{ "uap-servers", "t",			&dhcp_universe,  98, 1 },
324fcf
 #if defined(RFC4776_OPTIONS)
324fcf
         { "geoconf-civic", "X",                 &dhcp_universe, 99, 1 },
324fcf
diff -up dhcp-4.3.5b1/includes/dhcp.h.option97 dhcp-4.3.5b1/includes/dhcp.h
324fcf
--- dhcp-4.3.5b1/includes/dhcp.h.option97	2016-09-12 17:17:13.936691013 +0200
324fcf
+++ dhcp-4.3.5b1/includes/dhcp.h	2016-09-12 17:17:13.972691041 +0200
324fcf
@@ -159,6 +159,7 @@ struct dhcp_packet {
324fcf
 #define DHO_AUTHENTICATE			90  /* RFC3118, was 210 */
324fcf
 #define DHO_CLIENT_LAST_TRANSACTION_TIME	91
324fcf
 #define DHO_ASSOCIATED_IP			92
324fcf
+#define DHO_PXE_CLIENT_ID			97  /* RFC4578 */
324fcf
 #define DHO_SUBNET_SELECTION			118 /* RFC3011! */
324fcf
 #define DHO_DOMAIN_SEARCH			119 /* RFC3397 */
324fcf
 #define DHO_CLASSLESS_STATIC_ROUTES		121 /* RFC3442 */
324fcf
diff -up dhcp-4.3.5b1/server/dhcp.c.option97 dhcp-4.3.5b1/server/dhcp.c
324fcf
--- dhcp-4.3.5b1/server/dhcp.c.option97	2016-09-12 17:17:13.947691021 +0200
324fcf
+++ dhcp-4.3.5b1/server/dhcp.c	2016-09-12 17:17:13.973691042 +0200
324fcf
@@ -221,6 +221,10 @@ dhcp (struct packet *packet) {
324fcf
 			oc = lookup_option (&dhcp_universe, packet -> options,
324fcf
 					    DHO_DHCP_CLIENT_IDENTIFIER);
324fcf
 			if (!oc)
324fcf
+				oc = lookup_option (&dhcp_universe,
324fcf
+						    packet -> options,
324fcf
+						    DHO_PXE_CLIENT_ID);
324fcf
+			if (!oc)
324fcf
 				goto nolease;
324fcf
 
324fcf
 			memset (&data, 0, sizeof data);
324fcf
@@ -818,6 +822,9 @@ void dhcprelease (packet, ms_nulltp)
324fcf
 
324fcf
 	oc = lookup_option (&dhcp_universe, packet -> options,
324fcf
 			    DHO_DHCP_CLIENT_IDENTIFIER);
324fcf
+	if (!oc)
324fcf
+		oc = lookup_option (&dhcp_universe, packet -> options,
324fcf
+				    DHO_PXE_CLIENT_ID);
324fcf
 	memset (&data, 0, sizeof data);
324fcf
 	if (oc &&
324fcf
 	    evaluate_option_cache (&data, packet, (struct lease *)0,
324fcf
@@ -1286,6 +1293,9 @@ void dhcpinform (packet, ms_nulltp)
324fcf
          */
324fcf
 	oc = lookup_option(&dhcp_universe, packet->options,
324fcf
 			   DHO_DHCP_CLIENT_IDENTIFIER);
324fcf
+	if (!oc)
324fcf
+		oc = lookup_option (&dhcp_universe, packet -> options,
324fcf
+				    DHO_PXE_CLIENT_ID);
324fcf
 	memset(&d1, 0, sizeof(d1));
324fcf
 	if (oc &&
324fcf
 	    evaluate_option_cache(&d1, packet, NULL, NULL,
324fcf
@@ -2381,6 +2391,9 @@ void ack_lease (packet, lease, offer, wh
324fcf
 		   can be used. */
324fcf
 		oc = lookup_option (&dhcp_universe, packet -> options,
324fcf
 				    DHO_DHCP_CLIENT_IDENTIFIER);
324fcf
+		if (!oc)
324fcf
+			oc = lookup_option (&dhcp_universe, packet -> options,
324fcf
+					    DHO_PXE_CLIENT_ID);
324fcf
 		if (oc &&
324fcf
 		    evaluate_option_cache (&d1, packet, lease,
324fcf
 					   (struct client_state *)0,
324fcf
@@ -2962,6 +2975,9 @@ void ack_lease (packet, lease, offer, wh
324fcf
 		/* Record the uid, if given... */
324fcf
 		oc = lookup_option (&dhcp_universe, packet -> options,
324fcf
 				    DHO_DHCP_CLIENT_IDENTIFIER);
324fcf
+		if (!oc)
324fcf
+			oc = lookup_option (&dhcp_universe, packet -> options,
324fcf
+					    DHO_PXE_CLIENT_ID);
324fcf
 		if (oc &&
324fcf
 		    evaluate_option_cache(&d1, packet, lease, NULL,
324fcf
 					  packet->options, state->options,
324fcf
@@ -4068,6 +4084,9 @@ int find_lease (struct lease **lp,
324fcf
 	   specified unique client identifier. */
324fcf
 	oc = lookup_option (&dhcp_universe, packet -> options,
324fcf
 			    DHO_DHCP_CLIENT_IDENTIFIER);
324fcf
+	if (!oc)
324fcf
+		oc = lookup_option (&dhcp_universe, packet -> options,
324fcf
+				    DHO_PXE_CLIENT_ID);
324fcf
 	memset (&client_identifier, 0, sizeof client_identifier);
324fcf
 	if (oc &&
324fcf
 	    evaluate_option_cache (&client_identifier,
324fcf
diff -up dhcp-4.3.5b1/server/dhcpd.conf.5.option97 dhcp-4.3.5b1/server/dhcpd.conf.5
324fcf
--- dhcp-4.3.5b1/server/dhcpd.conf.5.option97	2016-09-12 17:17:13.885690972 +0200
324fcf
+++ dhcp-4.3.5b1/server/dhcpd.conf.5	2016-09-12 17:17:13.974691043 +0200
324fcf
@@ -1587,10 +1587,12 @@ should be a name identifying the host.
324fcf
 not specified for the host, \fIhostname\fR is used.
324fcf
 .PP
324fcf
 \fIHost\fR declarations are matched to actual DHCP or BOOTP clients
324fcf
-by matching the \fRdhcp-client-identifier\fR option specified in the
324fcf
+by matching the \fIdhcp-client-identifier\fR or \fIpxe-client-id\fR
324fcf
+options specified in the
324fcf
 \fIhost\fR declaration to the one supplied by the client, or, if the
324fcf
 \fIhost\fR declaration or the client does not provide a
324fcf
-\fRdhcp-client-identifier\fR option, by matching the \fIhardware\fR
324fcf
+\fIdhcp-client-identifier\fR or \fIpxe-client-id\fR options,
324fcf
+by matching the \fIhardware\fR
324fcf
 parameter in the \fIhost\fR declaration to the network hardware
324fcf
 address supplied by the client.  BOOTP clients do not normally
324fcf
 provide a \fIdhcp-client-identifier\fR, so the hardware address must
324fcf
@@ -1602,7 +1604,8 @@ to identify hosts.
324fcf
 .PP
324fcf
 Please be aware that
324fcf
 .B only
324fcf
-the \fIdhcp-client-identifier\fR option and the hardware address can be
324fcf
+the \fIdhcp-client-identifier\fR and \fIpxe-client-id\fR
324fcf
+options and the hardware address can be
324fcf
 used to match a host declaration, or the \fIhost-identifier option\fR
324fcf
 parameter for DHCPv6 servers.  For example, it is not possible to
324fcf
 match a host declaration to a \fIhost-name\fR option.  This is
324fcf
diff -up dhcp-4.3.5b1/server/dhcpleasequery.c.option97 dhcp-4.3.5b1/server/dhcpleasequery.c
324fcf
--- dhcp-4.3.5b1/server/dhcpleasequery.c.option97	2016-08-26 20:19:53.000000000 +0200
324fcf
+++ dhcp-4.3.5b1/server/dhcpleasequery.c	2016-09-12 17:17:13.974691043 +0200
324fcf
@@ -273,7 +273,7 @@ dhcpleasequery(struct packet *packet, in
324fcf
 		 */
324fcf
 
324fcf
 		memset(&uid, 0, sizeof(uid));
324fcf
-		if (get_option(&uid, 
324fcf
+		i = get_option(&uid,
324fcf
 			       &dhcp_universe,
324fcf
 			       packet,
324fcf
 			       NULL,
324fcf
@@ -283,8 +283,20 @@ dhcpleasequery(struct packet *packet, in
324fcf
 			       packet->options, 
324fcf
 			       &global_scope,
324fcf
 			       DHO_DHCP_CLIENT_IDENTIFIER,
324fcf
-			       MDL)) {
324fcf
-
324fcf
+			       MDL);
324fcf
+		if (!i)
324fcf
+			i = get_option(&uid,
324fcf
+				       &dhcp_universe,
324fcf
+				       packet,
324fcf
+				       NULL,
324fcf
+				       NULL,
324fcf
+				       packet->options,
324fcf
+				       NULL,
324fcf
+				       packet->options,
324fcf
+				       &global_scope,
324fcf
+				       DHO_PXE_CLIENT_ID,
324fcf
+				       MDL);
324fcf
+		if (i) {
324fcf
 			snprintf(dbg_info, 
324fcf
 				 sizeof(dbg_info), 
324fcf
 				 "client-id %s",
324fcf
diff -up dhcp-4.3.5b1/server/failover.c.option97 dhcp-4.3.5b1/server/failover.c
324fcf
--- dhcp-4.3.5b1/server/failover.c.option97	2016-08-26 20:19:53.000000000 +0200
324fcf
+++ dhcp-4.3.5b1/server/failover.c	2016-09-12 17:17:13.975691044 +0200
324fcf
@@ -5957,6 +5957,9 @@ int load_balance_mine (struct packet *pa
324fcf
 
324fcf
 	oc = lookup_option(&dhcp_universe, packet->options,
324fcf
 			   DHO_DHCP_CLIENT_IDENTIFIER);
324fcf
+	if (!oc)
324fcf
+		oc = lookup_option(&dhcp_universe, packet -> options,
324fcf
+				    DHO_PXE_CLIENT_ID);
324fcf
 	memset(&ds, 0, sizeof ds);
324fcf
 	if (oc &&
324fcf
 	    evaluate_option_cache(&ds, packet, NULL, NULL,
324fcf
diff -up dhcp-4.3.5b1/server/mdb.c.option97 dhcp-4.3.5b1/server/mdb.c
324fcf
--- dhcp-4.3.5b1/server/mdb.c.option97	2016-08-26 20:19:53.000000000 +0200
324fcf
+++ dhcp-4.3.5b1/server/mdb.c	2016-09-12 17:17:13.975691044 +0200
324fcf
@@ -129,8 +129,9 @@ static int find_uid_statement (struct ex
324fcf
 	    esp -> data.option &&
324fcf
 	    (esp -> data.option -> option -> universe ==
324fcf
 	     &dhcp_universe) &&
324fcf
-	    (esp -> data.option -> option -> code ==
324fcf
-	     DHO_DHCP_CLIENT_IDENTIFIER)) {
324fcf
+	    ((esp -> data.option -> option -> code ==
324fcf
+						DHO_DHCP_CLIENT_IDENTIFIER) ||
324fcf
+	     (esp -> data.option -> option -> code == DHO_PXE_CLIENT_ID))) {
324fcf
 		if (condp) {
324fcf
 			log_error ("dhcp client identifier may not be %s",
324fcf
 				   "specified conditionally.");