summaryrefslogtreecommitdiffstats
path: root/sys/netpfil/ipfw/ip_fw_private.h
diff options
context:
space:
mode:
authormelifaro <melifaro@FreeBSD.org>2012-11-30 19:36:55 +0000
committermelifaro <melifaro@FreeBSD.org>2012-11-30 19:36:55 +0000
commit6a45724ec724b0718130f941e8bd3ded5ef85a03 (patch)
tree8488e98bfa6a163fe1735fd94b34f407be5b8ef0 /sys/netpfil/ipfw/ip_fw_private.h
parentc07e3ec124db785f32d1fdd54ed55642750e07a6 (diff)
downloadFreeBSD-src-6a45724ec724b0718130f941e8bd3ded5ef85a03.zip
FreeBSD-src-6a45724ec724b0718130f941e8bd3ded5ef85a03.tar.gz
Use common macros for working with rule/dynamic counters.
This is done as preparation to introduce per-cpu ipfw counters. MFC after: 3 weeks
Diffstat (limited to 'sys/netpfil/ipfw/ip_fw_private.h')
-rw-r--r--sys/netpfil/ipfw/ip_fw_private.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/sys/netpfil/ipfw/ip_fw_private.h b/sys/netpfil/ipfw/ip_fw_private.h
index 7040211..0ea0b35 100644
--- a/sys/netpfil/ipfw/ip_fw_private.h
+++ b/sys/netpfil/ipfw/ip_fw_private.h
@@ -236,6 +236,28 @@ struct ip_fw_chain {
struct sockopt; /* used by tcp_var.h */
+/* Macro for working with various counters */
+#define IPFW_INC_RULE_COUNTER(_cntr, _bytes) do { \
+ (_cntr)->pcnt++; \
+ (_cntr)->bcnt += _bytes; \
+ (_cntr)->timestamp = time_uptime; \
+ } while (0)
+
+#define IPFW_INC_DYN_COUNTER(_cntr, _bytes) do { \
+ (_cntr)->pcnt++; \
+ (_cntr)->bcnt += _bytes; \
+ } while (0)
+
+#define IPFW_ZERO_RULE_COUNTER(_cntr) do { \
+ (_cntr)->pcnt = 0; \
+ (_cntr)->bcnt = 0; \
+ (_cntr)->timestamp = 0; \
+ } while (0)
+
+#define IPFW_ZERO_DYN_COUNTER(_cntr) do { \
+ (_cntr)->pcnt = 0; \
+ (_cntr)->bcnt = 0; \
+ } while (0)
/*
* The lock is heavily used by ip_fw2.c (the main file) and ip_fw_nat.c
* so the variable and the macros must be here.
OpenPOWER on IntegriCloud