Add define for incrementing blocked stats when the source IP is on the blocked map.
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
#include "include/xdpfw.h"
|
#include "include/xdpfw.h"
|
||||||
|
|
||||||
//#define DEBUG
|
//#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
|
#ifdef DEBUG
|
||||||
|
|
||||||
@@ -139,11 +140,13 @@ int xdp_prog_main(struct xdp_md *ctx)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Increase blocked stats entry.
|
#ifdef DOSTATSONBLOCKMAP
|
||||||
if (stats)
|
// Increase blocked stats entry.
|
||||||
{
|
if (stats)
|
||||||
__sync_fetch_and_add(&stats->blocked, 1);
|
{
|
||||||
}
|
__sync_fetch_and_add(&stats->blocked, 1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// They're still blocked. Drop the packet.
|
// They're still blocked. Drop the packet.
|
||||||
return XDP_DROP;
|
return XDP_DROP;
|
||||||
|
|||||||
Reference in New Issue
Block a user