1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-16 10:20:30 +00:00

Migrate structs ip6stat, icmp6stat and rip6stat to PCPU counters.

This commit is contained in:
Andrey V. Elsukov 2013-07-09 09:54:54 +00:00
parent 5b7cb97c2b
commit a786f67981
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=253085
9 changed files with 49 additions and 26 deletions

View File

@ -617,19 +617,23 @@ struct icmp6stat {
};
#ifdef _KERNEL
#include <sys/counter.h>
VNET_PCPUSTAT_DECLARE(struct icmp6stat, icmp6stat);
/*
* In-kernel consumers can use these accessor macros directly to update
* stats.
*/
#define ICMP6STAT_ADD(name, val) V_icmp6stat.name += (val)
#define ICMP6STAT_ADD(name, val) \
VNET_PCPUSTAT_ADD(struct icmp6stat, 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))
#define KMOD_ICMP6STAT_INC(name) \
kmod_icmp6stat_inc(offsetof(struct icmp6stat, name) / sizeof(uint64_t))
#endif
/*

View File

@ -114,7 +114,12 @@ __FBSDID("$FreeBSD$");
extern struct domain inet6domain;
VNET_DEFINE(struct icmp6stat, icmp6stat);
VNET_PCPUSTAT_DEFINE(struct icmp6stat, icmp6stat);
VNET_PCPUSTAT_SYSINIT(icmp6stat);
#ifdef VIMAGE
VNET_PCPUSTAT_SYSUNINIT(icmp6stat);
#endif /* VIMAGE */
VNET_DECLARE(struct inpcbinfo, ripcbinfo);
VNET_DECLARE(struct inpcbhead, ripcb);
@ -155,7 +160,7 @@ void
kmod_icmp6stat_inc(int statnum)
{
(*((u_quad_t *)&V_icmp6stat + statnum))++;
counter_u64_add(VNET(icmp6stat)[statnum], 1);
}
static void

View File

@ -506,8 +506,8 @@ SYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_SENDREDIRECTS, redirect, CTLFLAG_RW,
&VNET_NAME(ip6_sendredirects), 0, "");
SYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_DEFHLIM, hlim, CTLFLAG_RW,
&VNET_NAME(ip6_defhlim), 0, "");
SYSCTL_VNET_STRUCT(_net_inet6_ip6, IPV6CTL_STATS, stats, CTLFLAG_RW,
&VNET_NAME(ip6stat), ip6stat, "");
SYSCTL_VNET_PCPUSTAT(_net_inet6_ip6, IPV6CTL_STATS, stats, struct ip6stat,
ip6stat, "IP6 statistics (struct ip6stat, netinet6/ip6_var.h)");
SYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_MAXFRAGPACKETS, maxfragpackets,
CTLFLAG_RW, &VNET_NAME(ip6_maxfragpackets), 0, "");
SYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_ACCEPT_RTADV, accept_rtadv,
@ -559,8 +559,9 @@ SYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_AUTO_LINKLOCAL, auto_linklocal,
CTLFLAG_RW, &VNET_NAME(ip6_auto_linklocal), 0,
"Default value of per-interface flag for automatically adding an IPv6"
" link-local address to interfaces when attached");
SYSCTL_VNET_STRUCT(_net_inet6_ip6, IPV6CTL_RIP6STATS, rip6stats, CTLFLAG_RW,
&VNET_NAME(rip6stat), rip6stat, "");
SYSCTL_VNET_PCPUSTAT(_net_inet6_ip6, IPV6CTL_RIP6STATS, rip6stats,
struct rip6stat, rip6stat,
"Raw IP6 statistics (struct rip6stat, netinet6/raw_ip6.h)");
SYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_PREFER_TEMPADDR, prefer_tempaddr,
CTLFLAG_RW, &VNET_NAME(ip6_prefer_tempaddr), 0, "");
SYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_USE_DEFAULTZONE, use_defaultzone,
@ -589,8 +590,9 @@ SYSCTL_VNET_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRACCEPT, rediraccept,
CTLFLAG_RW, &VNET_NAME(icmp6_rediraccept), 0, "");
SYSCTL_VNET_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRTIMEOUT, redirtimeout,
CTLFLAG_RW, &VNET_NAME(icmp6_redirtimeout), 0, "");
SYSCTL_VNET_STRUCT(_net_inet6_icmp6, ICMPV6CTL_STATS, stats, CTLFLAG_RW,
&VNET_NAME(icmp6stat), icmp6stat, "");
SYSCTL_VNET_PCPUSTAT(_net_inet6_icmp6, ICMPV6CTL_STATS, stats,
struct icmp6stat, icmp6stat,
"ICMPv6 statistics (struct icmp6stat, netinet/icmp6.h)");
SYSCTL_VNET_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_PRUNE, nd6_prune, CTLFLAG_RW,
&VNET_NAME(nd6_prune), 0, "");
SYSCTL_VNET_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_DELAY, nd6_delay, CTLFLAG_RW,

View File

