ikev1: Don't log a reauthentication detection message if no children adopted
[strongswan.git] / src / libcharon / processing / jobs / adopt_children_job.c
index 93da960..f99c0b9 100644 (file)
@@ -43,7 +43,7 @@ METHOD(job_t, destroy, void,
        free(this);
 }
 
-METHOD(job_t, execute, void,
+METHOD(job_t, execute, job_requeue_t,
        private_adopt_children_job_t *this)
 {
        identification_t *my_id, *other_id, *xauth;
@@ -77,7 +77,7 @@ METHOD(job_t, execute, void,
                /* find old SA to adopt children from */
                children = linked_list_create();
                enumerator = charon->ike_sa_manager->create_id_enumerator(
-                                                                       charon->ike_sa_manager, my_id, other_id,
+                                                                       charon->ike_sa_manager, my_id, xauth,
                                                                        other->get_family(other));
                while (enumerator->enumerate(enumerator, &id))
                {
@@ -92,7 +92,7 @@ METHOD(job_t, execute, void,
                                         ike_sa->get_state(ike_sa) == IKE_PASSIVE) &&
                                        me->equals(me, ike_sa->get_my_host(ike_sa)) &&
                                        other->equals(other, ike_sa->get_other_host(ike_sa)) &&
-                                       xauth->equals(xauth, ike_sa->get_other_eap_id(ike_sa)) &&
+                                       other_id->equals(other_id, ike_sa->get_other_id(ike_sa)) &&
                                        cfg->equals(cfg, ike_sa->get_peer_cfg(ike_sa)))
                                {
                                        childenum = ike_sa->create_child_sa_enumerator(ike_sa);
@@ -102,8 +102,12 @@ METHOD(job_t, execute, void,
                                                children->insert_last(children, child_sa);
                                        }
                                        childenum->destroy(childenum);
-                                       DBG1(DBG_IKE, "detected reauth of existing IKE_SA, "
-                                                "adopting %d children", children->get_count(children));
+                                       if (children->get_count(children))
+                                       {
+                                               DBG1(DBG_IKE, "detected reauth of existing IKE_SA, "
+                                                        "adopting %d children",
+                                                        children->get_count(children));
+                                       }
                                        ike_sa->set_state(ike_sa, IKE_DELETING);
                                        charon->bus->ike_updown(charon->bus, ike_sa, FALSE);
                                        charon->ike_sa_manager->checkin_and_destroy(
@@ -146,7 +150,7 @@ METHOD(job_t, execute, void,
                }
                children->destroy_offset(children, offsetof(child_sa_t, destroy));
        }
-       destroy(this);
+       return JOB_REQUEUE_NONE;
 }
 
 METHOD(job_t, get_priority, job_priority_t,