From: Eric Leblond Date: Tue, 2 Jan 2018 11:50:26 +0000 (+0100) Subject: util-ebpf: add error handling in hash value fetch X-Git-Tag: suricata-4.1.0-beta1~200 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f3a206722e1bde8ac8ecdcb2c0eb856c9e69529;p=thirdparty%2Fsuricata.git util-ebpf: add error handling in hash value fetch --- diff --git a/src/util-ebpf.c b/src/util-ebpf.c index 4344b651fe..f51658d21e 100644 --- a/src/util-ebpf.c +++ b/src/util-ebpf.c @@ -292,7 +292,12 @@ static int EBPFForEachFlowV4Table(const char *iface, const char *name, uint64_t bytes_cnt = 0; struct pair values_array[nr_cpus]; memset(values_array, 0, sizeof(values_array)); - bpf_map_lookup_elem(mapfd, &key, values_array); + int res = bpf_map_lookup_elem(mapfd, &key, values_array); + if (res < 0) { + SCLogDebug("no entry in v4 table for %d -> %d", key.port16[0], key.port16[1]); + key = next_key; + continue; + } for (i = 0; i < nr_cpus; i++) { int ret = FlowCallback(mapfd, &key, &values_array[i], data); if (ret) { @@ -345,7 +350,12 @@ static int EBPFForEachFlowV6Table(const char *iface, const char *name, uint64_t bytes_cnt = 0; struct pair values_array[nr_cpus]; memset(values_array, 0, sizeof(values_array)); - bpf_map_lookup_elem(mapfd, &key, values_array); + int res = bpf_map_lookup_elem(mapfd, &key, values_array); + if (res < 0) { + SCLogDebug("no entry in v6 table for %d -> %d", key.port16[0], key.port16[1]); + key = next_key; + continue; + } for (i = 0; i < nr_cpus; i++) { int ret = FlowCallback(mapfd, &key, &values_array[i], data); if (ret) {