summaryrefslogtreecommitdiffstats
path: root/sys/kern/sys_socket.c
AgeCommit message (Collapse)AuthorFilesLines
2020-02-22In preparation for unlocking ioctl(2), grab the kernel lock as needed.anton1-1/+5
ok kettenis@ mpi@ visa@
2020-01-08Unify handling of ioctls FIOSETOWN/SIOCSPGRP/TIOCSPGRP andvisa1-9/+7
FIOGETOWN/SIOCGPGRP/TIOCGPGRP. Do this by determining the meaning of the ID parameter inside the sigio code. Also add cases for FIOSETOWN and FIOGETOWN where there have been TIOCSPGRP and TIOCGPGRP before. These changes allow removing the ID translation from sys_fcntl() and sys_ioctl(). Idea from NetBSD OK mpi@, claudio@
2020-01-05Constify instances of struct fileops.visa1-2/+2
OK anton@, mpi@, bluhm@
2018-11-19Utilize sigio with sockets.visa1-6/+4
OK mpi@
2018-08-20Reorder checks in the read/write(2) family of syscalls to prepare makingmpi1-3/+3
file operations mp-safe. This change makes it clear that `f_offset' is only accessed in vn_read() and vn_write(), which will help taking it out of the KERNEL_LOCK(). This refactoring uncovered a race in vn_read() which is now documented and will be addressed in a later diff. ok visa@
2018-07-30Use FNONBLOCK instead of SS_NBIO to check/indicate that the I/O modempi1-15/+19
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@
2018-07-10Move socket & pipe specific logic in their ioctl handler.mpi1-1/+7
ok visa@, tb@
2018-06-06Pass the socket to sounlock(), this prepare the terrain for per-socketmpi1-5/+5
locking. ok visa@, bluhm@
2018-04-26Remove solock() surrounding PRU_CONTROL in soo_ioctl().pirofti1-3/+1
We do not need the lock there. Missed this in my former commit pushing NET_LOCK() down the stack. Found the hard way by naddy@, sorry! OK mpi@.
2018-04-10Convert 'struct fileops' definitions to C99.mpi1-3/+8
ok millert@, deraadt@, florian@
2017-12-10Move SB_SPLICE, SB_WAIT and SB_SEL to `sb_flags', serialized by solock().mpi1-3/+3
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@
2017-11-14Push the NET_LOCK into ifioctl() and use the NET_RLOCK in ifioctl_get().tb1-3/+1
In particular, this allows SIOCGIF* requests to run in parallel. lots of help & ok mpi, ok visa, sashan
2017-08-11Remove NET_LOCK()'s argument.mpi1-3/+3
Tested by Hrvoje Popovski, ok bluhm@
2017-07-24Grab the socket lock in soo_ioctl() where `so_state', `so_rcv'mpi1-24/+31
and `so_snd' are modified. ok bluhm@, visa@
2017-07-20Extend the scope of the socket lock in soo_stat() to protect `so_state'mpi1-4/+3
and `so_rcv'. ok bluhm@, claudio@, visa@
2017-02-22Do not grab the NET_LOCK() when poll(2)ing on unix domain sockets.mpi1-3/+3
Fix the 'X freeze' while scanning with wireless interfaces. Problem reported by pirofti@. ok tb@, bluhm@
2017-02-14Wrap the NET_LOCK() into a per-socket solock() that does nothing formpi1-5/+5
unix domain sockets. This should prevent the multiple deadlock related to unix domain sockets. Inputs from millert@ and bluhm@, ok bluhm@
2017-01-31Remove the inifioctl hack, checking for an unheld NET_LOCK() inmpi1-8/+1
tsleep(9) & friends seem to only produce false positives and cannot be easily disabled.
2017-01-25Introduce a hack to remove false-positives when looking for memorympi1-1/+8
allocation that can sleep while holding the NET_LOCK(). To be removed once we're confident the remaining code paths are safe. Discussed with deraadt@
2016-12-19Introduce the NET_LOCK() a rwlock used to serialize accesses to the partsmpi1-9/+9
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-22Enforce that ifioctl() is called at IPL_SOFTNET.mpi1-3/+7
This will allow us to keep locking simple as soon as we trade splsoftnet() for a rwlock. ok bluhm@
2016-11-21Kill rtioctl() stub, returning EOPNOTSUPP since tree import.mpi1-2/+2
ok jsg@
2016-11-21Enforce that pr_usrreq functions are called at IPL_SOFTNET.mpi1-2/+10
This will allow us to keep locking simple as soon as we trade splsoftnet() for a rwlock. ok bluhm@, claudio@
2016-10-06Separate splsoftnet() from variable initialization.bluhm1-2/+3
From mpi@'s netlock diff; OK mikeb@
2015-12-05remove stale lint annotationstedu1-4/+1
2015-05-13test mbuf pointers against NULL not 0jsg1-6/+6
ok krw@ miod@
2014-07-13bzero -> memset. for the speeds.tedu1-2/+2
2014-03-30Eliminates struct pcred by moving the real and saved ugids intoguenther1-2/+2
struct ucred; struct process then directly links to the ucred Based on a discussion at c2k10 or so before noting that FreeBSD and NetBSD did this too. ok matthew@
2013-09-28poll(2) on a socket should set POLLHUP on EOF. This makes themillert1-2/+5
behavior of socketpair(2) match that of pipe(2) when the other end is closed. OK guenther@
2013-04-05remove some obsolete caststedu1-7/+6
2013-01-15Changing the socket buffer flags sb_flags was not interrupt safebluhm1-3/+3
as |= and &= are non-atomic operations. To avoid additional locks, put the flags that have to be accessed from interrupt into a separate sb_flagsintr 32 bit integer field. sb_flagsintr is protected by splsoftnet. Input from miod@ deraadt@; OK deraadt@
2009-02-22fix PR 6082: do not create more fd's than will fit in the message onotto1-2/+3
the receiving side when passing fd's. ok deraadt@ kettenis@
2008-10-02A closed, disconnected, or otherwise failed socket is still a socketderaadt1-2/+10
and should return stat information instead of EINVAL from deep in the guts of tcp_usrreq. While there, put some more information into struct stat, inspired by FreeBSD. EINVAL problem reported in PR 5943
2008-05-23Deal with the situation when TCP nfs mounts timeout and processesthib1-3/+3
get hung in nfs_reconnect() because they do not have the proper privilages to bind to a socket, by adding a struct proc * argument to sobind() (and the *_usrreq() routines, and finally in{6}_pcbbind) and do the sobind() with proc0 in nfs_connect. OK markus@, blambert@. "go ahead" deraadt@. Fixes an issue reported by bernd@ (Tested by bernd@). Fixes PR5135 too.
2007-02-26exclude control data from the number of bytes returned by FIONREAD ioctl()kurt1-2/+2
by adding a sb_datacc count to sockbuf that counts data excluding MT_CONTROL and MT_SONAME mbuf types. w/help from deraadt@. okay deraadt@ claudio@
2005-12-13ansi/deregister. No binary change.jsg1-28/+8
2003-09-23Replace select backends with poll backends. selscan() and pollscan()millert1-33/+28
now call the poll backend. With this change we implement greater poll(2) functionality instead of emulating it via the select backend. Adapted from NetBSD and including some changes from FreeBSD. Tested by many, deraadt@ OK
2003-06-02Remove the advertising clause in the UCB license which Berkeleymillert1-6/+2
rescinded 22 July 1999. Proofed by myself and Theo.
2001-05-14Add a fo_stat member to struct fileops. Used soon.art1-2/+2
Also add a stat function for kqueue from FreeBSD.
2001-05-14More generic arguments to soo_stat.art1-4/+6
2001-03-01port kqueue changes from freebsd, plus all required openbsd glue.provos1-3/+5
okay deraadt@, millert@ from jlemon@freebsd.org: extend kqueue down to the device layer, backwards compatible approach suggested by peter@freebsd.org
2000-04-19Change struct file interface methods read and write to pass file offset incsapuntz1-3/+5
and out. Make pread/pwrite in netbsd & linux thread safe - which is the whole point anyway.
1997-08-31for non-tty TIOCSPGRP/F_SETOWN/FIOSETOWN pgid setting calls, store uidderaadt1-1/+4
and euid as well, then deliver them using new csignal() interface which ensures that pgid setting process is permitted to signal the pgid process(es). Thanks to newsham@aloha.net for extensive help and discussion.
1997-02-24OpenBSD tagsniklas1-0/+1
1995-10-18initial import of NetBSD treederaadt1-0/+204