summaryrefslogtreecommitdiff
path: root/sys/kern/uipc_usrreq.c
AgeCommit message (Collapse)Author
2022-05-28s/grabing/grabbing/ in comments.andvar
2022-04-09unix(4): Convert membar_exit to membar_release.riastradh
Use atomic_load_consume or atomic_load_relaxed where necessary. Comment on why unlocked nonatomic access is valid where it is done.
2021-08-08introduce a SOL_LOCAL for unix-domain socket level socket optionsnia
as an alias of the current 0 used for these options, as in FreeBSD. reviewed by many.
2020-11-06PR/55777: Ruslan Nikolaev: Move the unp_sysctl_create to uipc_usrreq.c tochristos
facilitate splitting rump modules and does not require a dummy function.
2020-08-26add socket info for user and group for unix sockets in fstat.christos
2020-04-21Revert the changes made in February to make cwdinfo use mostly lockless,ad
which relied on taking extra vnode refs. Having benchmarked various experimental changes over the past few months it seems that it's better to avoid vnode refs as much as possible. cwdi_lock as a RW lock already did that to some extent for getcwd() and will permit the same for namei() too.
2020-02-23Merge from ad-namecache:ad
- Have a stab at clustering the members of vnode_t and vnode_impl_t in a more cache-conscious way. With that done, go back to adjusting v_usecount with atomics and keep vi_lock directly in vnode_impl_t (saves KVA). - Allow VOP_LOCK(LK_NONE) for the benefit of VFS_VGET() and VFS_ROOT(). Make sure LK_UPGRADE always comes with LK_NOWAIT. - Make cwdinfo use mostly lockless.
2020-02-01Load struct fdfile::ff_file with atomic_load_consume.riastradh
Exceptions: when we're only testing whether it's there, not about to dereference it. Note: We do not use atomic_store_release to set it because the preceding mutex_exit should be enough. (That said, it's not clear the mutex_enter/exit is needed unless refcnt > 0 already, in which case maybe it would be a win to switch from the membar implied by mutex_enter to the membar implied by atomic_store_release -- which I would generally expect to be much cheaper. And a little clearer without a long comment.)
2020-02-01Load struct filedesc::fd_dt with atomic_load_consume.riastradh
Exceptions: when fd_refcnt <= 1, or when holding fd_lock. While here: - Restore KASSERT(mutex_owned(&fdp->fd_lock)) in fd_unused. => This is used only in fd_close and fd_abort, where it holds. - Move bounds check assertion in fd_putfile to where it matters. - Store fd_dt with atomic_store_release. - Move load of fd_dt under lock in knote_fdclose. - Omit membar_consumer in fdesc_readdir. => atomic_load_consume serves the same purpose now. => Was needed only on alpha anyway.
2019-07-29Fix info leak: the padding after the header causes uninitialized heapmaxv
memory to be copied to userland in sys_recvmsg().
2019-06-03 Fix typo in comment (s/seperate/separate/).msaitoh
2019-03-01Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as brieflypgoyette
discussed on irc. NFCI intended. Ride the earlier kernel bump - it;s getting crowded.
2019-02-20compat70_ocreds_valid is not a pointer to a boolean, it is the booleanpgoyette
itself which controls whether or not we recognize the OCRED options. Should fix the panic identified in PR kern/53991 (awaiting confirmation from submitter).
2019-02-04add or adjust fallthru comments.mrg
2019-01-29Normalize all the compat hooks' names to the formpgoyette
<subsystem>_<function>_<version>_hook NFCI XXX Note that although this introduces a change in the kernel-to- XXX module interface, we are NOT bumping the kernel version number. XXX We will bump the version number once the interface stabilizes.
2019-01-27Merge the [pgoyette-compat] branchpgoyette
2018-11-08Don't call soroverflow when we return the error to the sender.roy
Thanks to thorpej@ for a sanity check.
2018-05-11Increase the default size of some receive buffers from 8k to 16k.roy
This mitigates recent reports of socket overflow errors and fixes PR bin/53247.
2018-05-05bump PIPSIZ from 4 to 8K like FreeBSD and provide the same sysctlschristos
2018-03-19socket: report receive buffer overflowsroy
Add soroverflow() which increments the overflow counter, sets so_error to ENOBUFS and wakes the receive socket up. Replace all code that manually increments this counter with soroverflow(). Add soroverflow() to raw_input(). This allows userland to detect route(4) overflows so it can re-sync with the current state.
2018-02-17fix LOCAL_PEEREID to not return the same info for both sides...christos
XXX: pullup-{7,8}
2017-12-02include opt_compat_netbsd.h, so that eg COMPAT_70 will be set.mrg
2016-10-31Memory leak, found by Mootja. It is easily triggerable from userland.maxv
2016-04-06Add sc_pid to sockcred so that SOCK_DGRAM and LOCAL_CREDS socket optionroy
can learn the process id of the AF_LOCAL sender. Add compat glue for old structure.
2015-05-02make connect syscall use sockaddr_big and modify pr_{send,connect}rtr
nam parameter type from buf * to sockaddr *. final commit for parameter type changes to protocol user requests * bump kernel version to 7.99.15 for parameter type changes to pr_{send,connect}
2015-04-26remove pr_generic from struct pr_usrreqs and all implementations ofrtr
pr_generic in protocols. bump to 7.99.13 approved by rmind@
2015-04-24make accept, getsockname and getpeername syscalls use sockaddr_big and modifyrtr
pr_{accept,sockname,peername} nam parameter type from mbuf * to sockaddr *. * retained use of mbuftypes[MT_SONAME] for now. * bump to netbsd version 7.99.12 for parameter type change. patch posted to tech-net@ 2015/04/19
2015-04-03* change pr_bind to accept struct sockaddr * instead of struct mbuf *rtr
* update protocol bind implementations to use/expect sockaddr * instead of mbuf * * introduce sockaddr_big struct for storage of addr data passed via sys_bind; sockaddr_big is of sufficient size and alignment to accommodate all addr data sizes received. * modify sys_bind to allocate sockaddr_big instead of using an mbuf. * bump kernel version to 7.99.9 for change to pr_bind() parameter type. Patch posted to tech-net@ http://mail-index.netbsd.org/tech-net/2015/03/15/msg005004.html The choice to use a new structure sockaddr_big has been retained since changing sockaddr_storage size would lead to unnecessary ABI change. The use of the new structure does not preclude future work that increases the size of sockaddr_storage and at that time sockaddr_big may be trivially replaced. Tested by mrg@ and myself, discussed with rmind@, posted to tech-net@
2015-03-01PR/39918: ITOH Yasufumi: Replace KASSERT with continue, since the filechristos
descriptor can be closed since closef() does not pay attention to FDEFER. XXX: Pullup-7
2015-02-28Place opening brace to function at column 0, like in the rest of the file.rtr
2015-02-02Handle LOCAL_PEERID for socketpair() connected sockets which connect throughchristos
connect2(). 1. move the code that sets the peerid structure into connect1(). This handles so2. The datagram code calls connect2 twice with flipped so arguments so both sockets get set. 2. in connect2 copy the peerid structure from so2 to so, so that that both stream sockets get set.
2014-10-08Make behavior of getsockname(2) (and maybe getpeername(2)) as the same astaca
NetBSD 6.1_STABLE and other operating system (OS X 10.9.5). * sa_len of sockaddr_un strucrure is always set to sizeof(sun_path). * pathname stored in sun_path is alwasys '\0' terminated (except length of sun_path is sizeof(sun_path)?). Should be fix PR kern/49247, runtime problem of lmtp service of dovecot2 on NetBSD current and NetBSD 7.0_BETA.
2014-09-05Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to getmatt
a correctly typed pointer.
2014-09-05Don't next structure and enum definitions.matt
Don't use C++ keywords new, try, class, private, etc.
2014-08-09split PRU_CONNECT2 & PRU_PURGEIF function out of pr_generic() usrreqrtr
switches and put into separate functions - always KASSERT(solocked(so)) even if not implemented (for PRU_CONNECT2 only) - replace calls to pr_generic() with req = PRU_CONNECT2 with calls to pr_connect2() - replace calls to pr_generic() with req = PRU_PURGEIF with calls to pr_purgeif() put common code from unp_connect2() (used by unp_connect() into unp_connect1() and call out to it when needed patch only briefly reviewed by rmind@
2014-08-08split PRU_RCVD function out of pr_generic() usrreq switches and put intortr
separate functions - always KASSERT(solocked(so)) even if not implemented - replace calls to pr_generic() with req = PRU_RCVD with calls to pr_rcvd()
2014-08-05actually use the passed in struct lwp *l instead of curlwp in unp_connect()rtr
2014-08-05split PRU_SEND function out of pr_generic() usrreq switches and put intortr
separate functions xxx_send(struct socket *, struct mbuf *, struct mbuf *, struct mbuf *, struct lwp *) - always KASSERT(solocked(so)) even if not implemented - replace calls to pr_generic() with req = PRU_SEND with calls to pr_send() rename existing functions that operate on PCB for consistency (and to free up their names for xxx_send() PRUs - l2cap_send() -> l2cap_send_pcb() - sco_send() -> sco_send_pcb() - rfcomm_send() -> rfcomm_send_pcb() patch reviewed by rmind
2014-08-05revert the removal of struct lwp * parameter from bind, listen and connectrtr
user requests. this should resolve the issue relating to nfs client hangs presented recently by wiz on current-users@
2014-07-31* remove declarations of unp_bind, unp_discard, unp_disconnect1, unp_drop,rtr
unp_shutdown1, unp_internalize and unp_output functions from sys/un.h and instead declare them as static in uipc_usrreq.c with prototype declarations as necessary. * remove struct lwp * parameter from unp_output() while here and just use curlwp instead. as discussed with rmind
2014-07-31split PRU_DISCONNECT, PRU_SHUTDOWN and PRU_ABORT function out ofrtr
pr_generic() usrreq switches and put into separate functions xxx_disconnect(struct socket *) xxx_shutdown(struct socket *) xxx_abort(struct socket *) - always KASSERT(solocked(so)) even if not implemented - replace calls to pr_generic() with req = PRU_{DISCONNECT,SHUTDOWN,ABORT} with calls to pr_{disconnect,shutdown,abort}() respectively rename existing internal functions used to implement above functionality to permit use of the names for xxx_{disconnect,shutdown,abort}(). - {l2cap,sco,rfcomm}_disconnect() -> {l2cap,sco,rfcomm}_disconnect_pcb() - {unp,rip,tcp}_disconnect() -> {unp,rip,tcp}_disconnect1() - unp_shutdown() -> unp_shutdown1() patch reviewed by rmind
2014-07-30split PRU_CONNECT function out of pr_generic() usrreq switches and putrtr
into seaparate functions xxx_listen(struct socket *, struct mbuf *) - always KASSERT(solocked(so)) and KASSERT(nam != NULL) - replace calls to pr_generic() with req = PRU_CONNECT with pr_connect() - rename existin {l2cap,sco,rfcomm}_connect() to {l2cap,sco,rfcomm}_connect_pcb() respectively to permit naming consistency with other protocols functions. - drop struct lwp * parameter from unp_connect() and at_pcbconnect() and use curlwp instead where appropriate. patch reviewed by rmind
2014-07-24split PRU_BIND and PRU_LISTEN function out of pr_generic() usrreqrtr
switches and put into separate functions xxx_bind(struct socket *, struct mbuf *) xxx_listen(struct socket *) - always KASSERT(solocked(so)) even if not implemented - replace calls to pr_generic() with req = PRU_BIND with call to pr_bind() - replace calls to pr_generic() with req = PRU_LISTEN with call to pr_listen() - drop struct lwp * parameter from at_pcbsetaddr(), in_pcbbind() and unp_bind() and always use curlwp. rename existing functions that operate on PCB for consistency (and to free up their names for xxx_{bind,listen}() PRUs - l2cap_{bind,listen}() -> l2cap_{bind,listen}_pcb() - sco_{bind,listen}() -> sco_{bind,listen}_pcb() - rfcomm_{bind,listen}() -> rfcomm_{bind,listen}_pcb() patch reviewed by rmind welcome to netbsd 6.99.48
2014-07-23split PRU_SENDOOB and PRU_RCVOOB function out of pr_generic() usrreqrtr
switches and put into separate functions xxx_sendoob(struct socket *, struct mbuf *, struct mbuf *) xxx_recvoob(struct socket *, struct mbuf *, int) - always KASSERT(solocked(so)) even if request is not implemented - replace calls to pr_generic() with req = PRU_{SEND,RCV}OOB with calls to pr_{send,recv}oob() respectively. there is still some tweaking of m_freem(m) and m_freem(control) to come for consistency. not performed with this commit for clarity. reviewed by rmind
2014-07-09* split PRU_ACCEPT function out of pr_generic() usrreq switches and putrtr
into a separate function xxx_accept(struct socket *, struct mbuf *) note: future cleanup will take place to remove struct mbuf parameter type and replace it with a more appropriate type. patch reviewed by rmind
2014-07-09* split PRU_PEERADDR and PRU_SOCKADDR function out of pr_generic()rtr
usrreq switches and put into separate functions xxx_{peer,sock}addr(struct socket *, struct mbuf *). - KASSERT(solocked(so)) always in new functions even if request is not implemented - KASSERT(pcb != NULL) and KASSERT(nam) if the request is implemented and not for tcp. * for tcp roll #ifdef KPROF and #ifdef DEBUG code from tcp_usrreq() into easier to cut & paste functions tcp_debug_capture() and tcp_debug_trace() - functions provided by rmind - remaining use of PRU_{PEER,SOCK}ADDR #define to be removed in a future commit. * rename netbt functions to permit consistency of pru function names (as has been done with other requests already split out). - l2cap_{peer,sock}addr() -> l2cap_{peer,sock}_addr_pcb() - rfcomm_{peer,sock}addr() -> rfcomm_{peer,sock}_addr_pcb() - sco_{peer,sock}addr() -> sco_{peer,sock}_addr_pcb() * split/refactor do_sys_getsockname(lwp, fd, which, nam) into two functions do_sys_get{peer,sock}name(fd, nam). - move PRU_PEERADDR handling into do_sys_getpeername() from do_sys_getsockname() - have svr4_stream directly call do_sys_get{sock,peer}name() respectively instead of providing `which' & fix a DPRINTF string that incorrectly wrote "getpeername" when it meant "getsockname" - fix sys_getpeername() and sys_getsockname() to call do_sys_get{sock,peer}name() without `which' and `lwp' & adjust comments - bump kernel version for removal of lwp & which parameters from do_sys_getsockname() note: future cleanup to remove struct mbuf * abuse in xxx_{peer,sock}name() still to come, not done in this commit since it is easier to do post split. patch reviewed by rmind welcome to 6.99.47
2014-07-07* sprinkle KASSERT(solocked(so)); in all pr_stat() functions.rtr
* fix remaining inconsistent struct socket parameter names.
2014-07-06* split PRU_SENSE functionality out of xxx_usrreq() switches and place intortr
separate xxx_stat(struct socket *, struct stat *) functions. * replace calls using pr_generic with req == PRU_SENSE with pr_stat(). further change will follow that cleans up the pattern used to extract the pcb and test for its presence. reviewed by rmind
2014-07-01fix parameter types in pr_ioctl, called xx_control() functions and removertr
abuse of pointer to struct mbuf type. param2 changed to u_long type and uses parameter name 'cmd' (ioctl command) param3 changed to void * type and uses parameter name 'data' param4 changed to struct ifnet * and uses parameter name 'ifp' param5 has been removed (formerly struct lwp *) and uses of 'l' have been replaced with curlwp from curproc(9). callers have had (now unnecessary) casts to struct mbuf * removed, called code has had (now unnecessary) casts to u_long, void * and struct ifnet * respectively removed. reviewed by rmind@
2014-06-22* split PRU_CONTROL functionality out of xxx_userreq() switches and placertr
into separate xxx_ioctl() functions. * place KASSERT(req != PRU_CONTROL) inside xxx_userreq() as it is now inappropriate for req = PRU_CONTROL in xxx_userreq(). * replace calls to pr_generic() with req = PRU_CONTROL with pr_ioctl(). * remove & fixup references to PRU_CONTROL xxx_userreq() function comments. * fix various comments references for xxx_userreq() that mentioned PRU_CONTROL as xxx_userreq() no longer handles the request. a further change will follow to fix parameter and naming inconsistencies retained from original code. Reviewed by rmind@