FreeBSD kernel kern code
|
#include <sys/cdefs.h>
#include "opt_param.h"
#include "opt_mbuf_stress_test.h"
#include "opt_mbuf_profiling.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/sysctl.h>
#include <sys/domain.h>
#include <sys/protosw.h>
#include <sys/uio.h>
#include <sys/vmmeter.h>
#include <sys/sbuf.h>
#include <sys/sdt.h>
#include <vm/vm.h>
#include <vm/vm_pageout.h>
#include <vm/vm_page.h>
#include <security/mac/mac_framework.h>
Go to the source code of this file.
Macros | |
#define | M_SANITY_ACTION(s) printf("mbuf %p: " s, m) |
Functions | |
__FBSDID ("$FreeBSD$") | |
SDT_PROBE_DEFINE5_XLATE (sdt,,, m__init, "struct mbuf *", "mbufinfo_t *", "uint32_t", "uint32_t", "uint16_t", "uint16_t", "uint32_t", "uint32_t", "uint32_t", "uint32_t") | |
SDT_PROBE_DEFINE3_XLATE (sdt,,, m__gethdr_raw, "uint32_t", "uint32_t", "uint16_t", "uint16_t", "struct mbuf *", "mbufinfo_t *") | |
SDT_PROBE_DEFINE3_XLATE (sdt,,, m__gethdr, "uint32_t", "uint32_t", "uint16_t", "uint16_t", "struct mbuf *", "mbufinfo_t *") | |
SDT_PROBE_DEFINE3_XLATE (sdt,,, m__get_raw, "uint32_t", "uint32_t", "uint16_t", "uint16_t", "struct mbuf *", "mbufinfo_t *") | |
SDT_PROBE_DEFINE3_XLATE (sdt,,, m__get, "uint32_t", "uint32_t", "uint16_t", "uint16_t", "struct mbuf *", "mbufinfo_t *") | |
SDT_PROBE_DEFINE4_XLATE (sdt,,, m__getcl, "uint32_t", "uint32_t", "uint16_t", "uint16_t", "uint32_t", "uint32_t", "struct mbuf *", "mbufinfo_t *") | |
SDT_PROBE_DEFINE5_XLATE (sdt,,, m__getjcl, "uint32_t", "uint32_t", "uint16_t", "uint16_t", "uint32_t", "uint32_t", "uint32_t", "uint32_t", "struct mbuf *", "mbufinfo_t *") | |
SDT_PROBE_DEFINE3_XLATE (sdt,,, m__clget, "struct mbuf *", "mbufinfo_t *", "uint32_t", "uint32_t", "uint32_t", "uint32_t") | |
SDT_PROBE_DEFINE4_XLATE (sdt,,, m__cljget, "struct mbuf *", "mbufinfo_t *", "uint32_t", "uint32_t", "uint32_t", "uint32_t", "void*", "void*") | |
SDT_PROBE_DEFINE (sdt,,, m__cljset) | |
SDT_PROBE_DEFINE1_XLATE (sdt,,, m__free, "struct mbuf *", "mbufinfo_t *") | |
SDT_PROBE_DEFINE1_XLATE (sdt,,, m__freem, "struct mbuf *", "mbufinfo_t *") | |
SYSCTL_INT (_kern_ipc, KIPC_MAX_LINKHDR, max_linkhdr, CTLFLAG_RD, &max_linkhdr, 0, "Size of largest link layer header") | |
SYSCTL_INT (_kern_ipc, KIPC_MAX_PROTOHDR, max_protohdr, CTLFLAG_RD, &max_protohdr, 0, "Size of largest protocol layer header") | |
SYSCTL_INT (_kern_ipc, KIPC_MAX_HDR, max_hdr, CTLFLAG_RD, &max_hdr, 0, "Size of largest link plus protocol header") | |
SYSCTL_INT (_kern_ipc, KIPC_MAX_DATALEN, max_datalen, CTLFLAG_RD, &max_datalen, 0, "Minimum space left in mbuf after max_hdr") | |
CTASSERT (MSIZE - offsetof(struct mbuf, m_dat)==MLEN) | |
CTASSERT (MSIZE - offsetof(struct mbuf, m_pktdat)==MHLEN) | |
CTASSERT (offsetof(struct mbuf, m_dat) % 8==0) | |
CTASSERT (offsetof(struct mbuf, m_pktdat) % 8==0) | |
CTASSERT (offsetof(struct mbuf, m_dat)==24) | |
CTASSERT (sizeof(struct pkthdr)==48) | |
CTASSERT (sizeof(struct m_ext)==180) | |
void | mb_dupcl (struct mbuf *n, struct mbuf *m) |
void | m_demote_pkthdr (struct mbuf *m) |
void | m_demote (struct mbuf *m0, int all, int flags) |
int | m_sanity (struct mbuf *m0, int sanitize) |
int | m_pkthdr_init (struct mbuf *m, int how) |
void | m_move_pkthdr (struct mbuf *to, struct mbuf *from) |
int | m_dup_pkthdr (struct mbuf *to, const struct mbuf *from, int how) |
struct mbuf * | m_prepend (struct mbuf *m, int len, int how) |
struct mbuf * | m_copym (struct mbuf *m, int off0, int len, int wait) |
struct mbuf * | m_copypacket (struct mbuf *m, int how) |
static void | m_copyfromunmapped (const struct mbuf *m, int off, int len, caddr_t cp) |
void | m_copydata (const struct mbuf *m, int off, int len, caddr_t cp) |
struct mbuf * | m_dup (const struct mbuf *m, int how) |
void | m_cat (struct mbuf *m, struct mbuf *n) |
void | m_catpkt (struct mbuf *m, struct mbuf *n) |
void | m_adj (struct mbuf *mp, int req_len) |
void | m_adj_decap (struct mbuf *mp, int len) |
struct mbuf * | m_pullup (struct mbuf *n, int len) |
struct mbuf * | m_copyup (struct mbuf *n, int len, int dstoff) |
struct mbuf * | m_split (struct mbuf *m0, int len0, int wait) |
struct mbuf * | m_devget (char *buf, int totlen, int off, struct ifnet *ifp, void(*copy)(char *from, caddr_t to, u_int len)) |
static void | m_copytounmapped (const struct mbuf *m, int off, int len, c_caddr_t cp) |
void | m_copyback (struct mbuf *m0, int off, int len, c_caddr_t cp) |
int | m_append (struct mbuf *m0, int len, c_caddr_t cp) |
static int | m_apply_extpg_one (struct mbuf *m, int off, int len, int(*f)(void *, void *, u_int), void *arg) |
static int | m_apply_one (struct mbuf *m, int off, int len, int(*f)(void *, void *, u_int), void *arg) |
int | m_apply (struct mbuf *m, int off, int len, int(*f)(void *, void *, u_int), void *arg) |
struct mbuf * | m_getptr (struct mbuf *m, int loc, int *off) |
void | m_print (const struct mbuf *m, int maxlen) |
u_int | m_fixhdr (struct mbuf *m0) |
u_int | m_length (struct mbuf *m0, struct mbuf **last) |
struct mbuf * | m_defrag (struct mbuf *m0, int how) |
static int | frags_per_mbuf (struct mbuf *m) |
struct mbuf * | m_collapse (struct mbuf *m0, int how, int maxfrags) |
void | mb_free_mext_pgs (struct mbuf *m) |
static struct mbuf * | m_uiotombuf_nomap (struct uio *uio, int how, int len, int maxseg, int flags) |
struct mbuf * | m_uiotombuf (struct uio *uio, int how, int len, int align, int flags) |
int | m_unmapped_uiomove (const struct mbuf *m, int m_off, struct uio *uio, int len) |
int | m_mbuftouio (struct uio *uio, const struct mbuf *m, int len) |
struct mbuf * | m_unshare (struct mbuf *m0, int how) |
Variables | |
int | max_linkhdr |
int | max_protohdr |
int | max_hdr |
int | max_datalen |
#define M_SANITY_ACTION | ( | s | ) | printf("mbuf %p: " s, m) |
__FBSDID | ( | "$FreeBSD$" | ) |
CTASSERT | ( | MSIZE - | offsetofstruct mbuf, m_dat = =MLEN | ) |
CTASSERT | ( | MSIZE - | offsetofstruct mbuf, m_pktdat = =MHLEN | ) |
CTASSERT | ( | offsetof(struct mbuf, m_dat) % | 8 = =0 | ) |
CTASSERT | ( | offsetof(struct mbuf, m_dat) | = =24 | ) |
CTASSERT | ( | offsetof(struct mbuf, m_pktdat) % | 8 = =0 | ) |
CTASSERT | ( | sizeof(struct m_ext) | = =180 | ) |
CTASSERT | ( | sizeof(struct pkthdr) | = =48 | ) |
|
static |
Definition at line 1555 of file uipc_mbuf.c.
Referenced by m_collapse().
void m_adj | ( | struct mbuf * | mp, |
int | req_len | ||
) |
Definition at line 799 of file uipc_mbuf.c.
References count, and m_freem().
Referenced by m_adj_decap(), and m_pulldown().
void m_adj_decap | ( | struct mbuf * | mp, |
int | len | ||
) |
Definition at line 872 of file uipc_mbuf.c.
References m_adj().
int m_append | ( | struct mbuf * | m0, |
int | len, | ||
c_caddr_t | cp | ||
) |
Definition at line 1243 of file uipc_mbuf.c.
int m_apply | ( | struct mbuf * | m, |
int | off, | ||
int | len, | ||
int(*)(void *, void *, u_int) | f, | ||
void * | arg | ||
) |
Definition at line 1342 of file uipc_mbuf.c.
References count, and m_apply_one().
|
static |
Definition at line 1282 of file uipc_mbuf.c.
References count.
Referenced by m_apply_one().
|
static |
Definition at line 1328 of file uipc_mbuf.c.
References m_apply_extpg_one().
Referenced by m_apply().
void m_cat | ( | struct mbuf * | m, |
struct mbuf * | n | ||
) |
Definition at line 762 of file uipc_mbuf.c.
Referenced by m_catpkt(), m_defrag(), and soreceive_stream().
void m_catpkt | ( | struct mbuf * | m, |
struct mbuf * | n | ||
) |
Definition at line 786 of file uipc_mbuf.c.
References m_cat(), and m_demote().
struct mbuf * m_collapse | ( | struct mbuf * | m0, |
int | how, | ||
int | maxfrags | ||
) |
Definition at line 1589 of file uipc_mbuf.c.
References frags_per_mbuf(), and m_copydata().
void m_copyback | ( | struct mbuf * | m0, |
int | off, | ||
int | len, | ||
c_caddr_t | cp | ||
) |
Definition at line 1184 of file uipc_mbuf.c.
References m_copytounmapped().
void m_copydata | ( | const struct mbuf * | m, |
int | off, | ||
int | len, | ||
caddr_t | cp | ||
) |
Definition at line 654 of file uipc_mbuf.c.
References count, and m_copyfromunmapped().
Referenced by ktls_check_rx(), ktls_decrypt(), m_collapse(), m_common_hash_gethdr(), m_defrag(), m_dup(), m_dup1(), m_pulldown(), mb_unmapped_compress(), sbcompress(), and sbready_compress().
|
static |
Definition at line 626 of file uipc_mbuf.c.
References m_unmapped_uiomove().
Referenced by m_copydata().
struct mbuf * m_copym | ( | struct mbuf * | m, |
int | off0, | ||
int | len, | ||
int | wait | ||
) |
Definition at line 506 of file uipc_mbuf.c.
References m_dup_pkthdr(), m_freem(), and mb_dupcl().
Referenced by md_get_mbuf(), soreceive_generic(), and soreceive_stream().
struct mbuf * m_copypacket | ( | struct mbuf * | m, |
int | how | ||
) |
Definition at line 579 of file uipc_mbuf.c.
References m_dup_pkthdr(), m_freem(), and mb_dupcl().
|
static |
Definition at line 1156 of file uipc_mbuf.c.
References m_unmapped_uiomove().
Referenced by m_copyback().
struct mbuf * m_copyup | ( | struct mbuf * | n, |
int | len, | ||
int | dstoff | ||
) |
Definition at line 964 of file uipc_mbuf.c.
References count, m_freem(), m_move_pkthdr(), and max_protohdr.
struct mbuf * m_defrag | ( | struct mbuf * | m0, |
int | how | ||
) |
Definition at line 1473 of file uipc_mbuf.c.
References m_cat(), m_copydata(), m_dup_pkthdr(), m_fixhdr(), and m_freem().
void m_demote | ( | struct mbuf * | m0, |
int | all, | ||
int | flags | ||
) |
Definition at line 279 of file uipc_mbuf.c.
References flags, and m_demote_pkthdr().
Referenced by m_catpkt(), and sbappendstream_locked().
void m_demote_pkthdr | ( | struct mbuf * | m | ) |
Definition at line 262 of file uipc_mbuf.c.
References m_tag_delete_chain().
Referenced by m_demote().
struct mbuf * m_devget | ( | char * | buf, |
int | totlen, | ||
int | off, | ||
struct ifnet * | ifp, | ||
void(*)(char *from, caddr_t to, u_int len) | copy | ||
) |
Definition at line 1095 of file uipc_mbuf.c.
References buf, m_freem(), and max_linkhdr.
struct mbuf * m_dup | ( | const struct mbuf * | m, |
int | how | ||
) |
Definition at line 687 of file uipc_mbuf.c.
References m_copydata(), m_dup_pkthdr(), and m_freem().
int m_dup_pkthdr | ( | struct mbuf * | to, |
const struct mbuf * | from, | ||
int | how | ||
) |
Definition at line 439 of file uipc_mbuf.c.
References m_tag_copy_chain(), and m_tag_delete_chain().
Referenced by m_copym(), m_copypacket(), m_defrag(), m_dup(), and m_dup1().
u_int m_fixhdr | ( | struct mbuf * | m0 | ) |
Definition at line 1435 of file uipc_mbuf.c.
References m_length().
Referenced by m_defrag(), and mb_fixhdr().
struct mbuf * m_getptr | ( | struct mbuf * | m, |
int | loc, | ||
int * | off | ||
) |
Definition at line 1374 of file uipc_mbuf.c.
u_int m_length | ( | struct mbuf * | m0, |
struct mbuf ** | last | ||
) |
Definition at line 1445 of file uipc_mbuf.c.
Referenced by ktls_detach_record(), m_fixhdr(), sbappendaddr_locked(), sosend_generic(), and vn_sendfile().
int m_mbuftouio | ( | struct uio * | uio, |
const struct mbuf * | m, | ||
int | len | ||
) |
Definition at line 1970 of file uipc_mbuf.c.
References m_unmapped_uiomove(), and uiomove().
Referenced by soreceive_stream().
void m_move_pkthdr | ( | struct mbuf * | to, |
struct mbuf * | from | ||
) |
Definition at line 403 of file uipc_mbuf.c.
References m_tag_delete_chain().
Referenced by m_copyup(), m_prepend(), m_pullup(), and m_unshare().
int m_pkthdr_init | ( | struct mbuf * | m, |
int | how | ||
) |
Definition at line 378 of file uipc_mbuf.c.
struct mbuf * m_prepend | ( | struct mbuf * | m, |
int | len, | ||
int | how | ||
) |
Definition at line 476 of file uipc_mbuf.c.
References m_freem(), and m_move_pkthdr().
void m_print | ( | const struct mbuf * | m, |
int | maxlen | ||
) |
Definition at line 1399 of file uipc_mbuf.c.
References printf().
struct mbuf * m_pullup | ( | struct mbuf * | n, |
int | len | ||
) |
Definition at line 903 of file uipc_mbuf.c.
References count, m_freem(), m_move_pkthdr(), and max_protohdr.
int m_sanity | ( | struct mbuf * | m0, |
int | sanitize | ||
) |
Definition at line 302 of file uipc_mbuf.c.
References m_freem(), M_SANITY_ACTION, and m_tag_delete_chain().
struct mbuf * m_split | ( | struct mbuf * | m0, |
int | len0, | ||
int | wait | ||
) |
Definition at line 1013 of file uipc_mbuf.c.
References m_split(), and mb_dupcl().
Referenced by m_split().
struct mbuf * m_uiotombuf | ( | struct uio * | uio, |
int | how, | ||
int | len, | ||
int | align, | ||
int | flags | ||
) |
Definition at line 1855 of file uipc_mbuf.c.
References flags, m_freem(), m_getm2(), m_uiotombuf_nomap(), and uiomove().
Referenced by sosend_dgram(), sosend_generic(), and vn_sendfile().
|
static |
Definition at line 1767 of file uipc_mbuf.c.
References flags, m_freem(), mb_alloc_ext_pgs(), and mb_free_mext_pgs().
Referenced by m_uiotombuf().
int m_unmapped_uiomove | ( | const struct mbuf * | m, |
int | m_off, | ||
struct uio * | uio, | ||
int | len | ||
) |
Definition at line 1914 of file uipc_mbuf.c.
References uiomove().
Referenced by m_copyfromunmapped(), m_copytounmapped(), m_mbuftouio(), and soreceive_generic().
struct mbuf * m_unshare | ( | struct mbuf * | m0, |
int | how | ||
) |
Definition at line 2007 of file uipc_mbuf.c.
References m_freem(), and m_move_pkthdr().
void mb_dupcl | ( | struct mbuf * | n, |
struct mbuf * | m | ||
) |
Definition at line 213 of file uipc_mbuf.c.
Referenced by ktls_detach_record(), m_copym(), m_copypacket(), and m_split().
void mb_free_mext_pgs | ( | struct mbuf * | m | ) |
Definition at line 1754 of file uipc_mbuf.c.
Referenced by ktls_finish_nonanon(), m_uiotombuf_nomap(), and mb_alloc_ext_plus_pages().
SDT_PROBE_DEFINE | ( | sdt | , |
m__cljset | |||
) |
SDT_PROBE_DEFINE1_XLATE | ( | sdt | , |
m__free | , | ||
"struct mbuf *" | , | ||
"mbufinfo_t *" | |||
) |
SDT_PROBE_DEFINE1_XLATE | ( | sdt | , |
m__freem | , | ||
"struct mbuf *" | , | ||
"mbufinfo_t *" | |||
) |
SDT_PROBE_DEFINE3_XLATE | ( | sdt | , |
m__clget | , | ||
"struct mbuf *" | , | ||
"mbufinfo_t *" | , | ||
"uint32_t" | , | ||
"uint32_t" | , | ||
"uint32_t" | , | ||
"uint32_t" | |||
) |
SDT_PROBE_DEFINE3_XLATE | ( | sdt | , |
m__get | , | ||
"uint32_t" | , | ||
"uint32_t" | , | ||
"uint16_t" | , | ||
"uint16_t" | , | ||
"struct mbuf *" | , | ||
"mbufinfo_t *" | |||
) |
SDT_PROBE_DEFINE3_XLATE | ( | sdt | , |
m__get_raw | , | ||
"uint32_t" | , | ||
"uint32_t" | , | ||
"uint16_t" | , | ||
"uint16_t" | , | ||
"struct mbuf *" | , | ||
"mbufinfo_t *" | |||
) |
SDT_PROBE_DEFINE3_XLATE | ( | sdt | , |
m__gethdr | , | ||
"uint32_t" | , | ||
"uint32_t" | , | ||
"uint16_t" | , | ||
"uint16_t" | , | ||
"struct mbuf *" | , | ||
"mbufinfo_t *" | |||
) |
SDT_PROBE_DEFINE3_XLATE | ( | sdt | , |
m__gethdr_raw | , | ||
"uint32_t" | , | ||
"uint32_t" | , | ||
"uint16_t" | , | ||
"uint16_t" | , | ||
"struct mbuf *" | , | ||
"mbufinfo_t *" | |||
) |
SDT_PROBE_DEFINE4_XLATE | ( | sdt | , |
m__cljget | , | ||
"struct mbuf *" | , | ||
"mbufinfo_t *" | , | ||
"uint32_t" | , | ||
"uint32_t" | , | ||
"uint32_t" | , | ||
"uint32_t" | , | ||
"void*" | , | ||
"void*" | |||
) |
SDT_PROBE_DEFINE4_XLATE | ( | sdt | , |
m__getcl | , | ||
"uint32_t" | , | ||
"uint32_t" | , | ||
"uint16_t" | , | ||
"uint16_t" | , | ||
"uint32_t" | , | ||
"uint32_t" | , | ||
"struct mbuf *" | , | ||
"mbufinfo_t *" | |||
) |
SDT_PROBE_DEFINE5_XLATE | ( | sdt | , |
m__getjcl | , | ||
"uint32_t" | , | ||
"uint32_t" | , | ||
"uint16_t" | , | ||
"uint16_t" | , | ||
"uint32_t" | , | ||
"uint32_t" | , | ||
"uint32_t" | , | ||
"uint32_t" | , | ||
"struct mbuf *" | , | ||
"mbufinfo_t *" | |||
) |
SDT_PROBE_DEFINE5_XLATE | ( | sdt | , |
m__init | , | ||
"struct mbuf *" | , | ||
"mbufinfo_t *" | , | ||
"uint32_t" | , | ||
"uint32_t" | , | ||
"uint16_t" | , | ||
"uint16_t" | , | ||
"uint32_t" | , | ||
"uint32_t" | , | ||
"uint32_t" | , | ||
"uint32_t" | |||
) |
SYSCTL_INT | ( | _kern_ipc | , |
KIPC_MAX_DATALEN | , | ||
max_datalen | , | ||
CTLFLAG_RD | , | ||
& | max_datalen, | ||
0 | , | ||
"Minimum space left in mbuf after max_hdr" | |||
) |
SYSCTL_INT | ( | _kern_ipc | , |
KIPC_MAX_HDR | , | ||
max_hdr | , | ||
CTLFLAG_RD | , | ||
& | max_hdr, | ||
0 | , | ||
"Size of largest link plus protocol header" | |||
) |
SYSCTL_INT | ( | _kern_ipc | , |
KIPC_MAX_LINKHDR | , | ||
max_linkhdr | , | ||
CTLFLAG_RD | , | ||
& | max_linkhdr, | ||
0 | , | ||
"Size of largest link layer header" | |||
) |
SYSCTL_INT | ( | _kern_ipc | , |
KIPC_MAX_PROTOHDR | , | ||
max_protohdr | , | ||
CTLFLAG_RD | , | ||
& | max_protohdr, | ||
0 | , | ||
"Size of largest protocol layer header" | |||
) |
int max_datalen |
Definition at line 123 of file uipc_mbuf.c.
Referenced by domain_init().
int max_hdr |
Definition at line 122 of file uipc_mbuf.c.
Referenced by domain_init(), sosend_dgram(), and sosend_generic().
int max_linkhdr |
Definition at line 120 of file uipc_mbuf.c.
Referenced by domain_init(), domaininit(), and m_devget().
int max_protohdr |
Definition at line 121 of file uipc_mbuf.c.
Referenced by domain_init(), m_copyup(), and m_pullup().