From 1f66f7ab4e7b32fb571cb5c95819df2895073b5a Mon Sep 17 00:00:00 2001 From: Christian Deacon Date: Thu, 13 Jun 2024 19:23:54 -0400 Subject: [PATCH] Add NANO_TO_SEC constant. --- src/xdpfw.h | 1 + src/xdpfw_kern.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/xdpfw.h b/src/xdpfw.h index 29597cf..0cadb43 100644 --- a/src/xdpfw.h +++ b/src/xdpfw.h @@ -6,6 +6,7 @@ #define MAX_FILTERS 80 #define MAX_TRACK_IPS 100000 #define MAX_CPUS 256 +#define NANO_TO_SEC 1000000000 #ifdef __BPF__ #define likely(x) __builtin_expect(!!(x), 1) diff --git a/src/xdpfw_kern.c b/src/xdpfw_kern.c index 81933f1..034a680 100644 --- a/src/xdpfw_kern.c +++ b/src/xdpfw_kern.c @@ -202,7 +202,7 @@ int xdp_prog_main(struct xdp_md *ctx) if (ip_stats) { // Check for reset. - if ((now - ip_stats->tracking) > 1000000000) + if ((now - ip_stats->tracking) > NANO_TO_SEC) { ip_stats->pps = 0; ip_stats->bps = 0;