summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_socket2.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* sbdrop(): use NULL instead of 0 in pointer assignmentmvs2021-02-111-2/+2
| | | | ok bluhm@
* Move UNIX domain sockets out of kernel lock. The new `unp_lock' rwlock(9)mvs2021-02-101-7/+27
| | | | | | | | used as solock()'s backend to protect the whole layer. With feedback from mpi@. ok bluhm@ claudio@
* Add soassertlocked() checks to sbappend() and sbappendaddr(). This bringsclaudio2020-04-111-1/+4
| | | | | them in line with sbappendstream() and sbappendrecord(). Agreed by mpi@
* Push the KERNEL_LOCK() insidge pgsigio() and selwakeup().mpi2020-02-141-3/+1
| | | | | | | | | | | The 3 subsystems: signal, poll/select and kqueue can now be addressed separatly. Note that bpf(4) and audio(4) currently delay the wakeups to a separate context in order to respect the KERNEL_LOCK() requirement. Sockets (UDP, TCP) and pipes spin to grab the lock for the sames reasons. ok anton@, visa@
* Keep socket timeout intervals in nsecs and use them with tsleep_nsec(9).mpi2020-01-151-8/+9
| | | | | | | | | | | | | | Introduce and use TIMEVAL_TO_NSEC() to convert SO_RCVTIMEO/SO_SNDTIMEO specified values into nanoseconds. As a side effect it is now possible to specify a timeout larger that (USHRT_MAX / 100) seconds. To keep code simple `so_linger' now represents a number of seconds with 0 meaning no timeout or 'infinity'. Yes, the 0 -> INFSLP API change makes conversions complicated as many timeout holders are still memset()'d. Inputs from cheloha@ and bluhm@, ok bluhm@
* Use the actual cluster size instead of fixed MCLBYTES for theyasuoka2019-04-161-2/+3
| | | | | | | | | condition in sb_compress(). Currently the actual cluster size might be 9KB even if the mtu is 1500, in this case a lot of memory space had been wasted, since sbcompress() doesn't compress because of previous condition. ok dlg claudio
* let sbcreatecontrol take a const void * instead of a caddr_t.dlg2019-02-151-4/+4
| | | | | | | | this makes it easier to call since you don't have to cast to caddr_t if it's a void *. this also changes a size argument from int to size_t. ok claudio@
* Utilize sigio with sockets.visa2018-11-191-5/+6
| | | | OK mpi@
* M_LEADINGSPACE() and M_TRAILINGSPACE() are just wrappers forclaudio2018-11-091-3/+3
| | | | | | m_leadingspace() and m_trailingspace(). Convert all callers to call directly the functions and remove the defines. OK krw@, mpi@
* Now that most archs have better NMBCLUSTERS defaults it is possible to bringclaudio2018-10-291-3/+2
| | | | | | | | | | | | | back rev 1.90. ---- mbufs and mbuf clusters are now backed by large pools. Because of this we can relax the oversubscribe limit of socketbuffers a fair bit. Instead of maxing out as sb_max * 1.125 or 2 * sb_hiwat the maximum is increased to 8 * sb_hiwat -- which seems to be a good compromise between memory waste and better socket buffer usage. OK deraadt@ ---- ok benno@
* After removing raw_usrreq() from route and pfkey, the global sockaddrbluhm2018-07-101-2/+2
| | | | | variables can be delared constant. OK claudio@ mpi@
* Do not unlock the KERNEL_LOCK() unconditionally in sounlock().mpi2018-06-111-7/+8
| | | | | | | Instead introduce two flags to deal with global lock recursion. This is necessary until we get per-socket lock. Req. by and ok visa@
* Pass the socket to sounlock(), this prepare the terrain for per-socketmpi2018-06-061-10/+23
| | | | | | locking. ok visa@, bluhm@
* Grab the KERNEL_LOCK() for unix/routing/pfkey sockets in solock()...mpi2018-05-071-2/+7
| | | | | | | ...and release it in sounlock(). This will allows us to progressively remove the KERNEL_LOCK() in syscalls. ok visa@ some time ago
* AF_LOCAL was a failed attempt (by POSIX?) to seem less UNIX-specific, butguenther2018-04-081-4/+4
| | | | | | | AF_UNIX is both the historical _and_ standard name, so prefer and recommend it in the headers, manpages, and kernel. ok miller@ deraadt@ schwarze@
* Revert previous. It triggers mbuf pool exhaustion on arm64.kettenis2018-02-181-2/+3
| | | | Requested by claudio@
* mbufs and mbuf clusters are now backed by large pools. Because of thisclaudio2018-02-101-3/+2
| | | | | | | | we can relax the oversubscribe limit of socketbuffers a fair bit. Instead of maxing out as sb_max * 1.125 or 2 * sb_hiwat the maximum is increased to 8 * sb_hiwat -- which seems to be a good compromise between memory waste and better socket buffer usage. OK deraadt@
* Delete unnecessary <sys/file.h> includesguenther2017-12-301-2/+1
| | | | ok millert@ krw@
* Move SB_SPLICE, SB_WAIT and SB_SEL to `sb_flags', serialized by solock().mpi2017-12-101-10/+11
| | | | | | | | | | | SB_KNOTE remains the only bit set on `sb_flagsintr' as it is set/unset in contexts related to kqueue(2) where we'd like to avoid grabbing solock(). While here add some KERNEL_LOCK()/UNLOCK() dances around selwakeup() and csignal() to mark which remaining functions need to be addressed in the socket layer. ok visa@, bluhm@
* We want `sb_flags' to be protected by the socket lock rather than thempi2017-11-231-4/+3
| | | | | | | | | KERNEL_LOCK(), so change asserts accordingly. This is now possible since sblock()/sbunlock() are always called with the socket lock held. ok bluhm@, visa@
* Remove NET_LOCK()'s argument.mpi2017-08-111-4/+4
| | | | Tested by Hrvoje Popovski, ok bluhm@
* Assert that the KERNEL_LOCK() is held prior to call csignal() andmpi2017-07-271-1/+2
| | | | | | selwakeup(). ok bluhm@
* soreserve() modifies `so_snd' and `so_rcv' so asserts that it is calledmpi2017-07-181-1/+2
| | | | | | | | with the socket lock. This change is safe because sbreserve() already asserts that the lock is held, but it acts as implicit documentation and indicates that I looked at the function.
* Always hold the socket lock when calling sblock().mpi2017-07-041-18/+4
| | | | | | Implicitely protects `so_state' with the socket lock in sosend(). ok visa@, bluhm@
* Assert that the socket lock is held when `so_state' is modified.mpi2017-07-041-6/+7
| | | | ok bluhm@, visa@
* Assert that the socket lock is held when `so_qlen' is modified.mpi2017-07-041-3/+5
| | | | ok bluhm@, visa@
* Add missing solock()/sounlock() dances around sbreserve().mpi2017-06-271-1/+6
| | | | | | While here document an abuse of parent socket's lock. Problem reported by krw@, analysis and ok bluhm@
* Assert that the corresponding socket is locked when manipulating socketmpi2017-06-261-21/+31
| | | | | | | | | | | | | | | | buffers. This is one step towards unlocking TCP input path. Note that all the functions asserting for the socket lock are not necessarilly MP-safe. All the fields of 'struct socket' aren't protected. Introduce a new kernel-only kqueue hint, NOTE_SUBMIT, to be able to tell when a filter needs to lock the underlying data structures. Logic and name taken from NetBSD. Tested by Hrvoje Popovski. ok claudio@, bluhm@, mikeb@
* Assert that the KERNEL_LOCK() is held when messing with routing,mpi2017-06-071-4/+12
| | | | | | pfkey and unix sockets. ok claudio@
* Push the NET_LOCK down into PF_KEY so that it can be treated like PF_ROUTE.claudio2017-05-271-4/+7
| | | | | | 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@
* Enable the NET_LOCK(), take 3.mpi2017-05-151-2/+6
| | | | | | Recursions are still marked as XXXSMP. ok deraadt@, bluhm@
* Revert the NET_LOCK() and bring back pf's contention lock for release.mpi2017-03-171-6/+2
| | | | | | | | | 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@
* Move PRU_ATTACH out of the pr_usrreq functions into pr_attach.claudio2017-03-131-3/+2
| | | | | | | 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
* Do not grab the NET_LOCK() for routing sockets operations.mpi2017-03-071-5/+8
| | | | | | | | 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@
* Wrap the NET_LOCK() into a per-socket solock() that does nothing formpi2017-02-141-6/+43
| | | | | | | | unix domain sockets. This should prevent the multiple deadlock related to unix domain sockets. Inputs from millert@ and bluhm@, ok bluhm@
* Enable the NET_LOCK(), take 2.mpi2017-01-251-2/+2
| | | | | | Recursions are currently known and marked a XXXSMP. Please report any assert to bugs@
* Change NET_LOCK()/NET_UNLOCK() to be simple wrappers aroundmpi2016-12-291-2/+2
| | | | | | | | | | | 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@
* Introduce the NET_LOCK() a rwlock used to serialize accesses to the partsmpi2016-12-191-9/+22
| | | | | | | | | | | 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@
* Bring back the SB_LOCK and SB_WANT flags to lock the socket buffersbluhm2016-11-151-18/+28
| | | | | | | | | | in process context. The read/write lock introduced in rev 1.64 would create lock ordering problems with the upcoming SOCKET_LOCK() mechanism. The current tsleep() in sblock() must be replaced with rwsleep(&socketlock) later. The sb_flags are protected by KERNEL_LOCK(). They must not be accessed from interrupt context, but nowadays softnet() is not an interrupt anyway. OK mpi@
* sowakeup() is only called from sorwakeup() and sowwakeup(). Bothbluhm2016-10-091-3/+2
| | | | | | have an splsoftassert(IPL_SOFTNET) now, so sowakeup() does not need to call splsoftnet() anymore. From mpi@'s netlock diff; OK mikeb@
* Remove redundant comments that say a function must be called atbluhm2016-10-061-3/+1
| | | | | splsoftnet() if the function does a splsoftassert(IPL_SOFTNET) anyway.
* After allocating a single 64 KB mbuf cluster in sosend(), the sendingbluhm2016-09-021-2/+3
| | | | | | | | | | socket buffer had no space anymore. The default mbuf space limit was only 32 KB. So no more data from user-land was accepted. As tcp_output() keeps the mbuf cluster for retransmits, it will be freed only after all ACKs have been received. That has killed our TCP send performance totally. To allow cycling through the mbufs periodically, we need space for at least 3 of them. Reported by Andreas Bartelt; testing with mikeb@; OK mikeb@ claudio@
* introduce rwlock for socketbuf instead of the old flag and tsleep dance.tedu2016-06-281-13/+20
| | | | ok mikeb bluhm
* Make sure that all padding bytes in cmsgs are actually zero by memsetclaudio2015-10-061-1/+2
| | | | CMSG_SIZE(len) bytes of the mbuf.
* MFREE(9) is dead, long live m_freem(9)!mpi2015-07-081-4/+4
| | | | ok bluhm@, claudio@, dlg@
* Get rid of the undocumented & temporary* m_copy() macro added formpi2015-06-301-2/+2
| | | | | | | | compatibility with 4.3BSD in September 1989. *Pick your own definition for "temporary". ok bluhm@, claudio@, dlg@
* Remove some includes include-what-you-use claims don'tjsg2015-03-141-2/+1
| | | | | | | have any direct symbols used. Tested for indirect use by compiling amd64/i386/sparc64 kernels. ok tedu@ deraadt@
* convert bcopy to memcpy/memmove. ok krwtedu2014-12-111-4/+4
|
* remove uneeded proc.h includesjsg2014-09-141-2/+1
| | | | ok mpi@ kspillner@
* Delete the SS_ISCONFIRMING flag that supported delayed connectionguenther2014-09-091-3/+3
| | | | | | confirmation: it was only used for netiso, which was deleted a *decade* ago ok mpi@ claudio@ ports scan by sthen@