Simplified destruction of policy_sa_t objects in Netlink interface.
This commit is contained in:
parent
0c2ce1905a
commit
4e9e4372f5
|
@ -491,10 +491,10 @@ static policy_sa_t *policy_sa_create(private_kernel_netlink_ipsec_t *this,
|
||||||
/**
|
/**
|
||||||
* Destroy a policy_sa(_fwd)_t object
|
* Destroy a policy_sa(_fwd)_t object
|
||||||
*/
|
*/
|
||||||
static void policy_sa_destroy(private_kernel_netlink_ipsec_t *this,
|
static void policy_sa_destroy(policy_sa_t *policy, policy_dir_t *dir,
|
||||||
policy_dir_t dir, policy_sa_t *policy)
|
private_kernel_netlink_ipsec_t *this)
|
||||||
{
|
{
|
||||||
if (dir == POLICY_FWD)
|
if (*dir == POLICY_FWD)
|
||||||
{
|
{
|
||||||
policy_sa_fwd_t *fwd = (policy_sa_fwd_t*)policy;
|
policy_sa_fwd_t *fwd = (policy_sa_fwd_t*)policy;
|
||||||
fwd->src_ts->destroy(fwd->src_ts);
|
fwd->src_ts->destroy(fwd->src_ts);
|
||||||
|
@ -539,14 +539,9 @@ static void policy_entry_destroy(private_kernel_netlink_ipsec_t *this,
|
||||||
}
|
}
|
||||||
if (policy->used_by)
|
if (policy->used_by)
|
||||||
{
|
{
|
||||||
enumerator_t *enumerator;
|
policy->used_by->invoke_function(policy->used_by,
|
||||||
policy_sa_t *sa;
|
(linked_list_invoke_t)policy_sa_destroy,
|
||||||
enumerator = policy->used_by->create_enumerator(policy->used_by);
|
&policy->direction, this);
|
||||||
while (enumerator->enumerate(enumerator, (void**)&sa))
|
|
||||||
{
|
|
||||||
policy_sa_destroy(this, policy->direction, sa);
|
|
||||||
}
|
|
||||||
enumerator->destroy(enumerator);
|
|
||||||
policy->used_by->destroy(policy->used_by);
|
policy->used_by->destroy(policy->used_by);
|
||||||
}
|
}
|
||||||
free(policy);
|
free(policy);
|
||||||
|
@ -2411,7 +2406,7 @@ METHOD(kernel_ipsec_t, del_policy, status_t,
|
||||||
if (reqid == mapping->sa->cfg.reqid)
|
if (reqid == mapping->sa->cfg.reqid)
|
||||||
{
|
{
|
||||||
current->used_by->remove_at(current->used_by, enumerator);
|
current->used_by->remove_at(current->used_by, enumerator);
|
||||||
policy_sa_destroy(this, direction, mapping);
|
policy_sa_destroy(mapping, &direction, this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
is_installed = FALSE;
|
is_installed = FALSE;
|
||||||
|
|
Loading…
Reference in New Issue