summaryrefslogtreecommitdiff
path: root/sbin/dhclient
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2013-07-11 01:34:01 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2013-07-11 01:34:01 +0000
commit984fabea9d92613f1cec5c6ee093728ca12bd792 (patch)
tree7b0a1b7bd334e3edb13fe1426ac3490166d68eea /sbin/dhclient
parenteee92dd9b16cd1cd92ebbf4748b6256096180754 (diff)
Put more debug verbiage under DEBUG. Add a few more debug messages.
Make packet discarding decisions before parsing the packet's possible options. No intended functional change.
Diffstat (limited to 'sbin/dhclient')
-rw-r--r--sbin/dhclient/options.c58
1 files changed, 36 insertions, 22 deletions
diff --git a/sbin/dhclient/options.c b/sbin/dhclient/options.c
index f5f608b4c61..88c13d61906 100644
--- a/sbin/dhclient/options.c
+++ b/sbin/dhclient/options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.c,v 1.55 2013/07/07 00:04:58 krw Exp $ */
+/* $OpenBSD: options.c,v 1.56 2013/07/11 01:34:00 krw Exp $ */
/* DHCP options parsing and reassembly. */
@@ -463,18 +463,37 @@ do_packet(unsigned int from_port, struct in_addr from,
char *type, *info;
int i, rslt, options_valid = 1;
- if (packet->hlen > sizeof(packet->chaddr)) {
- note("Discarding packet with invalid hlen.");
+ if (ifi->hw_address.hlen != packet->hlen) {
+#ifdef DEBUG
+ debug("Discarding packet with hlen != %s (%u)",
+ ifi->name, packet->hlen);
+#endif
+ return;
+ } else if (memcmp(ifi->hw_address.haddr, packet->chaddr,
+ packet->hlen)) {
+#ifdef DEBUG
+ debug("Discarding packet with chaddr != %s (%s)", ifi->name,
+ ether_ntoa((struct ether_addr *)packet->chaddr));
+#endif
return;
}
- /*
- * Silently drop the packet if the client hardware address in the
- * packet is not the hardware address of the interface being managed.
- */
- if ((ifi->hw_address.hlen != packet->hlen) ||
- (memcmp(ifi->hw_address.haddr, packet->chaddr, packet->hlen)))
+ if (client->xid != client->packet.xid) {
+#ifdef DEBUG
+ debug("Discarding packet with XID != %u (%u)", client->xid,
+ client->packet.xid);
+#endif
return;
+ }
+
+ for (ap = config->reject_list; ap; ap = ap->next)
+ if (from.s_addr == ap->addr.s_addr) {
+#ifdef DEBUG
+ debug("Discarding packet from address on reject list "
+ "(%s)", inet_ntoa(from));
+#endif
+ return;
+ }
memset(options, 0, sizeof(options));
@@ -518,11 +537,19 @@ do_packet(unsigned int from_port, struct in_addr from,
type = "DHCPACK";
break;
default:
+#ifdef DEBUG
+ debug("Discarding DHCP packet of unknown type (%d)",
+ options[DHO_DHCP_MESSAGE_TYPE].data[0]);
+#endif
break;
}
} else if (options_valid && packet->op == BOOTREPLY) {
handler = dhcpoffer;
type = "BOOTREPLY";
+ } else {
+#ifdef DEBUG
+ debug("Discarding packet which is neither DHCP nor BOOTP");
+#endif
}
if (hfrom->hlen == 6)
@@ -533,19 +560,6 @@ do_packet(unsigned int from_port, struct in_addr from,
if (rslt == -1)
error("no memory for info string");
- if (client->xid != client->packet.xid) {
-#ifdef DEBUG
- debug("XID mismatch on %s", info);
-#endif
- handler = NULL;
- }
-
- for (ap = config->reject_list; ap && handler; ap = ap->next)
- if (from.s_addr == ap->addr.s_addr) {
- note("Rejected %s.", info);
- handler = NULL;
- }
-
if (handler)
(*handler)(from, options, info);