trap-manager: Uninstall trap policies by name and not reqid
If a trap policy is concurrently uninstalled and reinstalled under a different name the reqid will be the same so the wrong trap might be removed.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) 2011-2015 Tobias Brunner
|
||||
* Copyright (C) 2011-2017 Tobias Brunner
|
||||
* Copyright (C) 2009 Martin Willi
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
* HSR Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
@@ -347,7 +347,7 @@ METHOD(trap_manager_t, install, uint32_t,
|
||||
}
|
||||
|
||||
METHOD(trap_manager_t, uninstall, bool,
|
||||
private_trap_manager_t *this, uint32_t reqid)
|
||||
private_trap_manager_t *this, char *peer, char *child)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
entry_t *entry, *found = NULL;
|
||||
@@ -356,8 +356,8 @@ METHOD(trap_manager_t, uninstall, bool,
|
||||
enumerator = this->traps->create_enumerator(this->traps);
|
||||
while (enumerator->enumerate(enumerator, &entry))
|
||||
{
|
||||
if (entry->child_sa &&
|
||||
entry->child_sa->get_reqid(entry->child_sa) == reqid)
|
||||
if (streq(entry->name, child) &&
|
||||
(!peer || streq(peer, entry->peer_cfg->get_name(entry->peer_cfg))))
|
||||
{
|
||||
this->traps->remove_at(this->traps, enumerator);
|
||||
found = entry;
|
||||
@@ -369,7 +369,6 @@ METHOD(trap_manager_t, uninstall, bool,
|
||||
|
||||
if (!found)
|
||||
{
|
||||
DBG1(DBG_CFG, "trap %d not found to uninstall", reqid);
|
||||
return FALSE;
|
||||
}
|
||||
destroy_entry(found);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) 2013-2017 Tobias Brunner
|
||||
* Copyright (C) 2009 Martin Willi
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
* HSR Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
@@ -46,10 +47,14 @@ struct trap_manager_t {
|
||||
/**
|
||||
* Uninstall a trap policy.
|
||||
*
|
||||
* @param id reqid of CHILD_SA to uninstall, returned by install()
|
||||
* If no peer configuration name is given the first matching child
|
||||
* configuration is uninstalled.
|
||||
*
|
||||
* @param peer peer configuration name or NULL
|
||||
* @param child child configuration name
|
||||
* @return TRUE if uninstalled successfully
|
||||
*/
|
||||
bool (*uninstall)(trap_manager_t *this, uint32_t reqid);
|
||||
bool (*uninstall)(trap_manager_t *this, char *peer, char *child);
|
||||
|
||||
/**
|
||||
* Create an enumerator over all installed traps.
|
||||
|
||||
Reference in New Issue
Block a user