summaryrefslogtreecommitdiffstats
path: root/sys/netinet/ip_var.h
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2009-08-02 19:43:32 +0000
committerrwatson <rwatson@FreeBSD.org>2009-08-02 19:43:32 +0000
commit5c6699ad3da677119a855665cf574faa86b982fc (patch)
treea40bf95a151eb088ca45c32ee899b724ba74dcea /sys/netinet/ip_var.h
parentb08de52c2d9909520082a33aafe53c6ee39df7d7 (diff)
downloadFreeBSD-src-5c6699ad3da677119a855665cf574faa86b982fc.zip
FreeBSD-src-5c6699ad3da677119a855665cf574faa86b982fc.tar.gz
Many network stack subsystems use a single global data structure to hold
all pertinent statatistics for the subsystem. These structures are sometimes "borrowed" by kernel modules that require a place to store statistics for similar events. Add KPI accessor functions for statistics structures referenced by kernel modules so that they no longer encode certain specifics of how the data structures are named and stored. This change is intended to make it easier to move to per-CPU network stats following 8.0-RELEASE. The following modules are affected by this change: if_bridge if_cxgb if_gif ip_mroute ipdivert pf In practice, most of these statistics consumers should, in fact, maintain their own statistics data structures rather than borrowing structures from the base network stack. However, that change is too agressive for this point in the release cycle. Reviewed by: bz Approved by: re (kib)
Diffstat (limited to 'sys/netinet/ip_var.h')
-rw-r--r--sys/netinet/ip_var.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h
index 74aecb1..448ba3d 100644
--- a/sys/netinet/ip_var.h
+++ b/sys/netinet/ip_var.h
@@ -131,11 +131,25 @@ struct ipstat {
#include <net/vnet.h>
+/*
+ * In-kernel consumers can use these accessor macros directly to update
+ * stats.
+ */
#define IPSTAT_ADD(name, val) V_ipstat.name += (val)
#define IPSTAT_SUB(name, val) V_ipstat.name -= (val)
#define IPSTAT_INC(name) IPSTAT_ADD(name, 1)
#define IPSTAT_DEC(name) IPSTAT_SUB(name, 1)
+/*
+ * Kernel module consumers must use this accessor macro.
+ */
+void kmod_ipstat_inc(int statnum);
+#define KMOD_IPSTAT_INC(name) \
+ kmod_ipstat_inc(offsetof(struct ipstat, name) / sizeof(u_long))
+void kmod_ipstat_dec(int statnum);
+#define KMOD_IPSTAT_DEC(name) \
+ kmod_ipstat_dec(offsetof(struct ipstat, name) / sizeof(u_long))
+
/* flags passed to ip_output as last parameter */
#define IP_FORWARDING 0x1 /* most of ip header exists */
#define IP_RAWOUTPUT 0x2 /* raw ip header exists */
OpenPOWER on IntegriCloud