From 9c19e1eb8c4bda1d3fe41a04121afa7654aa9c1f Mon Sep 17 00:00:00 2001 From: Christian Deacon Date: Thu, 4 Jun 2020 18:22:07 +0000 Subject: [PATCH] Add define for incrementing blocked stats when the source IP is on the blocked map. --- src/xdpfw_kern.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/xdpfw_kern.c b/src/xdpfw_kern.c index dba154b..3a37a11 100644 --- a/src/xdpfw_kern.c +++ b/src/xdpfw_kern.c @@ -16,6 +16,7 @@ #include "include/xdpfw.h" //#define DEBUG +#define DOSTATSONBLOCKMAP // Feel free to comment this out if you don't want the `blocked` entry on the stats map to be incremented every single time a packet is dropped from the source IP being on the blocked map. Commenting this line out should increase performance when blocking malicious traffic. #ifdef DEBUG @@ -139,11 +140,13 @@ int xdp_prog_main(struct xdp_md *ctx) } else { - // Increase blocked stats entry. - if (stats) - { - __sync_fetch_and_add(&stats->blocked, 1); - } + #ifdef DOSTATSONBLOCKMAP + // Increase blocked stats entry. + if (stats) + { + __sync_fetch_and_add(&stats->blocked, 1); + } + #endif // They're still blocked. Drop the packet. return XDP_DROP;