trap-manager: Remove reqid parameter from install() and change return type
Reqids for the same traffic selectors are now stable so we don't have to pass reqids of previously installed CHILD_SAs. Likewise, we don't need to know the reqid of the newly installed trap policy as we now uninstall by name.
This commit is contained in:
@@ -262,7 +262,7 @@ static void setup_tunnel(private_ha_tunnel_t *this,
|
||||
charon->backends->add_backend(charon->backends, &this->backend.public);
|
||||
|
||||
/* install an acquiring trap */
|
||||
this->trap = charon->traps->install(charon->traps, peer_cfg, child_cfg, 0);
|
||||
charon->traps->install(charon->traps, peer_cfg, child_cfg);
|
||||
}
|
||||
|
||||
METHOD(ha_tunnel_t, destroy, void,
|
||||
@@ -280,10 +280,7 @@ METHOD(ha_tunnel_t, destroy, void,
|
||||
}
|
||||
this->creds.local->destroy(this->creds.local);
|
||||
this->creds.remote->destroy(this->creds.remote);
|
||||
if (this->trap)
|
||||
{
|
||||
charon->traps->uninstall(charon->traps, HA_CFG_NAME, HA_CFG_NAME);
|
||||
}
|
||||
charon->traps->uninstall(charon->traps, HA_CFG_NAME, HA_CFG_NAME);
|
||||
free(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -588,47 +588,6 @@ METHOD(stroke_control_t, purge_ike, void,
|
||||
list->destroy(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an existing CHILD_SA/reqid
|
||||
*/
|
||||
static uint32_t find_reqid(child_cfg_t *child_cfg)
|
||||
{
|
||||
enumerator_t *enumerator, *children;
|
||||
child_sa_t *child_sa;
|
||||
ike_sa_t *ike_sa;
|
||||
char *name;
|
||||
uint32_t reqid;
|
||||
|
||||
reqid = charon->traps->find_reqid(charon->traps, child_cfg);
|
||||
if (reqid)
|
||||
{ /* already trapped */
|
||||
return reqid;
|
||||
}
|
||||
|
||||
name = child_cfg->get_name(child_cfg);
|
||||
enumerator = charon->controller->create_ike_sa_enumerator(
|
||||
charon->controller, TRUE);
|
||||
while (enumerator->enumerate(enumerator, &ike_sa))
|
||||
{
|
||||
children = ike_sa->create_child_sa_enumerator(ike_sa);
|
||||
while (children->enumerate(children, (void**)&child_sa))
|
||||
{
|
||||
if (streq(name, child_sa->get_name(child_sa)))
|
||||
{
|
||||
reqid = child_sa->get_reqid(child_sa);
|
||||
break;
|
||||
}
|
||||
}
|
||||
children->destroy(children);
|
||||
if (reqid)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
return reqid;
|
||||
}
|
||||
|
||||
/**
|
||||
* call charon to install a shunt or trap
|
||||
*/
|
||||
@@ -636,7 +595,6 @@ static void charon_route(peer_cfg_t *peer_cfg, child_cfg_t *child_cfg,
|
||||
char *name, FILE *out)
|
||||
{
|
||||
ipsec_mode_t mode;
|
||||
uint32_t reqid;
|
||||
|
||||
mode = child_cfg->get_mode(child_cfg);
|
||||
if (mode == MODE_PASS || mode == MODE_DROP)
|
||||
@@ -655,8 +613,7 @@ static void charon_route(peer_cfg_t *peer_cfg, child_cfg_t *child_cfg,
|
||||
}
|
||||
else
|
||||
{
|
||||
reqid = find_reqid(child_cfg);
|
||||
if (charon->traps->install(charon->traps, peer_cfg, child_cfg, reqid))
|
||||
if (charon->traps->install(charon->traps, peer_cfg, child_cfg))
|
||||
{
|
||||
fprintf(out, "'%s' routed\n", name);
|
||||
}
|
||||
|
||||
@@ -1953,41 +1953,6 @@ CALLBACK(peer_sn, bool,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find reqid of an existing CHILD_SA
|
||||
*/
|
||||
static uint32_t find_reqid(child_cfg_t *cfg)
|
||||
{
|
||||
enumerator_t *enumerator, *children;
|
||||
child_sa_t *child_sa;
|
||||
ike_sa_t *ike_sa;
|
||||
uint32_t reqid;
|
||||
|
||||
reqid = charon->traps->find_reqid(charon->traps, cfg);
|
||||
if (reqid)
|
||||
{ /* already trapped */
|
||||
return reqid;
|
||||
}
|
||||
|
||||
enumerator = charon->controller->create_ike_sa_enumerator(
|
||||
charon->controller, TRUE);
|
||||
while (!reqid && enumerator->enumerate(enumerator, &ike_sa))
|
||||
{
|
||||
children = ike_sa->create_child_sa_enumerator(ike_sa);
|
||||
while (children->enumerate(children, &child_sa))
|
||||
{
|
||||
if (streq(cfg->get_name(cfg), child_sa->get_name(child_sa)))
|
||||
{
|
||||
reqid = child_sa->get_reqid(child_sa);
|
||||
break;
|
||||
}
|
||||
}
|
||||
children->destroy(children);
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
return reqid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform start actions associated with a child config
|
||||
*/
|
||||
@@ -2012,8 +1977,7 @@ static void run_start_action(private_vici_config_t *this, peer_cfg_t *peer_cfg,
|
||||
peer_cfg->get_name(peer_cfg), child_cfg);
|
||||
break;
|
||||
default:
|
||||
charon->traps->install(charon->traps, peer_cfg, child_cfg,
|
||||
find_reqid(child_cfg));
|
||||
charon->traps->install(charon->traps, peer_cfg, child_cfg);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -601,41 +601,6 @@ CALLBACK(redirect, vici_message_t*,
|
||||
return builder->finalize(builder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find reqid of an existing CHILD_SA
|
||||
*/
|
||||
static uint32_t find_reqid(child_cfg_t *cfg)
|
||||
{
|
||||
enumerator_t *enumerator, *children;
|
||||
child_sa_t *child_sa;
|
||||
ike_sa_t *ike_sa;
|
||||
uint32_t reqid;
|
||||
|
||||
reqid = charon->traps->find_reqid(charon->traps, cfg);
|
||||
if (reqid)
|
||||
{ /* already trapped */
|
||||
return reqid;
|
||||
}
|
||||
|
||||
enumerator = charon->controller->create_ike_sa_enumerator(
|
||||
charon->controller, TRUE);
|
||||
while (!reqid && enumerator->enumerate(enumerator, &ike_sa))
|
||||
{
|
||||
children = ike_sa->create_child_sa_enumerator(ike_sa);
|
||||
while (children->enumerate(children, &child_sa))
|
||||
{
|
||||
if (streq(cfg->get_name(cfg), child_sa->get_name(child_sa)))
|
||||
{
|
||||
reqid = child_sa->get_reqid(child_sa);
|
||||
break;
|
||||
}
|
||||
}
|
||||
children->destroy(children);
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
return reqid;
|
||||
}
|
||||
|
||||
CALLBACK(install, vici_message_t*,
|
||||
private_vici_control_t *this, char *name, u_int id, vici_message_t *request)
|
||||
{
|
||||
@@ -666,8 +631,7 @@ CALLBACK(install, vici_message_t*,
|
||||
peer_cfg->get_name(peer_cfg), child_cfg);
|
||||
break;
|
||||
default:
|
||||
ok = charon->traps->install(charon->traps, peer_cfg, child_cfg,
|
||||
find_reqid(child_cfg));
|
||||
ok = charon->traps->install(charon->traps, peer_cfg, child_cfg);
|
||||
break;
|
||||
}
|
||||
peer_cfg->destroy(peer_cfg);
|
||||
|
||||
Reference in New Issue
Block a user