controller: Add parameter for maximum log level to initiate/terminate_*()
Previously, the logger installed by the controller always announced LEVEL_PRIVATE(4), which produced completely useless logging calls with the common clients (vici/stroke) whose default log level is LEVEL_CTRL(1). This can produce quite some overhead if there are e.g. a lot of concurrent initiate() calls.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2011-2019 Tobias Brunner
|
||||
* Copyright (C) 2011-2023 Tobias Brunner
|
||||
* Copyright (C) 2007-2011 Martin Willi
|
||||
*
|
||||
* Copyright (C) secunet Security Networks AG
|
||||
@@ -56,6 +56,11 @@ struct interface_logger_t {
|
||||
*/
|
||||
interface_listener_t *listener;
|
||||
|
||||
/**
|
||||
* Maximum log level to pass to callback
|
||||
*/
|
||||
level_t max_level;
|
||||
|
||||
/**
|
||||
* interface callback (listener gets redirected to here)
|
||||
*/
|
||||
@@ -241,9 +246,7 @@ METHOD(logger_t, listener_log, void,
|
||||
METHOD(logger_t, listener_get_level, level_t,
|
||||
interface_logger_t *this, debug_t group)
|
||||
{
|
||||
/* in order to allow callback listeners to decide what they want to log
|
||||
* we request any log message, but only if we actually want logging */
|
||||
return this->callback == controller_cb_empty ? LEVEL_SILENT : LEVEL_PRIVATE;
|
||||
return this->max_level;
|
||||
}
|
||||
|
||||
METHOD(job_t, get_priority_medium, job_priority_t,
|
||||
@@ -496,7 +499,8 @@ METHOD(job_t, initiate_execute, job_requeue_t,
|
||||
|
||||
METHOD(controller_t, initiate, status_t,
|
||||
private_controller_t *this, peer_cfg_t *peer_cfg, child_cfg_t *child_cfg,
|
||||
controller_cb_t callback, void *param, u_int timeout, bool limits)
|
||||
controller_cb_t callback, void *param, level_t max_level, u_int timeout,
|
||||
bool limits)
|
||||
{
|
||||
interface_job_t *job;
|
||||
status_t status;
|
||||
@@ -512,6 +516,7 @@ METHOD(controller_t, initiate, status_t,
|
||||
.log = _listener_log,
|
||||
.get_level = _listener_get_level,
|
||||
},
|
||||
.max_level = max_level,
|
||||
.callback = callback,
|
||||
.param = param,
|
||||
},
|
||||
@@ -587,7 +592,7 @@ METHOD(job_t, terminate_ike_execute, job_requeue_t,
|
||||
|
||||
METHOD(controller_t, terminate_ike, status_t,
|
||||
controller_t *this, uint32_t unique_id, bool force,
|
||||
controller_cb_t callback, void *param, u_int timeout)
|
||||
controller_cb_t callback, void *param, level_t max_level, u_int timeout)
|
||||
{
|
||||
interface_job_t *job;
|
||||
status_t status;
|
||||
@@ -602,6 +607,7 @@ METHOD(controller_t, terminate_ike, status_t,
|
||||
.log = _listener_log,
|
||||
.get_level = _listener_get_level,
|
||||
},
|
||||
.max_level = max_level,
|
||||
.callback = callback,
|
||||
.param = param,
|
||||
},
|
||||
@@ -688,7 +694,7 @@ METHOD(job_t, terminate_child_execute, job_requeue_t,
|
||||
|
||||
METHOD(controller_t, terminate_child, status_t,
|
||||
controller_t *this, uint32_t unique_id,
|
||||
controller_cb_t callback, void *param, u_int timeout)
|
||||
controller_cb_t callback, void *param, level_t max_level, u_int timeout)
|
||||
{
|
||||
interface_job_t *job;
|
||||
status_t status;
|
||||
@@ -704,6 +710,7 @@ METHOD(controller_t, terminate_child, status_t,
|
||||
.log = _listener_log,
|
||||
.get_level = _listener_get_level,
|
||||
},
|
||||
.max_level = max_level,
|
||||
.callback = callback,
|
||||
.param = param,
|
||||
},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2023 Tobias Brunner
|
||||
* Copyright (C) 2007 Martin Willi
|
||||
*
|
||||
* Copyright (C) secunet Security Networks AG
|
||||
@@ -82,6 +83,7 @@ struct controller_t {
|
||||
* @param child_cfg optional child_cfg to set up CHILD_SA from
|
||||
* @param cb logging callback
|
||||
* @param param parameter to include in each call of cb
|
||||
* @param max_level maximum log level for which cb is invoked
|
||||
* @param timeout timeout in ms to wait for callbacks, 0 to disable
|
||||
* @param limits whether to check limits regarding IKE_SA initiation
|
||||
* @return
|
||||
@@ -93,8 +95,8 @@ struct controller_t {
|
||||
*/
|
||||
status_t (*initiate)(controller_t *this,
|
||||
peer_cfg_t *peer_cfg, child_cfg_t *child_cfg,
|
||||
controller_cb_t callback, void *param, u_int timeout,
|
||||
bool limits);
|
||||
controller_cb_t callback, void *param,
|
||||
level_t max_level, u_int timeout, bool limits);
|
||||
|
||||
/**
|
||||
* Terminate an IKE_SA and all of its CHILD_SAs.
|
||||
@@ -110,6 +112,7 @@ struct controller_t {
|
||||
* retransmits are sent until then
|
||||
* @param cb logging callback
|
||||
* @param param parameter to include in each call of cb
|
||||
* @param max_level maximum log level for which cb is invoked
|
||||
* @param timeout timeout in ms to wait for callbacks, 0 to disable
|
||||
* @return
|
||||
* - SUCCESS, if CHILD_SA terminated
|
||||
@@ -119,7 +122,7 @@ struct controller_t {
|
||||
*/
|
||||
status_t (*terminate_ike)(controller_t *this, uint32_t unique_id,
|
||||
bool force, controller_cb_t callback, void *param,
|
||||
u_int timeout);
|
||||
level_t max_level, u_int timeout);
|
||||
|
||||
/**
|
||||
* Terminate a CHILD_SA.
|
||||
@@ -130,6 +133,7 @@ struct controller_t {
|
||||
* @param unique_id CHILD_SA unique ID to terminate
|
||||
* @param cb logging callback
|
||||
* @param param parameter to include in each call of cb
|
||||
* @param max_level maximum log level for which cb is invoked
|
||||
* @param timeout timeout in ms to wait for callbacks, 0 to disable
|
||||
* @return
|
||||
* - SUCCESS, if CHILD_SA terminated
|
||||
@@ -139,7 +143,7 @@ struct controller_t {
|
||||
*/
|
||||
status_t (*terminate_child)(controller_t *this, uint32_t unique_id,
|
||||
controller_cb_t callback, void *param,
|
||||
u_int timeout);
|
||||
level_t max_level, u_int timeout);
|
||||
|
||||
/**
|
||||
* Destroy a controller_t instance.
|
||||
|
||||
Reference in New Issue
Block a user