Convert routing statistics to VNET_PCPUSTAT.
Submitted by: ocochard Reviewed by: melifaro, glebius Differential Revision: https://reviews.freebsd.org/D22834
This commit is contained in:
parent
af1e30f8be
commit
185c3d2b93
@ -108,8 +108,15 @@ VNET_DEFINE(u_int, rt_add_addr_allfibs) = 1;
|
||||
SYSCTL_UINT(_net, OID_AUTO, add_addr_allfibs, CTLFLAG_RWTUN | CTLFLAG_VNET,
|
||||
&VNET_NAME(rt_add_addr_allfibs), 0, "");
|
||||
|
||||
VNET_DEFINE(struct rtstat, rtstat);
|
||||
#define V_rtstat VNET(rtstat)
|
||||
VNET_PCPUSTAT_DEFINE_STATIC(struct rtstat, rtstat);
|
||||
#define RTSTAT_ADD(name, val) \
|
||||
VNET_PCPUSTAT_ADD(struct rtstat, rtstat, name, (val))
|
||||
#define RTSTAT_INC(name) RTSTAT_ADD(name, 1)
|
||||
|
||||
VNET_PCPUSTAT_SYSINIT(rtstat);
|
||||
#ifdef VIMAGE
|
||||
VNET_PCPUSTAT_SYSUNINIT(rtstat);
|
||||
#endif
|
||||
|
||||
VNET_DEFINE(struct rib_head *, rt_tables);
|
||||
#define V_rt_tables VNET(rt_tables)
|
||||
@ -476,7 +483,7 @@ rtalloc1_fib(struct sockaddr *dst, int report, u_long ignflags,
|
||||
* which basically means: "cannot get there from here".
|
||||
*/
|
||||
miss:
|
||||
V_rtstat.rts_unreach++;
|
||||
RTSTAT_INC(rts_unreach);
|
||||
|
||||
if (report) {
|
||||
/*
|
||||
@ -587,7 +594,6 @@ rtredirect_fib(struct sockaddr *dst,
|
||||
{
|
||||
struct rtentry *rt;
|
||||
int error = 0;
|
||||
short *stat = NULL;
|
||||
struct rt_addrinfo info;
|
||||
struct ifaddr *ifa;
|
||||
struct rib_head *rnh;
|
||||
@ -661,8 +667,8 @@ rtredirect_fib(struct sockaddr *dst,
|
||||
RT_LOCK(rt);
|
||||
flags = rt->rt_flags;
|
||||
}
|
||||
|
||||
stat = &V_rtstat.rts_dynamic;
|
||||
if (error == 0)
|
||||
RTSTAT_INC(rts_dynamic);
|
||||
} else {
|
||||
|
||||
/*
|
||||
@ -673,7 +679,7 @@ rtredirect_fib(struct sockaddr *dst,
|
||||
rt->rt_flags &= ~RTF_GATEWAY;
|
||||
rt->rt_flags |= RTF_MODIFIED;
|
||||
flags |= RTF_MODIFIED;
|
||||
stat = &V_rtstat.rts_newgateway;
|
||||
RTSTAT_INC(rts_newgateway);
|
||||
/*
|
||||
* add the key and gateway (in one malloc'd chunk).
|
||||
*/
|
||||
@ -690,9 +696,7 @@ rtredirect_fib(struct sockaddr *dst,
|
||||
RTFREE_LOCKED(rt);
|
||||
out:
|
||||
if (error)
|
||||
V_rtstat.rts_badredirect++;
|
||||
else if (stat != NULL)
|
||||
(*stat)++;
|
||||
RTSTAT_INC(rts_badredirect);
|
||||
bzero((caddr_t)&info, sizeof(info));
|
||||
info.rti_info[RTAX_DST] = dst;
|
||||
info.rti_info[RTAX_GATEWAY] = gateway;
|
||||
|
@ -237,13 +237,14 @@ rt_update_ro_flags(struct route *ro)
|
||||
/*
|
||||
* Routing statistics.
|
||||
*/
|
||||
struct rtstat {
|
||||
short rts_badredirect; /* bogus redirect calls */
|
||||
short rts_dynamic; /* routes created by redirects */
|
||||
short rts_newgateway; /* routes modified by redirects */
|
||||
short rts_unreach; /* lookups which failed */
|
||||
short rts_wildcard; /* lookups satisfied by a wildcard */
|
||||
struct rtstat {
|
||||
uint64_t rts_badredirect; /* bogus redirect calls */
|
||||
uint64_t rts_dynamic; /* routes created by redirects */
|
||||
uint64_t rts_newgateway; /* routes modified by redirects */
|
||||
uint64_t rts_unreach; /* lookups which failed */
|
||||
uint64_t rts_wildcard; /* lookups satisfied by a wildcard */
|
||||
};
|
||||
|
||||
/*
|
||||
* Structures for routing messages.
|
||||
*/
|
||||
|
@ -776,22 +776,22 @@ rt_stats(void)
|
||||
xo_emit("{W:rttrash: symbol not in namelist}\n");
|
||||
return;
|
||||
}
|
||||
kread(rtsaddr, (char *)&rtstat, sizeof (rtstat));
|
||||
kread_counters(rtsaddr, (char *)&rtstat, sizeof (rtstat));
|
||||
kread(rttaddr, (char *)&rttrash, sizeof (rttrash));
|
||||
xo_emit("{T:routing}:\n");
|
||||
|
||||
#define p(f, m) if (rtstat.f || sflag <= 1) \
|
||||
xo_emit(m, rtstat.f, plural(rtstat.f))
|
||||
|
||||
p(rts_badredirect, "\t{:bad-redirects/%hu} "
|
||||
p(rts_badredirect, "\t{:bad-redirects/%ju} "
|
||||
"{N:/bad routing redirect%s}\n");
|
||||
p(rts_dynamic, "\t{:dynamically-created/%hu} "
|
||||
p(rts_dynamic, "\t{:dynamically-created/%ju} "
|
||||
"{N:/dynamically created route%s}\n");
|
||||
p(rts_newgateway, "\t{:new-gateways/%hu} "
|
||||
p(rts_newgateway, "\t{:new-gateways/%ju} "
|
||||
"{N:/new gateway%s due to redirects}\n");
|
||||
p(rts_unreach, "\t{:unreachable-destination/%hu} "
|
||||
p(rts_unreach, "\t{:unreachable-destination/%ju} "
|
||||
"{N:/destination%s found unreachable}\n");
|
||||
p(rts_wildcard, "\t{:wildcard-uses/%hu} "
|
||||
p(rts_wildcard, "\t{:wildcard-uses/%ju} "
|
||||
"{N:/use%s of a wildcard route}\n");
|
||||
#undef p
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user