From: krw Date: Fri, 16 Jun 2017 14:12:12 +0000 (+0000) Subject: Nuke 'is_bootp' field and just use a #define to check if the lease X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7f9b6e60bd29d00a4204a9aaa16b23194a9d5488;p=openbsd Nuke 'is_bootp' field and just use a #define to check if the lease has DHO_DHCP_MESSAGE_TYPE info. --- diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c index 4a798b69422..b061b6cfab4 100644 --- a/sbin/dhclient/clparse.c +++ b/sbin/dhclient/clparse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clparse.c,v 1.112 2017/06/14 16:52:35 krw Exp $ */ +/* $OpenBSD: clparse.c,v 1.113 2017/06/16 14:12:12 krw Exp $ */ /* Parser for dhclient config and lease files. */ @@ -560,7 +560,7 @@ parse_client_lease_declaration(FILE *cfile, struct client_lease *lease, switch (token) { case TOK_BOOTP: - lease->is_bootp = 1; + /* 'bootp' is just a comment. See BOOTP_LEASE(). */ break; case TOK_INTERFACE: token = next_token(&val, cfile); diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 868ac29b87b..9c0538ef2f5 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.427 2017/06/15 17:06:17 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.428 2017/06/16 14:12:12 krw Exp $ */ /* * Copyright 2004 Henning Brauer @@ -767,8 +767,8 @@ state_reboot(struct interface_info *ifi) } else ifi->active = get_recorded_lease(ifi); - /* If we don't remember an active lease, go straight to INIT. */ - if (!ifi->active || ifi->active->is_bootp) { + /* No active lease, or the lease is BOOTP, go straight to INIT. */ + if (!ifi->active || BOOTP_LEASE(ifi->active)) { ifi->state = S_INIT; state_init(ifi); return; @@ -835,7 +835,7 @@ state_selecting(struct interface_info *ifi) } /* If it was a BOOTREPLY, we can just take the lease right now. */ - if (!picked->options[DHO_DHCP_MESSAGE_TYPE].len) { + if (BOOTP_LEASE(picked)) { struct option_data *option; ifi->new = picked; @@ -1138,13 +1138,6 @@ dhcpoffer(struct interface_info *ifi, struct option_data *options, char *info) lease = packet_to_lease(ifi, options); - /* - * If this lease was acquired through a BOOTREPLY, record that - * fact. - */ - if (!options[DHO_DHCP_MESSAGE_TYPE].len) - lease->is_bootp = 1; - /* Figure out when we're supposed to stop selecting. */ stop_selecting = ifi->first_sending + config->select_interval; @@ -1879,7 +1872,7 @@ lease_as_string(struct interface_info *ifi, char *type, strlcat(string, type, sizeof(string)); strlcat(string, " {\n", sizeof(string)); - strlcat(string, (lease->is_bootp) ? " bootp;\n" : "", sizeof(string)); + strlcat(string, BOOTP_LEASE(lease) ? " bootp;\n" : "", sizeof(string)); buf = pretty_print_string(ifi->name, strlen(ifi->name), 1); if (buf == NULL) @@ -2355,7 +2348,6 @@ clone_lease(struct client_lease *oldlease) newlease->renewal = oldlease->renewal; newlease->rebind = oldlease->rebind; newlease->is_static = oldlease->is_static; - newlease->is_bootp = oldlease->is_bootp; newlease->address = oldlease->address; newlease->next_server = oldlease->next_server; memcpy(newlease->ssid, oldlease->ssid, sizeof(newlease->ssid)); @@ -2516,7 +2508,7 @@ compare_lease(struct client_lease *active, struct client_lease *new) if (active->address.s_addr != new->address.s_addr || active->is_static != new->is_static || - active->is_bootp != new->is_bootp) + BOOTP_LEASE(active) != BOOTP_LEASE(new)) return (1); if (active->server_name != new->server_name) { diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h index 4bfa2d81261..cd6645ca589 100644 --- a/sbin/dhclient/dhcpd.h +++ b/sbin/dhclient/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.182 2017/06/15 17:06:17 krw Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.183 2017/06/16 14:12:12 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer @@ -72,10 +72,10 @@ struct client_lease { char ssid[32]; uint8_t ssid_len; unsigned int is_static; - unsigned int is_bootp; unsigned int is_invalid; struct option_data options[256]; }; +#define BOOTP_LEASE(l) ((l)->options[DHO_DHCP_MESSAGE_TYPE].len == 0) /* Possible states in which the client can be. */ enum dhcp_state {