ike: Don't trigger message hook when fragmenting pre-generated messages
This is the case for the IKE_SA_INIT and the initial IKEv1 messages, which are pre-generated in tasks as at least parts of it are used to generate the AUTH payload. The IKE_SA_INIT message will never be fragmented, but the IKEv1 messages might be, so we can't just call generate_message(). Fixes #1478.
This commit is contained in:
@@ -1203,6 +1203,7 @@ METHOD(ike_sa_t, generate_message_fragmented, status_t,
|
|||||||
packet_t *packet;
|
packet_t *packet;
|
||||||
status_t status;
|
status_t status;
|
||||||
bool use_frags = FALSE;
|
bool use_frags = FALSE;
|
||||||
|
bool pre_generated = FALSE;
|
||||||
|
|
||||||
if (this->ike_cfg)
|
if (this->ike_cfg)
|
||||||
{
|
{
|
||||||
@@ -1237,14 +1238,21 @@ METHOD(ike_sa_t, generate_message_fragmented, status_t,
|
|||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pre_generated = message->is_encoded(message);
|
||||||
this->stats[STAT_OUTBOUND] = time_monotonic(NULL);
|
this->stats[STAT_OUTBOUND] = time_monotonic(NULL);
|
||||||
message->set_ike_sa_id(message, this->ike_sa_id);
|
message->set_ike_sa_id(message, this->ike_sa_id);
|
||||||
charon->bus->message(charon->bus, message, FALSE, TRUE);
|
if (!pre_generated)
|
||||||
|
{
|
||||||
|
charon->bus->message(charon->bus, message, FALSE, TRUE);
|
||||||
|
}
|
||||||
status = message->fragment(message, this->keymat, this->fragment_size,
|
status = message->fragment(message, this->keymat, this->fragment_size,
|
||||||
&fragments);
|
&fragments);
|
||||||
if (status == SUCCESS)
|
if (status == SUCCESS)
|
||||||
{
|
{
|
||||||
charon->bus->message(charon->bus, message, FALSE, FALSE);
|
if (!pre_generated)
|
||||||
|
{
|
||||||
|
charon->bus->message(charon->bus, message, FALSE, FALSE);
|
||||||
|
}
|
||||||
*packets = enumerator_create_filter(fragments, (void*)filter_fragments,
|
*packets = enumerator_create_filter(fragments, (void*)filter_fragments,
|
||||||
this, NULL);
|
this, NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user