From 73a928fa0b698396208e69ee5bdf52c57ef1c84e Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Sat, 8 Dec 2018 08:21:44 +0100 Subject: [PATCH] util-ebpf: fix loop on maps We were missing the last element of the map by working on previous key instead of current key. --- src/util-ebpf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util-ebpf.c b/src/util-ebpf.c index 70e359189c..1aa19d96de 100644 --- a/src/util-ebpf.c +++ b/src/util-ebpf.c @@ -401,7 +401,7 @@ static int EBPFForEachFlowV4Table(LiveDevice *dev, const char *name, * is 1 then we have a global hash. */ struct pair values_array[tcfg->cpus_count]; memset(values_array, 0, sizeof(values_array)); - int res = bpf_map_lookup_elem(mapfd, &key, values_array); + int res = bpf_map_lookup_elem(mapfd, &next_key, values_array); if (res < 0) { SCLogDebug("no entry in v4 table for %d -> %d", key.port16[0], key.port16[1]); SCLogDebug("errno: (%d) %s", errno, strerror(errno)); @@ -487,7 +487,7 @@ static int EBPFForEachFlowV6Table(LiveDevice *dev, const char *name, * is 1 then we have a global hash. */ struct pair values_array[tcfg->cpus_count]; memset(values_array, 0, sizeof(values_array)); - int res = bpf_map_lookup_elem(mapfd, &key, values_array); + int res = bpf_map_lookup_elem(mapfd, &next_key, values_array); if (res < 0) { SCLogDebug("no entry in v4 table for %d -> %d", key.port16[0], key.port16[1]); key = next_key;