child-sa: query SAD/SPD just for what we actually need to update statistics
authorMartin Willi <martin@revosec.ch>
Sun, 21 Apr 2013 14:50:17 +0000 (16:50 +0200)
committerMartin Willi <martin@revosec.ch>
Mon, 6 May 2013 15:01:13 +0000 (17:01 +0200)
src/libcharon/sa/child_sa.c

index a8c246b..5861fe3 100644 (file)
@@ -527,12 +527,15 @@ METHOD(child_sa_t, get_usestats, void,
        private_child_sa_t *this, bool inbound,
        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
                 * does not support querying the number of usebytes.
                 */
-               update_usetime(this, inbound);
+               if (time)
+               {
+                       update_usetime(this, inbound);
+               }
        }
        if (time)
        {