summaryrefslogtreecommitdiff
path: root/sbin/dhclient/clparse.c
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2016-10-06 16:29:18 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2016-10-06 16:29:18 +0000
commit432e4be4b386265a8c7d11952628bcf51e5c46b8 (patch)
tree45594b80c734d225dc12f89f96a261c03717cb16 /sbin/dhclient/clparse.c
parentd690d085048eb7d9e73e77cd86a4869ec7c25810 (diff)
Add support for RFC 6842, which says the client MUST drop packets when
the server provides a client-identifier value and it doesn't match the value the client sent. So stop suppressing client-identifer info in the leases file and when reading the leases file stop discarding leases that don't have current client-identifier info. Don't use them, but keep them around in case the client-identifier info changes back next time. Also construct the default client-identifier (if needed) before reading the leases file.
Diffstat (limited to 'sbin/dhclient/clparse.c')
-rw-r--r--sbin/dhclient/clparse.c42
1 files changed, 19 insertions, 23 deletions
diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c
index c7a6f087dd4..f427eafcb4c 100644
--- a/sbin/dhclient/clparse.c
+++ b/sbin/dhclient/clparse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clparse.c,v 1.102 2016/09/30 13:20:57 krw Exp $ */
+/* $OpenBSD: clparse.c,v 1.103 2016/10/06 16:29:17 krw Exp $ */
/* Parser for dhclient config and lease files. */
@@ -466,7 +466,6 @@ parse_client_lease_statement(FILE *cfile, int is_static, struct interface_info *
{
struct client_state *client = ifi->client;
struct client_lease *lease, *lp, *pl;
- struct option_data *opt1, *opt2;
int token;
token = next_token(NULL, cfile);
@@ -495,31 +494,28 @@ parse_client_lease_statement(FILE *cfile, int is_static, struct interface_info *
token = next_token(NULL, cfile);
/*
- * If the new lease is for an obsolete client-identifier, toss it.
- */
- opt1 = &lease->options[DHO_DHCP_CLIENT_IDENTIFIER];
- opt2 = &config->send_options[DHO_DHCP_CLIENT_IDENTIFIER];
- if (opt1->len && opt2->len && (opt1->len != opt2->len ||
- memcmp(opt1->data, opt2->data, opt1->len))) {
- note("Obsolete client identifier (%s) in recorded lease",
- pretty_print_option(DHO_DHCP_CLIENT_IDENTIFIER, opt1, 0));
- free_client_lease(lease);
- return;
- }
-
- /*
- * The new lease will supersede a lease of the same type and for
- * the same address or the same SSID.
+ * The new lease will supersede a lease which is of the same type
+ * AND the same ssid AND the same Client Identifier AND the same
+ * IP address.
*/
TAILQ_FOREACH_SAFE(lp, &client->leases, next, pl) {
if (lp->is_static != is_static)
continue;
- if ((strcmp(lp->ssid, ifi->ssid) == 0) ||
- (lp->address.s_addr == lease->address.s_addr)) {
- TAILQ_REMOVE(&client->leases, lp, next);
- lp->is_static = 0; /* Else it won't be freed. */
- free_client_lease(lp);
- }
+ if (strcmp(lp->ssid, ifi->ssid) != 0)
+ continue;
+ if ((lease->options[DHO_DHCP_CLIENT_IDENTIFIER].len != 0) &&
+ ((lp->options[DHO_DHCP_CLIENT_IDENTIFIER].len !=
+ lease->options[DHO_DHCP_CLIENT_IDENTIFIER].len) ||
+ memcmp(lp->options[DHO_DHCP_CLIENT_IDENTIFIER].data,
+ lease->options[DHO_DHCP_CLIENT_IDENTIFIER].data,
+ lp->options[DHO_DHCP_CLIENT_IDENTIFIER].len)))
+ continue;
+ if (lp->address.s_addr != lease->address.s_addr)
+ continue;
+
+ TAILQ_REMOVE(&client->leases, lp, next);
+ lp->is_static = 0; /* Else it won't be freed. */
+ free_client_lease(lp);
}
/*