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
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=355840
@ -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,
|
SYSCTL_UINT(_net, OID_AUTO, add_addr_allfibs, CTLFLAG_RWTUN | CTLFLAG_VNET,
|
||||||
&VNET_NAME(rt_add_addr_allfibs), 0, "");
|
&VNET_NAME(rt_add_addr_allfibs), 0, "");
|
||||||
|
|
||||||
VNET_DEFINE(struct rtstat, rtstat);
|
VNET_PCPUSTAT_DEFINE_STATIC(struct rtstat, rtstat);
|
||||||
#define V_rtstat VNET(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);
|
VNET_DEFINE(struct rib_head *, rt_tables);
|
||||||
#define V_rt_tables VNET(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".
|
* which basically means: "cannot get there from here".
|
||||||
*/
|
*/
|
||||||
miss:
|
miss:
|
||||||
V_rtstat.rts_unreach++;
|
RTSTAT_INC(rts_unreach);
|
||||||
|
|
||||||
if (report) {
|
if (report) {
|
||||||
/*
|
/*
|
||||||
@ -587,7 +594,6 @@ rtredirect_fib(struct sockaddr *dst,
|
|||||||
{
|
{
|
||||||
struct rtentry *rt;
|
struct rtentry *rt;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
short *stat = NULL;
|
|
||||||
struct rt_addrinfo info;
|
struct rt_addrinfo info;
|
||||||
struct ifaddr *ifa;
|
struct ifaddr *ifa;
|
||||||
struct rib_head *rnh;
|
struct rib_head *rnh;
|
||||||
@ -661,8 +667,8 @@ rtredirect_fib(struct sockaddr *dst,
|
|||||||
RT_LOCK(rt);
|
RT_LOCK(rt);
|
||||||
flags = rt->rt_flags;
|
flags = rt->rt_flags;
|
||||||
}
|
}
|
||||||
|
if (error == 0)
|
||||||
stat = &V_rtstat.rts_dynamic;
|
RTSTAT_INC(rts_dynamic);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -673,7 +679,7 @@ rtredirect_fib(struct sockaddr *dst,
|
|||||||
rt->rt_flags &= ~RTF_GATEWAY;
|
rt->rt_flags &= ~RTF_GATEWAY;
|
||||||
rt->rt_flags |= RTF_MODIFIED;
|
rt->rt_flags |= RTF_MODIFIED;
|
||||||
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).
|
* add the key and gateway (in one malloc'd chunk).
|
||||||
*/
|
*/
|
||||||
@ -690,9 +696,7 @@ rtredirect_fib(struct sockaddr *dst,
|
|||||||
RTFREE_LOCKED(rt);
|
RTFREE_LOCKED(rt);
|
||||||
out:
|
out:
|
||||||
if (error)
|
if (error)
|
||||||
V_rtstat.rts_badredirect++;
|
RTSTAT_INC(rts_badredirect);
|
||||||
else if (stat != NULL)
|
|
||||||
(*stat)++;
|
|
||||||
bzero((caddr_t)&info, sizeof(info));
|
bzero((caddr_t)&info, sizeof(info));
|
||||||
info.rti_info[RTAX_DST] = dst;
|
info.rti_info[RTAX_DST] = dst;
|
||||||
info.rti_info[RTAX_GATEWAY] = gateway;
|
info.rti_info[RTAX_GATEWAY] = gateway;
|
||||||
|
@ -237,13 +237,14 @@ rt_update_ro_flags(struct route *ro)
|
|||||||
/*
|
/*
|
||||||
* Routing statistics.
|
* Routing statistics.
|
||||||
*/
|
*/
|
||||||
struct rtstat {
|
struct rtstat {
|
||||||
short rts_badredirect; /* bogus redirect calls */
|
uint64_t rts_badredirect; /* bogus redirect calls */
|
||||||
short rts_dynamic; /* routes created by redirects */
|
uint64_t rts_dynamic; /* routes created by redirects */
|
||||||
short rts_newgateway; /* routes modified by redirects */
|
uint64_t rts_newgateway; /* routes modified by redirects */
|
||||||
short rts_unreach; /* lookups which failed */
|
uint64_t rts_unreach; /* lookups which failed */
|
||||||
short rts_wildcard; /* lookups satisfied by a wildcard */
|
uint64_t rts_wildcard; /* lookups satisfied by a wildcard */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Structures for routing messages.
|
* Structures for routing messages.
|
||||||
*/
|
*/
|
||||||
|
@ -776,22 +776,22 @@ rt_stats(void)
|
|||||||
xo_emit("{W:rttrash: symbol not in namelist}\n");
|
xo_emit("{W:rttrash: symbol not in namelist}\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
kread(rtsaddr, (char *)&rtstat, sizeof (rtstat));
|
kread_counters(rtsaddr, (char *)&rtstat, sizeof (rtstat));
|
||||||
kread(rttaddr, (char *)&rttrash, sizeof (rttrash));
|
kread(rttaddr, (char *)&rttrash, sizeof (rttrash));
|
||||||
xo_emit("{T:routing}:\n");
|
xo_emit("{T:routing}:\n");
|
||||||
|
|
||||||
#define p(f, m) if (rtstat.f || sflag <= 1) \
|
#define p(f, m) if (rtstat.f || sflag <= 1) \
|
||||||
xo_emit(m, rtstat.f, plural(rtstat.f))
|
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");
|
"{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");
|
"{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");
|
"{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");
|
"{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");
|
"{N:/use%s of a wildcard route}\n");
|
||||||
#undef p
|
#undef p
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user