From ef996a659619362fb034662df147b9c14f1ea04b Mon Sep 17 00:00:00 2001 From: gamemann Date: Mon, 6 Dec 2021 16:37:39 +0000 Subject: [PATCH] Check BPF stats map lookup result. --- src/xdpfw.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/xdpfw.c b/src/xdpfw.c index 5907aed..5ebc9bf 100644 --- a/src/xdpfw.c +++ b/src/xdpfw.c @@ -494,11 +494,15 @@ int main(int argc, char *argv[]) { __u32 key = 0; struct stats stats[cpus]; + //memset(&stats, 0, sizeof(struct stats) * cpus); __u64 allowed = 0; __u64 dropped = 0; - bpf_map_lookup_elem(statsmap, &key, &stats); + if (bpf_map_lookup_elem(statsmap, &key, &stats) != 0) + { + fprintf(stderr, "Error performing stats map lookup.\n"); + } for (int i = 0; i < cpus; i++) {