]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
util-ebpf: set livedev in flow
authorEric Leblond <eric@regit.org>
Mon, 10 Jun 2019 10:18:21 +0000 (12:18 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 18 Jun 2019 05:07:02 +0000 (07:07 +0200)
This will fix the accounting for pinned maps as the livedev field
of Flow is used to do the accounting of bypass flows.

src/util-ebpf.c

index a6dc53d3c41beff6b88dd1e52e4a79eb44017c01..4b6d0c21e9370926140e26c926f277874af5aba3 100644 (file)
@@ -501,7 +501,7 @@ int EBPFSetupXDP(const char *iface, int fd, uint8_t flags)
  *
  * \return false (this create function never returns true)
  */
-static bool EBPFCreateFlowForKey(struct flows_stats *flowstats, void *key,
+static bool EBPFCreateFlowForKey(struct flows_stats *flowstats, LiveDevice *dev, void *key,
                                  FlowKey *flow_key, struct timespec *ctime,
                                  uint64_t pkts_cnt, uint64_t bytes_cnt,
                                  int mapfd, int cpus_count)
@@ -549,6 +549,7 @@ static bool EBPFCreateFlowForKey(struct flows_stats *flowstats, void *key,
             eb->key[1] = key;
         }
     }
+    f->livedev = dev;
     FLOWLOCK_UNLOCK(f);
     return false;
 }
@@ -645,7 +646,7 @@ bool EBPFBypassUpdate(Flow *f, void *data, time_t tsec)
     return false;
 }
 
-typedef bool (*OpFlowForKey)(struct flows_stats *flowstats, void *key,
+typedef bool (*OpFlowForKey)(struct flows_stats *flowstats, LiveDevice*dev, void *key,
                             FlowKey *flow_key, struct timespec *ctime,
                             uint64_t pkts_cnt, uint64_t bytes_cnt,
                             int mapfd, int cpus_count);
@@ -731,7 +732,7 @@ static int EBPFForEachFlowV4Table(ThreadVars *th_v, LiveDevice *dev, const char
             flow_key.proto = IPPROTO_UDP;
         }
         flow_key.recursion_level = 0;
-        dead_flow = EBPFOpFlowForKey(flowstats, &next_key, &flow_key,
+        dead_flow = EBPFOpFlowForKey(flowstats, dev, &next_key, &flow_key,
                                      ctime, pkts_cnt, bytes_cnt,
                                      mapfd, tcfg->cpus_count);
         if (dead_flow) {
@@ -844,7 +845,7 @@ static int EBPFForEachFlowV6Table(ThreadVars *th_v,
             flow_key.proto = IPPROTO_UDP;
         }
         flow_key.recursion_level = 0;
-        pkts_cnt = EBPFOpFlowForKey(flowstats, &next_key, &flow_key,
+        pkts_cnt = EBPFOpFlowForKey(flowstats, dev, &next_key, &flow_key,
                                     ctime, pkts_cnt, bytes_cnt,
                                     mapfd, tcfg->cpus_count);
         if (pkts_cnt > 0) {