some more changes to IKE_SA and CHILD_SA logging
authorAndreas Steffen <andreas.steffen@strongswan.org>
Tue, 22 Jul 2008 17:10:10 +0000 (17:10 -0000)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Tue, 22 Jul 2008 17:10:10 +0000 (17:10 -0000)
src/charon/sa/ike_sa.c
src/charon/sa/tasks/child_create.c
src/charon/sa/tasks/child_delete.c
src/charon/sa/tasks/ike_auth.c
src/charon/sa/tasks/ike_delete.c
src/charon/sa/tasks/ike_init.c

index 21bb2f2..57cbd28 100644 (file)
@@ -645,8 +645,8 @@ static ike_sa_state_t get_state(private_ike_sa_t *this)
  */
 static void set_state(private_ike_sa_t *this, ike_sa_state_t state)
 {
-       DBG1(DBG_IKE, "IKE_SA '%s' state change: %N => %N",
-                get_name(this),
+       DBG1(DBG_IKE, "IKE_SA %s[%d] state change: %N => %N",
+                get_name(this), this->unique_id,
                 ike_sa_state_names, this->state,
                 ike_sa_state_names, state);
        
@@ -2037,7 +2037,7 @@ static status_t reestablish(private_ike_sa_t *this)
                        switch (action)
                        {
                                case ACTION_RESTART:
-                                       DBG1(DBG_IKE, "restarting CHILD_SA '%s'",
+                                       DBG1(DBG_IKE, "restarting CHILD_SA %s",
                                                 child_cfg->get_name(child_cfg));
                                        child_cfg->get_ref(child_cfg);
                                        status = new->initiate(new, child_cfg);
index dcdc853..71dc446 100644 (file)
@@ -590,8 +590,16 @@ static status_t build_i(private_child_create_t *this, message_t *message)
                        break;
        }
        
-       SIG_CHD(UP_START, NULL, "establishing CHILD_SA '%s'",
-                       this->config->get_name(this->config));
+       if (this->reqid)
+       {
+               SIG_CHD(UP_START, NULL, "establishing CHILD_SA %s{%d}",
+                               this->config->get_name(this->config), this->reqid);
+       }
+       else
+       {
+               SIG_CHD(UP_START, NULL, "establishing CHILD_SA %s{?}",
+                               this->config->get_name(this->config));
+       }
        
        /* reuse virtual IP if we already have one */
        me = this->ike_sa->get_virtual_ip(this->ike_sa, TRUE);
@@ -862,10 +870,12 @@ static status_t build_r(private_child_create_t *this, message_t *message)
        
        build_payloads(this, message);
        
-       SIG_CHD(UP_SUCCESS, this->child_sa, "CHILD_SA '%s{%d}' established "
-                       "with ts %#R=== %#R",
+       SIG_CHD(UP_SUCCESS, this->child_sa, "CHILD_SA %s{%d} established "
+                       "with SPIs %.8x_i %.8x_o and TS %#R=== %#R",
                        this->child_sa->get_name(this->child_sa),
                        this->child_sa->get_reqid(this->child_sa),
+                       ntohl(this->child_sa->get_spi(this->child_sa, TRUE)),
+                       ntohl(this->child_sa->get_spi(this->child_sa, FALSE)),
                        this->child_sa->get_traffic_selectors(this->child_sa, TRUE),
                        this->child_sa->get_traffic_selectors(this->child_sa, FALSE));
 
@@ -974,10 +984,12 @@ static status_t process_i(private_child_create_t *this, message_t *message)
        
        if (select_and_install(this, no_dh) == SUCCESS)
        {
-               SIG_CHD(UP_SUCCESS, this->child_sa, "CHILD_SA '%s{%d}' established "
-                               "with ts %#R=== %#R",
+               SIG_CHD(UP_SUCCESS, this->child_sa, "CHILD_SA %s{%d} established "
+                               "with SPIs %.8x_i %.8x_o and TS %#R=== %#R",
                                this->child_sa->get_name(this->child_sa),
                                this->child_sa->get_reqid(this->child_sa),
+                               ntohl(this->child_sa->get_spi(this->child_sa, TRUE)),
+                               ntohl(this->child_sa->get_spi(this->child_sa, FALSE)),
                                this->child_sa->get_traffic_selectors(this->child_sa, TRUE),
                                this->child_sa->get_traffic_selectors(this->child_sa, FALSE));
        }
index 268f41d..152b9bc 100644 (file)
@@ -54,16 +54,17 @@ struct private_child_delete_t {
  */
 static void build_payloads(private_child_delete_t *this, message_t *message)
 {
-       iterator_t *iterator;
        delete_payload_t *ah = NULL, *esp = NULL;
-       u_int32_t spi;
+       iterator_t *iterator;
        child_sa_t *child_sa;
        
        iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
        while (iterator->iterate(iterator, (void**)&child_sa))
        {       
-               spi = child_sa->get_spi(child_sa, TRUE);
-               switch (child_sa->get_protocol(child_sa))
+               protocol_id_t protocol = child_sa->get_protocol(child_sa);
+               u_int32_t spi = child_sa->get_spi(child_sa, TRUE);
+
+               switch (protocol)
                {
                        case PROTO_ESP:
                                if (esp == NULL)
@@ -72,6 +73,8 @@ static void build_payloads(private_child_delete_t *this, message_t *message)
                                        message->add_payload(message, (payload_t*)esp);
                                }
                                esp->add_spi(esp, spi);
+                               DBG1(DBG_IKE, "sending DELETE for %N CHILD_SA with SPI %.8x", 
+                                                          protocol_id_names, protocol, ntohl(spi));
                                break;
                        case PROTO_AH:
                                if (ah == NULL)
@@ -80,6 +83,8 @@ static void build_payloads(private_child_delete_t *this, message_t *message)
                                        message->add_payload(message, (payload_t*)ah);
                                }
                                ah->add_spi(ah, spi);
+                               DBG1(DBG_IKE, "sending DELETE for %N CHILD_SA with SPI %.8x", 
+                                                          protocol_id_names, protocol, ntohl(spi));
                                break;
                        default:
                                break;
@@ -207,10 +212,12 @@ static void log_children(private_child_delete_t *this)
        iterator = this->child_sas->create_iterator(this->child_sas, TRUE);
        while (iterator->iterate(iterator, (void**)&child_sa))
        {
-               SIG_CHD(DOWN_START, child_sa, "closing CHILD_SA '%s{%d}' "
-                               "with ts %#R=== %#R",
+               SIG_CHD(DOWN_START, child_sa, "closing CHILD_SA %s{%d} "
+                               "with SPIs %.8x_i %.8x_o and TS %#R=== %#R",
                                child_sa->get_name(child_sa),
                                child_sa->get_reqid(child_sa),
+                               ntohl(child_sa->get_spi(child_sa, TRUE)),
+                               ntohl(child_sa->get_spi(child_sa, FALSE)),
                                child_sa->get_traffic_selectors(child_sa, TRUE),
                                child_sa->get_traffic_selectors(child_sa, FALSE));
        }
index d45da76..6eeb15e 100644 (file)
@@ -377,7 +377,7 @@ static status_t build_auth_eap(private_ike_auth_t *this, message_t *message)
        if (!this->initiator)
        {
                this->ike_sa->set_state(this->ike_sa, IKE_ESTABLISHED);
-               SIG_IKE(UP_SUCCESS, "IKE_SA '%s[%d]' established between %H[%D]...%H[%D]",
+               SIG_IKE(UP_SUCCESS, "IKE_SA %s[%d] established between %H[%D]...%H[%D]",
                        this->ike_sa->get_name(this->ike_sa),
                        this->ike_sa->get_unique_id(this->ike_sa),
                        this->ike_sa->get_my_host(this->ike_sa),
@@ -424,7 +424,7 @@ static status_t process_auth_eap(private_ike_auth_t *this, message_t *message)
        if (this->initiator)
        {
                this->ike_sa->set_state(this->ike_sa, IKE_ESTABLISHED);
-               SIG_IKE(UP_SUCCESS, "IKE_SA '%s[%d]' established between %H[%D]...%H[%D]",
+               SIG_IKE(UP_SUCCESS, "IKE_SA %s[%d] established between %H[%D]...%H[%D]",
                        this->ike_sa->get_name(this->ike_sa),
                        this->ike_sa->get_unique_id(this->ike_sa),
                        this->ike_sa->get_my_host(this->ike_sa),
@@ -651,7 +651,7 @@ static status_t build_r(private_ike_auth_t *this, message_t *message)
        if (this->peer_authenticated)
        {
                this->ike_sa->set_state(this->ike_sa, IKE_ESTABLISHED);
-               SIG_IKE(UP_SUCCESS, "IKE_SA '%s[%d]' established between %H[%D]...%H[%D]",
+               SIG_IKE(UP_SUCCESS, "IKE_SA %s[%d] established between %H[%D]...%H[%D]",
                        this->ike_sa->get_name(this->ike_sa),
                        this->ike_sa->get_unique_id(this->ike_sa),
                        this->ike_sa->get_my_host(this->ike_sa),
@@ -765,7 +765,7 @@ static status_t process_i(private_ike_auth_t *this, message_t *message)
                return FAILED;
        }
        this->ike_sa->set_state(this->ike_sa, IKE_ESTABLISHED);
-       SIG_IKE(UP_SUCCESS, "IKE_SA '%s[%d]' established between %H[%D]...%H[%D]",
+       SIG_IKE(UP_SUCCESS, "IKE_SA %s[%d] established between %H[%D]...%H[%D]",
                this->ike_sa->get_name(this->ike_sa),
                this->ike_sa->get_unique_id(this->ike_sa),
                this->ike_sa->get_my_host(this->ike_sa),
index 879b103..67dddb0 100644 (file)
@@ -60,7 +60,9 @@ static status_t build_i(private_ike_delete_t *this, message_t *message)
        message->add_payload(message, (payload_t*)delete_payload);
        
        this->ike_sa->set_state(this->ike_sa, IKE_DELETING);
-       
+       DBG1(DBG_IKE, "sending DELETE for IKE_SA %s[%d]",
+                       this->ike_sa->get_name(this->ike_sa),
+                       this->ike_sa->get_unique_id(this->ike_sa));
        return NEED_MORE;
 }
 
@@ -83,7 +85,9 @@ static status_t process_r(private_ike_delete_t *this, message_t *message)
        switch (this->ike_sa->get_state(this->ike_sa))
        {
                case IKE_ESTABLISHED:
-                       DBG1(DBG_IKE, "deleting IKE_SA on request");
+                       DBG1(DBG_IKE, "received DELETE for IKE_SA %s[%d]",
+                                       this->ike_sa->get_name(this->ike_sa),
+                                       this->ike_sa->get_unique_id(this->ike_sa));
                        this->ike_sa->set_state(this->ike_sa, IKE_DELETING);
                        this->ike_sa->reestablish(this->ike_sa);
                        break;
index 9c513b2..bd4feb0 100644 (file)
@@ -230,8 +230,9 @@ static status_t build_i(private_ike_init_t *this, message_t *message)
        rng_t *rng;
        
        this->config = this->ike_sa->get_ike_cfg(this->ike_sa);
-       SIG_IKE(UP_START, "initiating IKE_SA '%s' to %H",
+       SIG_IKE(UP_START, "initiating IKE_SA %s[%d] to %H",
                this->ike_sa->get_name(this->ike_sa),
+               this->ike_sa->get_unique_id(this->ike_sa),
                this->ike_sa->get_other_host(this->ike_sa));
        this->ike_sa->set_state(this->ike_sa, IKE_CONNECTING);