summaryrefslogtreecommitdiff
path: root/sys/kern/uipc_socket.c
AgeCommit message (Collapse)Author
2016-01-15Improve the socket panic messages further. claudio@ wants to seeAlexander Bluhm
the socket type and dlg@ is interested in the pointers for ddb show socket. OK deraadt@ dlg@
2016-01-15print TAILQ_NEXT(so, so_qe) tooDavid Gwynne
2016-01-15add a "show socket" command to ddbDavid Gwynne
should help inspecting socket issues in the future. enthusiasm from mpi@ bluhm@ deraadt@
2016-01-13To make bug hunting easier, print more information in the soreceive()Alexander Bluhm
and somove() panic messages. OK phessler@ benno@ deraadt@ mpi@
2016-01-06Prevent integer overflows in sosend() and soreceive() by convertingStefan Kempf
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@
2015-12-05remove stale lint annotationsTed Unangst
2015-10-30Let m_resethdr() clear the whole mbuf packet header, not only theAlexander Bluhm
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@
2015-08-24Items from pool sosplice_pool are get in process context and putAlexander Bluhm
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@
2015-07-08MFREE(9) is dead, long live m_freem(9)!Martin Pieuchot
ok bluhm@, claudio@, dlg@
2015-06-30Get rid of the undocumented & temporary* m_copy() macro added forMartin Pieuchot
compatibility with 4.3BSD in September 1989. *Pick your own definition for "temporary". ok bluhm@, claudio@, dlg@
2015-06-16Store a unique ID, an interface index, rather than a pointer to theMartin Pieuchot
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@
2015-05-06Pass a thread pointer instead of its file descriptor table to getsock(9).Martin Pieuchot
Diff from Vitaliy Makkoveev. Manpage tweak and ok millert@
2015-03-14Remove some includes include-what-you-use claims don'tJonathan Gray
have any direct symbols used. Tested for indirect use by compiling amd64/i386/sparc64 kernels. ok tedu@ deraadt@
2015-02-10First step towards making uiomove() take a size_t size argument:Miod Vallat
- 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@
2014-12-11convert bcopy to memcpy/memmove. ok krwTed Unangst
2014-11-03Put the socket splicing fields into a seperate struct sosplice thatAlexander Bluhm
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@
2014-09-09Delete the SS_ISCONFIRMING flag that supported delayed connectionPhilip Guenther
confirmation: it was only used for netiso, which was deleted a *decade* ago ok mpi@ claudio@ ports scan by sthen@
2014-09-08remove uneeded route.h includesJonathan Gray
ok miod@ mpi@
2014-08-31Add additional kernel interfaces for setting close-on-exec on fdsPhilip Guenther
when creating them: pipe2(), dup3(), accept4(), MSG_CMSG_CLOEXEC, SOCK_CLOEXEC. Includes SOCK_NONBLOCK support. ok matthew@
2014-07-13bzero -> memset. for the speeds.Ted Unangst
2014-07-09spellingTed Unangst
2014-06-08Use memcpy to copy the sogetopt() SO_SPLICE off_t value, for it may not beMiod Vallat
correctly aligned. Similar in spirit to 1.119.
2014-04-07Retire kernel support for SO_DONTROUTE, this time without breakingMartin Pieuchot
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@
2014-03-30Eliminates struct pcred by moving the real and saved ugids intoPhilip Guenther
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@
2014-03-28revert "Retire kernel support for SO_DONTROUTE" diff, which does bad thingsStuart Henderson
for localhost connections. discussed with deraadt@
2014-03-27Retire kernel support for SO_DONTROUTE, since the plan is to alwaysMartin Pieuchot
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@
2014-03-18When creating a unix socket, save the PID for pf's log(user), even whenPhilip Guenther
not in the original thread. ok matthew@
2014-01-21Don't leak kernel stack in timeval padding in getsockopt(SO_{SND,RCV}TIMEO)Philip Guenther
ok mikeb@ deraadt@
2014-01-11When I created UDP socket splicing, I added the goto nextpkt loopAlexander Bluhm
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@
2013-12-10dead assignment; from david hill, ok claudioMike Belopuhov
2013-08-27Manipulate timevals seperately, not inside a mbuf. Alignment constraintsTheo de Raadt
miod ran into. ok miod matthew
2013-04-05remove some obsolete castsTed Unangst
2013-04-04Do not allow the listen(2) syscall for an already connected socket.Alexander Bluhm
This would create a weird set of states in TCP. FreeBSD has the same check. Issue found by and OK guenther@
2013-03-27Move soidle() into the big #ifdef SOCKET_SPLICE block to have itAlexander Bluhm
all in one place. Saves one additional #ifdef, no functional change. OK mikeb@
2013-03-19After a socket splicing timeout is fired, a network interrupt canAlexander Bluhm
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@
2013-02-16Fix a bug in udp socket splicing in case a packet gets diverted andAlexander Bluhm
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@
2013-01-17Expand the socket splicing functionality from TCP to UDP. MergeAlexander Bluhm
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@
2013-01-15Pass an EFBIG error to user land when the maximum splicing lengthAlexander Bluhm
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
2013-01-15Changing the socket buffer flags sb_flags was not interrupt safeAlexander Bluhm
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@
2012-12-31Put the #ifdef SOCKBUF_DEBUG around sbcheck() into a SBCHECK macro.Alexander Bluhm
That is consistent to the SBLASTRECORDCHK and SBLASTMBUFCHK macros. OK markus@
2012-10-05add send(2) MSG_DONTWAIT support which enables us to choose nonblockingYASUOKA Masahiko
or blocking for each send(2) call. diff from UMEZAWA Takeshi ok bluhm
2012-09-20In somove() free the mbufs when necessary instead of freeing themAlexander Bluhm
in the release path. Especially accessing m in a KDASSERT() could go wrong. OK claudio@
2012-09-19When a socket is spliced, it may not wakeup the userland for reading.Alexander Bluhm
There was a small race in sorwakeup() where that could happen if we slept before the SB_SPLICE flag was set. ok claudio@
2012-09-19In somove() make the call to pr_usrreq(PRU_RCVD) under the sameAlexander Bluhm
conditions as in soreceive(). My goal is to make socket splicing less protocol dependent. ok claudio@
2012-09-17Fix indent white spaces.Alexander Bluhm
2012-07-22unp_dispose() walks not just the mbuf chain (m_next) but also the packetPhilip Guenthe
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@
2012-07-10For setsockopt(SO_{SND,RCV}TIMEO), convert the timeval to ticks usingPhilip Guenthe
tvtohz() so that the rounding is correct and we don't time out a tick early ok claudio@
2012-07-10Try to cleanup the macro magic because of socket spliceing. Since structClaudio Jeker
socket is no longer affected by option SOCKET_SPLICE we can simplyfy the code. OK bluhm@
2012-07-07Fix two races in socket splicing. When somove() gets called fromAlexander Bluhm
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@
2012-04-24In sosend() for AF_UNIX control message sending, correctly calculateTheo de Raadt
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...