FreeBSD kernel IPv4 code
tcp_pcap.c File Reference
#include <sys/queue.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
#include <sys/eventhandler.h>
#include <machine/atomic.h>
#include <netinet/tcp_var.h>
#include <netinet/tcp_pcap.h>
Include dependency graph for tcp_pcap.c:

Go to the source code of this file.

Macros

#define M_LEADINGSPACE_NOWRITE(m)    ((m)->m_data - M_START(m))
 
#define V_tcp_pcap_packets   VNET(tcp_pcap_packets)
 

Functions

 SYSCTL_INT (_net_inet_tcp, OID_AUTO, tcp_pcap_aggressive_free, CTLFLAG_RW, &tcp_pcap_aggressive_free, 0, "Free saved packets when the memory system comes under pressure")
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, tcp_pcap_clusters_referenced_cur, CTLFLAG_RD, &tcp_pcap_clusters_referenced_cur, 0, "Number of clusters currently referenced on TCP PCAP queues")
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, tcp_pcap_clusters_referenced_max, CTLFLAG_RW, &tcp_pcap_clusters_referenced_max, 0, "Maximum number of clusters allowed to be referenced on TCP PCAP " "queues")
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, tcp_pcap_alloc_reuse_ext, CTLFLAG_RD, &tcp_pcap_alloc_reuse_ext, 0, "Number of mbufs with external storage reused for the TCP PCAP " "functionality")
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, tcp_pcap_alloc_reuse_mbuf, CTLFLAG_RD, &tcp_pcap_alloc_reuse_mbuf, 0, "Number of mbufs with internal storage reused for the TCP PCAP " "functionality")
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, tcp_pcap_alloc_new_mbuf, CTLFLAG_RD, &tcp_pcap_alloc_new_mbuf, 0, "Number of new mbufs allocated for the TCP PCAP functionality")
 
 VNET_DEFINE (int, tcp_pcap_packets)=0
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, tcp_pcap_packets, CTLFLAG_RW, &VNET_NAME(tcp_pcap_packets), 0, "Default number of packets saved per direction per TCPCB")
 
static void tcp_pcap_max_set (void)
 
void tcp_pcap_init (void)
 
static __inline bool tcp_pcap_take_cluster_reference (void)
 
static __inline void tcp_pcap_adj_cluster_reference (struct mbuf *m, int adj)
 
static void tcp_pcap_m_freem (struct mbuf *mb)
 
static void tcp_pcap_copy_bestfit (struct tcphdr *th, struct mbuf *m, struct mbuf *n)
 
void tcp_pcap_add (struct tcphdr *th, struct mbuf *m, struct mbufq *queue)
 
void tcp_pcap_drain (struct mbufq *queue)
 
void tcp_pcap_tcpcb_init (struct tcpcb *tp)
 
void tcp_pcap_set_sock_max (struct mbufq *queue, int newval)
 
int tcp_pcap_get_sock_max (struct mbufq *queue)
 

Variables

int tcp_pcap_aggressive_free = 1
 
static int tcp_pcap_clusters_referenced_cur = 0
 
static int tcp_pcap_clusters_referenced_max = 0
 
static int tcp_pcap_alloc_reuse_ext = 0
 
static int tcp_pcap_alloc_reuse_mbuf = 0
 
static int tcp_pcap_alloc_new_mbuf = 0
 

Macro Definition Documentation

◆ M_LEADINGSPACE_NOWRITE

#define M_LEADINGSPACE_NOWRITE (   m)     ((m)->m_data - M_START(m))

Definition at line 42 of file tcp_pcap.c.

◆ V_tcp_pcap_packets

#define V_tcp_pcap_packets   VNET(tcp_pcap_packets)

Definition at line 76 of file tcp_pcap.c.

Function Documentation

◆ SYSCTL_INT() [1/7]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
tcp_pcap_aggressive_free  ,
CTLFLAG_RW  ,
tcp_pcap_aggressive_free,
,
"Free saved packets when the memory system comes under pressure"   
)

◆ SYSCTL_INT() [2/7]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
tcp_pcap_alloc_new_mbuf  ,
CTLFLAG_RD  ,
tcp_pcap_alloc_new_mbuf,
,
"Number of new mbufs allocated for the TCP PCAP functionality"   
)

◆ SYSCTL_INT() [3/7]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
tcp_pcap_alloc_reuse_ext  ,
CTLFLAG_RD  ,
tcp_pcap_alloc_reuse_ext,
,
"Number of mbufs with external storage reused for the TCP PCAP " "functionality"   
)

◆ SYSCTL_INT() [4/7]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
tcp_pcap_alloc_reuse_mbuf  ,
CTLFLAG_RD  ,
tcp_pcap_alloc_reuse_mbuf,
,
"Number of mbufs with internal storage reused for the TCP PCAP " "functionality"   
)

◆ SYSCTL_INT() [5/7]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
tcp_pcap_clusters_referenced_cur  ,
CTLFLAG_RD  ,
tcp_pcap_clusters_referenced_cur,
,
"Number of clusters currently referenced on TCP PCAP queues"   
)

