summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_socket.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* add a "show socket" command to ddbdlg2016-01-151-1/+87
| | | | | | should help inspecting socket issues in the future. enthusiasm from mpi@ bluhm@ deraadt@
* To make bug hunting easier, print more information in the soreceive()bluhm2016-01-131-7/+7
| | | | | and somove() panic messages. OK phessler@ benno@ deraadt@ mpi@
* Prevent integer overflows in sosend() and soreceive() by convertingstefan2016-01-061-30/+27
| | | | | | | min()+uiomovei() to ulmin()+uiomove() and re-arranging space computations in sosend(). The soreceive() part was also reported by Martin Natano. ok bluhm@ and also discussed with tedu@
* remove stale lint annotationstedu2015-12-051-5/+1
|
* Let m_resethdr() clear the whole mbuf packet header, not only thebluhm2015-10-301-4/+2
| | | | | | | pf part. This allows to reuse this function in socket splicing. Reset the mbuf flags that are related to the packet header, but preserve the data flags. pair(4) tested by reyk@; sosplice(9) tested by bluhm@; OK mikeb@ reyk@
* Items from pool sosplice_pool are get in process context and putbluhm2015-08-241-2/+3
| | | | | | | | | in soft interrupt. So the pool needs an IPL_SOFTNET protection. This fixes a panic: mtx_enter: locking against myself. While there, call pool_setipl() also for socket_pool. Although this pool uses explicit spl protection around pool_get() and pool_put(), it is better to specify the IPL it is operating on. OK mpi@ mikeb@
* MFREE(9) is dead, long live m_freem(9)!mpi2015-07-081-5/+5
| | | | ok bluhm@, claudio@, dlg@
* Get rid of the undocumented & temporary* m_copy() macro added formpi2015-06-301-3/+3
| | | | | | | | compatibility with 4.3BSD in September 1989. *Pick your own definition for "temporary". ok bluhm@, claudio@, dlg@
* Store a unique ID, an interface index, rather than a pointer to thempi2015-06-161-2/+2
| | | | | | | | | | | | | | | receiving interface in the packet header of every mbuf. The interface pointer should now be retrieved when necessary with if_get(). If a NULL pointer is returned by if_get(), the interface has probably been destroy/removed and the mbuf should be freed. Such mechanism will simplify garbage collection of mbufs and limit problems with dangling ifp pointers. Tested by jmatthew@ and krw@, discussed with many. ok mikeb@, bluhm@, dlg@
* Pass a thread pointer instead of its file descriptor table to getsock(9).mpi2015-05-061-2/+2
| | | | | | Diff from Vitaliy Makkoveev. Manpage tweak and ok millert@
* 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@
* First step towards making uiomove() take a size_t size argument:miod2015-02-101-4/+4
| | | | | | | - rename uiomove() to uiomovei() and update all its users. - introduce uiomove(), which is similar to uiomovei() but with a size_t. - rewrite uiomovei() as an uiomove() wrapper. ok kettenis@
* convert bcopy to memcpy/memmove. ok krwtedu2014-12-111-3/+3
|
* Put the socket splicing fields into a seperate struct sosplice thatbluhm2014-11-031-22/+51
| | | | | | | gets only allocated when needed. This way struct socket shrinks from 472 to 392 bytes on amd64. When splicing gets active, another 88 bytes are allocated for struct sosplice. OK dlg@
* Delete the SS_ISCONFIRMING flag that supported delayed connectionguenther2014-09-091-9/+2
| | | | | | confirmation: it was only used for netiso, which was deleted a *decade* ago ok mpi@ claudio@ ports scan by sthen@
* remove uneeded route.h includesjsg2014-09-081-2/+1
| | | | ok miod@ mpi@
* Add additional kernel interfaces for setting close-on-exec on fdsguenther2014-08-311-2/+2
| | | | | | | when creating them: pipe2(), dup3(), accept4(), MSG_CMSG_CLOEXEC, SOCK_CLOEXEC. Includes SOCK_NONBLOCK support. ok matthew@
* bzero -> memset. for the speeds.tedu2014-07-131-4/+4
|
* spellingtedu2014-07-091-2/+2
|
* Use memcpy to copy the sogetopt() SO_SPLICE off_t value, for it may not bemiod2014-06-081-2/+3
| | | | correctly aligned. Similar in spirit to 1.119.
* Retire kernel support for SO_DONTROUTE, this time without breakingmpi2014-04-071-11/+15
| | | | | | | | | | | localhost connections. The plan is to always use the routing table for addresses and routes resolutions, so there is no future for an option that wants to bypass it. This option has never been implemented for IPv6 anyway, so let's just remove the IPv4 bits that you weren't aware of. Tested a least by lteo@, guenther@ and chrisz@, ok mikeb@, benno@
* Eliminates struct pcred by moving the real and saved ugids intoguenther2014-03-301-3/+3
| | | | | | | | | 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@
* revert "Retire kernel support for SO_DONTROUTE" diff, which does bad thingssthen2014-03-281-15/+11
| | | | for localhost connections. discussed with deraadt@
* Retire kernel support for SO_DONTROUTE, since the plan is to alwaysmpi2014-03-271-11/+15
| | | | | | | | use the routing table there's no future for an option that wants to bypass it. This option has never been implemented for IPv6 anyway, so let's just remove the IPv4 bits that you weren't aware of. Tested by florian@, man pages inputs from jmc@, ok benno@
* When creating a unix socket, save the PID for pf's log(user), even whenguenther2014-03-181-2/+2
| | | | | | not in the original thread. ok matthew@
* Don't leak kernel stack in timeval padding in getsockopt(SO_{SND,RCV}TIMEO)guenther2014-01-211-1/+2
| | | | ok mikeb@ deraadt@
* When I created UDP socket splicing, I added the goto nextpkt loopbluhm2014-01-111-2/+2
| | | | | | | | to splice multiple UDP packets in the m_nextpkt list. Some profiling with TCP splicing showed that checking so_rcv.sb_mb is wrong. It causes several useless runs through the loop. Better check for nextrecord which contains the original m_nextpkt value of the mbuf. OK mikeb@
* dead assignment; from david hill, ok claudiomikeb2013-12-101-3/+3
|
* Manipulate timevals seperately, not inside a mbuf. Alignment constraintsderaadt2013-08-271-8/+9
| | | | | miod ran into. ok miod matthew
* remove some obsolete caststedu2013-04-051-14/+11
|
* Do not allow the listen(2) syscall for an already connected socket.bluhm2013-04-041-1/+3
| | | | | | This would create a weird set of states in TCP. FreeBSD has the same check. Issue found by and OK guenther@
* Move soidle() into the big #ifdef SOCKET_SPLICE block to have itbluhm2013-03-271-18/+16
| | | | | all in one place. Saves one additional #ifdef, no functional change. OK mikeb@
* After a socket splicing timeout is fired, a network interrupt canbluhm2013-03-191-3/+5
| | | | | | | | unsplice() the sockets before soidle() goes to splsoftnet. In this case, unsplice() was called twice. So check wether splicing still exists within the splsoftnet protection. Uvm fault in sounsplice() reported by keith at scott-land dot net. OK claudio@
* Fix a bug in udp socket splicing in case a packet gets diverted andbluhm2013-02-161-1/+8
| | | | | | | | spliced and routed to loopback. The content of the pf header in the mbuf was keeping the divert information on its way. Reinitialize the whole packet header of the mbuf and remove the mbuf tags when the packet gets spliced. OK claudio@ markus@
* Expand the socket splicing functionality from TCP to UDP. Mergebluhm2013-01-171-12/+82
| | | | | | | the code relevant for UDP from sosend() and soreceive() into somove(). That allows the kernel to directly transfer the UDP data from one socket to another. OK claudio@
* Pass an EFBIG error to user land when the maximum splicing lengthbluhm2013-01-151-2/+5
| | | | | | | | has been reached. This creates a read event on the spliced source socket that can be noticed with select(2). So the kernel passes control to the relay process immediately. This could be used to log the end of an http request within a persistent connection. deraadt@ reyk@ mikeb@ like the idea
* Changing the socket buffer flags sb_flags was not interrupt safebluhm2013-01-151-7/+7
| | | | | | | | 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@
* Put the #ifdef SOCKBUF_DEBUG around sbcheck() into a SBCHECK macro.bluhm2012-12-311-4/+2
| | | | | That is consistent to the SBLASTRECORDCHK and SBLASTMBUFCHK macros. OK markus@
* add send(2) MSG_DONTWAIT support which enables us to choose nonblockingyasuoka2012-10-051-2/+2
| | | | | | | or blocking for each send(2) call. diff from UMEZAWA Takeshi ok bluhm
* In somove() free the mbufs when necessary instead of freeing thembluhm2012-09-201-21/+21
| | | | | | in the release path. Especially accessing m in a KDASSERT() could go wrong. OK claudio@
* When a socket is spliced, it may not wakeup the userland for reading.bluhm2012-09-191-3/+3
| | | | | | There was a small race in sorwakeup() where that could happen if we slept before the SB_SPLICE flag was set. ok claudio@
* In somove() make the call to pr_usrreq(PRU_RCVD) under the samebluhm2012-09-191-2/+2
| | | | | | conditions as in soreceive(). My goal is to make socket splicing less protocol dependent. ok claudio@
* Fix indent white spaces.bluhm2012-09-171-13/+13
|
* unp_dispose() walks not just the mbuf chain (m_next) but also the packetguenther2012-07-221-2/+2
| | | | | | | chain (m_nextpkt), so the mbuf passed to it must be disconnected completely from the socket buffer's chains. Problem noticed by yasuoka@; tweak from krw@, ok deraadt@
* For setsockopt(SO_{SND,RCV}TIMEO), convert the timeval to ticks usingguenther2012-07-101-6/+4
| | | | | | tvtohz() so that the rounding is correct and we don't time out a tick early ok claudio@
* Try to cleanup the macro magic because of socket spliceing. Since structclaudio2012-07-101-6/+12
| | | | | socket is no longer affected by option SOCKET_SPLICE we can simplyfy the code. OK bluhm@
* Fix two races in socket splicing. When somove() gets called frombluhm2012-07-071-4/+9
| | | | | | | | | | | sosplice() to move the data already there, it might sleep in m_copym(). Another process must not unsplice during that sleep, so also lock the receive buffer when sosplice is called with fd -1. The same sleep can allow network interrupts to modify the socket buffer. So use sbsync() to write back modifications within the loop instead of fixing the socket buffer after the loop. OK claudio@
* In sosend() for AF_UNIX control message sending, correctly calculatederaadt2012-04-241-3/+13
| | | | | | | | the size (internalized ones can be larger on some architectures) for fitting into the socket. Avoid getting confused by sb_hiwat as well. This fixes a variety of issues where sendmsg() would fail to deliver a fd set or fail to wait; even leading to file leakage. Worked on this with claudio for about a week...
* Add struct proc * argument to FRELE() and FILE_SET_MATURE() inguenther2012-04-221-4/+4
| | | | | | anticipation of further changes to closef(). No binary change. ok krw@ miod@ deraadt@
* Make rusage totals, itimers, and profile settings per-process insteadguenther2012-03-231-3/+3
| | | | | | | of per-rthread. Handling of per-thread tick and runtime counters inspired by how FreeBSD does it. ok kettenis@