FreeBSD kernel IPv4 code
|
#include <sys/cdefs.h>
#include "opt_rss.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/eventhandler.h>
#include <sys/kernel.h>
#include <sys/hash.h>
#include <sys/mbuf.h>
#include <sys/malloc.h>
#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/sysctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/rss_config.h>
#include <net/netisr.h>
#include <net/vnet.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/in_rss.h>
Go to the source code of this file.
Data Structures | |
struct | ipqbucket |
Macros | |
#define | IPREASS_NHASH_LOG2 10 |
#define | IPREASS_NHASH (1 << IPREASS_NHASH_LOG2) |
#define | IPREASS_HMASK (IPREASS_NHASH - 1) |
#define | V_ipq VNET(ipq) |
#define | V_ipq_hashseed VNET(ipq_hashseed) |
#define | IPQ_LOCK(i) mtx_lock(&V_ipq[i].lock) |
#define | IPQ_TRYLOCK(i) mtx_trylock(&V_ipq[i].lock) |
#define | IPQ_UNLOCK(i) mtx_unlock(&V_ipq[i].lock) |
#define | IPQ_LOCK_ASSERT(i) mtx_assert(&V_ipq[i].lock, MA_OWNED) |
#define | V_ipreass_maxbucketsize VNET(ipreass_maxbucketsize) |
#define | IP_MAXFRAGS (nmbclusters / 32) |
#define | IP_MAXFRAGPACKETS (imin(IP_MAXFRAGS, IPREASS_NHASH * 50)) |
#define | V_ipq_zone VNET(ipq_zone) |
#define | V_noreass VNET(noreass) |
#define | V_maxfragsperpacket VNET(maxfragsperpacket) |
#define | M_IP_FRAG M_PROTO9 |
#define | GETIP(m) ((struct ip*)((m)->m_pkthdr.PH_loc.ptr)) |
Functions | |
__FBSDID ("$FreeBSD$") | |
SYSCTL_DECL (_net_inet_ip) | |
VNET_DEFINE_STATIC (struct ipqbucket, ipq[IPREASS_NHASH]) | |
VNET_DEFINE_STATIC (uint32_t, ipq_hashseed) | |
VNET_DEFINE_STATIC (int, ipreass_maxbucketsize) | |
void | ipreass_init (void) |
void | ipreass_drain (void) |
void | ipreass_slowtimo (void) |
static int | sysctl_maxfragpackets (SYSCTL_HANDLER_ARGS) |
static int | sysctl_maxfragbucketsize (SYSCTL_HANDLER_ARGS) |
static void | ipreass_zone_change (void *) |
static void | ipreass_drain_tomax (void) |
static void | ipq_free (struct ipqbucket *, struct ipq *) |
static struct ipq * | ipq_reuse (int) |
static void | ipq_timeout (struct ipqbucket *bucket, struct ipq *fp) |
static void | ipq_drop (struct ipqbucket *bucket, struct ipq *fp) |
SYSCTL_INT (_net_inet_ip, OID_AUTO, maxfrags, CTLFLAG_RW, &maxfrags, 0, "Maximum number of IPv4 fragments allowed across all reassembly queues") | |
SYSCTL_UINT (_net_inet_ip, OID_AUTO, curfrags, CTLFLAG_RD, &nfrags, 0, "Current number of IPv4 fragments across all reassembly queues") | |
VNET_DEFINE_STATIC (uma_zone_t, ipq_zone) | |
SYSCTL_PROC (_net_inet_ip, OID_AUTO, maxfragpackets, CTLFLAG_VNET|CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_NEEDGIANT, NULL, 0, sysctl_maxfragpackets, "I", "Maximum number of IPv4 fragment reassembly queue entries") | |
SYSCTL_UMA_CUR (_net_inet_ip, OID_AUTO, fragpackets, CTLFLAG_VNET, &VNET_NAME(ipq_zone), "Current number of IPv4 fragment reassembly queue entries") | |
VNET_DEFINE_STATIC (int, noreass) | |
VNET_DEFINE_STATIC (int, maxfragsperpacket) | |
SYSCTL_INT (_net_inet_ip, OID_AUTO, maxfragsperpacket, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(maxfragsperpacket), 0, "Maximum number of IPv4 fragments allowed per packet") | |
SYSCTL_PROC (_net_inet_ip, OID_AUTO, maxfragbucketsize, CTLFLAG_VNET|CTLTYPE_INT|CTLFLAG_MPSAFE|CTLFLAG_RW, NULL, 0, sysctl_maxfragbucketsize, "I", "Maximum number of IPv4 fragment reassembly queue entries per bucket") | |
struct mbuf * | ip_reass (struct mbuf *m) |
static void | ipreass_cleanup (void *arg __unused, struct ifnet *ifp) |
EVENTHANDLER_DEFINE (ifnet_departure_event, ipreass_cleanup, NULL, 0) | |
Variables | |
static int | maxfrags |
static u_int __exclusive_cache_line | nfrags |
#define GETIP | ( | m | ) | ((struct ip*)((m)->m_pkthdr.PH_loc.ptr)) |
#define IP_MAXFRAGPACKETS (imin(IP_MAXFRAGS, IPREASS_NHASH * 50)) |
Definition at line 137 of file ip_reass.c.
#define IP_MAXFRAGS (nmbclusters / 32) |
Definition at line 136 of file ip_reass.c.
#define IPQ_LOCK | ( | i | ) | mtx_lock(&V_ipq[i].lock) |
Definition at line 86 of file ip_reass.c.
#define IPQ_LOCK_ASSERT | ( | i | ) | mtx_assert(&V_ipq[i].lock, MA_OWNED) |
Definition at line 89 of file ip_reass.c.
#define IPQ_TRYLOCK | ( | i | ) | mtx_trylock(&V_ipq[i].lock) |
Definition at line 87 of file ip_reass.c.
#define IPQ_UNLOCK | ( | i | ) | mtx_unlock(&V_ipq[i].lock) |
Definition at line 88 of file ip_reass.c.
#define IPREASS_HMASK (IPREASS_NHASH - 1) |
Definition at line 73 of file ip_reass.c.
#define IPREASS_NHASH (1 << IPREASS_NHASH_LOG2) |
Definition at line 72 of file ip_reass.c.
#define IPREASS_NHASH_LOG2 10 |
Definition at line 71 of file ip_reass.c.
#define M_IP_FRAG M_PROTO9 |
Definition at line 181 of file ip_reass.c.
#define V_ipq VNET(ipq) |
Definition at line 82 of file ip_reass.c.
#define V_ipq_hashseed VNET(ipq_hashseed) |
Definition at line 84 of file ip_reass.c.
#define V_ipq_zone VNET(ipq_zone) |
Definition at line 149 of file ip_reass.c.
#define V_ipreass_maxbucketsize VNET(ipreass_maxbucketsize) |
Definition at line 92 of file ip_reass.c.
#define V_maxfragsperpacket VNET(maxfragsperpacket) |
Definition at line 162 of file ip_reass.c.
#define V_noreass VNET(noreass) |
Definition at line 159 of file ip_reass.c.
__FBSDID | ( | "$FreeBSD$" | ) |
EVENTHANDLER_DEFINE | ( | ifnet_departure_event | , |
ipreass_cleanup | , | ||
NULL | , | ||
0 | |||
) |
struct mbuf * ip_reass | ( | struct mbuf * | m | ) |
Definition at line 183 of file ip_reass.c.
References count, GETIP, ip::ip_dst, ip::ip_hl, ip::ip_id, ip_len, ip::ip_len, IP_MAXPACKET, IP_MF, ip_off, ip::ip_off, ip::ip_p, ip::ip_tos, IPFRAGTTL, ipq_drop(), ipq::ipq_dst, ipq::ipq_frags, ipq::ipq_id, IPQ_LOCK, ipq::ipq_maxoff, ipq::ipq_nfrags, ipq::ipq_p, ipq_reuse(), ipq::ipq_ttl, IPQ_UNLOCK, IPREASS_HMASK, IPSTAT_INC, IPTOS_ECN_CE, IPTOS_ECN_MASK, IPTOS_ECN_NOTECT, M_IP_FRAG, maxfrags, next, nfrags, rss_mbuf_software_hash_v4(), in_addr::s_addr, V_ipq, V_ipq_hashseed, V_ipq_zone, V_ipreass_maxbucketsize, V_maxfragsperpacket, and V_noreass.
Referenced by ip_input().
Definition at line 116 of file ip_reass.c.
References bucket, ipq_free(), ipq::ipq_nfrags, and IPSTAT_ADD.
Referenced by ip_reass(), and ipreass_drain().
Definition at line 829 of file ip_reass.c.
References bucket, ipq::ipq_frags, ipq::ipq_nfrags, nfrags, and V_ipq_zone.
Referenced by ipq_drop(), and ipq_timeout().
|
static |
Definition at line 790 of file ip_reass.c.
References bucket, ipq::ipq_frags, IPQ_LOCK_ASSERT, ipq::ipq_nfrags, IPQ_TRYLOCK, IPQ_UNLOCK, IPREASS_NHASH, IPSTAT_ADD, nfrags, and V_ipq.
Referenced by ip_reass().
Definition at line 108 of file ip_reass.c.
References bucket, ipq_free(), ipq::ipq_nfrags, and IPSTAT_ADD.
Referenced by ipreass_drain_tomax(), and ipreass_slowtimo().
|
static |
Definition at line 633 of file ip_reass.c.
References ipq::ipq_frags, IPQ_LOCK, IPQ_UNLOCK, IPREASS_NHASH, V_ipq, and V_ipq_zone.
void ipreass_drain | ( | void | ) |
Definition at line 614 of file ip_reass.c.
References count, ipq_drop(), IPQ_LOCK, IPQ_UNLOCK, IPREASS_NHASH, and V_ipq.
Referenced by ip_drain(), and sysctl_maxfragpackets().
|
static |
Definition at line 690 of file ip_reass.c.
References count, IPQ_LOCK, ipq_timeout(), IPQ_UNLOCK, IPREASS_NHASH, V_ipq, V_ipq_zone, and V_ipreass_maxbucketsize.
Referenced by ipreass_zone_change(), sysctl_maxfragbucketsize(), and sysctl_maxfragpackets().
void ipreass_init | ( | void | ) |
Definition at line 563 of file ip_reass.c.
References IP_MAXFRAGPACKETS, IP_MAXFRAGS, IPREASS_NHASH, ipreass_zone_change(), maxfrags, V_ipq, V_ipq_hashseed, V_ipq_zone, V_ipreass_maxbucketsize, and V_maxfragsperpacket.
Referenced by ip_vnet_init().
void ipreass_slowtimo | ( | void | ) |
Definition at line 592 of file ip_reass.c.
References IPQ_LOCK, ipq_timeout(), ipq::ipq_ttl, IPQ_UNLOCK, IPREASS_NHASH, nfrags, and V_ipq.
Referenced by ip_slowtimo().
|
static |
Definition at line 727 of file ip_reass.c.
References IP_MAXFRAGPACKETS, IP_MAXFRAGS, ipreass_drain_tomax(), IPREASS_NHASH, maxfrags, V_ipq_zone, and V_ipreass_maxbucketsize.
Referenced by ipreass_init().
SYSCTL_DECL | ( | _net_inet_ip | ) |
SYSCTL_INT | ( | _net_inet_ip | , |
OID_AUTO | , | ||
maxfrags | , | ||
CTLFLAG_RW | , | ||
& | maxfrags, | ||
0 | , | ||
"Maximum number of IPv4 fragments allowed across all reassembly queues" | |||
) |
SYSCTL_INT | ( | _net_inet_ip | , |
OID_AUTO | , | ||
maxfragsperpacket | , | ||
CTLFLAG_VNET| | CTLFLAG_RW, | ||
& | VNET_NAMEmaxfragsperpacket, | ||
0 | , | ||
"Maximum number of IPv4 fragments allowed per packet" | |||
) |
|
static |
Definition at line 848 of file ip_reass.c.
References ipreass_drain_tomax(), and V_ipreass_maxbucketsize.
|
static |
Definition at line 751 of file ip_reass.c.
References ipreass_drain(), ipreass_drain_tomax(), IPREASS_NHASH, V_ipq_zone, V_ipreass_maxbucketsize, and V_noreass.
SYSCTL_PROC | ( | _net_inet_ip | , |
OID_AUTO | , | ||
maxfragbucketsize | , | ||
CTLFLAG_VNET|CTLTYPE_INT|CTLFLAG_MPSAFE| | CTLFLAG_RW, | ||
NULL | , | ||
0 | , | ||
sysctl_maxfragbucketsize | , | ||
"I" | , | ||
"Maximum number of IPv4 fragment reassembly queue entries per bucket" | |||
) |
SYSCTL_PROC | ( | _net_inet_ip | , |
OID_AUTO | , | ||
maxfragpackets | , | ||
CTLFLAG_VNET|CTLTYPE_INT|CTLFLAG_RW| | CTLFLAG_NEEDGIANT, | ||
NULL | , | ||
0 | , | ||
sysctl_maxfragpackets | , | ||
"I" | , | ||
"Maximum number of IPv4 fragment reassembly queue entries" | |||
) |
SYSCTL_UINT | ( | _net_inet_ip | , |
OID_AUTO | , | ||
curfrags | , | ||
CTLFLAG_RD | , | ||
& | nfrags, | ||
0 | , | ||
"Current number of IPv4 fragments across all reassembly queues" | |||
) |
SYSCTL_UMA_CUR | ( | _net_inet_ip | , |
OID_AUTO | , | ||
fragpackets | , | ||
CTLFLAG_VNET | , | ||
& | VNET_NAMEipq_zone, | ||
"Current number of IPv4 fragment reassembly queue entries" | |||
) |
VNET_DEFINE_STATIC | ( | int | , |
ipreass_maxbucketsize | |||
) |
VNET_DEFINE_STATIC | ( | int | , |
maxfragsperpacket | |||
) |
VNET_DEFINE_STATIC | ( | int | , |
noreass | |||
) |
VNET_DEFINE_STATIC | ( | uint32_t | , |
ipq_hashseed | |||
) |
VNET_DEFINE_STATIC | ( | uma_zone_t | , |
ipq_zone | |||
) |
|
static |
Definition at line 139 of file ip_reass.c.
Referenced by ip_reass(), ipreass_init(), and ipreass_zone_change().
|
static |
Definition at line 140 of file ip_reass.c.
Referenced by ip_fragment(), ip_reass(), ipq_free(), ipq_reuse(), and ipreass_slowtimo().