summaryrefslogtreecommitdiffstats
path: root/sys/nfs/nfs_socket.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* nfs: don't sleep on lboltcheloha2021-01-021-4/+4
| | | | | | | We can simulate the current behavior without lbolt by sleeping for 1 second on the &nowake channel. ok mpi@
* sys/nfs: misc. tsleep(9) -> tsleep_nsec(9); ok mpi@cheloha2020-01-211-14/+12
|
* Keep socket timeout intervals in nsecs and use them with tsleep_nsec(9).mpi2020-01-151-5/+6
| | | | | | | | | | | | | | 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@
* Convert infinite sleeps to tsleep_nsec(9).mpi2019-12-051-2/+2
| | | | ok jca@
* When killing a process, the signal is handled by any thread thatbluhm2019-05-131-4/+3
| | | | | | | | | | does not block the signal. If all threads block the signal, we delivered it to the main thread. This does not conform to POSIX. If any thread unblocks the signal, it should be delivered immediately to this thread. Mark such signals pending at the process instead of a single thread. Then any thread can handle it later. OK kettenis@ guenther@
* M_LEADINGSPACE() and M_TRAILINGSPACE() are just wrappers forclaudio2018-11-091-2/+2
| | | | | | m_leadingspace() and m_trailingspace(). Convert all callers to call directly the functions and remove the defines. OK krw@, mpi@
* Instead of calculating the mbuf packet header length here and there,bluhm2018-09-101-10/+3
| | | | | | put the algorithm into a new function m_calchdrlen(). Also set an uninitialized m_len to 0 in NFS code. OK claudio@
* Use FNONBLOCK instead of SS_NBIO to check/indicate that the I/O modempi2018-07-301-2/+2
| | | | | | | | | | | | | for sockets is non-blocking. This allows us to G/C SS_NBIO. Having to keep the two flags in sync in a mp-safe way is complicated. This change introduce a behavior change in sosplice(), it can now always block. However this should not matter much due to the socket lock being taken beforhand. ok bluhm@, benno@, visa@
* Pass the socket to sounlock(), this prepare the terrain for per-socketmpi2018-06-061-3/+3
| | | | | | locking. ok visa@, bluhm@
* nfs_connect() returns EINVAL at the beginning if nm_sotype isbluhm2017-09-071-1/+3
| | | | | | | | invalid. But the compiler cannot know whether it has changed in the meantime, so in the else case a bunch of variables would not be initialized. Add a panic() there to change the compiler's assumptions, the code should not be reached anyway. found by clang -Wuninitialized; OK deraadt@
* Preallocate option mbufs in order to reduce solock()/sounlock() dances.mpi2017-09-051-43/+35
| | | | | | | Finally protect the last `so_rcv' and `so_snd' accesses with the socket lock. ok visa@, bluhm@
* Change sosetopt() to no longer free the mbuf it receives and changempi2017-09-011-1/+5
| | | | | | all the callers to call m_freem(9). Support from deraadt@ and tedu@, ok visa@, bluhm@
* knf to fix tab/space mismatches that make it hard to tell what's insidetedu2017-08-141-150/+153
| | | | | an if vs the condition itself. weird contortions because of course the lines want to be like 900 columns wide, but i think it's better now.
* drop seriously lacking support for SEQPACKET.tedu2017-08-141-12/+8
| | | | | also move checks up sooner to prevent a (root) panic. ok bluhm
* Remove NET_LOCK()'s argument.mpi2017-08-111-4/+4
| | | | Tested by Hrvoje Popovski, ok bluhm@
* Move the solock()/sounlock() dance outside of sobind().mpi2017-08-101-1/+3
| | | | ok phessler@, visa@, bluhm@
* Move the socket lock "above" sosetopt(), sogetopt() and sosplice().mpi2017-08-091-2/+6
| | | | | | | Protect the fields modifieds by sosetopt() and simplify the dance with the stars. ok bluhm@
* Extend the scope of the socket lock to protect `so_state' in connect(2).mpi2017-07-241-3/+5
| | | | | | | As a side effect, soconnect() and soconnect2() now expect a locked socket, so update all the callers. ok bluhm@
* Add missing solock()/sounlock() dances around sbreserve().mpi2017-06-271-1/+3
| | | | | | 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-2/+2
| | | | | | | | | | | | | | | | 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@
* When dealing with mbuf pointers passed down as function parameters,bluhm2017-06-191-8/+5
| | | | | | | bugs could easily result in use-after-free or double free. Introduce m_freemp() which automatically resets the pointer before freeing it. So we have less dangling pointers in the kernel. OK krw@ mpi@ claudio@
* Remove useless splsoftnet().mpi2017-05-171-13/+4
| | | | | | | | | | Outside of USB, no code is executed in a softnet interrupt context. So what's protecting NFS data structures is the KERNEL_LOCK(). But more importantly, since r1.114 of nfs_socket.c, the 'softnet' thread is no longer executing NFS code. ok visa@
* Sync nfs_connect() w/ sys_connect().mpi2017-05-081-7/+6
| | | | ok bluhm@
* Prevent a recursion in the socket layer.mpi2017-03-031-17/+6
| | | | | | | | | 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.
* Keep local definitions local.mpi2017-02-221-1/+11
| | | | "good work" deraadt@, ok visa@
* Introduce the NET_LOCK() a rwlock used to serialize accesses to the partsmpi2016-12-191-3/+3
| | | | | | | | | | | 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@
* In kernel initialize struct sockaddr_in and sockaddr_in6 to zerobluhm2015-08-241-2/+3
| | | | | | | everywhere to avoid passing around pointers to uninitialized stack memory. While there, fix the call to in6_recoverscope() in fill_drlist(). OK deraadt@ mpi@
* m_freem() can handle NULL, do not check for this condition beforehands.deraadt2015-07-151-5/+3
| | | | ok stsp mpi
* Convert from hzto(9) to tvtohz(9); OK dlgmikeb2015-06-111-3/+3
|
* 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@
* use NGROUPS_MAXderaadt2015-01-171-3/+3
|
* bzero -> memsettedu2014-11-141-2/+2
|
* If somebody else is already processing the RPC requests on a stream socket,kettenis2014-04-181-2/+2
| | | | | | | don't panic, but just return. tested by nicm@ ok tedu@
* Move p_sigacts from struct proc to struct process.guenther2014-03-221-3/+3
| | | | testing help mpi@
* Remove max_datalen. It is only used once an can be replaced easily withclaudio2014-01-191-2/+2
| | | | MHLEN - max_hdr in that place. OK mikeb@
* format string fixes: size_t and signednesssf2013-07-041-4/+4
| | | | ok bluhm@
* Recommit the reverted sigacts change now that the NFS use-after-freeguenther2011-07-051-2/+3
| | | | | | | | problem has been tracked down. This fixes the sharing of the signal handling state: shared bits go in sigacts, per-rthread bits goes in struct proc. ok deraadt@
* Revert the sigacts diff: NFS can apparently retain pointers to processesguenther2011-04-181-3/+2
| | | | | | until they're zombies and then send them signals (for intr mounts). Until that is untangled, the sigacts change is unsafe. sthen@ was the victim for this one
* Correct the sharing of the signal handling state: stuff that shouldguenther2011-04-151-2/+3
| | | | | | | | | | | | be shared (p_sigignore, p_sigcatch, P_NOCLDSTOP, P_NOCLDWAIT) moves to struct sigacts, wihle stuff that should be per rthread (ps_oldmask, SAS_OLDMASK, ps_sigstk) moves to struct proc. Treat the coredumping state bits (ps_sig, ps_code, ps_type, ps_sigval) as per-rthread until our locking around coredumping is better. Oh, and remove the old SunOS-compat ps_usertramp member. "I like the sound of this" tedu@
* If we find something is not aligned according to ALIGNED_POINTER(), wederaadt2010-07-051-2/+3
| | | | | | | | | | | cannot then re-align it using ALIGN(). That is not portable since we have architectures where the modulo are quite different. define an ALIGN_POINTER() macro in place, and use it in one spot. This caused a NFS crash on sparc (which borrows mbufs and chains them itself in insane ways). I heard claudio and beck trying to diagnose it from over the room when suddenly I knew exactly what it was. blambert spent a few hours on it making sure that I wasn't insane.
* m_copyback can fail to allocate memory, but is a void fucntion so gymnasticsblambert2010-07-021-2/+2
| | | | | | | | | are required to detect that. Change the function to take a wait argument (used in nfs server, but M_NOWAIT everywhere else for now) and to return an error ok claudio@ henning@ krw@
* antsyjsg2009-10-191-54/+20
| | | | | | no binary change apart from nfsm_reqhead() which is clearly correct. ok thib@
* move to having requests on a per nfsmount tailq instead of one global one.thib2009-08-251-20/+16
| | | | | | | | | | also make the rexmit timeout per nfsmount, and make sure to start/stop the timer appropriately. now the nfs_timer() only fires if there is work todo, not always at nfs_ticks (it did, even if there where no nfsmounts in the system!). OK blambert@
* Remove the v2 writegather code. It did help alot back in the 80sthib2009-08-101-20/+1
| | | | | | | | | | but extensive performance benchmarking done by myself and jasper@ has shown that it doesn't help, at all - even on vaxens and in some cases it makes things significantly slower. "this excites me sexually" jetpack@ Tested by jasper@. OK blambert@
* group all of the on-stack variables that are uses by the nfsm_macrosthib2009-08-041-61/+45
| | | | | | | | | | | | | | to keep the data munging "state" into an nfsm_info structure. Each function now has this structure on its stack, and it and its members are now passed around so that the macros/functions can work there magic. this will make removing the nfsm_* macros way easier. Idea/code picked up from DragonflyBSD. Tested by krw@, jacekm@ and myself. OK blambert@.
* make sure we only ever try to read out post-op attributesthib2009-07-301-4/+8
| | | | | | | | or wcc data if we have a proper reply. found the hard way by ariane@, tested by ariane@. OK blambert@
* Instead of calculating a number of seconds to sleep, tsleep()ing onblambert2009-07-221-7/+6
| | | | | | | | lbolt and waking up every second and checking to see if the correct number of seconds has passed, just calculate the timeout once and pass that to tsleep(). ok thib@
* (struct foo *)0 -> NULL, every where I could find it.thib2009-07-201-34/+32
| | | | OK blambert@
* For memory that gets allocated for every NFS request, pools make moreblambert2009-07-201-3/+5
| | | | | | sense than malloc. ok thib@, who says the puffin still gets it either way
* if -> in, and the sentance makes more sense.thib2009-07-181-2/+2
|