@ -534,8 +534,6 @@ extern struct rwlock in6_ifaddr_lock;
#define IN6_IFADDR_WLOCK_ASSERT() rw_assert(&in6_ifaddr_lock, RA_WLOCKED)
#define IN6_IFADDR_WUNLOCK() rw_wunlock(&in6_ifaddr_lock)
VNET_DECLARE(struct icmp6stat, icmp6stat);
#define V_icmp6stat VNET(icmp6stat)
#define in6_ifstat_inc(ifp, tag) \
do { \
if (ifp) \

View File

@ -141,7 +141,11 @@ VNET_DECLARE(struct callout, in6_tmpaddrtimer_ch);
VNET_DEFINE(struct pfil_head, inet6_pfil_hook);
VNET_DEFINE(struct ip6stat, ip6stat);
VNET_PCPUSTAT_DEFINE(struct ip6stat, ip6stat);
VNET_PCPUSTAT_SYSINIT(ip6stat);
#ifdef VIMAGE
VNET_PCPUSTAT_SYSUNINIT(ip6stat);
#endif /* VIMAGE */
struct rwlock in6_ifaddr_lock;
RW_SYSINIT(in6_ifaddr_lock, &in6_ifaddr_lock, "in6_ifaddr_lock");

View File

@ -246,8 +246,12 @@ struct ip6stat {
};
#ifdef _KERNEL
#define IP6STAT_ADD(name, val) V_ip6stat.name += (val)
#define IP6STAT_SUB(name, val) V_ip6stat.name -= (val)
#include <sys/counter.h>
VNET_PCPUSTAT_DECLARE(struct ip6stat, ip6stat);
#define IP6STAT_ADD(name, val) \
VNET_PCPUSTAT_ADD(struct ip6stat, ip6stat, name, (val))
#define IP6STAT_SUB(name, val) IP6STAT_ADD(name, -(val))
#define IP6STAT_INC(name) IP6STAT_ADD(name, 1)
#define IP6STAT_DEC(name) IP6STAT_SUB(name, 1)
#endif
@ -297,7 +301,6 @@ struct ip6aux {
#define IP6_HDR_ALIGNED_P(ip) ((((intptr_t) (ip)) & 3) == 0)
#endif
VNET_DECLARE(struct ip6stat, ip6stat); /* statistics */
VNET_DECLARE(int, ip6_defhlim); /* default hop limit */
VNET_DECLARE(int, ip6_defmcasthlim); /* default multicast hop limit */
VNET_DECLARE(int, ip6_forwarding); /* act as router? */
@ -306,7 +309,6 @@ VNET_DECLARE(int, ip6_rr_prune); /* router renumbering prefix
* walk list every 5 sec. */
VNET_DECLARE(int, ip6_mcast_pmtu); /* enable pMTU discovery for multicast? */
VNET_DECLARE(int, ip6_v6only);
#define V_ip6stat VNET(ip6stat)
#define V_ip6_defhlim VNET(ip6_defhlim)
#define V_ip6_defmcasthlim VNET(ip6_defmcasthlim)
#define V_ip6_forwarding VNET(ip6_forwarding)

View File

@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/errno.h>
#include <sys/jail.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
@ -124,7 +125,12 @@ VNET_DECLARE(struct inpcbinfo, ripcbinfo);
extern u_long rip_sendspace;
extern u_long rip_recvspace;
VNET_DEFINE(struct rip6stat, rip6stat);
VNET_PCPUSTAT_DEFINE(struct rip6stat, rip6stat);
VNET_PCPUSTAT_SYSINIT(rip6stat);
#ifdef VIMAGE
VNET_PCPUSTAT_SYSUNINIT(rip6stat);
#endif /* VIMAGE */
/*
* Hooks for multicast routing. They all default to NULL, so leave them not

View File

@ -48,10 +48,12 @@ struct rip6stat {
};
#ifdef _KERNEL
#define RIP6STAT_ADD(name, val) V_rip6stat.name += (val)
#include <sys/counter.h>
VNET_PCPUSTAT_DECLARE(struct rip6stat, rip6stat);
#define RIP6STAT_ADD(name, val) \
VNET_PCPUSTAT_ADD(struct rip6stat, rip6stat, name, (val))
#define RIP6STAT_INC(name) RIP6STAT_ADD(name, 1)
VNET_DECLARE(struct rip6stat, rip6stat);
#define V_rip6stat VNET(rip6stat)
#endif
#endif /* _KERNEL */
#endif

View File

@ -376,7 +376,7 @@ ip6_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
return;
}
} else
kread(off, &ip6stat, len);
kread_counters(off, &ip6stat, len);
printf("%s:\n", name);
@ -858,7 +858,7 @@ icmp6_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
return;
}
} else
kread(off, &icmp6stat, len);
kread_counters(off, &icmp6stat, len);
printf("%s:\n", name);
@ -1052,7 +1052,7 @@ rip6_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
return;
}
} else
kread(off, &rip6stat, len);
kread_counters(off, &rip6stat, len);
printf("%s:\n", name);