summaryrefslogtreecommitdiff
path: root/sys/kern/uipc_mbuf.c
AgeCommit message (Collapse)Author
2016-06-13On localhost a user program may create a socket splicing loop.Alexander Bluhm
After writing data into this loop, it was spinning forever causing a kernel hang. Detect the loop by counting how often the same mbuf is spliced. If that happens 128 times, assume that there is a loop and abort the splicing with ELOOP. Bug found by tedu@; OK tedu@ millert@ benno@
2016-05-23remove the function pointer from mbufs. this memory is shared with dataTed Unangst
via unions, and we don't want to make it easy to control the target. instead an integer index into an array of acceptable functions is used. drivers using custom functions must register them to receive an index. ok deraadt
2016-04-15remove ml_filter, mq_filter, niq_filter.David Gwynne
theyre currently unused, so no functional change.
2016-04-08add m_purge for freeing a list of mbufs linked via m_nextpktDavid Gwynne
this tweaks m_freem so it returns the m_nextpkt from the mbuf it freed, like how m_free returns the m_next from the mbuf it frees. ok mpi@
2016-04-06correct the order of arguments to m_get in m_dup_pktDavid Gwynne
2016-03-29- packet must keep reference to statekeyAlexandr Nedvedicky
this is the second attempt to get it in, the first attempt got backed out on Jan 31 2016 the change also contains fixes contributed by Stefan Kempf in earlier iteration. OK srhen@
2016-03-22dont mix up the len and flats argument to MCLGETI in m_dup_pktDavid Gwynne
2016-02-23provide m_dup_pkt() for doing fast deep mbuf copies with a specified alignmentDavid Gwynne
if a physical interface receives a multicast/broadcast packet and has carp interfaces on it, that packet needs to be copied for reception by each of those carp interfaces. previously it was using m_copym2, but that doesn't respect the alignment of the source packet. this meant the ip header in the copies were aligned incorrectly for the network stack, which breaks strict alignment archs. m_dup_pkt lets carp specify that the payload needs an ETHER_ALIGN adjustment, so the ip header inside will be aligned correctly. reported and tested by anthony eden who hit this on armv7 i reproduced the problem on sparc64 and verified the fix on amd64 and sparc64 ok mpi@ mikeb@ deraadt@
2016-01-31- m_pkthdr.pf.statekey changes are not ready for 5.9, I must back them outAlexandr Nedvedicky
OK sthen@
2016-01-07- retrying to commit earlier change, which got backed outAlexandr Nedvedicky
- yet another tiny step towards MP PF. This time we need to make sure statekey attached to packet stays around, while accepted packet is routed through IP stack. this time I'm also bringing fix contributed by Stefan Kempf. Stefan's fix makes sure we grab reference in m_dup_pkthdr() OK bluhm@
2015-12-23revert previous:Jasper Lievisse Adriaanse
---------------------------------------------------------------------- revision 1.961 date: 2015/12/22 13:33:26; author: sashan; state: Exp; lines: +153 -44; commitid: oBRhtWcDV0ThviVT; - yet another tiny step towards MP PF. This time we need to make sure statekey attached to packet stays around, while accepted packet is routed through IP stack. OK mpi@, henning@ ---------------------------------------------------------------------- there have been multiple reports of KASSERT(!pf_state_key_isvalid(sk)) being triggered without much effort, so back this out for now.
2015-12-22- yet another tiny step towards MP PF. This time we need to make sureAlexandr Nedvedicky
statekey attached to packet stays around, while accepted packet is routed through IP stack. OK mpi@, henning@
2015-11-21Retire ml_requeue(9) and mq_requeue(9).Martin Pieuchot
As Kenjiro Cho pointed out it is very hard to cancel a dequeue operation for some queueing disciplines when such it keeps some internal states. As you can see, APIs can also Live Fast & Die Young. ok dlg@
2015-11-13Use ph_ prefix for tag-related fields.Martin Pieuchot
ok dlg@
2015-11-12Prefix flowid with ph_ and print it in m_print().Martin Pieuchot
ok dlg@
2015-11-02provide ml_purge and mq_purge.David Gwynne
these are modelled on IF_PURGE or IFQ_PURGE. they m_freem all the mbufs on an mbuf list or queue. ok jmatthew@ mpi@
2015-10-30Let m_resethdr() clear the whole mbuf packet header, not only theAlexander Bluhm
pf part. This allows to reuse this function in socket splicing. Reset the mbuf flags that are related to the packet header, but preserve the data flags. pair(4) tested by reyk@; sosplice(9) tested by bluhm@; OK mikeb@ reyk@
2015-10-30Add m_resethdr() to clear any state (pf, tags, flags) of an mbuf packet.Reyk Floeter
Start using it in pair(4) to clear state on the receiving interface; m_resethdr() will also be used in other parts of the stack. OK bluhm@ mikeb@
2015-10-22rename ml_join to ml_enlist and expose it to the rest of the kernel.David Gwynne
2015-08-14provide ml_requeue and mq_requeue for prepending mbufs on lists/queuesDavid Gwynne
ok mpi@ claudio@
2015-07-15m_free() can now accept NULL, as a normal free() function. This makesTheo de Raadt
calling code simpler. ok stsp mpi
2015-06-16Store a unique ID, an interface index, rather than a pointer to theMartin Pieuchot
receiving interface in the packet header of every mbuf. The interface pointer should now be retrieved when necessary with if_get(). If a NULL pointer is returned by if_get(), the interface has probably been destroy/removed and the mbuf should be freed. Such mechanism will simplify garbage collection of mbufs and limit problems with dangling ifp pointers. Tested by jmatthew@ and krw@, discussed with many. ok mikeb@, bluhm@, dlg@
2015-05-31If the first list was empty, ml_join() did not not clear the secondAlexander Bluhm
list after transferring all elements away. Reorder the conditionals to make sure that ml_init() is always called for a non empty second list. This makes all cases consistent and is less surprising. OK dlg@
2015-04-13Now that if_input() set the receiving interface pointer on mbufs for usMartin Pieuchot
there's no need to do it in m_devget(9). Stop passing an ``ifp'' will help for upcoming interface pointer -> index conversion. While here remove unused ``ifp'' argument from m_clget(9) and kill two birds^W layer violations in one commit. ok henning@
2015-03-14Remove some includes include-what-you-use claims don'tJonathan Gray
have any direct symbols used. Tested for indirect use by compiling amd64/i386/sparc64 kernels. ok tedu@ deraadt@
2015-02-07make mq_enlist drop mbufs is the queues length is exceeded.David Gwynne
ok mpi@ claudio@ henning@ and more at s2k15
2015-02-07add ml_filter and mq_filter functions to the mbuf list and queue apis.David Gwynne
this lets you run a filter function against each mbuf on a list or queue. if the filter matches on an mbuf, it can return non-zero to have ml_filter or mq_filter remove the mbuf and return it as part of a chain of mbufs. ok mpi@ claudio@ henning@ and s2k15 generally.
2014-12-11convert bcopy to memcpy/memmove. ok krwTed Unangst
2014-11-05change the mbuf pool wait channel name from mbpl to mbufpl. "mb"David Gwynne
isnt descriptive enough for me. ok deraadt@
2014-10-03if you're adding the first cluster reference, you dont have toDavid Gwynne
coordinate with other mbufs so you can add all the pointers without taking the extref lock. looks good deraadt@
2014-10-03i moved some macros into functions, and a trailing \ on a statementDavid Gwynne
snuck in. someone who knows how cpp/cc works can explain to me why this compiled.
2014-10-03now that pools are mpsafe, we can make the mbuf allocators on topDavid Gwynne
of pools mpsafe too. this calles pool_setipl(IPL_NET) against the mbuf and cluster pools, and removes the use of splnet(). the other locking done in the mbuf layer is for external cluster references. again, they relied on splnet to serialise these operations. because there is no shared memory associated with external clusters (except the cluster itself, which is completely dedicated to data payload, not meta info like a refcount or lock), this has been replaced with a single mutex that all reference ops are serialised with. tested by me, jmatthew@, bcook@, and phessler@
2014-09-14remove uneeded proc.h includesJonathan Gray
ok mpi@ kspillner@
2014-08-18introduce mbuf list and queue apis. both manage fifo lists of mbufsDavid Gwynne
and a count of the mbufs. struct mbuf_list and the ml_foo() apis can be used to build lists of mbufs where you dont need locking (eg, on the stack). struct mbuf_queue and mq_foo() wrap mbuf_lists with a mutex, and limits the number of mbufs that can be queued. they can be useful for moving mbufs between contexts/subsystems. with help from jmc@ for the manpage bits mpi@ is keen
2014-07-13bzero -> memset. for the speeds.Ted Unangst
2014-07-13treat external storage allocated by the mbuf layer the same asDavid Gwynne
external storage attached to an mbuf anywhere else. this means it uses MEXTADD to wire it up to the mbuf, and it relies on the ext_free and ext_arg bits in the header to call the right free function against the right pool. M_CLUSTER gets renamed to M_EXTWR. the type field in MEXTADD gets reused as a flags field so anything attaching storage to an mbuf can say if it is writable or not. ok claudio@
2014-07-09ext_type is set but never read. its a waste of space.David Gwynne
MEXTADD will be fixed later. ok henning@ deraadt@ mpi@
2014-07-09now that mclgeti doesnt do the rx ring accounting, cluster allocationDavid Gwynne
doesnt need to know which ifp an mbuf was allocated on so it can uncount it on free. while here, remove the ext_backend field which identifies the pool the cluster came from and use ext_arg instead. ok henning@ mpi@
2014-07-08pull the rx ring accounting out of the mbuf layer now that its all doneDavid Gwynne
via if_rxring things. this effectively deprecates the third argument for MCLGETI and m_clget and makes the mbuf layer no longer care about interfaces and simplifies the allocation paths. the timeout used to measure livelock has been moved to net/if.c. ok mpi@
2014-07-08cut things that relied on mclgeti for rx ring accounting/restriction overDavid Gwynne
to using if_rxr. cut the reporting systat did over to the rxr ioctl. tested as much as i can on alpha, amd64, and sparc64. mpi@ has run it on macppc. ok mpi@
2014-06-18trailing tabs arent needed.David Gwynne
2014-06-13Instead of updating all the cluster allocation water marks of all theMartin Pieuchot
interfaces when the kernel is livelocked, only do it for the current pool and defer the other updates. This allow us to get rid of an interface list iteration in a critical path. Ridding the libc crank since this change introduce an ABI break. ok claudio@
2014-05-04remove some hh and h format specifiersStefan Fritsch
gcc does not like hh in kprintf and it does not make any difference due to integer promotion rules. While there, remove some h's, too. suggested by kettenis@
2014-04-22Remove some altq tentacles.Martin Pieuchot
ok pelikan@, henning@
2014-04-21we'll do fine without casting NULL to struct foo * / void *Henning Brauer
ok gcc & md5 (alas, no binary change)
2014-04-14"struct pkthdr" holds a routing table ID, not a routing domain one.Martin Pieuchot
Avoid the confusion by using an appropriate name for the variable. Note that since routing domain IDs are a subset of the set of routing table IDs, the following idiom is correct: rtableid = rdomain But to get the routing domain ID corresponding to a given routing table ID, you must call rtable_l2(9). claudio@ likes it, ok mikeb@
2014-03-28Reduce uvm include madness. Use <uvm/uvm_extern.h> instead ofMartin Pieuchot
<uvm/uvm.h> if possible and remove double inclusions. ok beck@, mlarkin@, deraadt@
2014-03-27Store an ifp index instead of a pointer in the "struct mbuf_ext".Martin Pieuchot
This is part of the plan to remove the ifp pointer from the packet header that will allow us to stop garbage collecting mbuf(9)s when an ifp is detached/destroyed. ok mikeb@, lteo@, benno@
2014-01-19Remove max_datalen. It is only used once an can be replaced easily withClaudio Jeker
MHLEN - max_hdr in that place. OK mikeb@
2014-01-10Let "ddb show mbuf" print all mbuf fields in a consistent way. MoveAlexander Bluhm
bit field names into the header file below the definitions to keep them in sync. OK mikeb@ mpi@