FreeBSD kernel IPv4 code
tcp_stats.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/arb.h>
#include <sys/errno.h>
#include <sys/malloc.h>
#include <sys/qmath.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/sysctl.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/rmlock.h>
#include <sys/systm.h>
#include <sys/stats.h>
#include <net/vnet.h>
#include <netinet/in.h>
#include <netinet/in_pcb.h>
#include <netinet/tcp.h>
#include <netinet/tcp_var.h>
#include <netinet/cc/cc.h>
Include dependency graph for tcp_stats.c:

Go to the source code of this file.

Macros

#define V_tcp_perconn_stats_sample_rates   VNET(tcp_perconn_stats_sample_rates)
 
#define V_tcp_stats_nrates   VNET(tcp_stats_nrates)
 

Functions

 __FBSDID ("$FreeBSD$")
 
 VNET_DEFINE (int, tcp_perconn_stats_dflt_tpl)
 
 VNET_DEFINE (int, tcp_perconn_stats_enable)
 
 VNET_DEFINE_STATIC (struct stats_tpl_sample_rate *, tcp_perconn_stats_sample_rates)
 
 VNET_DEFINE_STATIC (int, tcp_stats_nrates)=0
 
static int tcp_stats_tpl_sr_cb (enum stats_tpl_sr_cb_action action, struct stats_tpl_sample_rate **rates, int *nrates, void *ctx)
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, perconn_stats_enable, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_perconn_stats_enable), 0, "Enable per-connection TCP stats gathering; 1 enables for all connections, " "2 enables random sampling across log id connection groups")
 
 SYSCTL_PROC (_net_inet_tcp, OID_AUTO, perconn_stats_sample_rates, CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_NEEDGIANT, tcp_stats_tpl_sr_cb, sizeof(struct rm_priotracker), stats_tpl_sample_rates, "A", "TCP stats per template random sampling rates, in CSV tpl_spec=percent " "key-value pairs (see stats(9) for template spec details)")
 
int tcp_stats_init ()
 
int tcp_stats_sample_rollthedice (struct tcpcb *tp, void *seed_bytes, size_t seed_len)
 
 RM_SYSINIT (tcp_stats_tpl_sampling_lock, &tcp_stats_tpl_sampling_lock, "tcp_stats_tpl_sampling_lock")
 

Variables

static struct rmlock tcp_stats_tpl_sampling_lock
 

Macro Definition Documentation

◆ V_tcp_perconn_stats_sample_rates

#define V_tcp_perconn_stats_sample_rates   VNET(tcp_perconn_stats_sample_rates)

Definition at line 70 of file tcp_stats.c.

◆ V_tcp_stats_nrates

#define V_tcp_stats_nrates   VNET(tcp_stats_nrates)

Definition at line 71 of file tcp_stats.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ RM_SYSINIT()

RM_SYSINIT ( tcp_stats_tpl_sampling_lock  ,
tcp_stats_tpl_sampling_lock,
"tcp_stats_tpl_sampling_lock"   
)

◆ SYSCTL_INT()

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
perconn_stats_enable  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_perconn_stats_enable,
,
"Enable per-connection TCP stats gathering; 1 enables for all  connections,
" "2 enables random sampling across log id connection groups"   
)

◆ SYSCTL_PROC()

SYSCTL_PROC ( _net_inet_tcp  ,
OID_AUTO  ,
perconn_stats_sample_rates  ,
CTLTYPE_STRING|CTLFLAG_RW|  CTLFLAG_NEEDGIANT,
tcp_stats_tpl_sr_cb  ,
sizeof(struct rm_priotracker)  ,
stats_tpl_sample_rates  ,
"A"  ,
"TCP stats per template random sampling  rates 
)

◆ tcp_stats_init()

int tcp_stats_init ( void  )

Definition at line 95 of file tcp_stats.c.

References CC_ECN, CC_NDUPACK, CC_RTO, CC_RTO_ERR, VOI_TCP_ACKLEN, VOI_TCP_CALCFRWINDIFF, VOI_TCP_CSIG, VOI_TCP_FRWIN, VOI_TCP_GPUT, VOI_TCP_GPUT_ND, VOI_TCP_LCWIN, VOI_TCP_RETXPB, VOI_TCP_RTT, and VOI_TCP_TXPB.

Referenced by tcp_vnet_init().

Here is the caller graph for this function:

◆ tcp_stats_sample_rollthedice()

int tcp_stats_sample_rollthedice ( struct tcpcb tp,
void *  seed_bytes,
size_t  seed_len 
)

Definition at line 187 of file tcp_stats.c.

References INP_WLOCK_ASSERT, tcpcb::t_inpcb, tcpcb::t_stats, tcp_stats_tpl_sampling_lock, V_tcp_perconn_stats_sample_rates, and V_tcp_stats_nrates.

Referenced by tcp_log_grow_tlb().

Here is the caller graph for this function:

◆ tcp_stats_tpl_sr_cb()

int tcp_stats_tpl_sr_cb ( enum stats_tpl_sr_cb_action  action,
struct stats_tpl_sample_rate **  rates,
int *  nrates,
void *  ctx 
)
static

◆ VNET_DEFINE() [1/2]

VNET_DEFINE ( int  ,
tcp_perconn_stats_dflt_tpl   
)

◆ VNET_DEFINE() [2/2]

VNET_DEFINE ( int  ,
tcp_perconn_stats_enable   
)

◆ VNET_DEFINE_STATIC() [1/2]

VNET_DEFINE_STATIC ( int  ,
tcp_stats_nrates   
)
pure virtual

◆ VNET_DEFINE_STATIC() [2/2]

VNET_DEFINE_STATIC ( struct stats_tpl_sample_rate *  ,
tcp_perconn_stats_sample_rates   
)

Variable Documentation

◆ tcp_stats_tpl_sampling_lock

struct rmlock tcp_stats_tpl_sampling_lock
static

Definition at line 73 of file tcp_stats.c.

Referenced by tcp_stats_sample_rollthedice(), and tcp_stats_tpl_sr_cb().