child-sa: query SAD/SPD just for what we actually need to update statistics

This commit is contained in:
Martin Willi
2013-05-06 17:01:13 +02:00
parent 470aad7e0c
commit bdaf9f97e6
+4 -1
View File
@@ -527,13 +527,16 @@ METHOD(child_sa_t, get_usestats, void,
private_child_sa_t *this, bool inbound, private_child_sa_t *this, bool inbound,
time_t *time, u_int64_t *bytes, u_int64_t *packets) time_t *time, u_int64_t *bytes, u_int64_t *packets)
{ {
if (update_usebytes(this, inbound) != FAILED) if ((!bytes && !packets) || update_usebytes(this, inbound) != FAILED)
{ {
/* there was traffic since last update or the kernel interface /* there was traffic since last update or the kernel interface
* does not support querying the number of usebytes. * does not support querying the number of usebytes.
*/ */
if (time)
{
update_usetime(this, inbound); update_usetime(this, inbound);
} }
}
if (time) if (time)
{ {
*time = inbound ? this->my_usetime : this->other_usetime; *time = inbound ? this->my_usetime : this->other_usetime;