child-sa: Query policies only if querying SAs doesn't update the use time
This commit is contained in:
+12
-12
@@ -759,19 +759,19 @@ METHOD(child_sa_t, get_usestats, void,
|
|||||||
private_child_sa_t *this, bool inbound,
|
private_child_sa_t *this, bool inbound,
|
||||||
time_t *time, uint64_t *bytes, uint64_t *packets)
|
time_t *time, uint64_t *bytes, uint64_t *packets)
|
||||||
{
|
{
|
||||||
if ((!bytes && !packets) || update_usebytes(this, inbound) != FAILED)
|
status_t status = NOT_SUPPORTED;
|
||||||
|
bool sa_use_time;
|
||||||
|
|
||||||
|
sa_use_time = charon->kernel->get_features(charon->kernel) & KERNEL_SA_USE_TIME;
|
||||||
|
|
||||||
|
if (bytes || packets || sa_use_time)
|
||||||
{
|
{
|
||||||
/* there was traffic since last update or the kernel interface
|
status = update_usebytes(this, inbound);
|
||||||
* does not support querying the number of usebytes.
|
}
|
||||||
*/
|
if (time && !sa_use_time && status != FAILED)
|
||||||
if (time)
|
{ /* query policies only if last use time is not available from SAs and
|
||||||
{
|
* there was either traffic or querying the SA wasn't supported */
|
||||||
if (!update_usetime(this, inbound) && !bytes && !packets)
|
update_usetime(this, inbound);
|
||||||
{
|
|
||||||
/* if policy query did not yield a usetime, query SAs instead */
|
|
||||||
update_usebytes(this, inbound);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (time)
|
if (time)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user