1de06f907SNik Clayton.\" Copyright (c) 2000 FreeBSD Inc. 2de06f907SNik Clayton.\" All rights reserved. 3de06f907SNik Clayton.\" 4de06f907SNik Clayton.\" Redistribution and use in source and binary forms, with or without 5de06f907SNik Clayton.\" modification, are permitted provided that the following conditions 6de06f907SNik Clayton.\" are met: 7de06f907SNik Clayton.\" 1. Redistributions of source code must retain the above copyright 8de06f907SNik Clayton.\" notice, this list of conditions and the following disclaimer. 9de06f907SNik Clayton.\" 2. Redistributions in binary form must reproduce the above copyright 10de06f907SNik Clayton.\" notice, this list of conditions and the following disclaimer in the 11de06f907SNik Clayton.\" documentation and/or other materials provided with the distribution. 12de06f907SNik Clayton.\" 13de06f907SNik Clayton.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14de06f907SNik Clayton.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15de06f907SNik Clayton.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16de06f907SNik Clayton.\" ARE DISCLAIMED. IN NO EVENT SHALL [your name] OR CONTRIBUTORS BE LIABLE 17de06f907SNik Clayton.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18de06f907SNik Clayton.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19de06f907SNik Clayton.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20de06f907SNik Clayton.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21de06f907SNik Clayton.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22de06f907SNik Clayton.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23de06f907SNik Clayton.\" SUCH DAMAGE. 24de06f907SNik Clayton.\" 25de06f907SNik Clayton.\" $FreeBSD$ 26de06f907SNik Clayton.\" 271cb58a07SMaxim Konovalov.Dd July 24, 2006 28de06f907SNik Clayton.Dt MBUF 9 29de06f907SNik Clayton.Os 30de06f907SNik Clayton.\" 31de06f907SNik Clayton.Sh NAME 32de06f907SNik Clayton.Nm mbuf 33de06f907SNik Clayton.Nd "memory management in the kernel IPC subsystem" 34de06f907SNik Clayton.\" 35de06f907SNik Clayton.Sh SYNOPSIS 3632eef9aeSRuslan Ermilov.In sys/param.h 37f16b3c0dSChad David.In sys/systm.h 3832eef9aeSRuslan Ermilov.In sys/mbuf.h 39de06f907SNik Clayton.\" 40bfd59721SBosko Milekic.Ss Mbuf allocation macros 41de06f907SNik Clayton.Fn MGET "struct mbuf *mbuf" "int how" "short type" 42de06f907SNik Clayton.Fn MGETHDR "struct mbuf *mbuf" "int how" "short type" 43de06f907SNik Clayton.Fn MCLGET "struct mbuf *mbuf" "int how" 44bfd59721SBosko Milekic.Fo MEXTADD 45bfd59721SBosko Milekic.Fa "struct mbuf *mbuf" 46bfd59721SBosko Milekic.Fa "caddr_t buf" 47bfd59721SBosko Milekic.Fa "u_int size" 48bfd59721SBosko Milekic.Fa "void (*free)(void *opt_args)" 49bfd59721SBosko Milekic.Fa "void *opt_args" 505d4050ccSBosko Milekic.Fa "short flags" 515d4050ccSBosko Milekic.Fa "int type" 52bfd59721SBosko Milekic.Fc 53bfd59721SBosko Milekic.Fn MEXTFREE "struct mbuf *mbuf" 54bfd59721SBosko Milekic.Fn MFREE "struct mbuf *mbuf" "struct mbuf *successor" 55de06f907SNik Clayton.\" 56bfd59721SBosko Milekic.Ss Mbuf utility macros 57f16b3c0dSChad David.Fn mtod "struct mbuf *mbuf" "type" 58bfd59721SBosko Milekic.Fn M_ALIGN "struct mbuf *mbuf" "u_int len" 59bfd59721SBosko Milekic.Fn MH_ALIGN "struct mbuf *mbuf" "u_int len" 60f16b3c0dSChad David.Ft int 61bfd59721SBosko Milekic.Fn M_LEADINGSPACE "struct mbuf *mbuf" 62f16b3c0dSChad David.Ft int 63bfd59721SBosko Milekic.Fn M_TRAILINGSPACE "struct mbuf *mbuf" 64da72b998SYaroslav Tykhiy.Fn M_MOVE_PKTHDR "struct mbuf *to" "struct mbuf *from" 65bfd59721SBosko Milekic.Fn M_PREPEND "struct mbuf *mbuf" "int len" "int how" 66bfd59721SBosko Milekic.Fn MCHTYPE "struct mbuf *mbuf" "u_int type" 67f16b3c0dSChad David.Ft int 685d4050ccSBosko Milekic.Fn M_WRITABLE "struct mbuf *mbuf" 69bfd59721SBosko Milekic.\" 70bfd59721SBosko Milekic.Ss Mbuf allocation functions 71de06f907SNik Clayton.Ft struct mbuf * 72de06f907SNik Clayton.Fn m_get "int how" "int type" 73de06f907SNik Clayton.Ft struct mbuf * 74328c0bbcSBosko Milekic.Fn m_getm "struct mbuf *orig" "int len" "int how" "int type" 75328c0bbcSBosko Milekic.Ft struct mbuf * 766c013706SMaxim Konovalov.Fn m_getcl "int how" "short type" "int flags" 776c013706SMaxim Konovalov.Ft struct mbuf * 78de06f907SNik Clayton.Fn m_getclr "int how" "int type" 79de06f907SNik Clayton.Ft struct mbuf * 80de06f907SNik Clayton.Fn m_gethdr "int how" "int type" 81bfd59721SBosko Milekic.Ft struct mbuf * 82bfd59721SBosko Milekic.Fn m_free "struct mbuf *mbuf" 83de06f907SNik Clayton.Ft void 84de06f907SNik Clayton.Fn m_freem "struct mbuf *mbuf" 85bfd59721SBosko Milekic.\" 86bfd59721SBosko Milekic.Ss Mbuf utility functions 87de06f907SNik Clayton.Ft void 88de06f907SNik Clayton.Fn m_adj "struct mbuf *mbuf" "int len" 899c3fd404SSam Leffler.Ft void 909c3fd404SSam Leffler.Fn m_align "struct mbuf *mbuf" "int len" 91b9def06bSSam Leffler.Ft int 92b9def06bSSam Leffler.Fn m_append "struct mbuf *mbuf" "int len" "c_caddr_t cp" 93de06f907SNik Clayton.Ft struct mbuf * 94de06f907SNik Clayton.Fn m_prepend "struct mbuf *mbuf" "int len" "int how" 95de06f907SNik Clayton.Ft struct mbuf * 967ac139a9SJohn-Mark Gurney.Fn m_copyup "struct mbuf *mbuf" "int len" "int dstoff" 977ac139a9SJohn-Mark Gurney.Ft struct mbuf * 98de06f907SNik Clayton.Fn m_pullup "struct mbuf *mbuf" "int len" 99de06f907SNik Clayton.Ft struct mbuf * 100de06f907SNik Clayton.Fn m_copym "struct mbuf *mbuf" "int offset" "int len" "int how" 101de06f907SNik Clayton.Ft struct mbuf * 102de06f907SNik Clayton.Fn m_copypacket "struct mbuf *mbuf" "int how" 103de06f907SNik Clayton.Ft struct mbuf * 104de06f907SNik Clayton.Fn m_dup "struct mbuf *mbuf" "int how" 105de06f907SNik Clayton.Ft void 1060d8e4c57SBruce Evans.Fn m_copydata "const struct mbuf *mbuf" "int offset" "int len" "caddr_t buf" 107de06f907SNik Clayton.Ft void 108de06f907SNik Clayton.Fn m_copyback "struct mbuf *mbuf" "int offset" "int len" "caddr_t buf" 109de06f907SNik Clayton.Ft struct mbuf * 110de06f907SNik Clayton.Fo m_devget 111de06f907SNik Clayton.Fa "char *buf" 112de06f907SNik Clayton.Fa "int len" 113de06f907SNik Clayton.Fa "int offset" 114de06f907SNik Clayton.Fa "struct ifnet *ifp" 115de06f907SNik Clayton.Fa "void (*copy)(char *from, caddr_t to, u_int len)" 116de06f907SNik Clayton.Fc 117de06f907SNik Clayton.Ft void 118de06f907SNik Clayton.Fn m_cat "struct mbuf *m" "struct mbuf *n" 119e60fa837SRuslan Ermilov.Ft u_int 1200b1c0994SPoul-Henning Kamp.Fn m_fixhdr "struct mbuf *mbuf" 121da72b998SYaroslav Tykhiy.Ft void 122da72b998SYaroslav Tykhiy.Fn m_dup_pkthdr "struct mbuf *to" "struct mbuf *from" 123da72b998SYaroslav Tykhiy.Ft void 124da72b998SYaroslav Tykhiy.Fn m_move_pkthdr "struct mbuf *to" "struct mbuf *from" 125e60fa837SRuslan Ermilov.Ft u_int 1260b1c0994SPoul-Henning Kamp.Fn m_length "struct mbuf *mbuf" "struct mbuf **last" 127de06f907SNik Clayton.Ft struct mbuf * 128de06f907SNik Clayton.Fn m_split "struct mbuf *mbuf" "int len" "int how" 12902312219SBruce M Simpson.Ft int 13002312219SBruce M Simpson.Fn m_apply "struct mbuf *mbuf" "int off" "int len" "int (*f)(void *arg, void *data, u_int len)" "void *arg" 13102312219SBruce M Simpson.Ft struct mbuf * 13202312219SBruce M Simpson.Fn m_getptr "struct mbuf *mbuf" "int loc" "int *off" 133a61bc764SMike Silbersack.Ft struct mbuf * 134a61bc764SMike Silbersack.Fn m_defrag "struct mbuf *m0" "int how" 13547e2996eSSam Leffler.Ft struct mbuf * 13647e2996eSSam Leffler.Fn m_unshare "struct mbuf *m0" "int how" 137de06f907SNik Clayton.\" 138de06f907SNik Clayton.Sh DESCRIPTION 1397b2fd183SYaroslav TykhiyAn 1407b2fd183SYaroslav Tykhiy.Vt mbuf 1417b2fd183SYaroslav Tykhiyis a basic unit of memory management in the kernel IPC subsystem. 1427b2fd183SYaroslav TykhiyNetwork packets and socket buffers are stored in 1437b2fd183SYaroslav Tykhiy.Vt mbufs . 1447b2fd183SYaroslav TykhiyA network packet may span multiple 1457b2fd183SYaroslav Tykhiy.Vt mbufs 1467b2fd183SYaroslav Tykhiyarranged into a 1477b2fd183SYaroslav Tykhiy.Vt mbuf chain 148c4d9468eSRuslan Ermilov(linked list), 149de06f907SNik Claytonwhich allows adding or trimming 150bfd59721SBosko Milekicnetwork headers with little overhead. 151de06f907SNik Clayton.Pp 1527b2fd183SYaroslav TykhiyWhile a developer should not bother with 1537b2fd183SYaroslav Tykhiy.Vt mbuf 1547b2fd183SYaroslav Tykhiyinternals without serious 155de06f907SNik Claytonreason in order to avoid incompatibilities with future changes, it 1567b2fd183SYaroslav Tykhiyis useful to understand the general structure of an 1577b2fd183SYaroslav Tykhiy.Vt mbuf . 158de06f907SNik Clayton.Pp 1597b2fd183SYaroslav TykhiyAn 1607b2fd183SYaroslav Tykhiy.Vt mbuf 1617b2fd183SYaroslav Tykhiyconsists of a variable-sized header and a small internal 162e73145f6SSheldon Hearnbuffer for data. 1637b2fd183SYaroslav TykhiyThe total size of an 1647b2fd183SYaroslav Tykhiy.Vt mbuf , 165bfd59721SBosko Milekic.Dv MSIZE , 166feccf50cSAlex Dupreis a constant defined in 167feccf50cSAlex Dupre.In sys/param.h . 1687b2fd183SYaroslav TykhiyThe 1697b2fd183SYaroslav Tykhiy.Vt mbuf 1707b2fd183SYaroslav Tykhiyheader includes: 171de06f907SNik Clayton.Pp 172238d9c59SYaroslav Tykhiy.Bl -tag -width "m_nextpkt" -offset indent 173be82a0bcSYaroslav Tykhiy.It Va m_next 174238d9c59SYaroslav Tykhiy.Pq Vt struct mbuf * 175238d9c59SYaroslav TykhiyA pointer to the next 1767b2fd183SYaroslav Tykhiy.Vt mbuf 1777b2fd183SYaroslav Tykhiyin the 178238d9c59SYaroslav Tykhiy.Vt mbuf chain . 179be82a0bcSYaroslav Tykhiy.It Va m_nextpkt 180238d9c59SYaroslav Tykhiy.Pq Vt struct mbuf * 181238d9c59SYaroslav TykhiyA pointer to the next 1827b2fd183SYaroslav Tykhiy.Vt mbuf chain 183238d9c59SYaroslav Tykhiyin the queue. 184be82a0bcSYaroslav Tykhiy.It Va m_data 185238d9c59SYaroslav Tykhiy.Pq Vt caddr_t 186238d9c59SYaroslav TykhiyA pointer to data attached to this 187238d9c59SYaroslav Tykhiy.Vt mbuf . 188be82a0bcSYaroslav Tykhiy.It Va m_len 189238d9c59SYaroslav Tykhiy.Pq Vt int 190238d9c59SYaroslav TykhiyThe length of the data. 191be82a0bcSYaroslav Tykhiy.It Va m_type 192238d9c59SYaroslav Tykhiy.Pq Vt short 193238d9c59SYaroslav TykhiyThe type of the data. 194be82a0bcSYaroslav Tykhiy.It Va m_flags 195238d9c59SYaroslav Tykhiy.Pq Vt int 196238d9c59SYaroslav TykhiyThe 1977b2fd183SYaroslav Tykhiy.Vt mbuf 198238d9c59SYaroslav Tykhiyflags. 199de06f907SNik Clayton.El 200de06f907SNik Clayton.Pp 2017b2fd183SYaroslav TykhiyThe 2027b2fd183SYaroslav Tykhiy.Vt mbuf 2037b2fd183SYaroslav Tykhiyflag bits are defined as follows: 204de06f907SNik Clayton.Bd -literal 205de06f907SNik Clayton/* mbuf flags */ 206de06f907SNik Clayton#define M_EXT 0x0001 /* has associated external storage */ 207de06f907SNik Clayton#define M_PKTHDR 0x0002 /* start of record */ 208de06f907SNik Clayton#define M_EOR 0x0004 /* end of record */ 2095d4050ccSBosko Milekic#define M_RDONLY 0x0008 /* associated data marked read-only */ 2105d4050ccSBosko Milekic#define M_PROTO1 0x0010 /* protocol-specific */ 2115d4050ccSBosko Milekic#define M_PROTO2 0x0020 /* protocol-specific */ 2125d4050ccSBosko Milekic#define M_PROTO3 0x0040 /* protocol-specific */ 2135d4050ccSBosko Milekic#define M_PROTO4 0x0080 /* protocol-specific */ 2145d4050ccSBosko Milekic#define M_PROTO5 0x0100 /* protocol-specific */ 215f434362aSYaroslav Tykhiy#define M_PROTO6 0x4000 /* protocol-specific (avoid M_BCAST conflict) */ 216f434362aSYaroslav Tykhiy#define M_FREELIST 0x8000 /* mbuf is on the free list */ 217de06f907SNik Clayton 218f434362aSYaroslav Tykhiy/* mbuf pkthdr flags (also stored in m_flags) */ 2195d4050ccSBosko Milekic#define M_BCAST 0x0200 /* send/received as link-level broadcast */ 2205d4050ccSBosko Milekic#define M_MCAST 0x0400 /* send/received as link-level multicast */ 2215d4050ccSBosko Milekic#define M_FRAG 0x0800 /* packet is fragment of larger packet */ 2225d4050ccSBosko Milekic#define M_FIRSTFRAG 0x1000 /* packet is first fragment */ 2235d4050ccSBosko Milekic#define M_LASTFRAG 0x2000 /* packet is last fragment */ 224de06f907SNik Clayton.Ed 225de06f907SNik Clayton.Pp 2267b2fd183SYaroslav TykhiyThe available 2277b2fd183SYaroslav Tykhiy.Vt mbuf 2287b2fd183SYaroslav Tykhiytypes are defined as follows: 229de06f907SNik Clayton.Bd -literal 230de06f907SNik Clayton/* mbuf types */ 231de06f907SNik Clayton#define MT_DATA 1 /* dynamic (data) allocation */ 2321cb58a07SMaxim Konovalov#define MT_HEADER MT_DATA /* packet header */ 233de06f907SNik Clayton#define MT_SONAME 8 /* socket name */ 234de06f907SNik Clayton#define MT_CONTROL 14 /* extra-data protocol message */ 235de06f907SNik Clayton#define MT_OOBDATA 15 /* expedited data */ 236de06f907SNik Clayton.Ed 237de06f907SNik Clayton.Pp 238de06f907SNik ClaytonIf the 239de06f907SNik Clayton.Dv M_PKTHDR 240de06f907SNik Claytonflag is set, a 2417b2fd183SYaroslav Tykhiy.Vt struct pkthdr Va m_pkthdr 2427b2fd183SYaroslav Tykhiyis added to the 2437b2fd183SYaroslav Tykhiy.Vt mbuf 2447b2fd183SYaroslav Tykhiyheader. 245e73145f6SSheldon HearnIt contains a pointer to the interface 246de06f907SNik Claytonthe packet has been received from 2477b2fd183SYaroslav Tykhiy.Pq Vt struct ifnet Va *rcvif , 248de06f907SNik Claytonand the total packet length 2497b2fd183SYaroslav Tykhiy.Pq Vt int Va len . 250e85cc3f5SRuslan ErmilovOptionally, it may also contain an attached list of packet tags 251e85cc3f5SRuslan Ermilov.Pq Vt "struct m_tag" . 252e85cc3f5SRuslan ErmilovSee 253e85cc3f5SRuslan Ermilov.Xr mbuf_tags 9 254e85cc3f5SRuslan Ermilovfor details. 2550193eb5eSYaroslav TykhiyFields used in offloading checksum calculation to the hardware are kept in 2560193eb5eSYaroslav Tykhiy.Va m_pkthdr 2570193eb5eSYaroslav Tykhiyas well. 2580193eb5eSYaroslav TykhiySee 2590193eb5eSYaroslav Tykhiy.Sx HARDWARE-ASSISTED CHECKSUM CALCULATION 2600193eb5eSYaroslav Tykhiyfor details. 261de06f907SNik Clayton.Pp 2627b2fd183SYaroslav TykhiyIf small enough, data is stored in the internal data buffer of an 2637b2fd183SYaroslav Tykhiy.Vt mbuf . 2647b2fd183SYaroslav TykhiyIf the data is sufficiently large, another 2657b2fd183SYaroslav Tykhiy.Vt mbuf 2667b2fd183SYaroslav Tykhiymay be added to the 2677b2fd183SYaroslav Tykhiy.Vt mbuf chain , 2687b2fd183SYaroslav Tykhiyor external storage may be associated with the 2697b2fd183SYaroslav Tykhiy.Vt mbuf . 270de06f907SNik Clayton.Dv MHLEN 2717b2fd183SYaroslav Tykhiybytes of data can fit into an 2727b2fd183SYaroslav Tykhiy.Vt mbuf 2737b2fd183SYaroslav Tykhiywith the 274de06f907SNik Clayton.Dv M_PKTHDR 275de06f907SNik Claytonflag set, 276de06f907SNik Clayton.Dv MLEN 277de06f907SNik Claytonbytes can otherwise. 278de06f907SNik Clayton.Pp 2797b2fd183SYaroslav TykhiyIf external storage is being associated with an 2807b2fd183SYaroslav Tykhiy.Vt mbuf , 2817b2fd183SYaroslav Tykhiythe 282be82a0bcSYaroslav Tykhiy.Va m_ext 28325f1a2e9SSheldon Hearnheader is added at the cost of losing the internal data buffer. 284e73145f6SSheldon HearnIt includes a pointer to external storage, the size of the storage, 285e73145f6SSheldon Hearna pointer to a function used for freeing the storage, 286e73145f6SSheldon Hearna pointer to an optional argument that can be passed to the function, 287e73145f6SSheldon Hearnand a pointer to a reference counter. 2887b2fd183SYaroslav TykhiyAn 2897b2fd183SYaroslav Tykhiy.Vt mbuf 2907b2fd183SYaroslav Tykhiyusing external storage has the 291de06f907SNik Clayton.Dv M_EXT 292de06f907SNik Claytonflag set. 293de06f907SNik Clayton.Pp 294bfd59721SBosko MilekicThe system supplies a macro for allocating the desired external storage 295bfd59721SBosko Milekicbuffer, 296bfd59721SBosko Milekic.Dv MEXTADD . 297bfd59721SBosko Milekic.Pp 298bfd59721SBosko MilekicThe allocation and management of the reference counter is handled by the 299e73145f6SSheldon Hearnsubsystem. 300bfd59721SBosko Milekic.Pp 301bfd59721SBosko MilekicThe system also supplies a default type of external storage buffer called an 3027b2fd183SYaroslav Tykhiy.Vt mbuf cluster . 3037b2fd183SYaroslav Tykhiy.Vt Mbuf clusters 3047b2fd183SYaroslav Tykhiycan be allocated and configured with the use of the 305bfd59721SBosko Milekic.Dv MCLGET 306e73145f6SSheldon Hearnmacro. 3077b2fd183SYaroslav TykhiyEach 3087b2fd183SYaroslav Tykhiy.Vt mbuf cluster 3097b2fd183SYaroslav Tykhiyis 310de06f907SNik Clayton.Dv MCLBYTES 311bfd59721SBosko Milekicin size, where MCLBYTES is a machine-dependent constant. 312bfd59721SBosko MilekicThe system defines an advisory macro 313de06f907SNik Clayton.Dv MINCLSIZE , 3147b2fd183SYaroslav Tykhiywhich is the smallest amount of data to put into an 3157b2fd183SYaroslav Tykhiy.Vt mbuf cluster . 31636a142c4SRuslan ErmilovIt is equal to the sum of 317de06f907SNik Clayton.Dv MLEN 318de06f907SNik Claytonand 319de06f907SNik Clayton.Dv MHLEN . 3207b2fd183SYaroslav TykhiyIt is typically preferable to store data into the data region of an 3217b2fd183SYaroslav Tykhiy.Vt mbuf , 3227b2fd183SYaroslav Tykhiyif size permits, as opposed to allocating a separate 3237b2fd183SYaroslav Tykhiy.Vt mbuf cluster 3247b2fd183SYaroslav Tykhiyto hold the same data. 325de06f907SNik Clayton.\" 326de06f907SNik Clayton.Ss Macros and Functions 327bfd59721SBosko MilekicThere are numerous predefined macros and functions that provide the 328bfd59721SBosko Milekicdeveloper with common utilities. 329de06f907SNik Clayton.\" 330de06f907SNik Clayton.Bl -ohang -offset indent 331de06f907SNik Clayton.It Fn mtod mbuf type 3327b2fd183SYaroslav TykhiyConvert an 3337b2fd183SYaroslav Tykhiy.Fa mbuf 3347b2fd183SYaroslav Tykhiypointer to a data pointer. 3357b2fd183SYaroslav TykhiyThe macro expands to the data pointer cast to the pointer of the specified 3367b2fd183SYaroslav Tykhiy.Fa type . 337de06f907SNik Clayton.Sy Note : 3387b2fd183SYaroslav TykhiyIt is advisable to ensure that there is enough contiguous data in 3397b2fd183SYaroslav Tykhiy.Fa mbuf . 340de06f907SNik ClaytonSee 341de06f907SNik Clayton.Fn m_pullup 342de06f907SNik Claytonfor details. 343de06f907SNik Clayton.It Fn MGET mbuf how type 3447b2fd183SYaroslav TykhiyAllocate an 3457b2fd183SYaroslav Tykhiy.Vt mbuf 3467b2fd183SYaroslav Tykhiyand initialize it to contain internal data. 34725f1a2e9SSheldon Hearn.Fa mbuf 3487b2fd183SYaroslav Tykhiywill point to the allocated 3497b2fd183SYaroslav Tykhiy.Vt mbuf 3507b2fd183SYaroslav Tykhiyon success, or be set to 351de06f907SNik Clayton.Dv NULL 352e73145f6SSheldon Hearnon failure. 353e73145f6SSheldon HearnThe 354de06f907SNik Clayton.Fa how 355de06f907SNik Claytonargument is to be set to 356c65b53c5STom Rhodes.Dv M_TRYWAIT 357de06f907SNik Claytonor 358c65b53c5STom Rhodes.Dv M_DONTWAIT . 35925f1a2e9SSheldon HearnIt specifies whether the caller is willing to block if necessary. 360e73145f6SSheldon HearnIf 361de06f907SNik Clayton.Fa how 36225f1a2e9SSheldon Hearnis set to 363c65b53c5STom Rhodes.Dv M_TRYWAIT , 36425f1a2e9SSheldon Hearna failed allocation will result in the caller being put 365bfd59721SBosko Milekicto sleep for a designated 36625f1a2e9SSheldon Hearnkern.ipc.mbuf_wait 367c4d9468eSRuslan Ermilov.Xr ( sysctl 8 368c4d9468eSRuslan Ermilovtunable) 36925f1a2e9SSheldon Hearnnumber of ticks. 3707b2fd183SYaroslav TykhiyA number of other functions and macros related to 3717b2fd183SYaroslav Tykhiy.Vt mbufs 3727b2fd183SYaroslav Tykhiyhave the same argument because they may 3737b2fd183SYaroslav Tykhiyat some point need to allocate new 3747b2fd183SYaroslav Tykhiy.Vt mbufs . 375c65b53c5STom Rhodes.Pp 3767b2fd183SYaroslav TykhiyProgrammers should be careful not to confuse the 3777b2fd183SYaroslav Tykhiy.Vt mbuf 3787b2fd183SYaroslav Tykhiyallocation flag 379c65b53c5STom Rhodes.Dv M_DONTWAIT 380c65b53c5STom Rhodeswith the 381c65b53c5STom Rhodes.Xr malloc 9 382c65b53c5STom Rhodesallocation flag, 383c65b53c5STom Rhodes.Dv M_NOWAIT . 384c65b53c5STom RhodesThey are not the same. 385de06f907SNik Clayton.It Fn MGETHDR mbuf how type 3867b2fd183SYaroslav TykhiyAllocate an 3877b2fd183SYaroslav Tykhiy.Vt mbuf 3887b2fd183SYaroslav Tykhiyand initialize it to contain a packet header 389e73145f6SSheldon Hearnand internal data. 390e73145f6SSheldon HearnSee 391de06f907SNik Clayton.Fn MGET 392de06f907SNik Claytonfor details. 393de06f907SNik Clayton.It Fn MCLGET mbuf how 3947b2fd183SYaroslav TykhiyAllocate and attach an 3957b2fd183SYaroslav Tykhiy.Vt mbuf cluster 3967b2fd183SYaroslav Tykhiyto 3977b2fd183SYaroslav Tykhiy.Fa mbuf . 398e73145f6SSheldon HearnIf the macro fails, the 399de06f907SNik Clayton.Dv M_EXT 4000227791bSRuslan Ermilovflag will not be set in 4017b2fd183SYaroslav Tykhiy.Fa mbuf . 402da72b998SYaroslav Tykhiy.It Fn M_ALIGN mbuf len 403da72b998SYaroslav TykhiySet the pointer 404da72b998SYaroslav Tykhiy.Fa mbuf->m_data 405da72b998SYaroslav Tykhiyto place an object of the size 406da72b998SYaroslav Tykhiy.Fa len 407da72b998SYaroslav Tykhiyat the end of the internal data area of 408da72b998SYaroslav Tykhiy.Fa mbuf , 409da72b998SYaroslav Tykhiylong word aligned. 410da72b998SYaroslav TykhiyApplicable only if 411da72b998SYaroslav Tykhiy.Fa mbuf 412da72b998SYaroslav Tykhiyis newly allocated with 413da72b998SYaroslav Tykhiy.Fn MGET 414da72b998SYaroslav Tykhiyor 415da72b998SYaroslav Tykhiy.Fn m_get . 416da72b998SYaroslav Tykhiy.It Fn MH_ALIGN mbuf len 417da72b998SYaroslav TykhiyServes the same purpose as 418da72b998SYaroslav Tykhiy.Fn M_ALIGN 419da72b998SYaroslav Tykhiydoes, but only for 420da72b998SYaroslav Tykhiy.Fa mbuf 421da72b998SYaroslav Tykhiynewly allocated with 422da72b998SYaroslav Tykhiy.Fn MGETHDR 423da72b998SYaroslav Tykhiyor 424da72b998SYaroslav Tykhiy.Fn m_gethdr , 425da72b998SYaroslav Tykhiyor initialized by 426da72b998SYaroslav Tykhiy.Fn m_dup_pkthdr 427da72b998SYaroslav Tykhiyor 428da72b998SYaroslav Tykhiy.Fn m_move_pkthdr . 4299c3fd404SSam Leffler.It Fn m_align mbuf len 4309c3fd404SSam LefflerServices the same purpose as 4319c3fd404SSam Leffler.Fn M_ALIGN 4329c3fd404SSam Lefflerbut handles any type of mbuf. 433da72b998SYaroslav Tykhiy.It Fn M_LEADINGSPACE mbuf 434da72b998SYaroslav TykhiyReturns the number of bytes available before the beginning 435da72b998SYaroslav Tykhiyof data in 436da72b998SYaroslav Tykhiy.Fa mbuf . 437da72b998SYaroslav Tykhiy.It Fn M_TRAILINGSPACE mbuf 438da72b998SYaroslav TykhiyReturns the number of bytes available after the end of data in 439da72b998SYaroslav Tykhiy.Fa mbuf . 440de06f907SNik Clayton.It Fn M_PREPEND mbuf len how 4417b2fd183SYaroslav TykhiyThis macro operates on an 4427b2fd183SYaroslav Tykhiy.Vt mbuf chain . 443de06f907SNik ClaytonIt is an optimized wrapper for 444de06f907SNik Clayton.Fn m_prepend 445de06f907SNik Claytonthat can make use of possible empty space before data 4465203edcdSRuslan Ermilov(e.g.\& left after trimming of a link-layer header). 4477b2fd183SYaroslav TykhiyThe new 4487b2fd183SYaroslav Tykhiy.Vt mbuf chain 4497b2fd183SYaroslav Tykhiypointer or 450de06f907SNik Clayton.Dv NULL 451de06f907SNik Claytonis in 452de06f907SNik Clayton.Fa mbuf 453de06f907SNik Claytonafter the call. 454da72b998SYaroslav Tykhiy.It Fn M_MOVE_PKTHDR to from 455da72b998SYaroslav TykhiyUsing this macro is equivalent to calling 456da72b998SYaroslav Tykhiy.Fn m_move_pkthdr to from . 4575d4050ccSBosko Milekic.It Fn M_WRITABLE mbuf 4587b2fd183SYaroslav TykhiyThis macro will evaluate true if 4597b2fd183SYaroslav Tykhiy.Fa mbuf 4607b2fd183SYaroslav Tykhiyis not marked 4615d4050ccSBosko Milekic.Dv M_RDONLY 4627b2fd183SYaroslav Tykhiyand if either 4637b2fd183SYaroslav Tykhiy.Fa mbuf 4647b2fd183SYaroslav Tykhiydoes not contain external storage or, 4655d4050ccSBosko Milekicif it does, 4665d4050ccSBosko Milekicthen if the reference count of the storage is not greater than 1. 4675d4050ccSBosko MilekicThe 4685d4050ccSBosko Milekic.Dv M_RDONLY 4697b2fd183SYaroslav Tykhiyflag can be set in 4707b2fd183SYaroslav Tykhiy.Fa mbuf->m_flags . 4715d4050ccSBosko MilekicThis can be achieved during setup of the external storage, 4725d4050ccSBosko Milekicby passing the 4735d4050ccSBosko Milekic.Dv M_RDONLY 4745d4050ccSBosko Milekicbit as a 4750b39b3ffSRuslan Ermilov.Fa flags 4765d4050ccSBosko Milekicargument to the 4775d4050ccSBosko Milekic.Fn MEXTADD 4787b2fd183SYaroslav Tykhiymacro, or can be directly set in individual 4797b2fd183SYaroslav Tykhiy.Vt mbufs . 480da72b998SYaroslav Tykhiy.It Fn MCHTYPE mbuf type 481da72b998SYaroslav TykhiyChange the type of 482da72b998SYaroslav Tykhiy.Fa mbuf 483da72b998SYaroslav Tykhiyto 484da72b998SYaroslav Tykhiy.Fa type . 485da72b998SYaroslav TykhiyThis is a relatively expensive operation and should be avoided. 486de06f907SNik Clayton.El 487de06f907SNik Clayton.Pp 488de06f907SNik ClaytonThe functions are: 489de06f907SNik Clayton.Bl -ohang -offset indent 490de06f907SNik Clayton.It Fn m_get how type 491de06f907SNik ClaytonA function version of 492bfd59721SBosko Milekic.Fn MGET 493bfd59721SBosko Milekicfor non-critical paths. 494328c0bbcSBosko Milekic.It Fn m_getm orig len how type 495328c0bbcSBosko MilekicAllocate 4960b39b3ffSRuslan Ermilov.Fa len 4977b2fd183SYaroslav Tykhiybytes worth of 4987b2fd183SYaroslav Tykhiy.Vt mbufs 4997b2fd183SYaroslav Tykhiyand 5007b2fd183SYaroslav Tykhiy.Vt mbuf clusters 5017b2fd183SYaroslav Tykhiyif necessary and append the resulting allocated 5027b2fd183SYaroslav Tykhiy.Vt mbuf chain 5037b2fd183SYaroslav Tykhiyto the 5047b2fd183SYaroslav Tykhiy.Vt mbuf chain 5057b2fd183SYaroslav Tykhiy.Fa orig , 5067b2fd183SYaroslav Tykhiyif it is 5070b39b3ffSRuslan Ermilov.No non- Ns Dv NULL . 508328c0bbcSBosko MilekicIf the allocation fails at any point, 5090b39b3ffSRuslan Ermilovfree whatever was allocated and return 5100b39b3ffSRuslan Ermilov.Dv NULL . 511328c0bbcSBosko MilekicIf 5120b39b3ffSRuslan Ermilov.Fa orig 5130b39b3ffSRuslan Ermilovis 5140b39b3ffSRuslan Ermilov.No non- Ns Dv NULL , 515328c0bbcSBosko Milekicit will not be freed. 516328c0bbcSBosko MilekicIt is possible to use 517328c0bbcSBosko Milekic.Fn m_getm 518328c0bbcSBosko Milekicto either append 5190b39b3ffSRuslan Ermilov.Fa len 5207b2fd183SYaroslav Tykhiybytes to an existing 5217b2fd183SYaroslav Tykhiy.Vt mbuf 5227b2fd183SYaroslav Tykhiyor 5237b2fd183SYaroslav Tykhiy.Vt mbuf chain 524328c0bbcSBosko Milekic(for example, one which may be sitting in a pre-allocated ring) 5257b2fd183SYaroslav Tykhiyor to simply perform an all-or-nothing 5267b2fd183SYaroslav Tykhiy.Vt mbuf 5277b2fd183SYaroslav Tykhiyand 5287b2fd183SYaroslav Tykhiy.Vt mbuf cluster 5297b2fd183SYaroslav Tykhiyallocation. 530de06f907SNik Clayton.It Fn m_gethdr how type 531de06f907SNik ClaytonA function version of 532bfd59721SBosko Milekic.Fn MGETHDR 533bfd59721SBosko Milekicfor non-critical paths. 5346c013706SMaxim Konovalov.It Fn m_getcl how type flags 5356c013706SMaxim KonovalovFetch an 5366c013706SMaxim Konovalov.Vt mbuf 5376c013706SMaxim Konovalovwith a 5386c013706SMaxim Konovalov.Vt mbuf cluster 5396c013706SMaxim Konovalovattached to it. 5406c013706SMaxim KonovalovIf one of the allocations fails, the entire allocation fails. 5416c013706SMaxim KonovalovThis routine is the preferred way of fetching both the 5426c013706SMaxim Konovalov.Vt mbuf 5436c013706SMaxim Konovalovand 5446c013706SMaxim Konovalov.Vt mbuf cluster 5456c013706SMaxim Konovalovtogether, as it avoids having to unlock/relock between allocations. 5466c013706SMaxim KonovalovReturns 5476c013706SMaxim Konovalov.Dv NULL 5486c013706SMaxim Konovalovon failure. 549de06f907SNik Clayton.It Fn m_getclr how type 5507b2fd183SYaroslav TykhiyAllocate an 5517b2fd183SYaroslav Tykhiy.Vt mbuf 5527b2fd183SYaroslav Tykhiyand zero out the data region. 55301e7fdafSMaxim Konovalov.It Fn m_free mbuf 55401e7fdafSMaxim KonovalovFrees 55501e7fdafSMaxim Konovalov.Vt mbuf . 556b7131a26SJohn-Mark GurneyReturns 557b7131a26SJohn-Mark Gurney.Va m_next 558b7131a26SJohn-Mark Gurneyof the freed 559b7131a26SJohn-Mark Gurney.Vt mbuf . 560de06f907SNik Clayton.El 561de06f907SNik Clayton.Pp 5627b2fd183SYaroslav TykhiyThe functions below operate on 5637b2fd183SYaroslav Tykhiy.Vt mbuf chains . 564de06f907SNik Clayton.Bl -ohang -offset indent 565de06f907SNik Clayton.It Fn m_freem mbuf 5667b2fd183SYaroslav TykhiyFree an entire 5677b2fd183SYaroslav Tykhiy.Vt mbuf chain , 5687b2fd183SYaroslav Tykhiyincluding any external storage. 569de06f907SNik Clayton.\" 570de06f907SNik Clayton.It Fn m_adj mbuf len 571de06f907SNik ClaytonTrim 572de06f907SNik Clayton.Fa len 5737b2fd183SYaroslav Tykhiybytes from the head of an 5747b2fd183SYaroslav Tykhiy.Vt mbuf chain 5757b2fd183SYaroslav Tykhiyif 576de06f907SNik Clayton.Fa len 577de06f907SNik Claytonis positive, from the tail otherwise. 578de06f907SNik Clayton.\" 579b9def06bSSam Leffler.It Fn m_append mbuf len cp 580b9def06bSSam LefflerAppend 581b9def06bSSam Leffler.Vt len 582b9def06bSSam Lefflerbytes of data 583b9def06bSSam Leffler.Vt cp 584b9def06bSSam Lefflerto the 585b9def06bSSam Leffler.Vt mbuf chain . 586b9def06bSSam LefflerExtend the mbuf chain if the new data does not fit in 587b9def06bSSam Lefflerexisting space. 588b9def06bSSam Leffler.\" 589de06f907SNik Clayton.It Fn m_prepend mbuf len how 5907b2fd183SYaroslav TykhiyAllocate a new 5917b2fd183SYaroslav Tykhiy.Vt mbuf 5927b2fd183SYaroslav Tykhiyand prepend it to the 5937b2fd183SYaroslav Tykhiy.Vt mbuf chain , 5947b2fd183SYaroslav Tykhiyhandle 595de06f907SNik Clayton.Dv M_PKTHDR 596de06f907SNik Claytonproperly. 597de06f907SNik Clayton.Sy Note : 5980227791bSRuslan ErmilovIt does not allocate any 5997b2fd183SYaroslav Tykhiy.Vt mbuf clusters , 6007b2fd183SYaroslav Tykhiyso 601de06f907SNik Clayton.Fa len 602de06f907SNik Claytonmust be less than 603de06f907SNik Clayton.Dv MLEN 604de06f907SNik Claytonor 605de06f907SNik Clayton.Dv MHLEN , 606de06f907SNik Claytondepending on the 607d0353b83SRuslan Ermilov.Dv M_PKTHDR 608d0353b83SRuslan Ermilovflag setting. 609de06f907SNik Clayton.\" 6107ac139a9SJohn-Mark Gurney.It Fn m_copyup mbuf len dstoff 6117ac139a9SJohn-Mark GurneySimilar to 6127ac139a9SJohn-Mark Gurney.Fn m_pullup 6137ac139a9SJohn-Mark Gurneybut copies 6147ac139a9SJohn-Mark Gurney.Fa len 6157ac139a9SJohn-Mark Gurneybytes of data into a new mbuf at 6167ac139a9SJohn-Mark Gurney.Fa dstoff 6177ac139a9SJohn-Mark Gurneybytes into the mbuf. 6187ac139a9SJohn-Mark GurneyThe 6197ac139a9SJohn-Mark Gurney.Fa dstoff 6207ac139a9SJohn-Mark Gurneyargument aligns the data and leaves room for a link layer header. 6214f068961SRuslan ErmilovReturns the new 6227ac139a9SJohn-Mark Gurney.Vt mbuf chain 6237ac139a9SJohn-Mark Gurneyon success, 6247ac139a9SJohn-Mark Gurneyand frees the 6257ac139a9SJohn-Mark Gurney.Vt mbuf chain 6267ac139a9SJohn-Mark Gurneyand returns 6277ac139a9SJohn-Mark Gurney.Dv NULL 6287ac139a9SJohn-Mark Gurneyon failure. 6297ac139a9SJohn-Mark Gurney.Sy Note : 6307ac139a9SJohn-Mark GurneyThe function does not allocate 6317ac139a9SJohn-Mark Gurney.Vt mbuf clusters , 6327ac139a9SJohn-Mark Gurneyso 6337ac139a9SJohn-Mark Gurney.Fa len + dstoff 6347ac139a9SJohn-Mark Gurneymust be less than 6357ac139a9SJohn-Mark Gurney.Dv MHLEN . 6367ac139a9SJohn-Mark Gurney.\" 637de06f907SNik Clayton.It Fn m_pullup mbuf len 638de06f907SNik ClaytonArrange that the first 639de06f907SNik Clayton.Fa len 6407b2fd183SYaroslav Tykhiybytes of an 6417b2fd183SYaroslav Tykhiy.Vt mbuf chain 6427b2fd183SYaroslav Tykhiyare contiguous and lay in the data area of 643de06f907SNik Clayton.Fa mbuf , 644de06f907SNik Claytonso they are accessible with 645de06f907SNik Clayton.Fn mtod mbuf type . 6467b2fd183SYaroslav TykhiyReturn the new 6477b2fd183SYaroslav Tykhiy.Vt mbuf chain 6487b2fd183SYaroslav Tykhiyon success, 649de06f907SNik Clayton.Dv NULL 650de06f907SNik Claytonon failure 6517b2fd183SYaroslav Tykhiy(the 6527b2fd183SYaroslav Tykhiy.Vt mbuf chain 6537b2fd183SYaroslav Tykhiyis freed in this case). 654de06f907SNik Clayton.Sy Note : 6550227791bSRuslan ErmilovIt does not allocate any 6567b2fd183SYaroslav Tykhiy.Vt mbuf clusters , 6577b2fd183SYaroslav Tykhiyso 658de06f907SNik Clayton.Fa len 659de06f907SNik Claytonmust be less than 660de06f907SNik Clayton.Dv MHLEN . 661de06f907SNik Clayton.\" 662de06f907SNik Clayton.It Fn m_copym mbuf offset len how 6637b2fd183SYaroslav TykhiyMake a copy of an 6647b2fd183SYaroslav Tykhiy.Vt mbuf chain 6657b2fd183SYaroslav Tykhiystarting 666de06f907SNik Clayton.Fa offset 667de06f907SNik Claytonbytes from the beginning, continuing for 668de06f907SNik Clayton.Fa len 669e73145f6SSheldon Hearnbytes. 670e73145f6SSheldon HearnIf 671de06f907SNik Clayton.Fa len 672de06f907SNik Claytonis 673de06f907SNik Clayton.Dv M_COPYALL , 6747b2fd183SYaroslav Tykhiycopy to the end of the 6757b2fd183SYaroslav Tykhiy.Vt mbuf chain . 676de06f907SNik Clayton.Sy Note : 6777b2fd183SYaroslav TykhiyThe copy is read-only, because the 6787b2fd183SYaroslav Tykhiy.Vt mbuf clusters 6797b2fd183SYaroslav Tykhiyare not copied, only their reference counts are incremented. 680de06f907SNik Clayton.\" 681de06f907SNik Clayton.It Fn m_copypacket mbuf how 682de06f907SNik ClaytonCopy an entire packet including header, which must be present. 683de06f907SNik ClaytonThis is an optimized version of the common case 684de06f907SNik Clayton.Fn m_copym mbuf 0 M_COPYALL how . 685de06f907SNik Clayton.Sy Note : 6867b2fd183SYaroslav Tykhiythe copy is read-only, because the 6877b2fd183SYaroslav Tykhiy.Vt mbuf clusters 6887b2fd183SYaroslav Tykhiyare not copied, only their reference counts are incremented. 689de06f907SNik Clayton.\" 690de06f907SNik Clayton.It Fn m_dup mbuf how 6917b2fd183SYaroslav TykhiyCopy a packet header 6927b2fd183SYaroslav Tykhiy.Vt mbuf chain 6937b2fd183SYaroslav Tykhiyinto a completely new 6947b2fd183SYaroslav Tykhiy.Vt mbuf chain , 6957b2fd183SYaroslav Tykhiyincluding copying any 6967b2fd183SYaroslav Tykhiy.Vt mbuf clusters . 697e73145f6SSheldon HearnUse this instead of 698de06f907SNik Clayton.Fn m_copypacket 6997b2fd183SYaroslav Tykhiywhen you need a writable copy of an 7007b2fd183SYaroslav Tykhiy.Vt mbuf chain . 701de06f907SNik Clayton.\" 702de06f907SNik Clayton.It Fn m_copydata mbuf offset len buf 7037b2fd183SYaroslav TykhiyCopy data from an 7047b2fd183SYaroslav Tykhiy.Vt mbuf chain 7057b2fd183SYaroslav Tykhiystarting 706de06f907SNik Clayton.Fa off 707de06f907SNik Claytonbytes from the beginning, continuing for 708de06f907SNik Clayton.Fa len 709de06f907SNik Claytonbytes, into the indicated buffer 710de06f907SNik Clayton.Fa buf . 711de06f907SNik Clayton.\" 712de06f907SNik Clayton.It Fn m_copyback mbuf offset len buf 713de06f907SNik ClaytonCopy 714de06f907SNik Clayton.Fa len 715de06f907SNik Claytonbytes from the buffer 716de06f907SNik Clayton.Fa buf 7177b2fd183SYaroslav Tykhiyback into the indicated 7187b2fd183SYaroslav Tykhiy.Vt mbuf chain , 719de06f907SNik Claytonstarting at 720de06f907SNik Clayton.Fa offset 7217b2fd183SYaroslav Tykhiybytes from the beginning of the 7227b2fd183SYaroslav Tykhiy.Vt mbuf chain , 7237b2fd183SYaroslav Tykhiyextending the 7247b2fd183SYaroslav Tykhiy.Vt mbuf chain 7257b2fd183SYaroslav Tykhiyif necessary. 726de06f907SNik Clayton.Sy Note : 7270227791bSRuslan ErmilovIt does not allocate any 7287b2fd183SYaroslav Tykhiy.Vt mbuf clusters , 7297b2fd183SYaroslav Tykhiyjust adds 7307b2fd183SYaroslav Tykhiy.Vt mbufs 7317b2fd183SYaroslav Tykhiyto the 7327b2fd183SYaroslav Tykhiy.Vt mbuf chain . 73336a142c4SRuslan ErmilovIt is safe to set 734de06f907SNik Clayton.Fa offset 7357b2fd183SYaroslav Tykhiybeyond the current 7367b2fd183SYaroslav Tykhiy.Vt mbuf chain 7377b2fd183SYaroslav Tykhiyend: zeroed 7387b2fd183SYaroslav Tykhiy.Vt mbufs 7397b2fd183SYaroslav Tykhiywill be allocated to fill the space. 740de06f907SNik Clayton.\" 7415d96084fSYaroslav Tykhiy.It Fn m_length mbuf last 7427b2fd183SYaroslav TykhiyReturn the length of the 7437b2fd183SYaroslav Tykhiy.Vt mbuf chain , 7447b2fd183SYaroslav Tykhiyand optionally a pointer to the last 7457b2fd183SYaroslav Tykhiy.Vt mbuf . 7460b1c0994SPoul-Henning Kamp.\" 747da72b998SYaroslav Tykhiy.It Fn m_dup_pkthdr to from how 748da72b998SYaroslav TykhiyUpon the function's completion, the 749da72b998SYaroslav Tykhiy.Vt mbuf 750da72b998SYaroslav Tykhiy.Fa to 751da72b998SYaroslav Tykhiywill contain an identical copy of 752da72b998SYaroslav Tykhiy.Fa from->m_pkthdr 753da72b998SYaroslav Tykhiyand the per-packet attributes found in the 754da72b998SYaroslav Tykhiy.Vt mbuf chain 755da72b998SYaroslav Tykhiy.Fa from . 756da72b998SYaroslav TykhiyThe 757da72b998SYaroslav Tykhiy.Vt mbuf 758da72b998SYaroslav Tykhiy.Fa from 759da72b998SYaroslav Tykhiymust have the flag 760da72b998SYaroslav Tykhiy.Dv M_PKTHDR 761da72b998SYaroslav Tykhiyinitially set, and 762da72b998SYaroslav Tykhiy.Fa to 763da72b998SYaroslav Tykhiymust be empty on entry. 764da72b998SYaroslav Tykhiy.\" 765da72b998SYaroslav Tykhiy.It Fn m_move_pkthdr to from 766da72b998SYaroslav TykhiyMove 767da72b998SYaroslav Tykhiy.Va m_pkthdr 768da72b998SYaroslav Tykhiyand the per-packet attributes from the 769da72b998SYaroslav Tykhiy.Vt mbuf chain 770da72b998SYaroslav Tykhiy.Fa from 771da72b998SYaroslav Tykhiyto the 772da72b998SYaroslav Tykhiy.Vt mbuf 773da72b998SYaroslav Tykhiy.Fa to . 774da72b998SYaroslav TykhiyThe 775da72b998SYaroslav Tykhiy.Vt mbuf 776da72b998SYaroslav Tykhiy.Fa from 777da72b998SYaroslav Tykhiymust have the flag 778da72b998SYaroslav Tykhiy.Dv M_PKTHDR 779da72b998SYaroslav Tykhiyinitially set, and 780da72b998SYaroslav Tykhiy.Fa to 781da72b998SYaroslav Tykhiymust be empty on entry. 782da72b998SYaroslav TykhiyUpon the function's completion, 783da72b998SYaroslav Tykhiy.Fa from 784da72b998SYaroslav Tykhiywill have the flag 785da72b998SYaroslav Tykhiy.Dv M_PKTHDR 786da72b998SYaroslav Tykhiyand the per-packet attributes cleared. 787da72b998SYaroslav Tykhiy.\" 7885d96084fSYaroslav Tykhiy.It Fn m_fixhdr mbuf 7897b2fd183SYaroslav TykhiySet the packet-header length to the length of the 7907b2fd183SYaroslav Tykhiy.Vt mbuf chain . 7910b1c0994SPoul-Henning Kamp.\" 792de06f907SNik Clayton.It Fn m_devget buf len offset ifp copy 793de06f907SNik ClaytonCopy data from a device local memory pointed to by 794de06f907SNik Clayton.Fa buf 7957b2fd183SYaroslav Tykhiyto an 7967b2fd183SYaroslav Tykhiy.Vt mbuf chain . 797e73145f6SSheldon HearnThe copy is done using a specified copy routine 798de06f907SNik Clayton.Fa copy , 799de06f907SNik Claytonor 800de06f907SNik Clayton.Fn bcopy 801de06f907SNik Claytonif 802de06f907SNik Clayton.Fa copy 803de06f907SNik Claytonis 804de06f907SNik Clayton.Dv NULL . 805de06f907SNik Clayton.\" 806de06f907SNik Clayton.It Fn m_cat m n 807de06f907SNik ClaytonConcatenate 808de06f907SNik Clayton.Fa n 809de06f907SNik Claytonto 810de06f907SNik Clayton.Fa m . 8117b2fd183SYaroslav TykhiyBoth 8127b2fd183SYaroslav Tykhiy.Vt mbuf chains 8137b2fd183SYaroslav Tykhiymust be of the same type. 814de06f907SNik Clayton.Fa N 815de06f907SNik Claytonis still valid after the function returned. 816de06f907SNik Clayton.Sy Note : 817de06f907SNik ClaytonIt does not handle 818de06f907SNik Clayton.Dv M_PKTHDR 819de06f907SNik Claytonand friends. 820de06f907SNik Clayton.\" 821de06f907SNik Clayton.It Fn m_split mbuf len how 8227b2fd183SYaroslav TykhiyPartition an 8237b2fd183SYaroslav Tykhiy.Vt mbuf chain 8247b2fd183SYaroslav Tykhiyin two pieces, returning the tail: 825de06f907SNik Claytonall but the first 826de06f907SNik Clayton.Fa len 827e73145f6SSheldon Hearnbytes. 828e73145f6SSheldon HearnIn case of failure, it returns 829de06f907SNik Clayton.Dv NULL 8307b2fd183SYaroslav Tykhiyand attempts to restore the 8317b2fd183SYaroslav Tykhiy.Vt mbuf chain 8327b2fd183SYaroslav Tykhiyto its original state. 83302312219SBruce M Simpson.\" 83402312219SBruce M Simpson.It Fn m_apply mbuf off len f arg 83502312219SBruce M SimpsonApply a function to an 83602312219SBruce M Simpson.Vt mbuf chain , 83702312219SBruce M Simpsonat offset 83802312219SBruce M Simpson.Fa off , 83902312219SBruce M Simpsonfor length 840f48cbcdeSRuslan Ermilov.Fa len 841f48cbcdeSRuslan Ermilovbytes. 84202312219SBruce M SimpsonTypically used to avoid calls to 84302312219SBruce M Simpson.Fn m_pullup 84402312219SBruce M Simpsonwhich would otherwise be unnecessary or undesirable. 84502312219SBruce M Simpson.Fa arg 84602312219SBruce M Simpsonis a convenience argument which is passed to the callback function 84702312219SBruce M Simpson.Fa f . 84802312219SBruce M Simpson.Pp 84902312219SBruce M SimpsonEach time 85002312219SBruce M Simpson.Fn f 85102312219SBruce M Simpsonis called, it will be passed 85202312219SBruce M Simpson.Fa arg , 85302312219SBruce M Simpsona pointer to the 85402312219SBruce M Simpson.Fa data 85502312219SBruce M Simpsonin the current mbuf, and the length 85602312219SBruce M Simpson.Fa len 85702312219SBruce M Simpsonof the data in this mbuf to which the function should be applied. 85802312219SBruce M Simpson.Pp 85902312219SBruce M SimpsonThe function should return zero to indicate success; 86002312219SBruce M Simpsonotherwise, if an error is indicated, then 86102312219SBruce M Simpson.Fn m_apply 86202312219SBruce M Simpsonwill return the error and stop iterating through the 86302312219SBruce M Simpson.Vt mbuf chain . 86402312219SBruce M Simpson.\" 86502312219SBruce M Simpson.It Fn m_getptr mbuf loc off 86602312219SBruce M SimpsonReturn a pointer to the mbuf containing the data located at 86702312219SBruce M Simpson.Fa loc 86802312219SBruce M Simpsonbytes from the beginning of the 86902312219SBruce M Simpson.Vt mbuf chain . 87002312219SBruce M SimpsonThe corresponding offset into the mbuf will be stored in 87102312219SBruce M Simpson.Fa *off . 872a61bc764SMike Silbersack.It Fn m_defrag m0 how 873f48cbcdeSRuslan ErmilovDefragment an mbuf chain, returning the shortest possible 874bdf86185SMike Silbersackchain of mbufs and clusters. 875bdf86185SMike SilbersackIf allocation fails and this can not be completed, 876bdf86185SMike Silbersack.Dv NULL 877bdf86185SMike Silbersackwill be returned and the original chain will be unchanged. 878bdf86185SMike SilbersackUpon success, the original chain will be freed and the new 879bdf86185SMike Silbersackchain will be returned. 880a61bc764SMike Silbersack.Fa how 881a61bc764SMike Silbersackshould be either 882a61bc764SMike Silbersack.Dv M_TRYWAIT 883a61bc764SMike Silbersackor 884a61bc764SMike Silbersack.Dv M_DONTWAIT , 885a61bc764SMike Silbersackdepending on the caller's preference. 886a61bc764SMike Silbersack.Pp 887a61bc764SMike SilbersackThis function is especially useful in network drivers, where 888a61bc764SMike Silbersackcertain long mbuf chains must be shortened before being added 889a61bc764SMike Silbersackto TX descriptor lists. 89047e2996eSSam Leffler.It Fn m_unshare m0 how 89147e2996eSSam LefflerCreate a version of the specified mbuf chain whose 89247e2996eSSam Lefflercontents can be safely modified without affecting other users. 89347e2996eSSam LefflerIf allocation fails and this operation can not be completed, 89447e2996eSSam Leffler.Dv NULL 89547e2996eSSam Lefflerwill be returned. 89647e2996eSSam LefflerThe original mbuf chain is always reclaimed and the reference 89747e2996eSSam Lefflercount of any shared mbuf clusters is decremented. 89847e2996eSSam Leffler.Fa how 89947e2996eSSam Lefflershould be either 90047e2996eSSam Leffler.Dv M_TRYWAIT 90147e2996eSSam Leffleror 90247e2996eSSam Leffler.Dv M_DONTWAIT , 90347e2996eSSam Lefflerdepending on the caller's preference. 90447e2996eSSam LefflerAs a side-effect of this process the returned 90547e2996eSSam Lefflermbuf chain may be compacted. 90647e2996eSSam Leffler.Pp 90747e2996eSSam LefflerThis function is especially useful in the transmit path of 90847e2996eSSam Lefflernetwork code, when data must be encrypted or otherwise 90947e2996eSSam Leffleraltered prior to transmission. 9103136363fSRuslan Ermilov.El 9110193eb5eSYaroslav Tykhiy.Sh HARDWARE-ASSISTED CHECKSUM CALCULATION 9120193eb5eSYaroslav TykhiyThis section currently applies to TCP/IP only. 9130193eb5eSYaroslav TykhiyIn order to save the host CPU resources, computing checksums is 9140193eb5eSYaroslav Tykhiyoffloaded to the network interface hardware if possible. 9150193eb5eSYaroslav TykhiyThe 9160193eb5eSYaroslav Tykhiy.Va m_pkthdr 9170193eb5eSYaroslav Tykhiymember of the leading 9180193eb5eSYaroslav Tykhiy.Vt mbuf 9190193eb5eSYaroslav Tykhiyof a packet contains two fields used for that purpose, 9200193eb5eSYaroslav Tykhiy.Vt int Va csum_flags 9210193eb5eSYaroslav Tykhiyand 9220193eb5eSYaroslav Tykhiy.Vt int Va csum_data . 9230193eb5eSYaroslav TykhiyThe meaning of those fields depends on the direction a packet flows in, 9240193eb5eSYaroslav Tykhiyand on whether the packet is fragmented. 9250193eb5eSYaroslav TykhiyHenceforth, 9260193eb5eSYaroslav Tykhiy.Va csum_flags 9270193eb5eSYaroslav Tykhiyor 9280193eb5eSYaroslav Tykhiy.Va csum_data 9290193eb5eSYaroslav Tykhiyof a packet 9300193eb5eSYaroslav Tykhiywill denote the corresponding field of the 9310193eb5eSYaroslav Tykhiy.Va m_pkthdr 9320193eb5eSYaroslav Tykhiymember of the leading 9330193eb5eSYaroslav Tykhiy.Vt mbuf 9340193eb5eSYaroslav Tykhiyin the 9350193eb5eSYaroslav Tykhiy.Vt mbuf chain 9360193eb5eSYaroslav Tykhiycontaining the packet. 9370193eb5eSYaroslav Tykhiy.Pp 9380193eb5eSYaroslav TykhiyOn output, checksum offloading is attempted after the outgoing 9390193eb5eSYaroslav Tykhiyinterface has been determined for a packet. 9400193eb5eSYaroslav TykhiyThe interface-specific field 9410193eb5eSYaroslav Tykhiy.Va ifnet.if_data.ifi_hwassist 9420193eb5eSYaroslav Tykhiy(see 9430193eb5eSYaroslav Tykhiy.Xr ifnet 9 ) 9440193eb5eSYaroslav Tykhiyis consulted for the capabilities of the interface to assist in 9450193eb5eSYaroslav Tykhiycomputing checksums. 9460193eb5eSYaroslav TykhiyThe 9470193eb5eSYaroslav Tykhiy.Va csum_flags 948f48cbcdeSRuslan Ermilovfield of the packet header is set to indicate which actions the interface 9490193eb5eSYaroslav Tykhiyis supposed to perform on it. 9500193eb5eSYaroslav TykhiyThe actions unsupported by the network interface are done in the 9510193eb5eSYaroslav Tykhiysoftware prior to passing the packet down to the interface driver; 9520193eb5eSYaroslav Tykhiysuch actions will never be requested through 9530193eb5eSYaroslav Tykhiy.Va csum_flags . 9540193eb5eSYaroslav Tykhiy.Pp 9550193eb5eSYaroslav TykhiyThe flags demanding a particular action from an interface are as follows: 9560193eb5eSYaroslav Tykhiy.Bl -tag -width ".Dv CSUM_TCP" -offset indent 9570193eb5eSYaroslav Tykhiy.It Dv CSUM_IP 9580193eb5eSYaroslav TykhiyThe IP header checksum is to be computed and stored in the 9590193eb5eSYaroslav Tykhiycorresponding field of the packet. 9600193eb5eSYaroslav TykhiyThe hardware is expected to know the format of an IP header 9610193eb5eSYaroslav Tykhiyto determine the offset of the IP checksum field. 9620193eb5eSYaroslav Tykhiy.It Dv CSUM_TCP 963f48cbcdeSRuslan ErmilovThe TCP checksum is to be computed. 964f48cbcdeSRuslan Ermilov(See below.) 9650193eb5eSYaroslav Tykhiy.It Dv CSUM_UDP 966f48cbcdeSRuslan ErmilovThe UDP checksum is to be computed. 967f48cbcdeSRuslan Ermilov(See below.) 9680193eb5eSYaroslav Tykhiy.El 9690193eb5eSYaroslav Tykhiy.Pp 970fbde705aSYaroslav TykhiyShould a TCP or UDP checksum be offloaded to the hardware, 9710193eb5eSYaroslav Tykhiythe field 9720193eb5eSYaroslav Tykhiy.Va csum_data 9730193eb5eSYaroslav Tykhiywill contain the byte offset of the checksum field relative to the 9740193eb5eSYaroslav Tykhiyend of the IP header. 9750193eb5eSYaroslav TykhiyIn this case, the checksum field will be initially 9760193eb5eSYaroslav Tykhiyset by the TCP/IP module to the checksum of the pseudo header 977fbde705aSYaroslav Tykhiydefined by the TCP and UDP specifications. 9780193eb5eSYaroslav Tykhiy.Pp 9790193eb5eSYaroslav TykhiyFor outbound packets which have been fragmented 9800193eb5eSYaroslav Tykhiyby the host CPU, the following will also be true, 9810193eb5eSYaroslav Tykhiyregardless of the checksum flag settings: 9820193eb5eSYaroslav Tykhiy.Bl -bullet -offset indent 9830193eb5eSYaroslav Tykhiy.It 9840193eb5eSYaroslav Tykhiyall fragments will have the flag 9850193eb5eSYaroslav Tykhiy.Dv M_FRAG 9860193eb5eSYaroslav Tykhiyset in their 9870193eb5eSYaroslav Tykhiy.Va m_flags 9880193eb5eSYaroslav Tykhiyfield; 9890193eb5eSYaroslav Tykhiy.It 9900193eb5eSYaroslav Tykhiythe first and the last fragments in the chain will have 9910193eb5eSYaroslav Tykhiy.Dv M_FIRSTFRAG 9920193eb5eSYaroslav Tykhiyor 9930193eb5eSYaroslav Tykhiy.Dv M_LASTFRAG 9940193eb5eSYaroslav Tykhiyset in their 9950193eb5eSYaroslav Tykhiy.Va m_flags , 9960193eb5eSYaroslav Tykhiycorrespondingly; 9970193eb5eSYaroslav Tykhiy.It 9980193eb5eSYaroslav Tykhiythe first fragment in the chain will have the total number 9990193eb5eSYaroslav Tykhiyof fragments contained in its 10000193eb5eSYaroslav Tykhiy.Va csum_data 10010193eb5eSYaroslav Tykhiyfield. 10020193eb5eSYaroslav Tykhiy.El 10030193eb5eSYaroslav Tykhiy.Pp 100476f80df6SYaroslav TykhiyThe last rule for fragmented packets takes precedence over the one 100576f80df6SYaroslav Tykhiyfor a TCP or UDP checksum. 100676f80df6SYaroslav TykhiyNevertheless, offloading a TCP or UDP checksum is possible for a 100776f80df6SYaroslav Tykhiyfragmented packet if the flag 100876f80df6SYaroslav Tykhiy.Dv CSUM_IP_FRAGS 100976f80df6SYaroslav Tykhiyis set in the field 101076f80df6SYaroslav Tykhiy.Va ifnet.if_data.ifi_hwassist 101176f80df6SYaroslav Tykhiyassociated with the network interface. 101276f80df6SYaroslav TykhiyHowever, in this case the interface is expected to figure out 101376f80df6SYaroslav Tykhiythe location of the checksum field within the sequence of fragments 101476f80df6SYaroslav Tykhiyby itself because 10150193eb5eSYaroslav Tykhiy.Va csum_data 101676f80df6SYaroslav Tykhiycontains a fragment count instead of a checksum offset value. 10170193eb5eSYaroslav Tykhiy.Pp 10180193eb5eSYaroslav TykhiyOn input, an interface indicates the actions it has performed 10190193eb5eSYaroslav Tykhiyon a packet by setting one or more of the following flags in 10200193eb5eSYaroslav Tykhiy.Va csum_flags 10210193eb5eSYaroslav Tykhiyassociated with the packet: 10220193eb5eSYaroslav Tykhiy.Bl -tag -width ".Dv CSUM_IP_CHECKED" -offset indent 10230193eb5eSYaroslav Tykhiy.It Dv CSUM_IP_CHECKED 10240193eb5eSYaroslav TykhiyThe IP header checksum has been computed. 10250193eb5eSYaroslav Tykhiy.It Dv CSUM_IP_VALID 10260193eb5eSYaroslav TykhiyThe IP header has a valid checksum. 10270193eb5eSYaroslav TykhiyThis flag can appear only in combination with 10280193eb5eSYaroslav Tykhiy.Dv CSUM_IP_CHECKED . 10290193eb5eSYaroslav Tykhiy.It Dv CSUM_DATA_VALID 10300193eb5eSYaroslav TykhiyThe checksum of the data portion of the IP packet has been computed 10310193eb5eSYaroslav Tykhiyand stored in the field 10320193eb5eSYaroslav Tykhiy.Va csum_data 10330193eb5eSYaroslav Tykhiyin network byte order. 10340193eb5eSYaroslav Tykhiy.It Dv CSUM_PSEUDO_HDR 10350193eb5eSYaroslav TykhiyCan be set only along with 10360193eb5eSYaroslav Tykhiy.Dv CSUM_DATA_VALID 10370193eb5eSYaroslav Tykhiyto indicate that the IP data checksum found in 10380193eb5eSYaroslav Tykhiy.Va csum_data 1039fbde705aSYaroslav Tykhiyallows for the pseudo header defined by the TCP and UDP specifications. 10400193eb5eSYaroslav TykhiyOtherwise the checksum of the pseudo header must be calculated by 10410193eb5eSYaroslav Tykhiythe host CPU and added to 10420193eb5eSYaroslav Tykhiy.Va csum_data 1043fbde705aSYaroslav Tykhiyto obtain the final checksum to be used for TCP or UDP validation purposes. 10440193eb5eSYaroslav Tykhiy.El 10450193eb5eSYaroslav Tykhiy.Pp 10460193eb5eSYaroslav TykhiyIf a particular network interface just indicates success or 10470193eb5eSYaroslav Tykhiyfailure of TCP or UDP checksum validation without returning 10480193eb5eSYaroslav Tykhiythe exact value of the checksum to the host CPU, its driver can mark 10490193eb5eSYaroslav Tykhiy.Dv CSUM_DATA_VALID 10500193eb5eSYaroslav Tykhiyand 10510193eb5eSYaroslav Tykhiy.Dv CSUM_PSEUDO_HDR 10520193eb5eSYaroslav Tykhiyin 10530193eb5eSYaroslav Tykhiy.Va csum_flags , 10540193eb5eSYaroslav Tykhiyand set 10550193eb5eSYaroslav Tykhiy.Va csum_data 10560193eb5eSYaroslav Tykhiyto 10570193eb5eSYaroslav Tykhiy.Li 0xFFFF 10580193eb5eSYaroslav Tykhiyhexadecimal to indicate a valid checksum. 1059f48cbcdeSRuslan ErmilovIt is a peculiarity of the algorithm used that the Internet checksum 10600193eb5eSYaroslav Tykhiycalculated over any valid packet will be 10610193eb5eSYaroslav Tykhiy.Li 0xFFFF 10620193eb5eSYaroslav Tykhiyas long as the original checksum field is included. 10630193eb5eSYaroslav Tykhiy.Pp 10640193eb5eSYaroslav TykhiyFor inbound packets which are IP fragments, all 10650193eb5eSYaroslav Tykhiy.Va csum_data 10660193eb5eSYaroslav Tykhiyfields will be summed during reassembly to obtain the final checksum 10670193eb5eSYaroslav Tykhiyvalue passed to an upper layer in the 10680193eb5eSYaroslav Tykhiy.Va csum_data 10690193eb5eSYaroslav Tykhiyfield of the reassembled packet. 10700193eb5eSYaroslav TykhiyThe 10710193eb5eSYaroslav Tykhiy.Va csum_flags 10720193eb5eSYaroslav Tykhiyfields of all fragments will be consolidated using logical AND 10730193eb5eSYaroslav Tykhiyto obtain the final value for 10740193eb5eSYaroslav Tykhiy.Va csum_flags . 10750193eb5eSYaroslav TykhiyThus, in order to successfully 10760193eb5eSYaroslav Tykhiyoffload checksum computation for fragmented data, 10770193eb5eSYaroslav Tykhiyall fragments should have the same value of 10780193eb5eSYaroslav Tykhiy.Va csum_flags . 10793cab047eSMike Silbersack.Sh STRESS TESTING 1080c8185672SRuslan ErmilovWhen running a kernel compiled with the option 1081c8185672SRuslan Ermilov.Dv MBUF_STRESS_TEST , 1082c8185672SRuslan Ermilovthe following 1083c8185672SRuslan Ermilov.Xr sysctl 8 Ns 1084c8185672SRuslan Ermilov-controlled options may be used to create 10853cab047eSMike Silbersackvarious failure/extreme cases for testing of network drivers 10867b2fd183SYaroslav Tykhiyand other parts of the kernel that rely on 10877b2fd183SYaroslav Tykhiy.Vt mbufs . 1088c8185672SRuslan Ermilov.Bl -tag -width ident 1089c8185672SRuslan Ermilov.It Va net.inet.ip.mbuf_frag_size 1090c8185672SRuslan ErmilovCauses 1091c8185672SRuslan Ermilov.Fn ip_output 10927b2fd183SYaroslav Tykhiyto fragment outgoing 10937b2fd183SYaroslav Tykhiy.Vt mbuf chains 10947b2fd183SYaroslav Tykhiyinto fragments of the specified size. 1095c8185672SRuslan ErmilovSetting this variable to 1 is an excellent way to 10967b2fd183SYaroslav Tykhiytest the long 10977b2fd183SYaroslav Tykhiy.Vt mbuf chain 10987b2fd183SYaroslav Tykhiyhandling ability of network drivers. 1099c8185672SRuslan Ermilov.It Va kern.ipc.m_defragrandomfailures 1100c8185672SRuslan ErmilovCauses the function 1101c8185672SRuslan Ermilov.Fn m_defrag 1102c8185672SRuslan Ermilovto randomly fail, returning 1103c8185672SRuslan Ermilov.Dv NULL . 1104c8185672SRuslan ErmilovAny piece of code which uses 1105c8185672SRuslan Ermilov.Fn m_defrag 1106c8185672SRuslan Ermilovshould be tested with this feature. 1107c8185672SRuslan Ermilov.El 1108de06f907SNik Clayton.Sh RETURN VALUES 1109de06f907SNik ClaytonSee above. 11100193eb5eSYaroslav Tykhiy.Sh SEE ALSO 1111e85cc3f5SRuslan Ermilov.Xr ifnet 9 , 1112e85cc3f5SRuslan Ermilov.Xr mbuf_tags 9 1113de06f907SNik Clayton.Sh HISTORY 1114de06f907SNik Clayton.\" Please correct me if I'm wrong 11157b2fd183SYaroslav Tykhiy.Vt Mbufs 11167b2fd183SYaroslav Tykhiyappeared in an early version of 1117753d686dSRuslan Ermilov.Bx . 111853b2520dSTom RhodesBesides being used for network packets, they were used 1119bfd59721SBosko Milekicto store various dynamic structures, such as routing table 1120bfd59721SBosko Milekicentries, interface addresses, protocol control blocks, etc. 1121de06f907SNik Clayton.Sh AUTHORS 11226575e6daSRuslan ErmilovThe original 11236575e6daSRuslan Ermilov.Nm 1124571dba6eSHiten Pandyamanual page was written by Yar Tikhiy. 1125