|
|
f9ed25 |
From 6fd7894ea57791c8eee16c21d19da34b909e016e Mon Sep 17 00:00:00 2001
|
|
|
f9ed25 |
From: Pavel Zhukov <pzhukov@redhat.com>
|
|
|
f9ed25 |
Date: Thu, 28 Feb 2019 16:40:38 +0100
|
|
|
f9ed25 |
Subject: [PATCH 23/26] option 97 - pxe-client-id
|
|
|
f9ed25 |
Cc: pzhukov@redhat.com
|
|
|
f9ed25 |
|
|
|
f9ed25 |
Bug-url: https://bugzilla.redhat.com/1058674
|
|
|
f9ed25 |
ISC-Bugs #38110
|
|
|
f9ed25 |
---
|
|
|
f9ed25 |
common/options.c | 27 ++++++++++++++++++++-------
|
|
|
f9ed25 |
common/tables.c | 3 ++-
|
|
|
f9ed25 |
includes/dhcp.h | 1 +
|
|
|
f9ed25 |
server/dhcp.c | 19 +++++++++++++++++++
|
|
|
f9ed25 |
server/dhcpd.conf.5 | 9 ++++++---
|
|
|
f9ed25 |
server/dhcpleasequery.c | 18 +++++++++++++++---
|
|
|
f9ed25 |
server/failover.c | 3 +++
|
|
|
f9ed25 |
server/mdb.c | 5 +++--
|
|
|
f9ed25 |
8 files changed, 69 insertions(+), 16 deletions(-)
|
|
|
f9ed25 |
|
|
|
f9ed25 |
diff --git a/common/options.c b/common/options.c
|
|
|
f9ed25 |
index 3034cf0..686dd12 100644
|
|
|
f9ed25 |
--- a/common/options.c
|
|
|
f9ed25 |
+++ b/common/options.c
|
|
|
f9ed25 |
@@ -4465,13 +4465,26 @@ int validate_packet(struct packet *packet)
|
|
|
f9ed25 |
"a future version of ISC DHCP will reject this");
|
|
|
f9ed25 |
}
|
|
|
f9ed25 |
} else {
|
|
|
f9ed25 |
- /*
|
|
|
f9ed25 |
- * If hlen is 0 we don't have any identifier, we warn the user
|
|
|
f9ed25 |
- * but continue processing the packet as we can.
|
|
|
f9ed25 |
- */
|
|
|
f9ed25 |
- if (packet->raw->hlen == 0) {
|
|
|
f9ed25 |
- log_debug("Received DHCPv4 packet without client-id"
|
|
|
f9ed25 |
- " option and empty hlen field.");
|
|
|
f9ed25 |
+ oc = lookup_option (&dhcp_universe, packet->options,
|
|
|
f9ed25 |
+ DHO_PXE_CLIENT_ID);
|
|
|
f9ed25 |
+ if (oc) {
|
|
|
f9ed25 |
+ /* Let's check if pxe-client-id is sane */
|
|
|
f9ed25 |
+ if ((oc->data.len < 2) ||
|
|
|
f9ed25 |
+ (oc->data.data[0] == '\0' &&
|
|
|
f9ed25 |
+ oc->data.len != 17)) {
|
|
|
f9ed25 |
+ log_debug("Dropped DHCPv4 packet with wrong "
|
|
|
f9ed25 |
+ "(len == %d) pxe-client-id", oc->data.len);
|
|
|
f9ed25 |
+ return (0);
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
+ } else {
|
|
|
f9ed25 |
+ /*
|
|
|
f9ed25 |
+ * If hlen is 0 we don't have any identifier, we warn the user
|
|
|
f9ed25 |
+ * but continue processing the packet as we can.
|
|
|
f9ed25 |
+ */
|
|
|
f9ed25 |
+ if (packet->raw->hlen == 0) {
|
|
|
f9ed25 |
+ log_debug("Received DHCPv4 packet without client-id"
|
|
|
f9ed25 |
+ " option and empty hlen field.");
|
|
|
f9ed25 |
+ }
|
|
|
f9ed25 |
}
|
|
|
f9ed25 |
}
|
|
|
f9ed25 |
|
|
|
f9ed25 |
diff --git a/common/tables.c b/common/tables.c
|
|
|
f9ed25 |
index f1be07d..4419220 100644
|
|
|
f9ed25 |
--- a/common/tables.c
|
|
|
f9ed25 |
+++ b/common/tables.c
|
|
|
f9ed25 |
@@ -196,8 +196,9 @@ static struct option dhcp_options[] = {
|
|
|
f9ed25 |
/* Defined by RFC 4578 */
|
|
|
f9ed25 |
{ "pxe-system-type", "Sa", &dhcp_universe, 93, 1 },
|
|
|
f9ed25 |
{ "pxe-interface-id", "BBB", &dhcp_universe, 94, 1 },
|
|
|
f9ed25 |
- { "pxe-client-id", "BX", &dhcp_universe, 97, 1 },
|
|
|
f9ed25 |
#endif
|
|
|
f9ed25 |
+ { "pxe-client-id", "BX", &dhcp_universe, 97, 1 },
|
|
|
f9ed25 |
+
|
|
|
f9ed25 |
{ "uap-servers", "t", &dhcp_universe, 98, 1 },
|
|
|
f9ed25 |
#if defined(RFC4776_OPTIONS)
|
|
|
f9ed25 |
{ "geoconf-civic", "X", &dhcp_universe, 99, 1 },
|
|
|
f9ed25 |
diff --git a/includes/dhcp.h b/includes/dhcp.h
|
|
|
f9ed25 |
index 4cc547a..4eb9791 100644
|
|
|
f9ed25 |
--- a/includes/dhcp.h
|
|
|
f9ed25 |
+++ b/includes/dhcp.h
|
|
|
f9ed25 |
@@ -158,6 +158,7 @@ struct dhcp_packet {
|
|
|
f9ed25 |
#define DHO_AUTHENTICATE 90 /* RFC3118, was 210 */
|
|
|
f9ed25 |
#define DHO_CLIENT_LAST_TRANSACTION_TIME 91
|
|
|
f9ed25 |
#define DHO_ASSOCIATED_IP 92
|
|
|
f9ed25 |
+#define DHO_PXE_CLIENT_ID 97 /* RFC4578 */
|
|
|
f9ed25 |
#define DHO_SUBNET_SELECTION 118 /* RFC3011! */
|
|
|
f9ed25 |
#define DHO_DOMAIN_SEARCH 119 /* RFC3397 */
|
|
|
f9ed25 |
#define DHO_CLASSLESS_STATIC_ROUTES 121 /* RFC3442 */
|
|
|
f9ed25 |
diff --git a/server/dhcp.c b/server/dhcp.c
|
|
|
f9ed25 |
index 0582c4c..4e86262 100644
|
|
|
f9ed25 |
--- a/server/dhcp.c
|
|
|
f9ed25 |
+++ b/server/dhcp.c
|
|
|
f9ed25 |
@@ -222,6 +222,10 @@ dhcp (struct packet *packet) {
|
|
|
f9ed25 |
if (lease -> uid_len) {
|
|
|
f9ed25 |
oc = lookup_option (&dhcp_universe, packet -> options,
|
|
|
f9ed25 |
DHO_DHCP_CLIENT_IDENTIFIER);
|
|
|
f9ed25 |
+ if (!oc)
|
|
|
f9ed25 |
+ oc = lookup_option (&dhcp_universe,
|
|
|
f9ed25 |
+ packet -> options,
|
|
|
f9ed25 |
+ DHO_PXE_CLIENT_ID);
|
|
|
f9ed25 |
if (!oc)
|
|
|
f9ed25 |
goto nolease;
|
|
|
f9ed25 |
|
|
|
f9ed25 |
@@ -820,6 +824,9 @@ void dhcprelease (packet, ms_nulltp)
|
|
|
f9ed25 |
|
|
|
f9ed25 |
oc = lookup_option (&dhcp_universe, packet -> options,
|
|
|
f9ed25 |
DHO_DHCP_CLIENT_IDENTIFIER);
|
|
|
f9ed25 |
+ if (!oc)
|
|
|
f9ed25 |
+ oc = lookup_option (&dhcp_universe, packet -> options,
|
|
|
f9ed25 |
+ DHO_PXE_CLIENT_ID);
|
|
|
f9ed25 |
memset (&data, 0, sizeof data);
|
|
|
f9ed25 |
if (oc &&
|
|
|
f9ed25 |
evaluate_option_cache (&data, packet, (struct lease *)0,
|
|
|
f9ed25 |
@@ -1331,6 +1338,9 @@ void dhcpinform (packet, ms_nulltp)
|
|
|
f9ed25 |
*/
|
|
|
f9ed25 |
oc = lookup_option(&dhcp_universe, packet->options,
|
|
|
f9ed25 |
DHO_DHCP_CLIENT_IDENTIFIER);
|
|
|
f9ed25 |
+ if (!oc)
|
|
|
f9ed25 |
+ oc = lookup_option (&dhcp_universe, packet -> options,
|
|
|
f9ed25 |
+ DHO_PXE_CLIENT_ID);
|
|
|
f9ed25 |
memset(&d1, 0, sizeof(d1));
|
|
|
f9ed25 |
if (oc &&
|
|
|
f9ed25 |
evaluate_option_cache(&d1, packet, NULL, NULL,
|
|
|
f9ed25 |
@@ -2441,6 +2451,9 @@ void ack_lease (packet, lease, offer, when, msg, ms_nulltp, hp)
|
|
|
f9ed25 |
can be used. */
|
|
|
f9ed25 |
oc = lookup_option (&dhcp_universe, packet -> options,
|
|
|
f9ed25 |
DHO_DHCP_CLIENT_IDENTIFIER);
|
|
|
f9ed25 |
+ if (!oc)
|
|
|
f9ed25 |
+ oc = lookup_option (&dhcp_universe, packet -> options,
|
|
|
f9ed25 |
+ DHO_PXE_CLIENT_ID);
|
|
|
f9ed25 |
if (oc &&
|
|
|
f9ed25 |
evaluate_option_cache (&d1, packet, lease,
|
|
|
f9ed25 |
(struct client_state *)0,
|
|
|
f9ed25 |
@@ -3033,6 +3046,9 @@ void ack_lease (packet, lease, offer, when, msg, ms_nulltp, hp)
|
|
|
f9ed25 |
/* Record the uid, if given... */
|
|
|
f9ed25 |
oc = lookup_option (&dhcp_universe, packet -> options,
|
|
|
f9ed25 |
DHO_DHCP_CLIENT_IDENTIFIER);
|
|
|
f9ed25 |
+ if (!oc)
|
|
|
f9ed25 |
+ oc = lookup_option (&dhcp_universe, packet -> options,
|
|
|
f9ed25 |
+ DHO_PXE_CLIENT_ID);
|
|
|
f9ed25 |
if (oc &&
|
|
|
f9ed25 |
evaluate_option_cache(&d1, packet, lease, NULL,
|
|
|
f9ed25 |
packet->options, state->options,
|
|
|
f9ed25 |
@@ -4150,6 +4166,9 @@ int find_lease (struct lease **lp,
|
|
|
f9ed25 |
specified unique client identifier. */
|
|
|
f9ed25 |
oc = lookup_option (&dhcp_universe, packet -> options,
|
|
|
f9ed25 |
DHO_DHCP_CLIENT_IDENTIFIER);
|
|
|
f9ed25 |
+ if (!oc)
|
|
|
f9ed25 |
+ oc = lookup_option (&dhcp_universe, packet -> options,
|
|
|
f9ed25 |
+ DHO_PXE_CLIENT_ID);
|
|
|
f9ed25 |
memset (&client_identifier, 0, sizeof client_identifier);
|
|
|
f9ed25 |
if (oc &&
|
|
|
f9ed25 |
evaluate_option_cache (&client_identifier,
|
|
|
f9ed25 |
diff --git a/server/dhcpd.conf.5 b/server/dhcpd.conf.5
|
|
|
f9ed25 |
index 89b5540..4751a8b 100644
|
|
|
f9ed25 |
--- a/server/dhcpd.conf.5
|
|
|
f9ed25 |
+++ b/server/dhcpd.conf.5
|
|
|
f9ed25 |
@@ -1664,10 +1664,12 @@ should be a name identifying the host. If a \fIhostname\fR option is
|
|
|
f9ed25 |
not specified for the host, \fIhostname\fR is used.
|
|
|
f9ed25 |
.PP
|
|
|
f9ed25 |
\fIHost\fR declarations are matched to actual DHCP or BOOTP clients
|
|
|
f9ed25 |
-by matching the \fRdhcp-client-identifier\fR option specified in the
|
|
|
f9ed25 |
+by matching the \fIdhcp-client-identifier\fR or \fIpxe-client-id\fR
|
|
|
f9ed25 |
+options specified in the
|
|
|
f9ed25 |
\fIhost\fR declaration to the one supplied by the client, or, if the
|
|
|
f9ed25 |
\fIhost\fR declaration or the client does not provide a
|
|
|
f9ed25 |
-\fRdhcp-client-identifier\fR option, by matching the \fIhardware\fR
|
|
|
f9ed25 |
+\fIdhcp-client-identifier\fR or \fIpxe-client-id\fR options,
|
|
|
f9ed25 |
+by matching the \fIhardware\fR
|
|
|
f9ed25 |
parameter in the \fIhost\fR declaration to the network hardware
|
|
|
f9ed25 |
address supplied by the client. BOOTP clients do not normally
|
|
|
f9ed25 |
provide a \fIdhcp-client-identifier\fR, so the hardware address must
|
|
|
f9ed25 |
@@ -1679,7 +1681,8 @@ to identify hosts.
|
|
|
f9ed25 |
.PP
|
|
|
f9ed25 |
Please be aware that
|
|
|
f9ed25 |
.B only
|
|
|
f9ed25 |
-the \fIdhcp-client-identifier\fR option and the hardware address can be
|
|
|
f9ed25 |
+the \fIdhcp-client-identifier\fR and \fIpxe-client-id\fR
|
|
|
f9ed25 |
+options and the hardware address can be
|
|
|
f9ed25 |
used to match a host declaration, or the \fIhost-identifier option\fR
|
|
|
f9ed25 |
parameter for DHCPv6 servers. For example, it is not possible to
|
|
|
f9ed25 |
match a host declaration to a \fIhost-name\fR option. This is
|
|
|
f9ed25 |
diff --git a/server/dhcpleasequery.c b/server/dhcpleasequery.c
|
|
|
f9ed25 |
index 7be0788..2fee698 100644
|
|
|
f9ed25 |
--- a/server/dhcpleasequery.c
|
|
|
f9ed25 |
+++ b/server/dhcpleasequery.c
|
|
|
f9ed25 |
@@ -276,7 +276,7 @@ dhcpleasequery(struct packet *packet, int ms_nulltp) {
|
|
|
f9ed25 |
*/
|
|
|
f9ed25 |
|
|
|
f9ed25 |
memset(&uid, 0, sizeof(uid));
|
|
|
f9ed25 |
- if (get_option(&uid,
|
|
|
f9ed25 |
+ i = get_option(&uid,
|
|
|
f9ed25 |
&dhcp_universe,
|
|
|
f9ed25 |
packet,
|
|
|
f9ed25 |
NULL,
|
|
|
f9ed25 |
@@ -286,8 +286,20 @@ dhcpleasequery(struct packet *packet, int ms_nulltp) {
|
|
|
f9ed25 |
packet->options,
|
|
|
f9ed25 |
&global_scope,
|
|
|
f9ed25 |
DHO_DHCP_CLIENT_IDENTIFIER,
|
|
|
f9ed25 |
- MDL)) {
|
|
|
f9ed25 |
-
|
|
|
f9ed25 |
+ MDL);
|
|
|
f9ed25 |
+ if (!i)
|
|
|
f9ed25 |
+ i = get_option(&uid,
|
|
|
f9ed25 |
+ &dhcp_universe,
|
|
|
f9ed25 |
+ packet,
|
|
|
f9ed25 |
+ NULL,
|
|
|
f9ed25 |
+ NULL,
|
|
|
f9ed25 |
+ packet->options,
|
|
|
f9ed25 |
+ NULL,
|
|
|
f9ed25 |
+ packet->options,
|
|
|
f9ed25 |
+ &global_scope,
|
|
|
f9ed25 |
+ DHO_PXE_CLIENT_ID,
|
|
|
f9ed25 |
+ MDL);
|
|
|
f9ed25 |
+ if (i) {
|
|
|
f9ed25 |
snprintf(dbg_info,
|
|
|
f9ed25 |
sizeof(dbg_info),
|
|
|
f9ed25 |
"client-id %s",
|
|
|
f9ed25 |
diff --git a/server/failover.c b/server/failover.c
|
|
|
f9ed25 |
index 72f7b00..40fa691 100644
|
|
|
f9ed25 |
--- a/server/failover.c
|
|
|
f9ed25 |
+++ b/server/failover.c
|
|
|
f9ed25 |
@@ -5988,6 +5988,9 @@ int load_balance_mine (struct packet *packet, dhcp_failover_state_t *state)
|
|
|
f9ed25 |
|
|
|
f9ed25 |
oc = lookup_option(&dhcp_universe, packet->options,
|
|
|
f9ed25 |
DHO_DHCP_CLIENT_IDENTIFIER);
|
|
|
f9ed25 |
+ if (!oc)
|
|
|
f9ed25 |
+ oc = lookup_option(&dhcp_universe, packet -> options,
|
|
|
f9ed25 |
+ DHO_PXE_CLIENT_ID);
|
|
|
f9ed25 |
memset(&ds, 0, sizeof ds);
|
|
|
f9ed25 |
if (oc &&
|
|
|
f9ed25 |
evaluate_option_cache(&ds, packet, NULL, NULL,
|
|
|
f9ed25 |
diff --git a/server/mdb.c b/server/mdb.c
|
|
|
f9ed25 |
index 052df67..8851366 100644
|
|
|
f9ed25 |
--- a/server/mdb.c
|
|
|
f9ed25 |
+++ b/server/mdb.c
|
|
|
f9ed25 |
@@ -129,8 +129,9 @@ static int find_uid_statement (struct executable_statement *esp,
|
|
|
f9ed25 |
esp -> data.option &&
|
|
|
f9ed25 |
(esp -> data.option -> option -> universe ==
|
|
|
f9ed25 |
&dhcp_universe) &&
|
|
|
f9ed25 |
- (esp -> data.option -> option -> code ==
|
|
|
f9ed25 |
- DHO_DHCP_CLIENT_IDENTIFIER)) {
|
|
|
f9ed25 |
+ ((esp -> data.option -> option -> code ==
|
|
|
f9ed25 |
+ DHO_DHCP_CLIENT_IDENTIFIER) ||
|
|
|
f9ed25 |
+ (esp -> data.option -> option -> code == DHO_PXE_CLIENT_ID))) {
|
|
|
f9ed25 |
if (condp) {
|
|
|
f9ed25 |
log_error ("dhcp client identifier may not be %s",
|
|
|
f9ed25 |
"specified conditionally.");
|
|
|
f9ed25 |
--
|
|
|
f9ed25 |
2.14.5
|
|
|
f9ed25 |
|