fixed SPI when rekeying and deleting CHILD_SAs

This commit is contained in:
Martin Willi
2006-06-19 08:54:19 +00:00
parent 891dfaf983
commit c65a4fff3f
5 changed files with 19 additions and 14 deletions
+6 -6
View File
@@ -108,9 +108,9 @@ struct private_child_sa_t {
u_int32_t hard_lifetime; u_int32_t hard_lifetime;
/** /**
* reqid of a CHILD_SA which rekeyed this one * has this CHILD_SA been rekeyed?
*/ */
u_int32_t rekeyed; bool rekeyed;
/** /**
* CHILD_SAs own logger * CHILD_SAs own logger
@@ -450,9 +450,9 @@ static status_t add_policies(private_child_sa_t *this, linked_list_t *my_ts_list
/** /**
* Implementation of child_sa_t.set_rekeyed. * Implementation of child_sa_t.set_rekeyed.
*/ */
static void set_rekeyed(private_child_sa_t *this, u_int32_t reqid) static void set_rekeyed(private_child_sa_t *this)
{ {
this->rekeyed = reqid; this->rekeyed = TRUE;
} }
/** /**
@@ -592,7 +592,7 @@ child_sa_t * child_sa_create(u_int32_t rekey, host_t *me, host_t* other,
this->public.add = (status_t(*)(child_sa_t*,proposal_t*,prf_plus_t*))add; this->public.add = (status_t(*)(child_sa_t*,proposal_t*,prf_plus_t*))add;
this->public.update = (status_t(*)(child_sa_t*,proposal_t*,prf_plus_t*))update; this->public.update = (status_t(*)(child_sa_t*,proposal_t*,prf_plus_t*))update;
this->public.add_policies = (status_t (*)(child_sa_t*, linked_list_t*,linked_list_t*))add_policies; this->public.add_policies = (status_t (*)(child_sa_t*, linked_list_t*,linked_list_t*))add_policies;
this->public.set_rekeyed = (void (*)(child_sa_t*,u_int32_t))set_rekeyed; this->public.set_rekeyed = (void (*)(child_sa_t*))set_rekeyed;
this->public.log_status = (void (*)(child_sa_t*, logger_t*, char*))log_status; this->public.log_status = (void (*)(child_sa_t*, logger_t*, char*))log_status;
this->public.destroy = (void(*)(child_sa_t*))destroy; this->public.destroy = (void(*)(child_sa_t*))destroy;
@@ -610,7 +610,7 @@ child_sa_t * child_sa_create(u_int32_t rekey, host_t *me, host_t* other,
this->reqid = rekey ? rekey : ++reqid; this->reqid = rekey ? rekey : ++reqid;
this->policies = linked_list_create(); this->policies = linked_list_create();
this->protocol = PROTO_NONE; this->protocol = PROTO_NONE;
this->rekeyed = 0; this->rekeyed = FALSE;
return (&this->public); return (&this->public);
} }
+1 -2
View File
@@ -153,9 +153,8 @@ struct child_sa_t {
* not remove its policy, as the new SA uses it. * not remove its policy, as the new SA uses it.
* *
* @param this calling object * @param this calling object
* @param reqid reqid of the SA which replaces this one.
*/ */
void (*set_rekeyed) (child_sa_t *this, u_int32_t reqid); void (*set_rekeyed) (child_sa_t *this);
/** /**
* @brief Log the status of a child_sa to a logger. * @brief Log the status of a child_sa to a logger.
+3 -3
View File
@@ -940,7 +940,7 @@ static u_int32_t destroy_child_sa(private_ike_sa_t *this, u_int32_t spi)
while (iterator->has_next(iterator)) while (iterator->has_next(iterator))
{ {
iterator->current(iterator, (void**)&child_sa); iterator->current(iterator, (void**)&child_sa);
if (child_sa->get_spi(child_sa, TRUE) == spi) if (child_sa->get_spi(child_sa, FALSE) == spi)
{ {
iterator->remove(iterator); iterator->remove(iterator);
break; break;
@@ -958,7 +958,7 @@ static u_int32_t destroy_child_sa(private_ike_sa_t *this, u_int32_t spi)
return 0; return 0;
} }
spi = child_sa->get_spi(child_sa, FALSE); spi = child_sa->get_spi(child_sa, TRUE);
child_sa->destroy(child_sa); child_sa->destroy(child_sa);
return spi; return spi;
} }
@@ -975,7 +975,7 @@ static child_sa_t* get_child_sa_by_spi(private_ike_sa_t *this, u_int32_t spi)
while (iterator->has_next(iterator)) while (iterator->has_next(iterator))
{ {
iterator->current(iterator, (void**)&current); iterator->current(iterator, (void**)&current);
if (current->get_spi(current, TRUE) == spi) if (current->get_spi(current, FALSE) == spi)
{ {
found = current; found = current;
} }
@@ -385,7 +385,7 @@ static status_t process_message(private_create_child_sa_requested_t *this, messa
old_child_sa = this->ike_sa->public.get_child_sa(&this->ike_sa->public, this->reqid); old_child_sa = this->ike_sa->public.get_child_sa(&this->ike_sa->public, this->reqid);
if (old_child_sa) if (old_child_sa)
{ {
old_child_sa->set_rekeyed(old_child_sa, this->child_sa->get_reqid(this->child_sa)); old_child_sa->set_rekeyed(old_child_sa);
} }
this->ike_sa->public.delete_child_sa(&this->ike_sa->public, this->reqid); this->ike_sa->public.delete_child_sa(&this->ike_sa->public, this->reqid);
} }
+8 -2
View File
@@ -321,7 +321,13 @@ static status_t process_create_child_sa(private_ike_sa_established_t *this, mess
if (notify && notify->get_notify_message_type(notify) == REKEY_SA) if (notify && notify->get_notify_message_type(notify) == REKEY_SA)
{ {
this->old_child_sa = this->ike_sa->get_child_sa(this->ike_sa, notify->get_spi(notify)); u_int32_t spi = notify->get_spi(notify);
this->old_child_sa = this->ike_sa->get_child_sa(this->ike_sa, spi);
this->logger->log(this->logger, CONTROL, "Rekeying CHILD_SA with SPI 0x%x", spi);
}
else
{
this->logger->log(this->logger, CONTROL, "Create new CHILD_SA");
} }
/* build response */ /* build response */
@@ -382,7 +388,7 @@ static status_t process_create_child_sa(private_ike_sa_established_t *this, mess
} }
if (this->old_child_sa) if (this->old_child_sa)
{ /* mark old child sa as rekeyed */ { /* mark old child sa as rekeyed */
this->old_child_sa->set_rekeyed(this->old_child_sa, this->child_sa->get_reqid(this->child_sa)); this->old_child_sa->set_rekeyed(this->old_child_sa);
} }
this->ike_sa->add_child_sa(this->ike_sa, this->child_sa); this->ike_sa->add_child_sa(this->ike_sa, this->child_sa);
} }