return ike_sa;
}
+METHOD(ike_sa_manager_t, checkout_new, void,
+ private_ike_sa_manager_t *this, ike_sa_t *ike_sa)
+{
+ u_int segment;
+ entry_t *entry;
+
+ segment = create_and_put_entry(this, ike_sa, &entry);
+ entry->checked_out = thread_current();
+ unlock_single_segment(this, segment);
+}
+
/**
* Get the message ID or message hash to detect early retransmissions
*/
{ /* 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);
-
- segment = create_and_put_entry(this, ike_sa, &entry);
- entry->checked_out = thread_current();
- unlock_single_segment(this, segment);
+ checkout_new(this, ike_sa);
charon->bus->set_sa(charon->bus, ike_sa);
goto out;
}
{
ike_sa = create_new(this, peer_cfg->get_ike_version(peer_cfg), TRUE);
ike_sa->set_peer_cfg(ike_sa, peer_cfg);
-
- segment = create_and_put_entry(this, ike_sa, &entry);
- entry->checked_out = thread_current();
- unlock_single_segment(this, segment);
+ checkout_new(this, ike_sa);
}
charon->bus->set_sa(charon->bus, ike_sa);
INIT(this,
.public = {
.create_new = _create_new,
+ .checkout_new = _checkout_new,
.checkout = _checkout,
.checkout_by_message = _checkout_by_message,
.checkout_by_config = _checkout_by_config,
bool initiator);
/**
+ * Register/checkout an IKE_SA created with create_new().
+ *
+ * This may be used shortly before calling checkin() for unregistered SAs
+ * created via create_new() to avoid race conditions so e.g. jobs may
+ * find the SA and block on it until checkin() is called.
+ *
+ * @note There is no check that verifies that the IKE_SA is not yet
+ * registered.
+ *
+ * @note The IKE_SA on the bus is not changed by this method.
+ *
+ * @param ike_sa IKE_SA to register
+ */
+ void (*checkout_new)(ike_sa_manager_t* this, ike_sa_t *ike_sa);
+
+ /**
* Checkout an existing IKE_SA.
*
* @param ike_sa_id the SA identifier, will be updated