util-ebpf: add error handling in hash value fetch

pull/3221/head
Eric Leblond 9 years ago
parent 60265e023a
commit 3f3a206722

@ -292,7 +292,12 @@ static int EBPFForEachFlowV4Table(const char *iface, const char *name,
uint64_t bytes_cnt = 0; uint64_t bytes_cnt = 0;
struct pair values_array[nr_cpus]; struct pair values_array[nr_cpus];
memset(values_array, 0, sizeof(values_array)); 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++) { for (i = 0; i < nr_cpus; i++) {
int ret = FlowCallback(mapfd, &key, &values_array[i], data); int ret = FlowCallback(mapfd, &key, &values_array[i], data);
if (ret) { if (ret) {
@ -345,7 +350,12 @@ static int EBPFForEachFlowV6Table(const char *iface, const char *name,
uint64_t bytes_cnt = 0; uint64_t bytes_cnt = 0;
struct pair values_array[nr_cpus]; struct pair values_array[nr_cpus];
memset(values_array, 0, sizeof(values_array)); 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++) { for (i = 0; i < nr_cpus; i++) {
int ret = FlowCallback(mapfd, &key, &values_array[i], data); int ret = FlowCallback(mapfd, &key, &values_array[i], data);
if (ret) { if (ret) {

Loading…
Cancel
Save