ike: Treat action_t as flags so 'start' and 'trap' can be combined
While combining the actions could cause duplicates (while the SA is initiated, traffic might trigger the trap and the initiation of another CHILD_SA), the previous commit should avoid most duplicates. If reuse_ikesa is disabled, duplicates can't be prevented, though.
This commit is contained in:
@@ -2060,7 +2060,7 @@ static status_t reestablish_children(private_ike_sa_t *this, ike_sa_t *new,
|
||||
}
|
||||
if (force)
|
||||
{
|
||||
action = ACTION_RESTART;
|
||||
action = ACTION_START;
|
||||
}
|
||||
else
|
||||
{ /* only restart CHILD_SAs that are configured accordingly */
|
||||
@@ -2073,7 +2073,7 @@ static status_t reestablish_children(private_ike_sa_t *this, ike_sa_t *new,
|
||||
action = child_sa->get_dpd_action(child_sa);
|
||||
}
|
||||
}
|
||||
if (action == ACTION_RESTART)
|
||||
if (action & ACTION_START)
|
||||
{
|
||||
child_init_args_t args = {
|
||||
.reqid = child_sa->get_reqid(child_sa),
|
||||
@@ -2150,17 +2150,14 @@ METHOD(ike_sa_t, reestablish, status_t,
|
||||
{
|
||||
action = child_sa->get_dpd_action(child_sa);
|
||||
}
|
||||
switch (action)
|
||||
if (action & ACTION_TRAP)
|
||||
{
|
||||
case ACTION_RESTART:
|
||||
restart = TRUE;
|
||||
break;
|
||||
case ACTION_ROUTE:
|
||||
charon->traps->install(charon->traps, this->peer_cfg,
|
||||
child_sa->get_config(child_sa));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
charon->traps->install(charon->traps, this->peer_cfg,
|
||||
child_sa->get_config(child_sa));
|
||||
}
|
||||
if (action & ACTION_START)
|
||||
{
|
||||
restart = TRUE;
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
@@ -152,23 +152,21 @@ static status_t delete_child(private_quick_delete_t *this,
|
||||
child_init_args_t args = {
|
||||
.reqid = child_sa->get_reqid(child_sa),
|
||||
};
|
||||
action_t action;
|
||||
|
||||
action = child_sa->get_close_action(child_sa);
|
||||
child_cfg = child_sa->get_config(child_sa);
|
||||
child_cfg->get_ref(child_cfg);
|
||||
|
||||
switch (child_sa->get_close_action(child_sa))
|
||||
if (action & ACTION_TRAP)
|
||||
{
|
||||
case ACTION_RESTART:
|
||||
child_cfg->get_ref(child_cfg);
|
||||
status = this->ike_sa->initiate(this->ike_sa, child_cfg,
|
||||
&args);
|
||||
break;
|
||||
case ACTION_ROUTE:
|
||||
charon->traps->install(charon->traps,
|
||||
this->ike_sa->get_peer_cfg(this->ike_sa),
|
||||
child_cfg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
charon->traps->install(charon->traps,
|
||||
this->ike_sa->get_peer_cfg(this->ike_sa),
|
||||
child_cfg);
|
||||
}
|
||||
if (action & ACTION_START)
|
||||
{
|
||||
child_cfg->get_ref(child_cfg);
|
||||
status = this->ike_sa->initiate(this->ike_sa, child_cfg, &args);
|
||||
}
|
||||
child_cfg->destroy(child_cfg);
|
||||
}
|
||||
|
||||
@@ -372,20 +372,16 @@ static status_t destroy_and_reestablish(private_child_delete_t *this)
|
||||
|
||||
if (entry->check_delete_action)
|
||||
{ /* enforce child_cfg policy if deleted passively */
|
||||
switch (action)
|
||||
if (action & ACTION_TRAP)
|
||||
{
|
||||
case ACTION_RESTART:
|
||||
child_cfg->get_ref(child_cfg);
|
||||
status = this->ike_sa->initiate(this->ike_sa, child_cfg,
|
||||
&args);
|
||||
break;
|
||||
case ACTION_ROUTE:
|
||||
charon->traps->install(charon->traps,
|
||||
this->ike_sa->get_peer_cfg(this->ike_sa),
|
||||
child_cfg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
charon->traps->install(charon->traps,
|
||||
this->ike_sa->get_peer_cfg(this->ike_sa),
|
||||
child_cfg);
|
||||
}
|
||||
if (action & ACTION_START)
|
||||
{
|
||||
child_cfg->get_ref(child_cfg);
|
||||
status = this->ike_sa->initiate(this->ike_sa, child_cfg, &args);
|
||||
}
|
||||
}
|
||||
child_cfg->destroy(child_cfg);
|
||||
|
||||
Reference in New Issue
Block a user