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

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