summaryrefslogtreecommitdiffstats
path: root/sys/netinet
diff options
context:
space:
mode:
authorae <ae@FreeBSD.org>2013-07-09 09:50:15 +0000
committerae <ae@FreeBSD.org>2013-07-09 09:50:15 +0000
commit705a50a05300cbec6176269dfe8b9e5ae0b12dab (patch)
treeef65cdea87ebd2ddc7dce18e0f6bd4aa6c63c183 /sys/netinet
parent1b1e1de2b2e27f692afabbf18eee1f7a70caa049 (diff)
downloadFreeBSD-src-705a50a05300cbec6176269dfe8b9e5ae0b12dab.zip
FreeBSD-src-705a50a05300cbec6176269dfe8b9e5ae0b12dab.tar.gz
Migrate structs arpstat, icmpstat, mrtstat, pimstat and udpstat to PCPU
counters.
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/icmp_var.h11
-rw-r--r--sys/netinet/if_ether.c13
-rw-r--r--sys/netinet/in.c3
-rw-r--r--sys/netinet/ip_icmp.c13
-rw-r--r--sys/netinet/ip_mroute.c21
-rw-r--r--sys/netinet/ip_mroute.h3
-rw-r--r--sys/netinet/pim_var.h3
-rw-r--r--sys/netinet/udp_usrreq.c13
-rw-r--r--sys/netinet/udp_var.h12
9 files changed, 53 insertions, 39 deletions
diff --git a/sys/netinet/icmp_var.h b/sys/netinet/icmp_var.h
index d939cc2..809879d 100644
--- a/sys/netinet/icmp_var.h
+++ b/sys/netinet/icmp_var.h
@@ -58,11 +58,15 @@ struct icmpstat {
};
#ifdef _KERNEL
+#include <sys/counter.h>
+
+VNET_PCPUSTAT_DECLARE(struct icmpstat, icmpstat);
/*
* In-kernel consumers can use these accessor macros directly to update
* stats.
*/
-#define ICMPSTAT_ADD(name, val) V_icmpstat.name += (val)
+#define ICMPSTAT_ADD(name, val) \
+ VNET_PCPUSTAT_ADD(struct icmpstat, icmpstat, name, (val))
#define ICMPSTAT_INC(name) ICMPSTAT_ADD(name, 1)
/*
@@ -70,7 +74,7 @@ struct icmpstat {
*/
void kmod_icmpstat_inc(int statnum);
#define KMOD_ICMPSTAT_INC(name) \
- kmod_icmpstat_inc(offsetof(struct icmpstat, name) / sizeof(u_long))
+ kmod_icmpstat_inc(offsetof(struct icmpstat, name) / sizeof(uint64_t))
#endif
/*
@@ -91,9 +95,6 @@ void kmod_icmpstat_inc(int statnum);
#ifdef _KERNEL
SYSCTL_DECL(_net_inet_icmp);
-VNET_DECLARE(struct icmpstat, icmpstat); /* icmp statistics. */
-#define V_icmpstat VNET(icmpstat)
-
extern int badport_bandlim(int);
#define BANDLIM_UNLIMITED -1
#define BANDLIM_ICMP_UNREACH 0
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c
index ad31557..675e0dd 100644
--- a/sys/netinet/if_ether.c
+++ b/sys/netinet/if_ether.c
@@ -89,7 +89,12 @@ VNET_DEFINE(int, useloopback) = 1; /* use loopback interface for
static VNET_DEFINE(int, arp_proxyall) = 0;
static VNET_DEFINE(int, arpt_down) = 20; /* keep incomplete entries for
* 20 seconds */
-VNET_DEFINE(struct arpstat, arpstat); /* ARP statistics, see if_arp.h */
+VNET_PCPUSTAT_DEFINE(struct arpstat, arpstat); /* ARP statistics, see if_arp.h */
+VNET_PCPUSTAT_SYSINIT(arpstat);
+
+#ifdef VIMAGE
+VNET_PCPUSTAT_SYSUNINIT(arpstat);
+#endif /* VIMAGE */
static VNET_DEFINE(int, arp_maxhold) = 1;
@@ -97,7 +102,6 @@ static VNET_DEFINE(int, arp_maxhold) = 1;
#define V_arpt_down VNET(arpt_down)
#define V_arp_maxtries VNET(arp_maxtries)
#define V_arp_proxyall VNET(arp_proxyall)
-#define V_arpstat VNET(arpstat)
#define V_arp_maxhold VNET(arp_maxhold)
SYSCTL_VNET_INT(_net_link_ether_inet, OID_AUTO, max_age, CTLFLAG_RW,
@@ -115,9 +119,8 @@ SYSCTL_VNET_INT(_net_link_ether_inet, OID_AUTO, proxyall, CTLFLAG_RW,
SYSCTL_VNET_INT(_net_link_ether_inet, OID_AUTO, wait, CTLFLAG_RW,
&VNET_NAME(arpt_down), 0,
"Incomplete ARP entry lifetime in seconds");
-SYSCTL_VNET_STRUCT(_net_link_ether_arp, OID_AUTO, stats, CTLFLAG_RW,
- &VNET_NAME(arpstat), arpstat,
- "ARP statistics (struct arpstat, net/if_arp.h)");
+SYSCTL_VNET_PCPUSTAT(_net_link_ether_arp, OID_AUTO, stats, struct arpstat,
+ arpstat, "ARP statistics (struct arpstat, net/if_arp.h)");
SYSCTL_VNET_INT(_net_link_ether_inet, OID_AUTO, maxhold, CTLFLAG_RW,
&VNET_NAME(arp_maxhold), 0,
"Number of packets to hold per ARP entry");
diff --git a/sys/netinet/in.c b/sys/netinet/in.c
index 4e73b95..363f671 100644
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -85,9 +85,6 @@ SYSCTL_VNET_INT(_net_inet_ip, OID_AUTO, no_same_prefix, CTLFLAG_RW,
VNET_DECLARE(struct inpcbinfo, ripcbinfo);
#define V_ripcbinfo VNET(ripcbinfo)
-VNET_DECLARE(struct arpstat, arpstat); /* ARP statistics, see if_arp.h */
-#define V_arpstat VNET(arpstat)
-
/*
* Return 1 if an internet address is for a ``local'' host
* (one to which we have a connection).
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c
index 39d6f7e..deabf44 100644
--- a/sys/netinet/ip_icmp.c
+++ b/sys/netinet/ip_icmp.c
@@ -92,9 +92,14 @@ SYSCTL_VNET_INT(_net_inet_icmp, OID_AUTO, icmplim_output, CTLFLAG_RW,
"Enable logging of ICMP response rate limiting");
#ifdef INET
-VNET_DEFINE(struct icmpstat, icmpstat);
-SYSCTL_VNET_STRUCT(_net_inet_icmp, ICMPCTL_STATS, stats, CTLFLAG_RW,
- &VNET_NAME(icmpstat), icmpstat, "");
+VNET_PCPUSTAT_DEFINE(struct icmpstat, icmpstat);
+VNET_PCPUSTAT_SYSINIT(icmpstat);
+SYSCTL_VNET_PCPUSTAT(_net_inet_icmp, ICMPCTL_STATS, stats, struct icmpstat,
+ icmpstat, "ICMP statistics (struct icmpstat, netinet/icmp_var.h)");
+
+#ifdef VIMAGE
+VNET_PCPUSTAT_SYSUNINIT(icmpstat);
+#endif /* VIMAGE */
static VNET_DEFINE(int, icmpmaskrepl) = 0;
#define V_icmpmaskrepl VNET(icmpmaskrepl)
@@ -197,7 +202,7 @@ void
kmod_icmpstat_inc(int statnum)
{
- (*((u_long *)&V_icmpstat + statnum))++;
+ counter_u64_add(VNET(icmpstat)[statnum], 1);
}
/*
diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c
index b2b52c0..23f1be7 100644
--- a/sys/netinet/ip_mroute.c
+++ b/sys/netinet/ip_mroute.c
@@ -93,6 +93,7 @@ __FBSDID("$FreeBSD$");
#include <sys/syslog.h>
#include <sys/systm.h>
#include <sys/time.h>
+#include <sys/counter.h>
#include <net/if.h>
#include <net/netisr.h>
@@ -145,11 +146,11 @@ static struct mtx mrouter_mtx;
static int ip_mrouter_cnt; /* # of vnets with active mrouters */
static int ip_mrouter_unloading; /* Allow no more V_ip_mrouter sockets */
-static VNET_DEFINE(struct mrtstat, mrtstat);
-#define V_mrtstat VNET(mrtstat)
-SYSCTL_VNET_STRUCT(_net_inet_ip, OID_AUTO, mrtstat, CTLFLAG_RW,
- &VNET_NAME(mrtstat), mrtstat,
- "IPv4 Multicast Forwarding Statistics (struct mrtstat, "
+static VNET_PCPUSTAT_DEFINE(struct mrtstat, mrtstat);
+VNET_PCPUSTAT_SYSINIT(mrtstat);
+VNET_PCPUSTAT_SYSUNINIT(mrtstat);
+SYSCTL_VNET_PCPUSTAT(_net_inet_ip, OID_AUTO, mrtstat, struct mrtstat,
+ mrtstat, "IPv4 Multicast Forwarding Statistics (struct mrtstat, "
"netinet/ip_mroute.h)");
static VNET_DEFINE(u_long, mfchash);
@@ -225,13 +226,13 @@ static VNET_DEFINE(struct callout, bw_upcalls_ch);
#define BW_UPCALLS_PERIOD (hz) /* periodical flush of bw upcalls */
-static VNET_DEFINE(struct pimstat, pimstat);
-#define V_pimstat VNET(pimstat)
+static VNET_PCPUSTAT_DEFINE(struct pimstat, pimstat);
+VNET_PCPUSTAT_SYSINIT(pimstat);
+VNET_PCPUSTAT_SYSUNINIT(pimstat);
SYSCTL_NODE(_net_inet, IPPROTO_PIM, pim, CTLFLAG_RW, 0, "PIM");
-SYSCTL_VNET_STRUCT(_net_inet_pim, PIMCTL_STATS, stats, CTLFLAG_RD,
- &VNET_NAME(pimstat), pimstat,
- "PIM Statistics (struct pimstat, netinet/pim_var.h)");
+SYSCTL_VNET_PCPUSTAT(_net_inet_pim, PIMCTL_STATS, stats, struct pimstat,
+ pimstat, "PIM Statistics (struct pimstat, netinet/pim_var.h)");
static u_long pim_squelch_wholepkt = 0;
SYSCTL_ULONG(_net_inet_pim, OID_AUTO, squelch_wholepkt, CTLFLAG_RW,
diff --git a/sys/netinet/ip_mroute.h b/sys/netinet/ip_mroute.h
index 605b80d..65f7d83 100644
--- a/sys/netinet/ip_mroute.h
+++ b/sys/netinet/ip_mroute.h
@@ -222,7 +222,8 @@ struct mrtstat {
};
#ifdef _KERNEL
-#define MRTSTAT_ADD(name, val) V_mrtstat.name += (val)
+#define MRTSTAT_ADD(name, val) \
+ VNET_PCPUSTAT_ADD(struct mrtstat, mrtstat, name, (val))
#define MRTSTAT_INC(name) MRTSTAT_ADD(name, 1)
#endif
diff --git a/sys/netinet/pim_var.h b/sys/netinet/pim_var.h
index a4ea234..1fdfb10 100644
--- a/sys/netinet/pim_var.h
+++ b/sys/netinet/pim_var.h
@@ -60,7 +60,8 @@ struct pimstat {
};
#ifdef _KERNEL
-#define PIMSTAT_ADD(name, val) V_pimstat.name += (val)
+#define PIMSTAT_ADD(name, val) \
+ VNET_PCPUSTAT_ADD(struct pimstat, pimstat, name, (val))
#define PIMSTAT_INC(name) PIMSTAT_ADD(name, 1)
#endif
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index 6bc94c3..982a2db 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -143,11 +143,14 @@ static VNET_DEFINE(uma_zone_t, udpcb_zone);
#define UDBHASHSIZE 128
#endif
-VNET_DEFINE(struct udpstat, udpstat); /* from udp_var.h */
-SYSCTL_VNET_STRUCT(_net_inet_udp, UDPCTL_STATS, stats, CTLFLAG_RW,
- &VNET_NAME(udpstat), udpstat,
- "UDP statistics (struct udpstat, netinet/udp_var.h)");
+VNET_PCPUSTAT_DEFINE(struct udpstat, udpstat); /* from udp_var.h */
+VNET_PCPUSTAT_SYSINIT(udpstat);
+SYSCTL_VNET_PCPUSTAT(_net_inet_udp, UDPCTL_STATS, stats, struct udpstat,
+ udpstat, "UDP statistics (struct udpstat, netinet/udp_var.h)");
+#ifdef VIMAGE
+VNET_PCPUSTAT_SYSUNINIT(udpstat);
+#endif /* VIMAGE */
#ifdef INET
static void udp_detach(struct socket *so);
static int udp_output(struct inpcb *, struct mbuf *, struct sockaddr *,
@@ -207,7 +210,7 @@ void
kmod_udpstat_inc(int statnum)
{
- (*((u_long *)&V_udpstat + statnum))++;
+ counter_u64_add(VNET(udpstat)[statnum], 1);
}
int
diff --git a/sys/netinet/udp_var.h b/sys/netinet/udp_var.h
index 53bbf1e..0c26b88 100644
--- a/sys/netinet/udp_var.h
+++ b/sys/netinet/udp_var.h
@@ -94,19 +94,23 @@ struct udpstat {
};
#ifdef _KERNEL
+#include <sys/counter.h>
+
+VNET_PCPUSTAT_DECLARE(struct udpstat, udpstat);
/*
* In-kernel consumers can use these accessor macros directly to update
* stats.
*/
-#define UDPSTAT_ADD(name, val) V_udpstat.name += (val)
+#define UDPSTAT_ADD(name, val) \
+ VNET_PCPUSTAT_ADD(struct udpstat, 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))
+#define KMOD_UDPSTAT_INC(name) \
+ kmod_udpstat_inc(offsetof(struct udpstat, name) / sizeof(uint64_t))
#endif
/*
@@ -140,10 +144,8 @@ VNET_DECLARE(struct inpcbinfo, udbinfo);
extern u_long udp_sendspace;
extern u_long udp_recvspace;
VNET_DECLARE(int, udp_cksum);
-VNET_DECLARE(struct udpstat, udpstat);
VNET_DECLARE(int, udp_blackhole);
#define V_udp_cksum VNET(udp_cksum)
-#define V_udpstat VNET(udpstat)
#define V_udp_blackhole VNET(udp_blackhole)
extern int udp_log_in_vain;
OpenPOWER on IntegriCloud