Migrate structs arpstat, icmpstat, mrtstat, pimstat and udpstat to PCPU
counters.
This commit is contained in:
parent
5da0521fce
commit
5b7cb97c2b
@ -127,13 +127,21 @@ struct arpstat {
|
||||
uint64_t dupips; /* # of duplicate IPs detected. */
|
||||
};
|
||||
|
||||
#ifdef _KERNEL
|
||||
#include <sys/counter.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
VNET_PCPUSTAT_DECLARE(struct arpstat, arpstat);
|
||||
/*
|
||||
* In-kernel consumers can use these accessor macros directly to update
|
||||
* stats.
|
||||
*/
|
||||
#define ARPSTAT_ADD(name, val) V_arpstat.name += (val)
|
||||
#define ARPSTAT_SUB(name, val) V_arpstat.name -= (val)
|
||||
#define ARPSTAT_ADD(name, val) \
|
||||
VNET_PCPUSTAT_ADD(struct arpstat, arpstat, name, (val))
|
||||
#define ARPSTAT_SUB(name, val) ARPSTAT_ADD(name, -(val))
|
||||
#define ARPSTAT_INC(name) ARPSTAT_ADD(name, 1)
|
||||
#define ARPSTAT_DEC(name) ARPSTAT_SUB(name, 1)
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* !_NET_IF_ARP_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
|
||||
|
@ -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");
|
||||
|
@ -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).
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -756,7 +756,7 @@ udp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
|
||||
return;
|
||||
}
|
||||
} else
|
||||
kread(off, &udpstat, len);
|
||||
kread_counters(off, &udpstat, len);
|
||||
|
||||
printf("%s:\n", name);
|
||||
#define p(f, m) if (udpstat.f || sflag <= 1) \
|
||||
@ -923,7 +923,7 @@ arp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
|
||||
return;
|
||||
}
|
||||
} else
|
||||
kread(off, &arpstat, len);
|
||||
kread_counters(off, &arpstat, len);
|
||||
|
||||
printf("%s:\n", name);
|
||||
|
||||
@ -1010,7 +1010,7 @@ icmp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
|
||||
return;
|
||||
}
|
||||
} else
|
||||
kread(off, &icmpstat, len);
|
||||
kread_counters(off, &icmpstat, len);
|
||||
|
||||
printf("%s:\n", name);
|
||||
|
||||
@ -1217,7 +1217,7 @@ pim_stats(u_long off __unused, const char *name, int af1 __unused,
|
||||
} else {
|
||||
if (off == 0)
|
||||
return;
|
||||
kread(off, &pimstat, len);
|
||||
kread_counters(off, &pimstat, len);
|
||||
}
|
||||
|
||||
printf("%s:\n", name);
|
||||
|
@ -350,7 +350,7 @@ mrt_stats(u_long mstaddr)
|
||||
return;
|
||||
}
|
||||
} else
|
||||
kread(mstaddr, (char *)&mrtstat, sizeof(mrtstat));
|
||||
kread_counters(mstaddr, &mrtstat, len);
|
||||
|
||||
printf("IPv4 multicast forwarding:\n");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user