summaryrefslogtreecommitdiff
path: root/server/dhcpv6.c
diff options
context:
space:
mode:
authorShawn Routhier <sar@isc.org>2013-10-31 14:09:24 -0700
committerShawn Routhier <sar@isc.org>2013-10-31 14:09:24 -0700
commitd9b5c150b727912a773695967df635ef62b1bec9 (patch)
treec15c606f497696a24c70d86049dd00190e61a7d7 /server/dhcpv6.c
parent47e8308dea6ee44ce19edf4fdf3331fa41a986f7 (diff)
downloadisc-dhcp-d9b5c150b727912a773695967df635ef62b1bec9.tar.gz
[master]
Add log messages for when the addresses we assign.
Diffstat (limited to 'server/dhcpv6.c')
-rw-r--r--server/dhcpv6.c197
1 files changed, 159 insertions, 38 deletions
diff --git a/server/dhcpv6.c b/server/dhcpv6.c
index 4f150511..6daba5e4 100644
--- a/server/dhcpv6.c
+++ b/server/dhcpv6.c
@@ -61,6 +61,7 @@ struct reply_state {
struct ia_xx *old_ia;
struct option_state *reply_ia;
struct data_string fixed;
+ struct iaddrcidrnet fixed_pref; /* static prefix for logging */
/* IAADDR/PREFIX level persistent state */
struct iasubopt *lease;
@@ -1896,6 +1897,62 @@ reply_process_ia_na(struct reply_state *reply, struct option_cache *ia) {
putULong(reply->buf.data + ia_cursor + 12, reply->rebind);
/*
+ * yes, goto's aren't the best but we also want to avoid extra
+ * indents
+ */
+ if (status == ISC_R_CANCELED)
+ goto cleanup;
+
+ /*
+ * Handle static leases, we always log stuff and if it's
+ * a hard binding we run any commit statements that we have
+ */
+ if (reply->static_lease) {
+ char tmp_addr[INET6_ADDRSTRLEN];
+ log_info("%s NA: address %s to client with duid %s iaid = %d "
+ "static",
+ dhcpv6_type_names[reply->buf.reply.msg_type],
+ inet_ntop(AF_INET6, reply->fixed.data, tmp_addr,
+ sizeof(tmp_addr)),
+ print_hex_1(reply->client_id.len,
+ reply->client_id.data, 60),
+ iaid);
+
+ if ((reply->buf.reply.msg_type == DHCPV6_REPLY) &&
+ (reply->on_star.on_commit != NULL)) {
+ execute_statements(NULL, reply->packet, NULL, NULL,
+ reply->packet->options,
+ reply->opt_state, NULL,
+ reply->on_star.on_commit, NULL);
+ executable_statement_dereference
+ (&reply->on_star.on_commit, MDL);
+ }
+ goto cleanup;
+ }
+
+ /*
+ * If we have any addresses log what we are doing.
+ */
+ if (reply->ia->num_iasubopt != 0) {
+ struct iasubopt *tmp;
+ int i;
+ char tmp_addr[INET6_ADDRSTRLEN];
+
+ for (i = 0 ; i < reply->ia->num_iasubopt ; i++) {
+ tmp = reply->ia->iasubopt[i];
+
+ log_info("%s NA: address %s to client with duid %s "
+ "iaid = %d valid for %d seconds",
+ dhcpv6_type_names[reply->buf.reply.msg_type],
+ inet_ntop(AF_INET6, &tmp->addr,
+ tmp_addr, sizeof(tmp_addr)),
+ print_hex_1(reply->client_id.len,
+ reply->client_id.data, 60),
+ iaid, tmp->valid);
+ }
+ }
+
+ /*
* If this is not a 'soft' binding, consume the new changes into
* the database (if any have been attached to the ia_na).
*
@@ -1903,9 +1960,9 @@ reply_process_ia_na(struct reply_state *reply, struct option_cache *ia) {
* leases onto this IA_NA rather than any old ones, and updating
* pool timers for each (if any).
*/
- if ((status != ISC_R_CANCELED) && !reply->static_lease &&
- (reply->buf.reply.msg_type == DHCPV6_REPLY) &&
- (reply->ia->num_iasubopt != 0)) {
+
+ if ((reply->ia->num_iasubopt != 0) &&
+ (reply->buf.reply.msg_type == DHCPV6_REPLY)) {
struct iasubopt *tmp;
struct data_string *ia_id;
int i;
@@ -1971,20 +2028,6 @@ reply_process_ia_na(struct reply_state *reply, struct option_cache *ia) {
write_ia(reply->ia);
}
- /*
- * If this would be a hard binding for a static lease
- * run any commit statements that we have
- */
- if ((status != ISC_R_CANCELED) && reply->static_lease &&
- (reply->buf.reply.msg_type == DHCPV6_REPLY) &&
- (reply->on_star.on_commit != NULL)) {
- execute_statements(NULL, reply->packet, NULL, NULL,
- reply->packet->options, reply->opt_state,
- NULL, reply->on_star.on_commit, NULL);
- executable_statement_dereference
- (&reply->on_star.on_commit, MDL);
- }
-
cleanup:
if (packet_ia != NULL)
option_state_dereference(&packet_ia, MDL);
@@ -2597,16 +2640,45 @@ reply_process_ia_ta(struct reply_state *reply, struct option_cache *ia) {
reply->cursor - (ia_cursor + 4));
/*
- * Consume the new changes into the database (if any have been
- * attached to the ia_ta).
+ * yes, goto's aren't the best but we also want to avoid extra
+ * indents
+ */
+ if (status == ISC_R_CANCELED)
+ goto cleanup;
+
+ /*
+ * If we have any addresses log what we are doing.
+ */
+ if (reply->ia->num_iasubopt != 0) {
+ struct iasubopt *tmp;
+ int i;
+ char tmp_addr[INET6_ADDRSTRLEN];
+
+ for (i = 0 ; i < reply->ia->num_iasubopt ; i++) {
+ tmp = reply->ia->iasubopt[i];
+
+ log_info("%s TA: address %s to client with duid %s "
+ "iaid = %d valid for %d seconds",
+ dhcpv6_type_names[reply->buf.reply.msg_type],
+ inet_ntop(AF_INET6, &tmp->addr,
+ tmp_addr, sizeof(tmp_addr)),
+ print_hex_1(reply->client_id.len,
+ reply->client_id.data, 60),
+ iaid,
+ tmp->valid);
+ }
+ }
+
+ /*
+ * For hard bindings we consume the new changes into
+ * the database (if any have been attached to the ia_ta).
*
* Loop through the assigned dynamic addresses, referencing the
* leases onto this IA_TA rather than any old ones, and updating
* pool timers for each (if any).
*/
- if ((status != ISC_R_CANCELED) &&
- (reply->buf.reply.msg_type == DHCPV6_REPLY) &&
- (reply->ia->num_iasubopt != 0)) {
+ if ((reply->ia->num_iasubopt != 0) &&
+ (reply->buf.reply.msg_type == DHCPV6_REPLY)) {
struct iasubopt *tmp;
struct data_string *ia_id;
int i;
@@ -3616,6 +3688,64 @@ reply_process_ia_pd(struct reply_state *reply, struct option_cache *ia) {
putULong(reply->buf.data + ia_cursor + 12, reply->rebind);
/*
+ * yes, goto's aren't the best but we also want to avoid extra
+ * indents
+ */
+ if (status == ISC_R_CANCELED)
+ goto cleanup;
+
+ /*
+ * Handle static prefixes, we always log stuff and if it's
+ * a hard binding we run any commit statements that we have
+ */
+ if (reply->static_prefixes != 0) {
+ char tmp_addr[INET6_ADDRSTRLEN];
+ log_info("%s PD: address %s/%d to client with duid %s "
+ "iaid = %d static",
+ dhcpv6_type_names[reply->buf.reply.msg_type],
+ inet_ntop(AF_INET6, reply->fixed_pref.lo_addr.iabuf,
+ tmp_addr, sizeof(tmp_addr)),
+ reply->fixed_pref.bits,
+ print_hex_1(reply->client_id.len,
+ reply->client_id.data, 60),
+ iaid);
+ if ((reply->buf.reply.msg_type == DHCPV6_REPLY) &&
+ (reply->on_star.on_commit != NULL)) {
+ execute_statements(NULL, reply->packet, NULL, NULL,
+ reply->packet->options,
+ reply->opt_state,
+ NULL, reply->on_star.on_commit,
+ NULL);
+ executable_statement_dereference
+ (&reply->on_star.on_commit, MDL);
+ }
+ goto cleanup;
+ }
+
+ /*
+ * If we have any addresses log what we are doing.
+ */
+ if (reply->ia->num_iasubopt != 0) {
+ struct iasubopt *tmp;
+ int i;
+ char tmp_addr[INET6_ADDRSTRLEN];
+
+ for (i = 0 ; i < reply->ia->num_iasubopt ; i++) {
+ tmp = reply->ia->iasubopt[i];
+
+ log_info("%s PD: address %s/%d to client with duid %s"
+ " iaid = %d valid for %d seconds",
+ dhcpv6_type_names[reply->buf.reply.msg_type],
+ inet_ntop(AF_INET6, &tmp->addr,
+ tmp_addr, sizeof(tmp_addr)),
+ (int)tmp->plen,
+ print_hex_1(reply->client_id.len,
+ reply->client_id.data, 60),
+ iaid, tmp->valid);
+ }
+ }
+
+ /*
* If this is not a 'soft' binding, consume the new changes into
* the database (if any have been attached to the ia_pd).
*
@@ -3623,8 +3753,7 @@ reply_process_ia_pd(struct reply_state *reply, struct option_cache *ia) {
* prefixes onto this IA_PD rather than any old ones, and updating
* prefix pool timers for each (if any).
*/
- if ((status != ISC_R_CANCELED) && (reply->static_prefixes == 0) &&
- (reply->buf.reply.msg_type == DHCPV6_REPLY) &&
+ if ((reply->buf.reply.msg_type == DHCPV6_REPLY) &&
(reply->ia->num_iasubopt != 0)) {
struct iasubopt *tmp;
struct data_string *ia_id;
@@ -3673,20 +3802,6 @@ reply_process_ia_pd(struct reply_state *reply, struct option_cache *ia) {
write_ia(reply->ia);
}
- /*
- * If this would be a hard binding for a static lease
- * run any commit statements that we have
- */
- if ((status != ISC_R_CANCELED) && reply->static_prefixes != 0 &&
- (reply->buf.reply.msg_type == DHCPV6_REPLY) &&
- (reply->on_star.on_commit != NULL)) {
- execute_statements(NULL, reply->packet, NULL, NULL,
- reply->packet->options, reply->opt_state,
- NULL, reply->on_star.on_commit, NULL);
- executable_statement_dereference
- (&reply->on_star.on_commit, MDL);
- }
-
cleanup:
if (packet_ia != NULL)
option_state_dereference(&packet_ia, MDL);
@@ -3880,6 +3995,9 @@ reply_process_prefix(struct reply_state *reply, struct option_cache *pref) {
log_fatal("Impossible condition at %s:%d.", MDL);
group = reply->subnet->group;
subnet_dereference(&reply->subnet, MDL);
+
+ /* Copy the static prefix for logging purposes */
+ memcpy(&reply->fixed_pref, &tmp_pref, sizeof(tmp_pref));
} else {
if (reply->lease == NULL)
log_fatal("Impossible condition at %s:%d.", MDL);
@@ -4127,6 +4245,9 @@ find_client_prefix(struct reply_state *reply) {
group = reply->subnet->group;
subnet_dereference(&reply->subnet, MDL);
+ /* Copy the prefix for logging purposes */
+ memcpy(&reply->fixed_pref, &l->cidrnet, sizeof(send_pref));
+
goto send_pref;
}