bus: Change ike_update() signature and only call it once

This avoids multiple events when both addresses change (e.g. switching
address families).
This commit is contained in:
Tobias Brunner
2021-01-18 11:34:40 +01:00
parent 5ef10ec326
commit 08a3ee0cce
6 changed files with 43 additions and 50 deletions
+23 -12
View File
@@ -1116,7 +1116,8 @@ METHOD(ike_sa_t, float_ports, void,
METHOD(ike_sa_t, update_hosts, void,
private_ike_sa_t *this, host_t *me, host_t *other, bool force)
{
bool update = FALSE;
host_t *new_me = NULL, *new_other = NULL;
bool silent = FALSE;
if (me == NULL)
{
@@ -1131,18 +1132,16 @@ METHOD(ike_sa_t, update_hosts, void,
if (this->my_host->is_anyaddr(this->my_host) ||
this->other_host->is_anyaddr(this->other_host))
{
set_my_host(this, me->clone(me));
set_other_host(this, other->clone(other));
update = TRUE;
new_me = me;
new_other = other;
silent = TRUE;
}
else
{
/* update our address in any case */
if (force && !me->equals(me, this->my_host))
{
charon->bus->ike_update(charon->bus, &this->public, TRUE, me);
set_my_host(this, me->clone(me));
update = TRUE;
new_me = me;
}
if (!other->equals(other, this->other_host) &&
@@ -1154,20 +1153,32 @@ METHOD(ike_sa_t, update_hosts, void,
(!has_condition(this, COND_NAT_HERE) ||
!has_condition(this, COND_ORIGINAL_INITIATOR)))
{
charon->bus->ike_update(charon->bus, &this->public, FALSE, other);
set_other_host(this, other->clone(other));
update = TRUE;
new_other = other;
}
}
}
/* update all associated CHILD_SAs, if required */
if (update)
if (new_me || new_other)
{
enumerator_t *enumerator;
child_sa_t *child_sa;
linked_list_t *vips;
if (!silent)
{
charon->bus->ike_update(charon->bus, &this->public,
new_me ?: this->my_host,
new_other ?: this->other_host);
}
if (new_me)
{
set_my_host(this, new_me->clone(new_me));
}
if (new_other)
{
set_other_host(this, new_other->clone(new_other));
}
vips = linked_list_create_from_enumerator(
array_create_enumerator(this->my_vips));