Revert "Implement RFC-6842 (Client-ids in DHCP replies.)"

This reverts commit 88a77a78ad.

A least one client has been found which breaks with this change. Since
the use-case is not clear, I'm reverting the change, at least for now.
This commit is contained in:
Simon Kelley
2017-04-28 22:43:00 +01:00
parent 5ce3e76fbf
commit a9df0e30b0
2 changed files with 11 additions and 25 deletions

View File

@@ -74,9 +74,6 @@ version 2.77
of "local addresses only" entries. Thanks to Hannu Nyman for of "local addresses only" entries. Thanks to Hannu Nyman for
the patch. the patch.
Implement RFC 6842. Thanks to Reddeiah Raju Konduru for
pointing out that this was missing.
Make --bogus-priv apply to IPv6, for the prefixes specified Make --bogus-priv apply to IPv6, for the prefixes specified
in RFC6303. Thanks to Kevin Darbyshire-Bryant for work on this. in RFC6303. Thanks to Kevin Darbyshire-Bryant for work on this.

View File

@@ -38,7 +38,7 @@ static void log_packet(char *type, void *addr, unsigned char *ext_mac,
static unsigned char *option_find(struct dhcp_packet *mess, size_t size, int opt_type, int minsize); static unsigned char *option_find(struct dhcp_packet *mess, size_t size, int opt_type, int minsize);
static unsigned char *option_find1(unsigned char *p, unsigned char *end, int opt, int minsize); static unsigned char *option_find1(unsigned char *p, unsigned char *end, int opt, int minsize);
static size_t dhcp_packet_size(struct dhcp_packet *mess, unsigned char *agent_id, unsigned char *real_end); static size_t dhcp_packet_size(struct dhcp_packet *mess, unsigned char *agent_id, unsigned char *real_end);
static void clear_packet(struct dhcp_packet *mess, unsigned char *end, unsigned int sz); static void clear_packet(struct dhcp_packet *mess, unsigned char *end);
static int in_list(unsigned char *list, int opt); static int in_list(unsigned char *list, int opt);
static void do_options(struct dhcp_context *context, static void do_options(struct dhcp_context *context,
struct dhcp_packet *mess, struct dhcp_packet *mess,
@@ -612,7 +612,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
now); now);
lease_set_interface(lease, int_index, now); lease_set_interface(lease, int_index, now);
clear_packet(mess, end, 0); clear_packet(mess, end);
do_options(context, mess, end, NULL, hostname, get_domain(mess->yiaddr), do_options(context, mess, end, NULL, hostname, get_domain(mess->yiaddr),
netid, subnet_addr, 0, 0, -1, NULL, vendor_class_len, now, 0xffffffff, 0); netid, subnet_addr, 0, 0, -1, NULL, vendor_class_len, now, 0xffffffff, 0);
} }
@@ -815,7 +815,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
if (!service || !service->basename || !context) if (!service || !service->basename || !context)
return 0; return 0;
clear_packet(mess, end, sz); clear_packet(mess, end);
mess->yiaddr = mess->ciaddr; mess->yiaddr = mess->ciaddr;
mess->ciaddr.s_addr = 0; mess->ciaddr.s_addr = 0;
@@ -883,7 +883,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
mess->flags |= htons(0x8000); /* broadcast */ mess->flags |= htons(0x8000); /* broadcast */
} }
clear_packet(mess, end, sz); clear_packet(mess, end);
/* Redirect EFI clients to port 4011 */ /* Redirect EFI clients to port 4011 */
if (pxearch >= 6) if (pxearch >= 6)
@@ -1067,7 +1067,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
log_packet("DHCPOFFER" , &mess->yiaddr, emac, emac_len, iface_name, NULL, NULL, mess->xid); log_packet("DHCPOFFER" , &mess->yiaddr, emac, emac_len, iface_name, NULL, NULL, mess->xid);
time = calc_time(context, config, option_find(mess, sz, OPTION_LEASE_TIME, 4)); time = calc_time(context, config, option_find(mess, sz, OPTION_LEASE_TIME, 4));
clear_packet(mess, end, sz); clear_packet(mess, end);
option_put(mess, end, OPTION_MESSAGE_TYPE, 1, DHCPOFFER); option_put(mess, end, OPTION_MESSAGE_TYPE, 1, DHCPOFFER);
option_put(mess, end, OPTION_SERVER_IDENTIFIER, INADDRSZ, ntohl(server_id(context, override, fallback).s_addr)); option_put(mess, end, OPTION_SERVER_IDENTIFIER, INADDRSZ, ntohl(server_id(context, override, fallback).s_addr));
option_put(mess, end, OPTION_LEASE_TIME, 4, time); option_put(mess, end, OPTION_LEASE_TIME, 4, time);
@@ -1250,7 +1250,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
log_packet("DHCPNAK", &mess->yiaddr, emac, emac_len, iface_name, NULL, message, mess->xid); log_packet("DHCPNAK", &mess->yiaddr, emac, emac_len, iface_name, NULL, message, mess->xid);
mess->yiaddr.s_addr = 0; mess->yiaddr.s_addr = 0;
clear_packet(mess, end, sz); clear_packet(mess, end);
option_put(mess, end, OPTION_MESSAGE_TYPE, 1, DHCPNAK); option_put(mess, end, OPTION_MESSAGE_TYPE, 1, DHCPNAK);
option_put(mess, end, OPTION_SERVER_IDENTIFIER, INADDRSZ, ntohl(server_id(context, override, fallback).s_addr)); option_put(mess, end, OPTION_SERVER_IDENTIFIER, INADDRSZ, ntohl(server_id(context, override, fallback).s_addr));
option_put_string(mess, end, OPTION_MESSAGE, message, borken_opt); option_put_string(mess, end, OPTION_MESSAGE, message, borken_opt);
@@ -1406,7 +1406,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
log_packet("DHCPACK", &mess->yiaddr, emac, emac_len, iface_name, hostname, NULL, mess->xid); log_packet("DHCPACK", &mess->yiaddr, emac, emac_len, iface_name, hostname, NULL, mess->xid);
clear_packet(mess, end, sz); clear_packet(mess, end);
option_put(mess, end, OPTION_MESSAGE_TYPE, 1, DHCPACK); option_put(mess, end, OPTION_MESSAGE_TYPE, 1, DHCPACK);
option_put(mess, end, OPTION_SERVER_IDENTIFIER, INADDRSZ, ntohl(server_id(context, override, fallback).s_addr)); option_put(mess, end, OPTION_SERVER_IDENTIFIER, INADDRSZ, ntohl(server_id(context, override, fallback).s_addr));
option_put(mess, end, OPTION_LEASE_TIME, 4, time); option_put(mess, end, OPTION_LEASE_TIME, 4, time);
@@ -1457,7 +1457,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
override = lease->override; override = lease->override;
} }
clear_packet(mess, end, sz); clear_packet(mess, end);
option_put(mess, end, OPTION_MESSAGE_TYPE, 1, DHCPACK); option_put(mess, end, OPTION_MESSAGE_TYPE, 1, DHCPACK);
option_put(mess, end, OPTION_SERVER_IDENTIFIER, INADDRSZ, ntohl(server_id(context, override, fallback).s_addr)); option_put(mess, end, OPTION_SERVER_IDENTIFIER, INADDRSZ, ntohl(server_id(context, override, fallback).s_addr));
@@ -2186,22 +2186,11 @@ static struct dhcp_opt *pxe_opts(int pxe_arch, struct dhcp_netid *netid, struct
return ret; return ret;
} }
static void clear_packet(struct dhcp_packet *mess, unsigned char *end, unsigned int sz) static void clear_packet(struct dhcp_packet *mess, unsigned char *end)
{ {
unsigned char *opt;
unsigned int clid_tot = 0;
/* If sz is non-zero, save any client-id option by copying it as the first
option in the new packet */
if (sz != 0 && (opt = option_find(mess, sz, OPTION_CLIENT_ID, 1)))
{
clid_tot = option_len(opt) + 2u;
memmove(&mess->options[0] + sizeof(u32), opt, clid_tot);
}
memset(mess->sname, 0, sizeof(mess->sname)); memset(mess->sname, 0, sizeof(mess->sname));
memset(mess->file, 0, sizeof(mess->file)); memset(mess->file, 0, sizeof(mess->file));
memset(&mess->options[0] + sizeof(u32) + clid_tot, 0, end - (&mess->options[0] + sizeof(u32) + clid_tot)); memset(&mess->options[0] + sizeof(u32), 0, end - (&mess->options[0] + sizeof(u32)));
mess->siaddr.s_addr = 0; mess->siaddr.s_addr = 0;
} }