kernel-interface: Raise expires with a proto/SPI/dst tuple instead of reqid

This commit is contained in:
Martin Willi
2015-02-20 13:34:50 +01:00
parent 971a91685d
commit f81a949748
20 changed files with 124 additions and 118 deletions
@@ -30,11 +30,6 @@ struct private_delete_child_sa_job_t {
*/
delete_child_sa_job_t public;
/**
* reqid of the CHILD_SA
*/
u_int32_t reqid;
/**
* protocol of the CHILD_SA (ESP/AH)
*/
@@ -45,6 +40,11 @@ struct private_delete_child_sa_job_t {
*/
u_int32_t spi;
/**
* SA destination address
*/
host_t *dst;
/**
* Delete for an expired CHILD_SA
*/
@@ -54,6 +54,7 @@ struct private_delete_child_sa_job_t {
METHOD(job_t, destroy, void,
private_delete_child_sa_job_t *this)
{
this->dst->destroy(this->dst);
free(this);
}
@@ -62,12 +63,12 @@ METHOD(job_t, execute, job_requeue_t,
{
ike_sa_t *ike_sa;
ike_sa = charon->ike_sa_manager->checkout_by_id(charon->ike_sa_manager,
this->reqid, TRUE);
ike_sa = charon->child_sa_manager->checkout(charon->child_sa_manager,
this->protocol, this->spi, this->dst, NULL);
if (ike_sa == NULL)
{
DBG1(DBG_JOB, "CHILD_SA with reqid %d not found for delete",
this->reqid);
DBG1(DBG_JOB, "CHILD_SA %N/0x%08x/%H not found for delete",
protocol_id_names, this->protocol, htonl(this->spi), this->dst);
}
else
{
@@ -87,8 +88,8 @@ METHOD(job_t, get_priority, job_priority_t,
/*
* Described in header
*/
delete_child_sa_job_t *delete_child_sa_job_create(u_int32_t reqid,
protocol_id_t protocol, u_int32_t spi, bool expired)
delete_child_sa_job_t *delete_child_sa_job_create(protocol_id_t protocol,
u_int32_t spi, host_t *dst, bool expired)
{
private_delete_child_sa_job_t *this;
@@ -100,12 +101,11 @@ delete_child_sa_job_t *delete_child_sa_job_create(u_int32_t reqid,
.destroy = _destroy,
},
},
.reqid = reqid,
.protocol = protocol,
.spi = spi,
.dst = dst->clone(dst),
.expired = expired,
);
return &this->public;
}
@@ -44,16 +44,13 @@ struct delete_child_sa_job_t {
/**
* Creates a job of type DELETE_CHILD_SA.
*
* The CHILD_SA is identified by its reqid, protocol (AH/ESP) and its
* inbound SPI.
*
* @param reqid reqid of the CHILD_SA, as used in kernel
* @param protocol protocol of the CHILD_SA
* @param spi security parameter index of the CHILD_SA
* @param dst SA destination address
* @param expired TRUE if CHILD_SA already expired
* @return delete_child_sa_job_t object
*/
delete_child_sa_job_t *delete_child_sa_job_create(u_int32_t reqid,
protocol_id_t protocol, u_int32_t spi, bool expired);
delete_child_sa_job_t *delete_child_sa_job_create(protocol_id_t protocol,
u_int32_t spi, host_t *dst, bool expired);
#endif /** DELETE_CHILD_SA_JOB_H_ @}*/
@@ -24,16 +24,12 @@ typedef struct private_rekey_child_sa_job_t private_rekey_child_sa_job_t;
* Private data of an rekey_child_sa_job_t object.
*/
struct private_rekey_child_sa_job_t {
/**
* Public rekey_child_sa_job_t interface.
*/
rekey_child_sa_job_t public;
/**
* reqid of the child to rekey
*/
u_int32_t reqid;
/**
* protocol of the CHILD_SA (ESP/AH)
*/
@@ -43,11 +39,17 @@ struct private_rekey_child_sa_job_t {
* inbound SPI of the CHILD_SA
*/
u_int32_t spi;
/**
* SA destination address
*/
host_t *dst;
};
METHOD(job_t, destroy, void,
private_rekey_child_sa_job_t *this)
{
this->dst->destroy(this->dst);
free(this);
}
@@ -56,12 +58,12 @@ METHOD(job_t, execute, job_requeue_t,
{
ike_sa_t *ike_sa;
ike_sa = charon->ike_sa_manager->checkout_by_id(charon->ike_sa_manager,
this->reqid, TRUE);
ike_sa = charon->child_sa_manager->checkout(charon->child_sa_manager,
this->protocol, this->spi, this->dst, NULL);
if (ike_sa == NULL)
{
DBG2(DBG_JOB, "CHILD_SA with reqid %d not found for rekeying",
this->reqid);
DBG1(DBG_JOB, "CHILD_SA %N/0x%08x/%H not found for rekey",
protocol_id_names, this->protocol, htonl(this->spi), this->dst);
}
else
{
@@ -80,9 +82,8 @@ METHOD(job_t, get_priority, job_priority_t,
/*
* Described in header
*/
rekey_child_sa_job_t *rekey_child_sa_job_create(u_int32_t reqid,
protocol_id_t protocol,
u_int32_t spi)
rekey_child_sa_job_t *rekey_child_sa_job_create(protocol_id_t protocol,
u_int32_t spi, host_t *dst)
{
private_rekey_child_sa_job_t *this;
@@ -94,9 +95,9 @@ rekey_child_sa_job_t *rekey_child_sa_job_create(u_int32_t reqid,
.destroy = _destroy,
},
},
.reqid = reqid,
.protocol = protocol,
.spi = spi,
.dst = dst->clone(dst),
);
return &this->public;
@@ -43,15 +43,11 @@ struct rekey_child_sa_job_t {
/**
* Creates a job of type REKEY_CHILD_SA.
*
* The CHILD_SA is identified by its protocol (AH/ESP) and its
* inbound SPI.
*
* @param reqid reqid of the CHILD_SA to rekey
* @param protocol protocol of the CHILD_SA
* @param spi security parameter index of the CHILD_SA
* @param dst SA destination address
* @return rekey_child_sa_job_t object
*/
rekey_child_sa_job_t *rekey_child_sa_job_create(u_int32_t reqid,
protocol_id_t protocol,
u_int32_t spi);
rekey_child_sa_job_t *rekey_child_sa_job_create(protocol_id_t protocol,
u_int32_t spi, host_t *dst);
#endif /** REKEY_CHILD_SA_JOB_H_ @}*/