summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_mbuf.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge r258128 from head:glebius2013-11-221-0/+1
| | | | | | Fix a very bad typo from r248887. Approved by: re (kib)
* Pad m_hdr on 32bit architectures to to prevent alignment and paddingandre2013-08-271-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | problems with the way MLEN, MHLEN, and struct mbuf are set up. CTASSERT's are provided to detect such issues at compile time in the future. The #define MLEN and MHLEN calculation do not take actual compiler- induced alignment and padding inside the complete struct mbuf into account. Accordingly appropriate attention is required when changing members of struct mbuf. Ideally one would calculate MLEN as (MSIZE - sizeof(((struct mbuf *)0)->m_hdr) but that doesn't work as the compiler refuses to operate on an as of yet incomplete structure. In particular ARM 32bit has more strict alignment requirements which caused 4 bytes of padding between m_hdr and pkthdr in struct mbuf because of the 64bit members in pkthdr. This wasn't picked up by MLEN and MHLEN causing an overflow of the mbuf provided data storage by overestimating its size. I386 didn't show this problem because it handles unaligned access just fine, albeit at a small performance penalty. On 64bit architectures the struct mbuf layout is 64bit aligned in all places. Reported by: Thomas Skibo <ThomasSkibo-at-sbcglobal-dot-net> Tested by: tuexen, ian, Thomas Skibo (extended patch) Sponsored by: The FreeBSD Foundation
* Give (*ext_free) an int return value allowing for very sophisticatedandre2013-08-251-2/+2
| | | | | | | | external mbuf buffer management capabilities in the future. For now only EXT_FREE_OK is defined with current legacy behavior. Sponsored by: The FreeBSD Foundation
* Restructure the mbuf pkthdr to make it fit for upcoming capabilities andandre2013-08-241-7/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | features. The changes in particular are: o Remove rarely used "header" pointer and replace it with a 64bit protocol/ layer specific union PH_loc for local use. Protocols can flexibly overlay their own 8 to 64 bit fields to store information while the packet is worked on. o Mechanically convert IP reassembly, IGMP/MLD and ATM to use pkthdr.PH_loc instead of pkthdr.header. o Extend csum_flags to 64bits to allow for additional future offload information to be carried (e.g. iSCSI, IPsec offload, and others). o Move the RSS hash type enumerator from abusing m_flags to its own 8bit rsstype field. Adjust accessor macros. o Add cosqos field to store Class of Service / Quality of Service information with the packet. It is not yet supported in any drivers but allows us to get on par with Cisco/Juniper in routing applications (plus MPLS QoS) with a modernized ALTQ. o Add four 8 bit fields l[2-5]hlen to store the relative header offsets from the start of the packet. This is important for various offload capabilities and to relieve the drivers from having to parse the packet and protocol headers to find out location of checksums and other information. Header parsing in drivers is a lot of copy-paste and unhandled corner cases which we want to avoid. o Add another flexible 64bit union to map various additional persistent packet information, like ether_vtag, tso_segsz and csum fields. Depending on the csum_flags settings some fields may have different usage making it very flexible and adaptable to future capabilities. o Restructure the CSUM flags to better signify their outbound (down the stack) and inbound (up the stack) use. The CSUM flags used to be a bit chaotic and rather poorly documented leading to incorrect use in many places. Bring clarity into their use through better naming. Compatibility mappings are provided to preserve the API. The drivers can be corrected one by one and MFC'd without issue. o The size of pkthdr stays the same at 48/56bytes (32/64bit architectures). Sponsored by: The FreeBSD Foundation
* Add an mbuf pointer parameter to (*ext_free) to give the externalandre2013-08-241-3/+3
| | | | | | | | | | | | free function access to the mbuf the external memory was attached to. Mechanically adjust all users to include the mbuf parameter. This fixes a long standing annoyance for external free functions. Before one had to sacrifice one of the argument pointers for this. Sponsored by: The FreeBSD Foundation
* dd a 24 bits wide ext_flags field to m_ext by reducing ext_typeandre2013-08-241-0/+3
| | | | | | | | | | | | | | | | | | | | | to 8 bits. ext_type is an enumerator and the number of types we have is a mere dozen. A couple of ext_types are renumbered to fit within 8 bits. EXT_VENDOR[1-4] and EXT_EXP[1-4] types for vendor-internal and experimental local mapping. The ext_flags field is currently unused but has a couple of flags already defined for future use. Again vendor and experimental flags are provided for local mapping. EXT_FLAG_BITS is provided for the printf(9) %b identifier. Initialize and copy ext_flags in the relevant mbuf functions. Improve alignment and packing of struct m_ext on 32 and 64 archs by carefully sorting the fields.
* Revert r254520 and resurrect the M_NOFREE mbuf flag and functionality.andre2013-08-211-1/+9
| | | | Requested by: np, grehan
* Remove the unused M_NOFREE mbuf flag. It didn't have any in-tree usersandre2013-08-191-10/+1
| | | | | | | | | | for a very long time, if ever. Should such a functionality ever be needed again the appropriate and much better way to do it is through a custom EXT_SOMETHING external mbuf type together with a dedicated *ext_free function. Discussed with: trociny, glebius
* Nuke mbstat. It wasn't used for mbuf statistics since FreeBSD 5.glebius2013-07-151-6/+0
| | | | | | Now that r253351 moved sendfile() stats to a separate struct, the last field used in mbstat is m_mcfail, which is updated, but never read or obtained from userland.
* Fix bug in m_split() in a case when split len matches len of theglebius2013-03-291-1/+10
| | | | | | | first mbuf, and the first mbuf is M_PKTHDR. PR: kern/176144 Submitted by: Jacques Fourie <jacques.fourie gmail.com>
* In m_align() add assertions that mbuf is virgin, similar to assertionsglebius2013-03-171-4/+12
| | | | in M_ALIGN(), MH_ALIGN, MEXT_ALIGN() macros.
* - Replace compat macros with function calls.glebius2013-03-161-17/+15
| | | | | | - Remove superfluous cleaning of m_len after allocating. Sponsored by: Nginx, Inc.
* Contrary to what the deleted comment said, the m_move_pkthdr()glebius2013-03-161-35/+10
| | | | | | | | | will not smash the M_EXT and data pointer, so it is safe to pass an mbuf with external storage procuded by m_getcl() to m_move_pkthdr(). Reviewed by: andre Sponsored by: Nginx, Inc.
* Make m_get2() never use clusters that are bigger than PAGE_SIZE.glebius2013-03-151-13/+3
| | | | | Requested by: andre, jhb Sponsored by: Nginx, Inc.
* Functions m_getm2() and m_get2() have different order of arguments,glebius2013-03-121-1/+1
| | | | | | | and that can drive someone crazy. While m_get2() is young and not documented yet, change its order of arguments to match m_getm2(). Sorry for churn, but better now than later.
* The m_extadd() can fail due to memory allocation failure, thus:glebius2013-03-121-14/+19
| | | | | | | | | - Make it return int, not void. - Add wait parameter. - Update MEXTADD() macro appropriately, defaults to M_NOWAIT, as before this change. Sponsored by: Nginx, Inc.
* - Move large functions m_getjcl() and m_get2() to kern/uipc_mbuf.cglebius2013-01-241-0/+73
| | | | | | - style(9) fixes to mbuf.h Reviewed by: bde
* Mechanically substitute flags from historic mbuf allocator withglebius2012-12-051-10/+10
| | | | | | | | | malloc(9) flags within sys. Exceptions: - sys/contrib not touched - sys/mbuf.h edited manually
* Since the macro dtom() has been removed, fix comments about the dtom.kevlo2012-10-291-2/+2
| | | | Reviewed by: glebius
* Improve m_cat() by being able to also merge contents from M_EXTandre2012-10-281-3/+3
| | | | | | | | | | mbuf's by doing proper testing with M_WRITABLE(). In m_collapse() replace an incomplete manual check for M_RDONLY with the M_WRITABLE() macro that also tests for shared buffers and other cases that make a particular mbuf immutable. MFC after: 2 weeks
* Fix found places where uio_resid is truncated to int.kib2012-02-211-1/+2
| | | | | | | | | Add the sysctl debug.iosize_max_clamp, enabled by default. Setting the sysctl to zero allows to perform the SSIZE_MAX-sized i/o requests from the usermode. Discussed with: bde, das (previous versions) MFC after: 1 month
* Xen netback driver rewrite.ken2012-01-261-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | share/man/man4/Makefile, share/man/man4/xnb.4, sys/dev/xen/netback/netback.c, sys/dev/xen/netback/netback_unit_tests.c: Rewrote the netback driver for xen to attach properly via newbus and work properly in both HVM and PVM mode (only HVM is tested). Works with the in-tree FreeBSD netfront driver or the Windows netfront driver from SuSE. Has not been extensively tested with a Linux netfront driver. Does not implement LRO, TSO, or polling. Includes unit tests that may be run through sysctl after compiling with XNB_DEBUG defined. sys/dev/xen/blkback/blkback.c, sys/xen/interface/io/netif.h: Comment elaboration. sys/kern/uipc_mbuf.c: Fix page fault in kernel mode when calling m_print() on a null mbuf. Since m_print() is only used for debugging, there are no performance concerns for extra error checking code. sys/kern/subr_scanf.c: Add the "hh" and "ll" width specifiers from C99 to scanf(). A few callers were already using "ll" even though scanf() was handling it as "l". Submitted by: Alan Somers <alans@spectralogic.com> Submitted by: John Suykerbuyk <johns@spectralogic.com> Sponsored by: Spectra Logic MFC after: 1 week Reviewed by: ken
* Fix typos - remove duplicate "the".brucec2011-02-211-1/+1
| | | | | | PR: bin/154928 Submitted by: Eitan Adler <lists at eitanadler.com> MFC after: 3 days
* Revert r210225 - turns out I was wrong; the "/*-" is not license-onlytrasz2010-07-181-1/+1
| | | | | | | thing; it's also used to indicate that the comment should not be automatically rewrapped. Explained by: cperciva@
* The "/*-" comment marker is supposed to denote copyrights. Remove non-copyrighttrasz2010-07-181-1/+1
| | | | occurences from sys/sys/ and sys/kern/.
* Correctly copy the M_RDONLY flag when duplicating a referencecperciva2010-07-131-0/+1
| | | | | | | | to an mbuf external buffer. Approved by: so (cperciva) Approved by: re (kensmith) Security: FreeBSD-SA-10:07.mbuf
* Use ISO C99 integer types in sys/kern where possible.ed2010-06-211-1/+1
| | | | | | There are only about 100 occurences of the BSD-specific u_int*_t datatypes in sys/kern. The ISO C99 integer types are used here more often.
* Remove a redundant variable assignment.zec2010-05-011-2/+1
| | | | | Reviewed by: bz, rwatson MFC after: 3 days
* Add m_mbuftouio() helper function to copy(out) an arbitraryandre2009-06-221-0/+28
| | | | | | | | | long mbuf chain into an arbitrary large uio in a single step. It is a functional mirror image of m_uiotombuf(). This function is supposed to be used instead of hand rolled code with the same purpose and to concentrate it into one place for potential further optimization or hardware assistance.
* Update m_demote:andre2009-06-221-4/+6
| | | | | | - remove HT_HEADER test (MT_HEADER == MT_DATA for some time now) - be more pedantic about m_nextpkt in other than first mbuf - update m_flags to be retained
* Move "options MAC" from opt_mac.h to opt_global.h, as it's now in GENERICrwatson2009-06-051-1/+0
| | | | | | | | and used in a large number of files, but also because an increasing number of incorrect uses of MAC calls were sneaking in due to copy-and-paste of MAC-aware code without the associated opt_mac.h include. Discussed with: pjd
* Remove unneeded include.rwatson2009-06-021-2/+0
| | | | MFC after: 3 days
* Teach m_copyback() to use trailing space of the last mbuf in chain.mav2009-01-181-0/+4
|
* Remove the alignment of the align parameter. This is up to the caller to passthompsa2008-09-051-3/+1
| | | | | | | | | in and it breaks tap(4) on strict alignment machines as m_uiotombuf is called with ETHER_ALIGN. Found by: Jared Go Reviewed by: emax MFC after: 3 days
* Attempt to make the print types more friendly to other architectures.julian2008-04-301-15/+15
| | | | | Prodded by: Max Laier Help from: BMS, jhb
* Add an option (compiled out by default)julian2008-04-291-0/+152
| | | | | | | | | to profile outoing packets for a number of mbuf chain related parameters e.g. number of mbufs, wasted space. probably will do with further work later. Reviewed by: various
* Replaced the misleading uses of a historical artefact M_TRYWAIT with M_WAIT.ru2008-03-251-1/+1
| | | | | | | | | | Removed dead code that assumed that M_TRYWAIT can return NULL; it's not true since the advent of MBUMA. Reviewed by: arch There are ongoing disputes as to whether we want to switch to directly using UMA flags M_WAITOK/M_NOWAIT for mbuf(9) allocation.
* Give MEXTADD() another argument to make both void pointers to thephk2008-02-011-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | free function controlable, instead of passing the KVA of the buffer storage as the first argument. Fix all conventional users of the API to pass the KVA of the buffer as the first argument, to make this a no-op commit. Likely break the only non-convetional user of the API, after informing the relevant committer. Update the mbuf(9) manual page, which was already out of sync on this point. Bump __FreeBSD_version to 800016 as there is no way to tell how many arguments a CPP macro needs any other way. This paves the way for giving sendfile(9) a way to wait for the passed storage to have been accessed before returning. This does not affect the memory layout or size of mbufs. Parental oversight by: sam and rwatson. No MFC is anticipated.
* promote ath_defrag to m_collapse (and retire private+unusedsam2008-01-171-0/+86
| | | | | | | m_collapse from cxgb) Reviewed by: pyun, jhb, kmacy MFC after: 2 weeks
* This patch adds an M_NOFREE flag which allows one to mark an mbuf askmacy2007-10-061-0/+11
| | | | | | | | | | | | not being independently freeable. This allows one to embed an mbuf in the cluster itself. This confers the benefits of the packet zone on all cluster sizes. Embedded mbufs currently suffer from the same limitation that packet zone mbufs do in that one cannot disconnect them and pass them around independently of the cluster. It would likely be possible to eliminate this limitation in the future by adding a second reference for the mbuf itself. Approved by: re(gnn)
* Generally migrate to ANSI function headers, and remove 'register' use.rwatson2007-05-161-1/+1
|
* remove now invalid check from m_sanitykmacy2007-04-141-10/+5
| | | | panic on m_sanity check failure with INVARIANTS
* Unbreak writes of 0 bytes. Zero byte writes happen when only ancillaryandre2007-01-221-2/+5
| | | | | | | | | | | control data but no payload data is passed. Change m_uiotombuf() to return at least one empty mbuf if the requested length was zero. Add comment to sosend_dgram and sosend_generic(). Diagnoses by: jhb Regression test by: rwatson Pointy hat to. andre
* The prepend function did not handle non-pkthdr's correctly.rrs2006-12-211-2/+7
| | | | | | | | | | | It always called MH_ALIGN for small lengths being prepended (less than MHLEN). This meant that if you did a prepend on a non M_PKTHDR the system would panic with the KASSERT in MH_ALIGN. Instead we are not aware of this and do a MH_ALIGN or M_ALIGN as appropriate. Reviewed by: andre Approved by: gnn
* Rename m_getm() to m_getm2() and rewrite it to allocate up to page sizedandre2006-11-021-86/+89
| | | | | | | | | | | | | | mbuf clusters. Add a flags parameter to accept M_PKTHDR and M_EOR mbuf chain flags. Provide compatibility macro for m_getm() calling m_getm2() with M_PKTHDR set. Rewrite m_uiotombuf() to use m_getm2() for mbuf allocation and do the uiomove() in a tight loop over the mbuf chain. Add a flags parameter to accept mbuf flags to be passed to m_getm2(). Adjust all callers for the extra parameter. Sponsored by: TCP/IP Optimization Fundraise 2005 MFC after: 3 month
* Complete break-out of sys/sys/mac.h into sys/security/mac/mac_framework.hrwatson2006-10-221-1/+2
| | | | | | | | | | | | | begun with a repo-copy of mac.h to mac_framework.h. sys/mac.h now contains the userspace and user<->kernel API and definitions, with all in-kernel interfaces moved to mac_framework.h, which is now included across most of the kernel instead. This change is the first step in a larger cleanup and sweep of MAC Framework interfaces in the kernel, and will not be MFC'd. Obtained from: TrustedBSD Project Sponsored by: SPARTA
* atomic_fetchadd_int is used by mb_free_ext(), but itrrs2006-09-211-1/+1
| | | | | | | | | | | | | | | | | returns the previous value that the "add" effected (In this case we are adding -1), afterwhich we compare it to '0'... to see if we free the mbuf... we should be comparing it to '1'... Note that this only effects when there is contention since there is a first part to the comparison that checks to see if its '1'. So this bug would only crop up if two CPU's are trying to free the same mbuf refcount at the same time. This will happen in SCTP but I doubt can happen in TCP or UDP. PR: N/A Submitted by: rrs Reviewed by: gnn,sam Approved by: gnn,sam
* Move some functions and definitions from uipc_socket2.c to uipc_socket.c:rwatson2006-06-101-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | - Move sonewconn(), which creates new sockets for incoming connections on listen sockets, so that all socket allocate code is together in uipc_socket.c. - Move 'maxsockets' and associated sysctls to uipc_socket.c with the socket allocation code. - Move kern.ipc sysctl node to uipc_socket.c, add a SYSCTL_DECL() for it to sysctl.h and remove lots of scattered implementations in various IPC modules. - Sort sodealloc() after soalloc() in uipc_socket.c for dependency order reasons. Statisticize soalloc() and sodealloc() as they are now required only in uipc_socket.c, and are internal to the socket implementation. After this change, socket allocation and deallocation is entirely centralized in one file, and uipc_socket2.c consists entirely of socket buffer manipulation and default protocol switch functions. MFC after: 1 month
* promote fast ipsec's m_clone routine for public use; it is renamedsam2006-03-151-0/+153
| | | | | | | m_unshare and the caller can now control how mbufs are allocated Reviewed by: andre, luigi, mlaier MFC after: 1 week
* spell pdata correctly, we now will only dump maxlen of each mbuf in thejmg2006-03-141-1/+1
| | | | | chain, instead of the entire mbuf... This should probably be reworked so that it prints at max maxlen bytes for the entire chain...
OpenPOWER on IntegriCloud