summaryrefslogtreecommitdiff
path: root/sys/netsmb/smb_trantcp.c
Commit message (Collapse)AuthorAgeFilesLines
* Rework socket upcalls to close some races with setup/teardown of upcalls.John Baldwin2009-06-011-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Each socket upcall is now invoked with the appropriate socket buffer locked. It is not permissible to call soisconnected() with this lock held; however, so socket upcalls now return an integer value. The two possible values are SU_OK and SU_ISCONNECTED. If an upcall returns SU_ISCONNECTED, then the soisconnected() will be invoked on the socket after the socket buffer lock is dropped. - A new API is provided for setting and clearing socket upcalls. The API consists of soupcall_set() and soupcall_clear(). - To simplify locking, each socket buffer now has a separate upcall. - When a socket upcall returns SU_ISCONNECTED, the upcall is cleared from the receive socket buffer automatically. Note that a SO_SND upcall should never return SU_ISCONNECTED. - All this means that accept filters should now return SU_ISCONNECTED instead of calling soisconnected() directly. They also no longer need to explicitly clear the upcall on the new socket. - The HTTP accept filter still uses soupcall_set() to manage its internal state machine, but other accept filters no longer have any explicit knowlege of socket upcall internals aside from their return value. - The various RPC client upcalls currently drop the socket buffer lock while invoking soreceive() as a temporary band-aid. The plan for the future is to add a new flag to allow soreceive() to be called with the socket buffer locked. - The AIO callback for socket I/O is now also invoked with the socket buffer locked. Previously sowakeup() would drop the socket buffer lock only to call aio_swake() which immediately re-acquired the socket buffer lock for the duration of the function call. Discussed with: rwatson, rmacklem Notes: svn path=/head/; revision=193272
* Retire the MALLOC and FREE macros. They are an abomination unto style(9).Dag-Erling Smørgrav2008-10-231-1/+1
| | | | | | | MFC after: 3 months Notes: svn path=/head/; revision=184205
* Replaced the misleading uses of a historical artefact M_TRYWAIT with M_WAIT.Ruslan Ermilov2008-03-251-3/+1
| | | | | | | | | | | | | Removed dead code that assumed that M_TRYWAIT can return NULL; it's not true since the advent of MBUMA. Reviewed by: arch There are ongoing disputes as to whether we want to switch to directly using UMA flags M_WAITOK/M_NOWAIT for mbuf(9) allocation. Notes: svn path=/head/; revision=177599
* Refactor select to reduce contention and hide internal implementationJeff Roberson2007-12-161-79/+1
| | | | | | | | | | | | | | | | | | | | | | | | details from consumers. - Track individual selecters on a per-descriptor basis such that there are no longer collisions and after sleeping for events only those descriptors which triggered events must be rescaned. - Protect the selinfo (per descriptor) structure with a mtx pool mutex. mtx pool mutexes were chosen to preserve api compatibility with existing code which does nothing but bzero() to setup selinfo structures. - Use a per-thread wait channel rather than a global wait channel. - Hide select implementation details in a seltd structure which is opaque to the rest of the kernel. - Provide a 'selsocket' interface for those kernel consumers who wish to select on a socket when they have no fd so they no longer have to be aware of select implementation details. Tested by: kris Reviewed on: arch Notes: svn path=/head/; revision=174647
* Initialize some variables that GCC4.2 thinks might possibly be used withoutMatt Jacob2007-06-151-0/+2
| | | | | | | being initialized. Notes: svn path=/head/; revision=170804
* Commit 14/14 of sched_lock decomposition.Jeff Roberson2007-06-051-7/+7
| | | | | | | | | | | | | | - Use thread_lock() rather than sched_lock for per-thread scheduling sychronization. - Use the per-process spinlock rather than the sched_lock for per-process scheduling synchronization. Tested by: kris, current@ Tested on: i386, amd64, ULE, 4BSD, libthr, libkse, PREEMPTION, etc. Discussed with: kris, attilio, kmacy, jhb, julian, bde (small parts each) Notes: svn path=/head/; revision=170307
* - Fix ncp_poll() to not panic if the socket doesn't have any pending data.John Baldwin2006-08-031-10/+6
| | | | | | | | | | | | | | | | | | | | | | | We have to adjust curthread's state enough so that it appears to be in a poll(2) or select(2) call so that selrecord() will work and then teardown that state after calling sopoll(). - Fix some minor nits in nearby ncp_sock_rselect() and in the identical nbssn_rselect() function in the netsmb code: - Don't call nb_poll()/ncp_poll() now that ncp_poll() already fakes up poll(2) state since the rselect() functions already do that. Just invoke sopoll() directly. - To make things slightly more intuitive, store the results of sopoll() in a new 'revents' variable rather than 'error' since that's what sopoll() actually returns. - If the requested timeout time has been exceeded by the time we get ready to block, then return EWOULDBLOCK rather than 0 to signal a timeout as this is what the calling code expects. Tested by: Eric Christeson <eric.j.christeson AT gmail> (1) MFC after: 1 week Notes: svn path=/head/; revision=160954
* soreceive_generic(), and sopoll_generic(). Add new functions sosend(),Robert Watson2006-07-241-8/+4
| | | | | | | | | | | | | | | | | | | soreceive(), and sopoll(), which are wrappers for pru_sosend, pru_soreceive, and pru_sopoll, and are now used univerally by socket consumers rather than either directly invoking the old so*() functions or directly invoking the protocol switch method (about an even split prior to this commit). This completes an architectural change that was begun in 1996 to permit protocols to provide substitute implementations, as now used by UDP. Consumers now uniformly invoke sosend(), soreceive(), and sopoll() to perform these operations on sockets -- in particular, distributed file systems and socket system calls. Architectural head nod: sam, gnn, wollman Notes: svn path=/head/; revision=160619
* /* -> /*- for license, minor formatting changesWarner Losh2005-01-071-1/+1
| | | | Notes: svn path=/head/; revision=139823
* Merge additional socket buffer locking from rwatson_netperf:Robert Watson2004-06-171-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Lock down low hanging fruit use of sb_flags with socket buffer lock. - Lock down low hanging fruit use of so_state with socket lock. - Lock down low hanging fruit use of so_options. - Lock down low-hanging fruit use of sb_lowwat and sb_hiwat with socket buffer lock. - Annotate situations in which we unlock the socket lock and then grab the receive socket buffer lock, which are currently actually the same lock. Depending on how we want to play our cards, we may want to coallesce these lock uses to reduce overhead. - Convert a if()->panic() into a KASSERT relating to so_state in soaccept(). - Remove a number of splnet()/splx() references. More complex merging of socket and socket buffer locking to follow. Notes: svn path=/head/; revision=130653
* The socket field so_state is used to hold a variety of socket relatedRobert Watson2004-06-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | flags relating to several aspects of socket functionality. This change breaks out several bits relating to send and receive operation into a new per-socket buffer field, sb_state, in order to facilitate locking. This is required because, in order to provide more granular locking of sockets, different state fields have different locking properties. The following fields are moved to sb_state: SS_CANTRCVMORE (so_state) SS_CANTSENDMORE (so_state) SS_RCVATMARK (so_state) Rename respectively to: SBS_CANTRCVMORE (so_rcv.sb_state) SBS_CANTSENDMORE (so_snd.sb_state) SBS_RCVATMARK (so_rcv.sb_state) This facilitates locking by isolating fields to be located with other identically locked fields, and permits greater granularity in socket locking by avoiding storing fields with different locking semantics in the same short (avoiding locking conflicts). In the future, we may wish to coallesce sb_state and sb_flags; for the time being I leave them separate and there is no additional memory overhead due to the packing/alignment of shorts in the socket buffer structure. Notes: svn path=/head/; revision=130480
* Rename dup_sockaddr() to sodupsockaddr() for consistency with otherRobert Watson2004-03-011-2/+2
| | | | | | | | | | | | | | | functions in kern_socket.c. Rename the "canwait" field to "mflags" and pass M_WAITOK and M_NOWAIT in from the caller context rather than "1" or "0". Correct mflags pass into mac_init_socket() from previous commit to not include M_ZERO. Submitted by: sam Notes: svn path=/head/; revision=126425
* Use __FBSDID().David E. O'Brien2003-06-111-2/+4
| | | | Notes: svn path=/head/; revision=116189
* Back out M_* changes, per decision of the TRB.Warner Losh2003-02-191-2/+2
| | | | | | | Approved by: trb Notes: svn path=/head/; revision=111119
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.Alfred Perlstein2003-01-211-2/+2
| | | | | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT. Notes: svn path=/head/; revision=109623
* o Untangle the confusion with the malloc flags {M_WAITOK, M_NOWAIT} andBosko Milekic2002-12-191-1/+1
| | | | | | | | | | | | | the mbuf allocator flags {M_TRYWAIT, M_DONTWAIT}. o Fix a bpf_compat issue where malloc() was defined to just call bpf_alloc() and pass the 'canwait' flag(s) along. It's been changed to call bpf_alloc() but pass the corresponding M_TRYWAIT or M_DONTWAIT flag (and only one of those two). Submitted by: Hiten Pandya <hiten@unixdaemons.com> (hiten->commit_count++) Notes: svn path=/head/; revision=108107
* Fix a fatal typo introduced in revision 1.13 that caused the mbuf chains toTim J. Robbins2002-11-261-1/+1
| | | | | | | | | be created incorrectly for requests larger than NB_SORECEIVE_CHUNK bytes. Approved by: re Notes: svn path=/head/; revision=107293
* Increase send/receive queue to accomodate large readx/writex requests.Boris Popov2002-09-181-20/+68
| | | | | | | | | | Receive packets in a small pieces (NB_SORECEIVE_CHUNK), so TCP slowstart will get its ACKs faster. Obtained from: Darwin Notes: svn path=/head/; revision=103528
* Back out my lats commit of locking down a socket, it conflicts with hsu's work.Seigo Tanimura2002-05-311-9/+1
| | | | | | | Requested by: hsu Notes: svn path=/head/; revision=97658
* Lock down a socket, milestone 1.Seigo Tanimura2002-05-201-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | o Add a mutex (sb_mtx) to struct sockbuf. This protects the data in a socket buffer. The mutex in the receive buffer also protects the data in struct socket. o Determine the lock strategy for each members in struct socket. o Lock down the following members: - so_count - so_options - so_linger - so_state o Remove *_locked() socket APIs. Make the following socket APIs touching the members above now require a locked socket: - sodisconnect() - soisconnected() - soisconnecting() - soisdisconnected() - soisdisconnecting() - sofree() - soref() - sorele() - sorwakeup() - sotryfree() - sowakeup() - sowwakeup() Reviewed by: alfred Notes: svn path=/head/; revision=96972
* Revert the change of #includes in sys/filedesc.h and sys/socketvar.h.Seigo Tanimura2002-04-301-4/+7
| | | | | | | | | | | | | Requested by: bde Since locking sigio_lock is usually followed by calling pgsigio(), move the declaration of sigio_lock and the definitions of SIGIO_*() to sys/signalvar.h. While I am here, sort include files alphabetically, where possible. Notes: svn path=/head/; revision=95759
* Initialize thread select queue in the same way as rev 1.93 of sys_generic.cBoris Popov2002-04-231-0/+3
| | | | | | | | | does. Missed and found by: alfred Notes: svn path=/head/; revision=95313
* Missed this file for select SMP fixes associated with rev 1.93 ofAlfred Perlstein2002-03-141-27/+24
| | | | | | | kern/sys_generic.c Notes: svn path=/head/; revision=92261
* Simple p_ucred -> td_ucred changes to start using the per-thread ucredJohn Baldwin2002-02-271-1/+1
| | | | | | | reference. Notes: svn path=/head/; revision=91406
* Spelling fixes.Boris Popov2001-12-311-1/+1
| | | | | | | | | PR: kern/33131 Submitted by: Anders Andersson <anders@hack.org> MFC after: 1 week Notes: svn path=/head/; revision=88741
* o Make the credential used by socreate() an explicit argument toRobert Watson2001-12-311-1/+2
| | | | | | | | | | | | | | | | | socreate(), rather than getting it implicitly from the thread argument. o Make NFS cache the credential provided at mount-time, and use the cached credential (nfsmount->nm_cred) when making calls to socreate() on initially connecting, or reconnecting the socket. This fixes bugs involving NFS over TCP and ipfw uid/gid rules, as well as bugs involving NFS and mandatory access control implementations. Reviewed by: freebsd-arch Notes: svn path=/head/; revision=88739
* Pull netsmb requester from the pre-KSE world. This update mostly basedBoris Popov2001-12-021-46/+59
| | | | | | | on the patches submitted by Max Khon <fjoe@iclub.nsu.ru> Notes: svn path=/head/; revision=87192
* Back out scanning file descriptors with holding a process lock.Seigo Tanimura2001-05-151-2/+16
| | | | | | | | selrecord() requires allproc sx in pfind(), resulting in lock order reversal between allproc and a process lock. Notes: svn path=/head/; revision=76618
* - Convert msleep(9) in select(2) and poll(2) to cv_*wait*(9).Seigo Tanimura2001-05-141-9/+13
| | | | | | | | | | | | | | | | - Since polling should not involve sleeping, keep holding a process lock upon scanning file descriptors. - Hold a reference to every file descriptor prior to entering polling loop in order to avoid lock order reversal between lockmgr and p_mtx upon calling fdrop() in fo_poll(). (NOTE: this work has not been done for netncp and netsmb yet because a socket itself has no reference counts.) Reviewed by: jhb Notes: svn path=/head/; revision=76564
* Import kernel part of SMB/CIFS requester.Boris Popov2001-04-101-0/+672
Add smbfs(CIFS) filesystem. Userland part will be in the ports tree for a while. Obtained from: smbfs-1.3.7-dev package. Notes: svn path=/head/; revision=75374