◆ SYSCTL_INT() [6/7]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
tcp_pcap_clusters_referenced_max  ,
CTLFLAG_RW  ,
tcp_pcap_clusters_referenced_max,
,
"Maximum number of clusters allowed to be referenced on TCP PCAP " "queues"   
)

◆ SYSCTL_INT() [7/7]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
tcp_pcap_packets  ,
CTLFLAG_RW  ,
VNET_NAMEtcp_pcap_packets,
,
"Default number of packets saved per direction per TCPCB"   
)

◆ tcp_pcap_add()

void tcp_pcap_add ( struct tcphdr *  th,
struct mbuf *  m,
struct mbufq *  queue 
)

◆ tcp_pcap_adj_cluster_reference()

static __inline void tcp_pcap_adj_cluster_reference ( struct mbuf *  m,
int  adj 
)
static

Definition at line 120 of file tcp_pcap.c.

References tcp_pcap_clusters_referenced_cur.

Referenced by tcp_pcap_add().

Here is the caller graph for this function:

◆ tcp_pcap_copy_bestfit()

static void tcp_pcap_copy_bestfit ( struct tcphdr *  th,
struct mbuf *  m,
struct mbuf *  n 
)
static

Definition at line 159 of file tcp_pcap.c.

Referenced by tcp_pcap_add().

Here is the caller graph for this function:

◆ tcp_pcap_drain()

void tcp_pcap_drain ( struct mbufq *  queue)

Definition at line 426 of file tcp_pcap.c.

References tcp_pcap_m_freem().

Referenced by tcp_discardcb(), and tcp_drain().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tcp_pcap_get_sock_max()

int tcp_pcap_get_sock_max ( struct mbufq *  queue)

Definition at line 449 of file tcp_pcap.c.

Referenced by tcp_default_ctloutput().

Here is the caller graph for this function:

◆ tcp_pcap_init()

void tcp_pcap_init ( void  )

Definition at line 90 of file tcp_pcap.c.

References tcp_pcap_max_set().

Referenced by tcp_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tcp_pcap_m_freem()

static void tcp_pcap_m_freem ( struct mbuf *  mb)
static

Definition at line 139 of file tcp_pcap.c.

References tcp_pcap_clusters_referenced_cur.

Referenced by tcp_pcap_add(), tcp_pcap_drain(), and tcp_pcap_set_sock_max().

Here is the caller graph for this function:

◆ tcp_pcap_max_set()

static void tcp_pcap_max_set ( void  )
static

Definition at line 83 of file tcp_pcap.c.

References tcp_pcap_clusters_referenced_max.

Referenced by tcp_pcap_init().

Here is the caller graph for this function:

◆ tcp_pcap_set_sock_max()

void tcp_pcap_set_sock_max ( struct mbufq *  queue,
int  newval 
)

Definition at line 441 of file tcp_pcap.c.

References tcp_pcap_m_freem().

Referenced by tcp_default_ctloutput().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tcp_pcap_take_cluster_reference()

static __inline bool tcp_pcap_take_cluster_reference ( void  )
static

Definition at line 104 of file tcp_pcap.c.

References tcp_pcap_clusters_referenced_cur, and tcp_pcap_clusters_referenced_max.

Referenced by tcp_pcap_add().

Here is the caller graph for this function:

◆ tcp_pcap_tcpcb_init()

void tcp_pcap_tcpcb_init ( struct tcpcb tp)

Definition at line 434 of file tcp_pcap.c.

References V_tcp_pcap_packets.

Referenced by tcp_newtcpcb().

Here is the caller graph for this function:

◆ VNET_DEFINE()

VNET_DEFINE ( int  ,
tcp_pcap_packets   
)
pure virtual

Variable Documentation

◆ tcp_pcap_aggressive_free

int tcp_pcap_aggressive_free = 1

Definition at line 45 of file tcp_pcap.c.

Referenced by tcp_drain().

◆ tcp_pcap_alloc_new_mbuf

int tcp_pcap_alloc_new_mbuf = 0
static

Definition at line 62 of file tcp_pcap.c.

Referenced by tcp_pcap_add().

◆ tcp_pcap_alloc_reuse_ext

int tcp_pcap_alloc_reuse_ext = 0
static

Definition at line 60 of file tcp_pcap.c.

Referenced by tcp_pcap_add().

◆ tcp_pcap_alloc_reuse_mbuf

int tcp_pcap_alloc_reuse_mbuf = 0
static

Definition at line 61 of file tcp_pcap.c.

Referenced by tcp_pcap_add().

◆ tcp_pcap_clusters_referenced_cur

int tcp_pcap_clusters_referenced_cur = 0
static

◆ tcp_pcap_clusters_referenced_max

int tcp_pcap_clusters_referenced_max = 0
static

Definition at line 47 of file tcp_pcap.c.

Referenced by tcp_pcap_max_set(), and tcp_pcap_take_cluster_reference().