kernel-interface: Raise expires with a proto/SPI/dst tuple instead of reqid
This commit is contained in:
@@ -815,17 +815,18 @@ METHOD(kernel_interface_t, acquire, void,
|
||||
}
|
||||
|
||||
METHOD(kernel_interface_t, expire, void,
|
||||
private_kernel_interface_t *this, u_int32_t reqid, u_int8_t protocol,
|
||||
u_int32_t spi, bool hard)
|
||||
private_kernel_interface_t *this, u_int8_t protocol, u_int32_t spi,
|
||||
host_t *dst, bool hard)
|
||||
{
|
||||
kernel_listener_t *listener;
|
||||
enumerator_t *enumerator;
|
||||
|
||||
this->mutex->lock(this->mutex);
|
||||
enumerator = this->listeners->create_enumerator(this->listeners);
|
||||
while (enumerator->enumerate(enumerator, &listener))
|
||||
{
|
||||
if (listener->expire &&
|
||||
!listener->expire(listener, reqid, protocol, spi, hard))
|
||||
!listener->expire(listener, protocol, spi, dst, hard))
|
||||
{
|
||||
this->listeners->remove_at(this->listeners, enumerator);
|
||||
}
|
||||
|
||||
@@ -559,13 +559,13 @@ struct kernel_interface_t {
|
||||
/**
|
||||
* Raise an expire event.
|
||||
*
|
||||
* @param reqid reqid of the expired SA
|
||||
* @param protocol protocol of the expired SA
|
||||
* @param spi spi of the expired SA
|
||||
* @param dst destination address of expired SA
|
||||
* @param hard TRUE if it is a hard expire, FALSE otherwise
|
||||
*/
|
||||
void (*expire)(kernel_interface_t *this, u_int32_t reqid,
|
||||
u_int8_t protocol, u_int32_t spi, bool hard);
|
||||
void (*expire)(kernel_interface_t *this, u_int8_t protocol, u_int32_t spi,
|
||||
host_t *dst, bool hard);
|
||||
|
||||
/**
|
||||
* Raise a mapping event.
|
||||
|
||||
@@ -49,14 +49,14 @@ struct kernel_listener_t {
|
||||
/**
|
||||
* Hook called if an exire event for an IPsec SA is received.
|
||||
*
|
||||
* @param reqid reqid of the expired SA
|
||||
* @param protocol protocol of the expired SA
|
||||
* @param spi spi of the expired SA
|
||||
* @param dst destination address of expired SA
|
||||
* @param hard TRUE if it is a hard expire, FALSE otherwise
|
||||
* @return TRUE to remain registered, FALSE to unregister
|
||||
*/
|
||||
bool (*expire)(kernel_listener_t *this, u_int32_t reqid,
|
||||
u_int8_t protocol, u_int32_t spi, bool hard);
|
||||
bool (*expire)(kernel_listener_t *this, u_int8_t protocol, u_int32_t spi,
|
||||
host_t *dst, bool hard);
|
||||
|
||||
/**
|
||||
* Hook called if the NAT mappings of an IPsec SA changed.
|
||||
|
||||
@@ -870,25 +870,26 @@ static void process_expire(private_kernel_netlink_ipsec_t *this,
|
||||
struct nlmsghdr *hdr)
|
||||
{
|
||||
struct xfrm_user_expire *expire;
|
||||
u_int32_t spi, reqid;
|
||||
u_int32_t spi;
|
||||
u_int8_t protocol;
|
||||
host_t *dst;
|
||||
|
||||
expire = NLMSG_DATA(hdr);
|
||||
protocol = expire->state.id.proto;
|
||||
spi = expire->state.id.spi;
|
||||
reqid = expire->state.reqid;
|
||||
|
||||
DBG2(DBG_KNL, "received a XFRM_MSG_EXPIRE");
|
||||
|
||||
if (protocol != IPPROTO_ESP && protocol != IPPROTO_AH)
|
||||
if (protocol == IPPROTO_ESP || protocol == IPPROTO_AH)
|
||||
{
|
||||
DBG2(DBG_KNL, "ignoring XFRM_MSG_EXPIRE for SA with SPI %.8x and "
|
||||
"reqid {%u} which is not a CHILD_SA", ntohl(spi), reqid);
|
||||
return;
|
||||
dst = xfrm2host(expire->state.family, &expire->state.id.daddr, 0);
|
||||
if (dst)
|
||||
{
|
||||
hydra->kernel_interface->expire(hydra->kernel_interface, protocol,
|
||||
spi, dst, expire->hard != 0);
|
||||
dst->destroy(dst);
|
||||
}
|
||||
}
|
||||
|
||||
hydra->kernel_interface->expire(hydra->kernel_interface, reqid, protocol,
|
||||
spi, expire->hard != 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1296,7 +1296,8 @@ static void process_expire(private_kernel_pfkey_ipsec_t *this,
|
||||
{
|
||||
pfkey_msg_t response;
|
||||
u_int8_t protocol;
|
||||
u_int32_t spi, reqid;
|
||||
u_int32_t spi;
|
||||
host_t *dst;
|
||||
bool hard;
|
||||
|
||||
DBG2(DBG_KNL, "received an SADB_EXPIRE");
|
||||
@@ -1309,18 +1310,18 @@ static void process_expire(private_kernel_pfkey_ipsec_t *this,
|
||||
|
||||
protocol = satype2proto(msg->sadb_msg_satype);
|
||||
spi = response.sa->sadb_sa_spi;
|
||||
reqid = response.x_sa2->sadb_x_sa2_reqid;
|
||||
hard = response.lft_hard != NULL;
|
||||
|
||||
if (protocol != IPPROTO_ESP && protocol != IPPROTO_AH)
|
||||
if (protocol == IPPROTO_ESP || protocol == IPPROTO_AH)
|
||||
{
|
||||
DBG2(DBG_KNL, "ignoring SADB_EXPIRE for SA with SPI %.8x and "
|
||||
"reqid {%u} which is not a CHILD_SA", ntohl(spi), reqid);
|
||||
return;
|
||||
dst = host_create_from_sockaddr((sockaddr_t*)(response.dst + 1));
|
||||
if (dst)
|
||||
{
|
||||
hydra->kernel_interface->expire(hydra->kernel_interface, protocol,
|
||||
spi, dst, hard);
|
||||
dst->destroy(dst);
|
||||
}
|
||||
}
|
||||
|
||||
hydra->kernel_interface->expire(hydra->kernel_interface, reqid, protocol,
|
||||
spi, hard);
|
||||
}
|
||||
|
||||
#ifdef SADB_X_MIGRATE
|
||||
|
||||
Reference in New Issue
Block a user