ike-sa-manager: Ensure we were able to create a new IKE_SA

This may happen if we are unable to allocate an SPI.
This commit is contained in:
Tobias Brunner 2021-02-16 14:43:52 +01:00
parent cb85967655
commit f4258c56f5
1 changed files with 10 additions and 4 deletions

View File

@ -1501,8 +1501,11 @@ METHOD(ike_sa_manager_t, checkout_by_config, ike_sa_t*,
if (!this->reuse_ikesa && peer_cfg->get_ike_version(peer_cfg) != IKEV1)
{ /* IKE_SA reuse disabled by config (not possible for IKEv1) */
ike_sa = create_new(this, peer_cfg->get_ike_version(peer_cfg), TRUE);
ike_sa->set_peer_cfg(ike_sa, peer_cfg);
checkout_new(this, ike_sa);
if (ike_sa)
{
ike_sa->set_peer_cfg(ike_sa, peer_cfg);
checkout_new(this, ike_sa);
}
charon->bus->set_sa(charon->bus, ike_sa);
goto out;
}
@ -1573,8 +1576,11 @@ METHOD(ike_sa_manager_t, checkout_by_config, ike_sa_t*,
if (!ike_sa)
{
ike_sa = create_new(this, peer_cfg->get_ike_version(peer_cfg), TRUE);
ike_sa->set_peer_cfg(ike_sa, peer_cfg);
checkout_new(this, ike_sa);
if (ike_sa)
{
ike_sa->set_peer_cfg(ike_sa, peer_cfg);
checkout_new(this, ike_sa);
}
}
charon->bus->set_sa(charon->bus, ike_sa);