summaryrefslogtreecommitdiff
path: root/sys/kern/uipc_socket.c
AgeCommit message (Collapse)Author
2017-05-31new socketoption SO_ZEROIZE: zero out all mbufs sent over socketMarkus Friedl
ok deraadt bluhm
2017-05-27Push the NET_LOCK down into PF_KEY so that it can be treated like PF_ROUTE.Claudio Jeker
Only pfkeyv2_send() needs the NET_LOCK() so grab it at the start and release at the end. This should allow to push the locks down in other places. OK mpi@, bluhm@
2017-05-15so_splicelen needs to be protected by the socket lock. We are nowMartin Pieuchot
safe since we're always holding the KERNEL_LOCK() but we want to move away from that. Suggested by and ok bluhm@
2017-05-15Enable the NET_LOCK(), take 3.Martin Pieuchot
Recursions are still marked as XXXSMP. ok deraadt@, bluhm@
2017-04-02Less convoluted code in soshutdown()Theo de Raadt
ok guenther
2017-03-17Revert the NET_LOCK() and bring back pf's contention lock for release.Martin Pieuchot
For the moment the NET_LOCK() is always taken by threads running under KERNEL_LOCK(). That means it doesn't buy us anything except a possible deadlock that we did not spot. So make sure this doesn't happen, we'll have plenty of time in the next release cycle to stress test it. ok visa@
2017-03-13Move PRU_ATTACH out of the pr_usrreq functions into pr_attach.Claudio Jeker
Attach is quite a different thing to the other PRU functions and this should make locking a bit simpler. This also removes the ugly hack on how proto was passed to the attach function. OK bluhm@ and mpi@ on a previous version
2017-03-07Do not grab the NET_LOCK() for routing sockets operations.Martin Pieuchot
The only function that need the lock is rtm_output() as it messes with the routing table. So grab the lock there since it is safe to sleep in a process context. ok bluhm@
2017-03-03Prevent a recursion in the socket layer.Martin Pieuchot
Always defere soreceive() to an nfsd(8) process instead of doing it in the 'softnet' thread. Avoiding this recursion ensure that we do not introduce a new sleeping point by releasing and grabbing the netlock. Tested by many, committing now in order to find possible performance regression.
2017-02-14Wrap the NET_LOCK() into a per-socket solock() that does nothing forMartin Pieuchot
unix domain sockets. This should prevent the multiple deadlock related to unix domain sockets. Inputs from millert@ and bluhm@, ok bluhm@
2017-02-01In sogetopt, preallocate an mbuf to avoid using sleeping mallocs withDavid Hill
the netlock held. This also changes the prototypes of the *ctloutput functions to take an mbuf instead of an mbuf pointer. help, guidance from bluhm@ and mpi@ ok bluhm@
2017-01-27In sosend() the size of the control message for file descriptorAlexander Bluhm
passing is checked. As the data type has changed in unp_internalize(), the calculation has to be adapted in sosend(). Found by relayd regress test on i386. OK millert@
2017-01-26Do not hold the netlock while pool_get() may sleep. It is notAlexander Bluhm
necessary to lock code that initializes a new socket structure before it has been linked to any global list. OK mpi@
2017-01-25As NET_LOCK() is a read/write lock, it can sleep in sotask(). SoAlexander Bluhm
the TASKQ_CANTSLEEP flag is no longer valid for the splicing thread. OK mikeb@
2017-01-25Enable the NET_LOCK(), take 2.Martin Pieuchot
Recursions are currently known and marked a XXXSMP. Please report any assert to bugs@
2016-12-29Change NET_LOCK()/NET_UNLOCK() to be simple wrappers aroundMartin Pieuchot
splsoftnet()/splx() until the known issues are fixed. In other words, stop using a rwlock since it creates a deadlock when chrome is used. Issue reported by Dimitris Papastamos and kettenis@ ok visa@
2016-12-20Grab the NET_LOCK() in so{s,g}etopt(), pffasttimo() and pfslowtimo().Martin Pieuchot
ok rzalamena@, bluhm@
2016-12-19Introduce the NET_LOCK() a rwlock used to serialize accesses to the partsMartin Pieuchot
of the network stack that are not yet ready to be executed in parallel or where new sleeping points are not possible. This first pass replace all the entry points leading to ip_output(). This is done to not introduce new sleeping points when trying to acquire ART's write lock, needed when a new L2 entry is created via the RT_RESOLVE. Inputs from and ok bluhm@, ok dlg@
2016-11-29m_free() and m_freem() test for NULL. Simplify callers which had their ownJonathan Gray
NULL tests. ok mpi@
2016-11-23Some socket splicing tests on loopback hang with large mbufs andAlexander Bluhm
reduced buffer size. If the send buffer size is less than the size of a single mbuf, it will never fit. So if the send buffer is empty, split the large mbuf and move only a part. OK claudio@
2016-11-22Enforce that pr_ctloutput is called at IPL_SOFTNET.Martin Pieuchot
This will allow us to keep locking simple as soon as we trade splsoftnet() for a rwlock. ok bluhm@
2016-11-21Enforce that pr_usrreq functions are called at IPL_SOFTNET.Martin Pieuchot
This will allow us to keep locking simple as soon as we trade splsoftnet() for a rwlock. ok bluhm@, claudio@
2016-11-14Remove splnet() from socket kqueue code.Martin Pieuchot
splnet() was necessary when link state changes were executed from hardware interrupt handlers, nowdays all the changes are serialized by the KERNEL_LOCK() so assert that it is held instead. ok mikeb@
2016-10-06Remove redundant comments that say a function must be called atAlexander Bluhm
splsoftnet() if the function does a splsoftassert(IPL_SOFTNET) anyway.
2016-10-06Separate splsoftnet() from variable initialization.Alexander Bluhm
From mpi@'s netlock diff; OK mikeb@
2016-09-20Protect soshutdown() with splsoftnet() to define one layer whereAlexander Bluhm
we enter networking code. Fixes an splassert() found by David Hill. OK mikeb@
2016-09-20Add some spl softnet assertions that will help us to find the rightAlexander Bluhm
places for the upcoming network lock. This might trigger some asserts, but we have to find the missing code paths. OK mpi@
2016-09-15all pools have their ipl set via pool_setipl, so fold it into pool_init.David Gwynne
the ioff argument to pool_init() is unused and has been for many years, so this replaces it with an ipl argument. because the ipl will be set on init we no longer need pool_setipl. most of these changes have been done with coccinelle using the spatch below. cocci sucks at formatting code though, so i fixed that by hand. the manpage and subr_pool.c bits i did myself. ok tedu@ jmatthew@ @ipl@ expression pp; expression ipl; expression s, a, o, f, m, p; @@ -pool_init(pp, s, a, o, f, m, p); -pool_setipl(pp, ipl); +pool_init(pp, s, a, ipl, f, m, p);
2016-09-13Do not raise splsoftnet() recursively in soaccept().Martin Pieuchot
This is not an issue right now, but it will become one when an non recursive lock will be used. ok claudio@
2016-09-03If sosend() cannot allocate a large cluster, try a small one asAlexander Bluhm
fallback. OK claudio@
2016-09-03Return immediately when m_getuio() fails by invalid uio parameter.YASUOKA Masahiko
ok mikeb bluhm claudio
2016-08-25Spliced TCP sockets become faster when the output part is runningAlexander Bluhm
as its own task thread. This is inspired by userland copy where a process also has to go through the scheduler. This gives the socket buffer a chance to be filled up and tcp_output() is called less often and with bigger chunks. When two kernel tasks share all the workload, the current scheduler implementation will hang userland processes on single cpu machines. As a workaround put a yield() into the splicing thread after each task execution. This reduces the number of calls of tcp_output() even more. OK tedu@ mpi@
2016-08-25Completely revert the M_WAIT change on the cluster allocation andAlexander Bluhm
bring back the behaviour of rev 1.72. Although allocating small mbufs when allocating an mbuf cluster fails seems suboptimal, this should not be changed as a side effect when introducing m_getuio(). OK claudio@
2016-08-22Refactor the uio to mbuf code out of sosend and start to make use ofClaudio Jeker
MCLGETI and large mbuf clusters. This should speed up local connections a fair bit. OK dlg@ and bluhm@ (after reverting the M_WAIT change on the cluster allocation)
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-06-12Fix format string in ddb show socket.Alexander Bluhm
2016-03-14Change a bunch of (<blah> *)0 to NULL.Kenneth R Westerback
ok beck@ deraadt@
2016-01-15Improve the socket panic messages further. claudio@ wants to seeAlexander Bluhm
the socket type and dlg@ is interested in the pointers for ddb show socket. OK deraadt@ dlg@
2016-01-15print TAILQ_NEXT(so, so_qe) tooDavid Gwynne
2016-01-15add a "show socket" command to ddbDavid Gwynne
should help inspecting socket issues in the future. enthusiasm from mpi@ bluhm@ deraadt@
2016-01-13To make bug hunting easier, print more information in the soreceive()Alexander Bluhm
and somove() panic messages. OK phessler@ benno@ deraadt@ mpi@
2016-01-06Prevent integer overflows in sosend() and soreceive() by convertingStefan Kempf
min()+uiomovei() to ulmin()+uiomove() and re-arranging space computations in sosend(). The soreceive() part was also reported by Martin Natano. ok bluhm@ and also discussed with tedu@
2015-12-05remove stale lint annotationsTed Unangst
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-08-24Items from pool sosplice_pool are get in process context and putAlexander Bluhm
in soft interrupt. So the pool needs an IPL_SOFTNET protection. This fixes a panic: mtx_enter: locking against myself. While there, call pool_setipl() also for socket_pool. Although this pool uses explicit spl protection around pool_get() and pool_put(), it is better to specify the IPL it is operating on. OK mpi@ mikeb@
2015-07-08MFREE(9) is dead, long live m_freem(9)!Martin Pieuchot
ok bluhm@, claudio@, dlg@
2015-06-30Get rid of the undocumented & temporary* m_copy() macro added forMartin Pieuchot
compatibility with 4.3BSD in September 1989. *Pick your own definition for "temporary". ok bluhm@, claudio@, dlg@
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-06Pass a thread pointer instead of its file descriptor table to getsock(9).Martin Pieuchot
Diff from Vitaliy Makkoveev. Manpage tweak and ok millert@
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@