]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
util-ebpf: fix ipv6 cleaning and add comments
authorEric Leblond <eric@regit.org>
Sun, 17 Dec 2017 10:58:59 +0000 (11:58 +0100)
committerEric Leblond <eric@regit.org>
Tue, 6 Feb 2018 15:58:18 +0000 (16:58 +0100)
src/util-ebpf.c

index 48c9e6c349c4b1ad497b11a0b4354e35c87f492d..d3d26220eb2a6ba834c2eeff0763d66e713a153e 100644 (file)
@@ -246,13 +246,17 @@ static int EBPFForEachFlowV4Table(const char *name,
         for (i = 0; i < nr_cpus; i++) {
             int ret = FlowCallback(mapfd, &key, &values_array[i], data);
             if (ret) {
+                /* no packet for the flow on this CPU, let's start accumulating
+                   value we can compute the counters */
                 pkts_cnt += values_array[i].packets;
                 bytes_cnt += values_array[i].bytes;
             } else {
+                /* Packet seen on one CPU so we keep the flow */
                 iret = 0;
                 break;
             }
         }
+        /* No packet seen, we discard the flow  and do accounting */
         if (iret) {
             flowstats->count++;
             flowstats->packets += pkts_cnt;
@@ -273,7 +277,6 @@ static int EBPFForEachFlowV6Table(const char *name,
 {
     int mapfd = EBPFGetMapFDByName(name);
     struct flowv6_keys key = {}, next_key;
-    struct pair value = {0, 0, 0};
     int found = 0;
     unsigned int i;
     unsigned int nr_cpus = UtilCpuGetNumProcessorsConfigured();