2020-08-28 10:01:57 +03:00
|
|
|
/* $NetBSD: in_pcb_hdr.h,v 1.15 2020/08/28 07:01:57 riastradh Exp $ */
|
2003-09-04 13:16:57 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2003 WIDE Project.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the project nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1982, 1986, 1990, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* @(#)in_pcb.h 8.1 (Berkeley) 6/10/93
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NETINET_IN_PCB_HDR_H_
|
|
|
|
#define _NETINET_IN_PCB_HDR_H_
|
|
|
|
|
2020-08-28 10:01:57 +03:00
|
|
|
#include <sys/types.h>
|
2003-09-04 13:16:57 +04:00
|
|
|
#include <sys/queue.h>
|
|
|
|
|
2020-08-28 10:01:57 +03:00
|
|
|
#include <netinet/in.h>
|
|
|
|
|
2003-09-04 13:16:57 +04:00
|
|
|
struct inpcbpolicy;
|
2020-08-28 10:01:57 +03:00
|
|
|
struct inpcbtable;
|
|
|
|
struct mbuf;
|
|
|
|
struct sockaddr;
|
|
|
|
struct socket;
|
2003-09-04 13:16:57 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* align it with inpcb and in6pcb!
|
|
|
|
*/
|
|
|
|
struct inpcb_hdr {
|
|
|
|
LIST_ENTRY(inpcb_hdr) inph_hash;
|
2003-10-28 20:18:37 +03:00
|
|
|
LIST_ENTRY(inpcb_hdr) inph_lhash;
|
2013-11-23 18:20:21 +04:00
|
|
|
TAILQ_ENTRY(inpcb_hdr) inph_queue;
|
2003-09-04 13:16:57 +04:00
|
|
|
int inph_af; /* address family - AF_INET */
|
2007-03-04 08:59:00 +03:00
|
|
|
void * inph_ppcb; /* pointer to per-protocol pcb */
|
2003-09-04 13:16:57 +04:00
|
|
|
int inph_state; /* bind/connect state */
|
2012-06-25 19:28:38 +04:00
|
|
|
int inph_portalgo;
|
2003-09-04 13:16:57 +04:00
|
|
|
struct socket *inph_socket; /* back pointer to socket */
|
|
|
|
struct inpcbtable *inph_table;
|
|
|
|
struct inpcbpolicy *inph_sp; /* security policy */
|
|
|
|
};
|
|
|
|
|
2004-03-02 05:11:14 +03:00
|
|
|
#define sotoinpcb_hdr(so) ((struct inpcb_hdr *)(so)->so_pcb)
|
2017-04-25 08:44:11 +03:00
|
|
|
#define inph_locked(inph) (solocked((inph)->inph_socket))
|
2004-03-02 05:11:14 +03:00
|
|
|
|
2003-09-04 13:16:57 +04:00
|
|
|
LIST_HEAD(inpcbhead, inpcb_hdr);
|
|
|
|
|
Reduces the resources demanded by TCP sessions in TIME_WAIT-state using
methods called Vestigial Time-Wait (VTW) and Maximum Segment Lifetime
Truncation (MSLT).
MSLT and VTW were contributed by Coyote Point Systems, Inc.
Even after a TCP session enters the TIME_WAIT state, its corresponding
socket and protocol control blocks (PCBs) stick around until the TCP
Maximum Segment Lifetime (MSL) expires. On a host whose workload
necessarily creates and closes down many TCP sockets, the sockets & PCBs
for TCP sessions in TIME_WAIT state amount to many megabytes of dead
weight in RAM.
Maximum Segment Lifetimes Truncation (MSLT) assigns each TCP session to
a class based on the nearness of the peer. Corresponding to each class
is an MSL, and a session uses the MSL of its class. The classes are
loopback (local host equals remote host), local (local host and remote
host are on the same link/subnet), and remote (local host and remote
host communicate via one or more gateways). Classes corresponding to
nearer peers have lower MSLs by default: 2 seconds for loopback, 10
seconds for local, 60 seconds for remote. Loopback and local sessions
expire more quickly when MSLT is used.
Vestigial Time-Wait (VTW) replaces a TIME_WAIT session's PCB/socket
dead weight with a compact representation of the session, called a
"vestigial PCB". VTW data structures are designed to be very fast and
memory-efficient: for fast insertion and lookup of vestigial PCBs,
the PCBs are stored in a hash table that is designed to minimize the
number of cacheline visits per lookup/insertion. The memory both
for vestigial PCBs and for elements of the PCB hashtable come from
fixed-size pools, and linked data structures exploit this to conserve
memory by representing references with a narrow index/offset from the
start of a pool instead of a pointer. When space for new vestigial PCBs
runs out, VTW makes room by discarding old vestigial PCBs, oldest first.
VTW cooperates with MSLT.
It may help to think of VTW as a "FIN cache" by analogy to the SYN
cache.
A 2.8-GHz Pentium 4 running a test workload that creates TIME_WAIT
sessions as fast as it can is approximately 17% idle when VTW is active
versus 0% idle when VTW is inactive. It has 103 megabytes more free RAM
when VTW is active (approximately 64k vestigial PCBs are created) than
when it is inactive.
2011-05-03 22:28:44 +04:00
|
|
|
struct vestigial_inpcb;
|
2017-06-02 06:41:20 +03:00
|
|
|
struct in6_addr;
|
Reduces the resources demanded by TCP sessions in TIME_WAIT-state using
methods called Vestigial Time-Wait (VTW) and Maximum Segment Lifetime
Truncation (MSLT).
MSLT and VTW were contributed by Coyote Point Systems, Inc.
Even after a TCP session enters the TIME_WAIT state, its corresponding
socket and protocol control blocks (PCBs) stick around until the TCP
Maximum Segment Lifetime (MSL) expires. On a host whose workload
necessarily creates and closes down many TCP sockets, the sockets & PCBs
for TCP sessions in TIME_WAIT state amount to many megabytes of dead
weight in RAM.
Maximum Segment Lifetimes Truncation (MSLT) assigns each TCP session to
a class based on the nearness of the peer. Corresponding to each class
is an MSL, and a session uses the MSL of its class. The classes are
loopback (local host equals remote host), local (local host and remote
host are on the same link/subnet), and remote (local host and remote
host communicate via one or more gateways). Classes corresponding to
nearer peers have lower MSLs by default: 2 seconds for loopback, 10
seconds for local, 60 seconds for remote. Loopback and local sessions
expire more quickly when MSLT is used.
Vestigial Time-Wait (VTW) replaces a TIME_WAIT session's PCB/socket
dead weight with a compact representation of the session, called a
"vestigial PCB". VTW data structures are designed to be very fast and
memory-efficient: for fast insertion and lookup of vestigial PCBs,
the PCBs are stored in a hash table that is designed to minimize the
number of cacheline visits per lookup/insertion. The memory both
for vestigial PCBs and for elements of the PCB hashtable come from
fixed-size pools, and linked data structures exploit this to conserve
memory by representing references with a narrow index/offset from the
start of a pool instead of a pointer. When space for new vestigial PCBs
runs out, VTW makes room by discarding old vestigial PCBs, oldest first.
VTW cooperates with MSLT.
It may help to think of VTW as a "FIN cache" by analogy to the SYN
cache.
A 2.8-GHz Pentium 4 running a test workload that creates TIME_WAIT
sessions as fast as it can is approximately 17% idle when VTW is active
versus 0% idle when VTW is inactive. It has 103 megabytes more free RAM
when VTW is active (approximately 64k vestigial PCBs are created) than
when it is inactive.
2011-05-03 22:28:44 +04:00
|
|
|
|
|
|
|
/* Hooks for vestigial pcb entries.
|
|
|
|
* If vestigial entries exist for a table (TCP only)
|
|
|
|
* the vestigial pointer is set.
|
|
|
|
*/
|
|
|
|
typedef struct vestigial_hooks {
|
|
|
|
/* IPv4 hooks */
|
|
|
|
void *(*init_ports4)(struct in_addr, u_int, int);
|
|
|
|
int (*next_port4)(void *, struct vestigial_inpcb *);
|
|
|
|
int (*lookup4)(struct in_addr, uint16_t,
|
|
|
|
struct in_addr, uint16_t,
|
|
|
|
struct vestigial_inpcb *);
|
|
|
|
/* IPv6 hooks */
|
|
|
|
void *(*init_ports6)(const struct in6_addr*, u_int, int);
|
|
|
|
int (*next_port6)(void *, struct vestigial_inpcb *);
|
|
|
|
int (*lookup6)(const struct in6_addr *, uint16_t,
|
|
|
|
const struct in6_addr *, uint16_t,
|
|
|
|
struct vestigial_inpcb *);
|
|
|
|
} vestigial_hooks_t;
|
|
|
|
|
2013-11-24 02:23:26 +04:00
|
|
|
TAILQ_HEAD(inpcbqueue, inpcb_hdr);
|
|
|
|
|
2003-09-04 13:16:57 +04:00
|
|
|
struct inpcbtable {
|
2013-11-24 02:23:26 +04:00
|
|
|
struct inpcbqueue inpt_queue;
|
2003-10-28 20:18:37 +03:00
|
|
|
struct inpcbhead *inpt_porthashtbl;
|
2003-09-04 13:16:57 +04:00
|
|
|
struct inpcbhead *inpt_bindhashtbl;
|
|
|
|
struct inpcbhead *inpt_connecthashtbl;
|
2003-10-28 20:18:37 +03:00
|
|
|
u_long inpt_porthash;
|
2003-09-04 13:16:57 +04:00
|
|
|
u_long inpt_bindhash;
|
|
|
|
u_long inpt_connecthash;
|
|
|
|
u_int16_t inpt_lastport;
|
|
|
|
u_int16_t inpt_lastlow;
|
Reduces the resources demanded by TCP sessions in TIME_WAIT-state using
methods called Vestigial Time-Wait (VTW) and Maximum Segment Lifetime
Truncation (MSLT).
MSLT and VTW were contributed by Coyote Point Systems, Inc.
Even after a TCP session enters the TIME_WAIT state, its corresponding
socket and protocol control blocks (PCBs) stick around until the TCP
Maximum Segment Lifetime (MSL) expires. On a host whose workload
necessarily creates and closes down many TCP sockets, the sockets & PCBs
for TCP sessions in TIME_WAIT state amount to many megabytes of dead
weight in RAM.
Maximum Segment Lifetimes Truncation (MSLT) assigns each TCP session to
a class based on the nearness of the peer. Corresponding to each class
is an MSL, and a session uses the MSL of its class. The classes are
loopback (local host equals remote host), local (local host and remote
host are on the same link/subnet), and remote (local host and remote
host communicate via one or more gateways). Classes corresponding to
nearer peers have lower MSLs by default: 2 seconds for loopback, 10
seconds for local, 60 seconds for remote. Loopback and local sessions
expire more quickly when MSLT is used.
Vestigial Time-Wait (VTW) replaces a TIME_WAIT session's PCB/socket
dead weight with a compact representation of the session, called a
"vestigial PCB". VTW data structures are designed to be very fast and
memory-efficient: for fast insertion and lookup of vestigial PCBs,
the PCBs are stored in a hash table that is designed to minimize the
number of cacheline visits per lookup/insertion. The memory both
for vestigial PCBs and for elements of the PCB hashtable come from
fixed-size pools, and linked data structures exploit this to conserve
memory by representing references with a narrow index/offset from the
start of a pool instead of a pointer. When space for new vestigial PCBs
runs out, VTW makes room by discarding old vestigial PCBs, oldest first.
VTW cooperates with MSLT.
It may help to think of VTW as a "FIN cache" by analogy to the SYN
cache.
A 2.8-GHz Pentium 4 running a test workload that creates TIME_WAIT
sessions as fast as it can is approximately 17% idle when VTW is active
versus 0% idle when VTW is inactive. It has 103 megabytes more free RAM
when VTW is active (approximately 64k vestigial PCBs are created) than
when it is inactive.
2011-05-03 22:28:44 +04:00
|
|
|
|
|
|
|
vestigial_hooks_t *vestige;
|
2003-09-04 13:16:57 +04:00
|
|
|
};
|
|
|
|
#define inpt_lasthi inpt_lastport
|
|
|
|
|
|
|
|
/* states in inp_state: */
|
|
|
|
#define INP_ATTACHED 0
|
|
|
|
#define INP_BOUND 1
|
|
|
|
#define INP_CONNECTED 2
|
|
|
|
|
2020-08-21 00:21:31 +03:00
|
|
|
typedef int (*pcb_overudp_cb_t)(struct mbuf **, int, struct socket *,
|
|
|
|
struct sockaddr *, void *);
|
|
|
|
|
2005-12-11 02:31:41 +03:00
|
|
|
#endif /* !_NETINET_IN_PCB_HDR_H_ */
|