diff options
author | rwatson <rwatson@FreeBSD.org> | 2009-08-02 19:43:32 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2009-08-02 19:43:32 +0000 |
commit | 5c6699ad3da677119a855665cf574faa86b982fc (patch) | |
tree | a40bf95a151eb088ca45c32ee899b724ba74dcea /sys/netinet/ip_input.c | |
parent | b08de52c2d9909520082a33aafe53c6ee39df7d7 (diff) | |
download | FreeBSD-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_input.c')
-rw-r--r-- | sys/netinet/ip_input.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 05de6d8..7886fa7 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -235,6 +235,27 @@ VNET_DEFINE(int, fw_one_pass) = 1; static void ip_freef(struct ipqhead *, struct ipq *); +/* + * Kernel module interface for updating ipstat. The argument is an index + * into ipstat treated as an array of u_long. While this encodes the general + * layout of ipstat into the caller, it doesn't encode its location, so that + * future changes to add, for example, per-CPU stats support won't cause + * binary compatibility problems for kernel modules. + */ +void +kmod_ipstat_inc(int statnum) +{ + + (*((u_long *)&V_ipstat + statnum))++; +} + +void +kmod_ipstat_dec(int statnum) +{ + + (*((u_long *)&V_ipstat + statnum))--; +} + static int sysctl_netinet_intr_queue_maxlen(SYSCTL_HANDLER_ARGS) { |