diff options
| author | Robert Watson <rwatson@FreeBSD.org> | 2009-08-02 19:43:32 +0000 |
|---|---|---|
| committer | Robert Watson <rwatson@FreeBSD.org> | 2009-08-02 19:43:32 +0000 |
| commit | 315e3e38faa1ac7e775bbbbca0079c23fa3513ea (patch) | |
| tree | a40bf95a151eb088ca45c32ee899b724ba74dcea /sys/netinet | |
| parent | 9734411552a036160bfa03958256bdd3bfe6119f (diff) | |
Notes
Diffstat (limited to 'sys/netinet')
| -rw-r--r-- | sys/netinet/icmp6.h | 11 | ||||
| -rw-r--r-- | sys/netinet/icmp_var.h | 11 | ||||
| -rw-r--r-- | sys/netinet/in_gif.c | 6 | ||||
| -rw-r--r-- | sys/netinet/ip_divert.c | 10 | ||||
| -rw-r--r-- | sys/netinet/ip_icmp.c | 14 | ||||
| -rw-r--r-- | sys/netinet/ip_input.c | 21 | ||||
| -rw-r--r-- | sys/netinet/ip_var.h | 14 | ||||
| -rw-r--r-- | sys/netinet/tcp_input.c | 14 | ||||
| -rw-r--r-- | sys/netinet/tcp_var.h | 11 | ||||
| -rw-r--r-- | sys/netinet/udp_usrreq.c | 14 | ||||
| -rw-r--r-- | sys/netinet/udp_var.h | 11 |
11 files changed, 129 insertions, 8 deletions
diff --git a/sys/netinet/icmp6.h b/sys/netinet/icmp6.h index 7dc22e555848..c3a8ac7fcac3 100644 --- a/sys/netinet/icmp6.h +++ b/sys/netinet/icmp6.h @@ -600,8 +600,19 @@ struct icmp6stat { }; #ifdef _KERNEL +/* + * In-kernel consumers can use these accessor macros directly to update + * stats. + */ #define ICMP6STAT_ADD(name, val) V_icmp6stat.name += (val) #define ICMP6STAT_INC(name) ICMP6STAT_ADD(name, 1) + +/* + * Kernel module consumers must use this accessor macro. + */ +void kmod_icmp6stat_inc(int statnum); +#define KMOD_ICMP6STAT_INC(name) \ + kmod_icmp6stat_inc(offsetof(struct icmp6stat, name) / sizeof(u_quad_t)) #endif /* diff --git a/sys/netinet/icmp_var.h b/sys/netinet/icmp_var.h index 4d70adaf14ec..30da6a262421 100644 --- a/sys/netinet/icmp_var.h +++ b/sys/netinet/icmp_var.h @@ -58,8 +58,19 @@ struct icmpstat { }; #ifdef _KERNEL +/* + * In-kernel consumers can use these accessor macros directly to update + * stats. + */ #define ICMPSTAT_ADD(name, val) V_icmpstat.name += (val) #define ICMPSTAT_INC(name) ICMPSTAT_ADD(name, 1) + +/* + * Kernel module consumers must use this accessor macro. + */ +void kmod_icmpstat_inc(int statnum); +#define KMOD_ICMPSTAT_INC(name) \ + kmod_icmpstat_inc(offsetof(struct icmpstat, name) / sizeof(u_long)) #endif /* diff --git a/sys/netinet/in_gif.c b/sys/netinet/in_gif.c index 3872ddefe13b..44b9961d44b2 100644 --- a/sys/netinet/in_gif.c +++ b/sys/netinet/in_gif.c @@ -281,14 +281,14 @@ in_gif_input(struct mbuf *m, int off) sc = (struct gif_softc *)encap_getarg(m); if (sc == NULL) { m_freem(m); - IPSTAT_INC(ips_nogif); + KMOD_IPSTAT_INC(ips_nogif); return; } gifp = GIF2IFP(sc); if (gifp == NULL || (gifp->if_flags & IFF_UP) == 0) { m_freem(m); - IPSTAT_INC(ips_nogif); + KMOD_IPSTAT_INC(ips_nogif); return; } @@ -348,7 +348,7 @@ in_gif_input(struct mbuf *m, int off) break; default: - IPSTAT_INC(ips_nogif); + KMOD_IPSTAT_INC(ips_nogif); m_freem(m); return; } diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 691031014846..31059e9acd76 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -186,7 +186,7 @@ void div_input(struct mbuf *m, int off) { - IPSTAT_INC(ips_noproto); + KMOD_IPSTAT_INC(ips_noproto); m_freem(m); } @@ -310,8 +310,8 @@ divert_packet(struct mbuf *m, int incoming) INP_INFO_RUNLOCK(&V_divcbinfo); if (sa == NULL) { m_freem(m); - IPSTAT_INC(ips_noproto); - IPSTAT_DEC(ips_delivered); + KMOD_IPSTAT_INC(ips_noproto); + KMOD_IPSTAT_DEC(ips_delivered); } } @@ -396,7 +396,7 @@ div_output(struct socket *so, struct mbuf *m, struct sockaddr_in *sin, ip->ip_off = ntohs(ip->ip_off); /* Send packet to output processing */ - IPSTAT_INC(ips_rawout); /* XXX */ + KMOD_IPSTAT_INC(ips_rawout); /* XXX */ #ifdef MAC mac_inpcb_create_mbuf(inp, m); @@ -567,7 +567,7 @@ div_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, /* Packet must have a header (but that's about it) */ if (m->m_len < sizeof (struct ip) && (m = m_pullup(m, sizeof (struct ip))) == 0) { - IPSTAT_INC(ips_toosmall); + KMOD_IPSTAT_INC(ips_toosmall); m_freem(m); return EINVAL; } diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index b7906e32b82d..fcb9ca6ceaa2 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -172,6 +172,20 @@ icmp_init(void) } /* + * Kernel module interface for updating icmpstat. The argument is an index + * into icmpstat treated as an array of u_long. While this encodes the + * general layout of icmpstat 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_icmpstat_inc(int statnum) +{ + + (*((u_long *)&V_icmpstat + statnum))++; +} + +/* * Generate an error packet of type error * in response to bad packet ip. */ diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 05de6d8a00f9..7886fa737163 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) { diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h index 74aecb18e78d..448ba3d79784 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 */ diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 22ee3d7bd72e..470d782ee5e7 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -217,6 +217,20 @@ static void tcp_newreno_partial_ack(struct tcpcb *, struct tcphdr *); static void inline tcp_congestion_exp(struct tcpcb *); +/* + * Kernel module interface for updating tcpstat. The argument is an index + * into tcpstat treated as an array of u_long. While this encodes the + * general layout of tcpstat 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_tcpstat_inc(int statnum) +{ + + (*((u_long *)&V_tcpstat + statnum))++; +} + static void inline tcp_congestion_exp(struct tcpcb *tp) { diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 8845769df4fa..96353f3df537 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -474,8 +474,19 @@ struct tcpstat { }; #ifdef _KERNEL +/* + * In-kernel consumers can use these accessor macros directly to update + * stats. + */ #define TCPSTAT_ADD(name, val) V_tcpstat.name += (val) #define TCPSTAT_INC(name) TCPSTAT_ADD(name, 1) + +/* + * Kernel module consumers must use this accessor macro. + */ +void kmod_tcpstat_inc(int statnum); +#define KMOD_TCPSTAT_INC(name) \ + kmod_tcpstat_inc(offsetof(struct tcpstat, name) / sizeof(u_long)) #endif /* diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 520fc949ed38..019ceb3ef281 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -203,6 +203,20 @@ udp_init(void) EVENTHANDLER_PRI_ANY); } +/* + * Kernel module interface for updating udpstat. The argument is an index + * into udpstat treated as an array of u_long. While this encodes the + * general layout of udpstat 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_udpstat_inc(int statnum) +{ + + (*((u_long *)&V_udpstat + statnum))++; +} + int udp_newudpcb(struct inpcb *inp) { diff --git a/sys/netinet/udp_var.h b/sys/netinet/udp_var.h index 803167076023..b8d994cc3a62 100644 --- a/sys/netinet/udp_var.h +++ b/sys/netinet/udp_var.h @@ -91,8 +91,19 @@ struct udpstat { }; #ifdef _KERNEL +/* + * In-kernel consumers can use these accessor macros directly to update + * stats. + */ #define UDPSTAT_ADD(name, val) V_udpstat.name += (val) #define UDPSTAT_INC(name) UDPSTAT_ADD(name, 1) + +/* + * Kernel module consumers must use this accessor macro. + */ +void kmod_udpstat_inc(int statnum); +#define KMOD_UDPSTAT_INC(name) \ + kmod_udpstat_inc(offsetof(struct udpstat, name) / sizeof(u_long)) #endif /* |
