From: Eric Leblond Date: Sat, 8 Dec 2018 07:21:44 +0000 (+0100) Subject: util-ebpf: fix loop on maps X-Git-Tag: suricata-5.0.0-rc1~390 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=73a928fa0b698396208e69ee5bdf52c57ef1c84e;p=thirdparty%2Fsuricata.git util-ebpf: fix loop on maps We were missing the last element of the map by working on previous key instead of current key. --- 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;