summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorShawn Routhier <sar@isc.org>2012-09-19 14:38:53 -0700
committerShawn Routhier <sar@isc.org>2012-09-19 14:38:53 -0700
commit6075861eacee14052f6cd755000b4dc6073c0c20 (patch)
treeeb20005043d2d3ed9827f3fda3a016e56994d607 /common
parentd78336c4e640a7b7427b0e4cf833fd24b5f070ca (diff)
downloadisc-dhcp-6075861eacee14052f6cd755000b4dc6073c0c20.tar.gz
[v4_2]
Update the memory leakage debug code to work with v6.
Diffstat (limited to 'common')
-rw-r--r--common/options.c96
1 files changed, 52 insertions, 44 deletions
diff --git a/common/options.c b/common/options.c
index eccaa244..51940f16 100644
--- a/common/options.c
+++ b/common/options.c
@@ -3749,55 +3749,51 @@ void do_packet (interface, packet, len, from_port, from, hfrom)
#endif
#if defined (TRACING)
- trace_inpacket_stash (interface, packet, len, from_port, from, hfrom);
+ trace_inpacket_stash(interface, packet, len, from_port, from, hfrom);
#endif
- decoded_packet = (struct packet *)0;
- if (!packet_allocate (&decoded_packet, MDL)) {
- log_error ("do_packet: no memory for incoming packet!");
+ decoded_packet = NULL;
+ if (!packet_allocate(&decoded_packet, MDL)) {
+ log_error("do_packet: no memory for incoming packet!");
return;
}
- decoded_packet -> raw = packet;
- decoded_packet -> packet_length = len;
- decoded_packet -> client_port = from_port;
- decoded_packet -> client_addr = from;
- interface_reference (&decoded_packet -> interface, interface, MDL);
- decoded_packet -> haddr = hfrom;
-
- if (packet -> hlen > sizeof packet -> chaddr) {
- packet_dereference (&decoded_packet, MDL);
- log_info ("Discarding packet with bogus hlen.");
+ decoded_packet->raw = packet;
+ decoded_packet->packet_length = len;
+ decoded_packet->client_port = from_port;
+ decoded_packet->client_addr = from;
+ interface_reference(&decoded_packet->interface, interface, MDL);
+ decoded_packet->haddr = hfrom;
+
+ if (packet->hlen > sizeof packet->chaddr) {
+ packet_dereference(&decoded_packet, MDL);
+ log_info("Discarding packet with bogus hlen.");
return;
}
/* If there's an option buffer, try to parse it. */
- if (decoded_packet -> packet_length >= DHCP_FIXED_NON_UDP + 4) {
- if (!parse_options (decoded_packet)) {
- if (decoded_packet -> options)
+ if (decoded_packet->packet_length >= DHCP_FIXED_NON_UDP + 4) {
+ if (!parse_options(decoded_packet)) {
+ if (decoded_packet->options)
option_state_dereference
- (&decoded_packet -> options, MDL);
+ (&decoded_packet->options, MDL);
packet_dereference (&decoded_packet, MDL);
return;
}
- if (decoded_packet -> options_valid &&
- (op = lookup_option (&dhcp_universe,
- decoded_packet -> options,
- DHO_DHCP_MESSAGE_TYPE))) {
+ if (decoded_packet->options_valid &&
+ (op = lookup_option(&dhcp_universe,
+ decoded_packet->options,
+ DHO_DHCP_MESSAGE_TYPE))) {
struct data_string dp;
- memset (&dp, 0, sizeof dp);
- evaluate_option_cache (&dp, decoded_packet,
- (struct lease *)0,
- (struct client_state *)0,
- decoded_packet -> options,
- (struct option_state *)0,
- (struct binding_scope **)0,
- op, MDL);
+ memset(&dp, 0, sizeof dp);
+ evaluate_option_cache(&dp, decoded_packet, NULL, NULL,
+ decoded_packet->options, NULL,
+ NULL, op, MDL);
if (dp.len > 0)
- decoded_packet -> packet_type = dp.data [0];
+ decoded_packet->packet_type = dp.data[0];
else
- decoded_packet -> packet_type = 0;
- data_string_forget (&dp, MDL);
+ decoded_packet->packet_type = 0;
+ data_string_forget(&dp, MDL);
}
}
@@ -3809,19 +3805,17 @@ void do_packet (interface, packet, len, from_port, from, hfrom)
}
/* If the caller kept the packet, they'll have upped the refcnt. */
- packet_dereference (&decoded_packet, MDL);
+ packet_dereference(&decoded_packet, MDL);
#if defined (DEBUG_MEMORY_LEAKAGE)
- log_info ("generation %ld: %ld new, %ld outstanding, %ld long-term",
- dmalloc_generation,
- dmalloc_outstanding - previous_outstanding,
- dmalloc_outstanding, dmalloc_longterm);
-#endif
-#if defined (DEBUG_MEMORY_LEAKAGE)
- dmalloc_dump_outstanding ();
+ log_info("generation %ld: %ld new, %ld outstanding, %ld long-term",
+ dmalloc_generation,
+ dmalloc_outstanding - previous_outstanding,
+ dmalloc_outstanding, dmalloc_longterm);
+ dmalloc_dump_outstanding();
#endif
#if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY)
- dump_rc_history (0);
+ dump_rc_history(0);
#endif
}
@@ -3855,6 +3849,9 @@ do_packet6(struct interface_info *interface, const char *packet,
const struct dhcpv6_packet *msg;
const struct dhcpv6_relay_packet *relay;
struct packet *decoded_packet;
+#if defined (DEBUG_MEMORY_LEAKAGE)
+ unsigned long previous_outstanding = dmalloc_outstanding;
+#endif
if (!packet6_len_okay(packet, len)) {
log_info("do_packet6: "
@@ -3882,8 +3879,8 @@ do_packet6(struct interface_info *interface, const char *packet,
/* decoded_packet->circuit_id_len = 0; */
/* decoded_packet->remote_id = NULL; */
/* decoded_packet->remote_id_len = 0; */
- decoded_packet->raw = (struct dhcp_packet *) packet;
- decoded_packet->packet_length = (unsigned) len;
+ decoded_packet->raw = (struct dhcp_packet *)packet;
+ decoded_packet->packet_length = (unsigned)len;
decoded_packet->client_port = from_port;
decoded_packet->client_addr = *from;
interface_reference(&decoded_packet->interface, interface, MDL);
@@ -3935,6 +3932,17 @@ do_packet6(struct interface_info *interface, const char *packet,
dhcpv6(decoded_packet);
packet_dereference(&decoded_packet, MDL);
+
+#if defined (DEBUG_MEMORY_LEAKAGE)
+ log_info("generation %ld: %ld new, %ld outstanding, %ld long-term",
+ dmalloc_generation,
+ dmalloc_outstanding - previous_outstanding,
+ dmalloc_outstanding, dmalloc_longterm);
+ dmalloc_dump_outstanding();
+#endif
+#if defined (DEBUG_RC_HISTORY_EXHAUSTIVELY)
+ dump_rc_history(0);
+#endif
}
#endif /* DHCPv6 */