FreeBSD kernel IPv4 code
|
#include <sys/cdefs.h>
#include "opt_inet6.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/hash.h>
#include <sys/jail.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/malloc.h>
#include <sys/proc.h>
#include <sys/sbuf.h>
#include <sys/smr.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/sysctl.h>
#include <net/vnet.h>
#include <netinet/in.h>
#include <netinet/in_pcb.h>
#include <netinet/tcp.h>
#include <netinet/tcp_var.h>
#include <vm/uma.h>
Go to the source code of this file.
Data Structures | |
struct | hc_head |
struct | hc_metrics |
struct | tcp_hostcache |
Macros | |
#define | TCP_HOSTCACHE_HASHSIZE 512 |
#define | TCP_HOSTCACHE_BUCKETLIMIT 30 |
#define | TCP_HOSTCACHE_EXPIRE 60*60 /* one hour */ |
#define | TCP_HOSTCACHE_PRUNE 5*60 /* every 5 minutes */ |
#define | V_tcp_hostcache VNET(tcp_hostcache) |
#define | V_tcp_hc_callout VNET(tcp_hc_callout) |
#define | V_tcp_use_hostcache VNET(tcp_use_hostcache) |
#define | HOSTCACHE_HASH(inc) |
#define | THC_LOCK(h) mtx_lock(&(h)->hch_mtx) |
#define | THC_UNLOCK(h) mtx_unlock(&(h)->hch_mtx) |
#define | msec(u) (((u) + 500) / 1000) |
Functions | |
__FBSDID ("$FreeBSD$") | |
VNET_DEFINE_STATIC (struct tcp_hostcache, tcp_hostcache) | |
VNET_DEFINE_STATIC (struct callout, tcp_hc_callout) | |
static struct hc_metrics * | tcp_hc_lookup (struct in_conninfo *) |
static int | sysctl_tcp_hc_list (SYSCTL_HANDLER_ARGS) |
static int | sysctl_tcp_hc_histo (SYSCTL_HANDLER_ARGS) |
static int | sysctl_tcp_hc_purgenow (SYSCTL_HANDLER_ARGS) |
static void | tcp_hc_purge_internal (int) |
static void | tcp_hc_purge (void *) |
static | SYSCTL_NODE (_net_inet_tcp, OID_AUTO, hostcache, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "TCP Host cache") |
VNET_DEFINE (int, tcp_use_hostcache) | |
SYSCTL_INT (_net_inet_tcp_hostcache, OID_AUTO, enable, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_use_hostcache), 0, "Enable the TCP hostcache") | |
SYSCTL_UINT (_net_inet_tcp_hostcache, OID_AUTO, cachelimit, CTLFLAG_VNET|CTLFLAG_RDTUN, &VNET_NAME(tcp_hostcache.cache_limit), 0, "Overall entry limit for hostcache") | |
SYSCTL_UINT (_net_inet_tcp_hostcache, OID_AUTO, hashsize, CTLFLAG_VNET|CTLFLAG_RDTUN, &VNET_NAME(tcp_hostcache.hashsize), 0, "Size of TCP hostcache hashtable") | |
SYSCTL_UINT (_net_inet_tcp_hostcache, OID_AUTO, bucketlimit, CTLFLAG_VNET|CTLFLAG_RDTUN, &VNET_NAME(tcp_hostcache.bucket_limit), 0, "Per-bucket hash limit for hostcache") | |
SYSCTL_UINT (_net_inet_tcp_hostcache, OID_AUTO, count, CTLFLAG_VNET|CTLFLAG_RD, &VNET_NAME(tcp_hostcache.cache_count), 0, "Current number of entries in hostcache") | |
SYSCTL_INT (_net_inet_tcp_hostcache, OID_AUTO, expire, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_hostcache.expire), 0, "Expire time of TCP hostcache entries") | |
SYSCTL_INT (_net_inet_tcp_hostcache, OID_AUTO, prune, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_hostcache.prune), 0, "Time between purge runs") | |
SYSCTL_INT (_net_inet_tcp_hostcache, OID_AUTO, purge, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_hostcache.purgeall), 0, "Expire all entries on next purge run") | |
SYSCTL_PROC (_net_inet_tcp_hostcache, OID_AUTO, list, CTLTYPE_STRING|CTLFLAG_RD|CTLFLAG_SKIP|CTLFLAG_MPSAFE, 0, 0, sysctl_tcp_hc_list, "A", "List of all hostcache entries") | |
SYSCTL_PROC (_net_inet_tcp_hostcache, OID_AUTO, histo, CTLTYPE_STRING|CTLFLAG_RD|CTLFLAG_SKIP|CTLFLAG_MPSAFE, 0, 0, sysctl_tcp_hc_histo, "A", "Print a histogram of hostcache hashbucket utilization") | |
SYSCTL_PROC (_net_inet_tcp_hostcache, OID_AUTO, purgenow, CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_MPSAFE, NULL, 0, sysctl_tcp_hc_purgenow, "I", "Immediately purge all entries") | |
static | MALLOC_DEFINE (M_HOSTCACHE, "hostcache", "TCP hostcache") |
void | tcp_hc_init (void) |
static bool | tcp_hc_cmp (struct hc_metrics *hc_entry, struct in_conninfo *inc) |
void | tcp_hc_get (struct in_conninfo *inc, struct hc_metrics_lite *hc_metrics_lite) |
uint32_t | tcp_hc_getmtu (struct in_conninfo *inc) |
void | tcp_hc_updatemtu (struct in_conninfo *inc, uint32_t mtu) |
void | tcp_hc_update (struct in_conninfo *inc, struct hc_metrics_lite *hcml) |
#define HOSTCACHE_HASH | ( | inc | ) |
Definition at line 215 of file tcp_hostcache.c.
#define msec | ( | u | ) | (((u) + 500) / 1000) |
#define TCP_HOSTCACHE_BUCKETLIMIT 30 |
Definition at line 142 of file tcp_hostcache.c.
#define TCP_HOSTCACHE_EXPIRE 60*60 /* one hour */ |
Definition at line 143 of file tcp_hostcache.c.
#define TCP_HOSTCACHE_HASHSIZE 512 |
Definition at line 141 of file tcp_hostcache.c.
#define TCP_HOSTCACHE_PRUNE 5*60 /* every 5 minutes */ |
Definition at line 144 of file tcp_hostcache.c.
#define THC_LOCK | ( | h | ) | mtx_lock(&(h)->hch_mtx) |
Definition at line 223 of file tcp_hostcache.c.
#define THC_UNLOCK | ( | h | ) | mtx_unlock(&(h)->hch_mtx) |
Definition at line 224 of file tcp_hostcache.c.
#define V_tcp_hc_callout VNET(tcp_hc_callout) |
Definition at line 150 of file tcp_hostcache.c.
#define V_tcp_hostcache VNET(tcp_hostcache) |
Definition at line 147 of file tcp_hostcache.c.
#define V_tcp_use_hostcache VNET(tcp_use_hostcache) |
Definition at line 164 of file tcp_hostcache.c.
__FBSDID | ( | "$FreeBSD$" | ) |
|
static |
SYSCTL_INT | ( | _net_inet_tcp_hostcache | , |
OID_AUTO | , | ||
enable | , | ||
CTLFLAG_VNET| | CTLFLAG_RW, | ||
& | VNET_NAMEtcp_use_hostcache, | ||
0 | , | ||
"Enable the TCP hostcache" | |||
) |
SYSCTL_INT | ( | _net_inet_tcp_hostcache | , |
OID_AUTO | , | ||
expire | , | ||
CTLFLAG_VNET| | CTLFLAG_RW, | ||
& | VNET_NAMEtcp_hostcache.expire, | ||
0 | , | ||
"Expire time of TCP hostcache entries" | |||
) |
SYSCTL_INT | ( | _net_inet_tcp_hostcache | , |
OID_AUTO | , | ||
prune | , | ||
CTLFLAG_VNET| | CTLFLAG_RW, | ||
& | VNET_NAMEtcp_hostcache.prune, | ||
0 | , | ||
"Time between purge runs" | |||
) |
SYSCTL_INT | ( | _net_inet_tcp_hostcache | , |
OID_AUTO | , | ||
purge | , | ||
CTLFLAG_VNET| | CTLFLAG_RW, | ||
& | VNET_NAMEtcp_hostcache.purgeall, | ||
0 | , | ||
"Expire all entries on next purge run" | |||
) |
|
static |
SYSCTL_PROC | ( | _net_inet_tcp_hostcache | , |
OID_AUTO | , | ||
histo | , | ||
CTLTYPE_STRING|CTLFLAG_RD|CTLFLAG_SKIP| | CTLFLAG_MPSAFE, | ||
0 | , | ||
0 | , | ||
sysctl_tcp_hc_histo | , | ||
"A" | , | ||
"Print a histogram of hostcache hashbucket utilization" | |||
) |
SYSCTL_PROC | ( | _net_inet_tcp_hostcache | , |
OID_AUTO | , | ||
list | , | ||
CTLTYPE_STRING|CTLFLAG_RD|CTLFLAG_SKIP| | CTLFLAG_MPSAFE, | ||
0 | , | ||
0 | , | ||
sysctl_tcp_hc_list | , | ||
"A" | , | ||
"List of all hostcache entries" | |||
) |
SYSCTL_PROC | ( | _net_inet_tcp_hostcache | , |
OID_AUTO | , | ||
purgenow | , | ||
CTLTYPE_INT|CTLFLAG_RW| | CTLFLAG_MPSAFE, | ||
NULL | , | ||
0 | , | ||
sysctl_tcp_hc_purgenow | , | ||
"I" | , | ||
"Immediately purge all entries" | |||
) |
|
static |
Definition at line 716 of file tcp_hostcache.c.
References V_tcp_hostcache.
|
static |
Definition at line 630 of file tcp_hostcache.c.
References inet_ntoa_r(), msec, TCP_RTT_SCALE, TCP_RTTVAR_SCALE, THC_LOCK, THC_UNLOCK, and V_tcp_hostcache.
|
static |
Definition at line 830 of file tcp_hostcache.c.
References tcp_hc_purge(), tcp_hc_purge_internal(), V_tcp_hc_callout, and V_tcp_hostcache.
SYSCTL_UINT | ( | _net_inet_tcp_hostcache | , |
OID_AUTO | , | ||
bucketlimit | , | ||
CTLFLAG_VNET| | CTLFLAG_RDTUN, | ||
& | VNET_NAMEtcp_hostcache.bucket_limit, | ||
0 | , | ||
"Per-bucket hash limit for hostcache" | |||
) |
SYSCTL_UINT | ( | _net_inet_tcp_hostcache | , |
OID_AUTO | , | ||
cachelimit | , | ||
CTLFLAG_VNET| | CTLFLAG_RDTUN, | ||
& | VNET_NAMEtcp_hostcache.cache_limit, | ||
0 | , | ||
"Overall entry limit for hostcache" | |||
) |
SYSCTL_UINT | ( | _net_inet_tcp_hostcache | , |
OID_AUTO | , | ||
count | , | ||
CTLFLAG_VNET| | CTLFLAG_RD, | ||
& | VNET_NAMEtcp_hostcache.cache_count, | ||
0 | , | ||
"Current number of entries in hostcache" | |||
) |
SYSCTL_UINT | ( | _net_inet_tcp_hostcache | , |
OID_AUTO | , | ||
hashsize | , | ||
CTLFLAG_VNET| | CTLFLAG_RDTUN, | ||
& | VNET_NAMEtcp_hostcache.hashsize, | ||
0 | , | ||
"Size of TCP hostcache hashtable" | |||
) |
|
static |
Definition at line 318 of file tcp_hostcache.c.
References in_conninfo::inc_flags, and INC_ISIPV6.
Referenced by tcp_hc_lookup(), and tcp_hc_update().
void tcp_hc_get | ( | struct in_conninfo * | inc, |
struct hc_metrics_lite * | hc_metrics_lite | ||
) |
Definition at line 377 of file tcp_hostcache.c.
References hc_metrics_lite::rmx_cwnd, hc_metrics_lite::rmx_mtu, hc_metrics_lite::rmx_recvpipe, hc_metrics_lite::rmx_rtt, hc_metrics_lite::rmx_rttvar, hc_metrics_lite::rmx_sendpipe, hc_metrics_lite::rmx_ssthresh, tcp_hc_lookup(), V_tcp_hostcache, and V_tcp_use_hostcache.
Referenced by cc_conn_init(), and tcp_mss_update().
uint32_t tcp_hc_getmtu | ( | struct in_conninfo * | inc | ) |
Definition at line 416 of file tcp_hostcache.c.
References tcp_hc_lookup(), V_tcp_hostcache, and V_tcp_use_hostcache.
Referenced by sctp_hc_get_mtu(), and tcp_mssopt().
void tcp_hc_init | ( | void | ) |
Definition at line 227 of file tcp_hostcache.c.
References tcp_hc_purge(), TCP_HOSTCACHE_BUCKETLIMIT, TCP_HOSTCACHE_EXPIRE, TCP_HOSTCACHE_HASHSIZE, TCP_HOSTCACHE_PRUNE, V_tcp_hc_callout, and V_tcp_hostcache.
Referenced by tcp_vnet_init().
|
static |
Definition at line 340 of file tcp_hostcache.c.
References HOSTCACHE_HASH, tcp_hc_cmp(), and V_tcp_hostcache.
Referenced by tcp_hc_get(), and tcp_hc_getmtu().
|
static |
Definition at line 807 of file tcp_hostcache.c.
References tcp_hc_purge(), tcp_hc_purge_internal(), V_tcp_hc_callout, and V_tcp_hostcache.
Referenced by sysctl_tcp_hc_purgenow(), tcp_hc_init(), and tcp_hc_purge().
|
static |
Definition at line 757 of file tcp_hostcache.c.
References THC_LOCK, THC_UNLOCK, and V_tcp_hostcache.
Referenced by sysctl_tcp_hc_purgenow(), and tcp_hc_purge().
void tcp_hc_update | ( | struct in_conninfo * | inc, |
struct hc_metrics_lite * | hcml | ||
) |
Definition at line 452 of file tcp_hostcache.c.
References HOSTCACHE_HASH, in_conninfo::inc_flags, INC_ISIPV6, hc_metrics_lite::rmx_cwnd, hc_metrics_lite::rmx_mtu, hc_metrics_lite::rmx_recvpipe, hc_metrics_lite::rmx_rtt, hc_metrics_lite::rmx_rttvar, hc_metrics_lite::rmx_sendpipe, hc_metrics_lite::rmx_ssthresh, tcp_hc_cmp(), TCPSTAT_INC, THC_LOCK, THC_UNLOCK, V_tcp_hostcache, and V_tcp_use_hostcache.
Referenced by tcp_freecb(), and tcp_hc_updatemtu().
void tcp_hc_updatemtu | ( | struct in_conninfo * | inc, |
uint32_t | mtu | ||
) |
Definition at line 440 of file tcp_hostcache.c.
References hc_metrics_lite::rmx_mtu, and tcp_hc_update().
Referenced by sctp_hc_set_mtu().
VNET_DEFINE | ( | int | , |
tcp_use_hostcache | |||
) |
VNET_DEFINE_STATIC | ( | struct callout | , |
tcp_hc_callout | |||
) |
VNET_DEFINE_STATIC | ( | struct tcp_hostcache | , |
tcp_hostcache | |||
) |