]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
util-ebpf: add error handling in hash value fetch
authorEric Leblond <eric@regit.org>
Tue, 2 Jan 2018 11:50:26 +0000 (12:50 +0100)
committerEric Leblond <eric@regit.org>
Tue, 6 Feb 2018 15:58:19 +0000 (16:58 +0100)
src/util-ebpf.c

index 4344b651fefcec45f53443c38f6e7a8f81f0ee4f..f51658d21e1aec24d2e290a90c0b30a86781be2d 100644 (file)
@@ -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) {