History log of /netbsd-current/sys/kern/uipc_socket2.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.143 03-Jan-2024 andvar

s/addreseses/addresses/ in comments (and one missing whitespace).


Revision tags: netbsd-10-0-RC2 thorpej-ifq-base thorpej-altq-separation-base netbsd-10-0-RC1 netbsd-10-base
# 1.142 26-Oct-2022 riastradh

ddb/db_active.h: New home for extern db_active.

This can be included unconditionally, and db_active can then be
queried unconditionally; if DDB is not in the kernel, then db_active
is a constant zero. Reduces need for #include opt_ddb.h, #ifdef DDB.


Revision tags: bouyer-sunxi-drm-base
# 1.141 09-Apr-2022 riastradh

unix(4): Convert membar_exit to membar_release.

Use atomic_load_consume or atomic_load_relaxed where necessary.

Comment on why unlocked nonatomic access is valid where it is done.


# 1.140 02-Oct-2021 thorpej

- fifo_poll(): If the last writer has disappeared, detect this and return
POLLHUP, per POSIX.
- fifo_close(): Use the new fifo_socantrcvmore(), which is like the
garden-variety socantrcvmore(), except it specifies POLL_HUP rather
than POLL_IN (so the correct code for SIGIO is sent).
- sowakeup(): Allow POLL_HUP as a code (notifies poll'ers with POLLHUP).
- Add test cases for correct POLLHUP behavior with FIFOs.

Fixes PR kern/56429.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.139 04-Mar-2021 msaitoh

Add missing opt_inet.h.


# 1.138 26-Aug-2020 christos

branches: 1.138.2;
add socket info for user and group for unix sockets in fstat.


# 1.137 23-May-2020 ad

Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.136 01-Feb-2020 riastradh

Load struct fdfile::ff_file with atomic_load_consume.

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.)


# 1.135 01-Feb-2020 riastradh

Load struct filedesc::fd_dt with atomic_load_consume.

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.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.134 11-Jul-2019 maxv

branches: 1.134.2; 1.134.4;
Fix info leaks: the alignment of the structures causes uninitialized heap
memory to be copied to userland in sys_recvmsg().


Revision tags: phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.133 04-Nov-2018 christos

- Introduce a new SO_RERROR socket option to explicitly turn on
receive overflow errors re-instating the default behavior to
silently ignore them as before 2018-03-19.
- Introduce a new kern.sooptions sysctl to control the default
behavior of socket options. Setting this to 0x4000 (SO_RERROR),
turns on receive overflow error reporting for all sockets.
- Change dhcpcd to turn on SO_RERROR on all its sockets.

As discussed in tech-net.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.132 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: pgoyette-compat-0728
# 1.131 20-Jul-2018 msaitoh

Add "show socket" command written by Hiroki SUENAGA. It prints usage of
system's socket buffers.


Revision tags: phil-wifi-base pgoyette-compat-0625
# 1.130 06-Jun-2018 roy

branches: 1.130.2;
Separate receive socket errors from general socket errors.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502
# 1.129 29-Apr-2018 maxv

Remove references to m_copy in comments.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.128 19-Mar-2018 roy

socket: report receive buffer overflows

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.


# 1.127 18-Mar-2018 christos

- Convert sb_lowat to unsigned for consistency. There are no negative value
uses
- Check for overflow as mentioned in the comment
- Sprinkle const


Revision tags: pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.126 06-Jul-2017 christos

branches: 1.126.4;
move the timestamp stuff to uipc_socket.c because it already has the compat
includes.


# 1.125 06-Jul-2017 christos

Merge the two copies SO_TIMESTAMP/SO_OTIMESTAMP processing to a single
function, and add a SOOPT_TIMESTAMP define reducing compat pollution from
5 places to 1.


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.124 02-Oct-2016 christos

branches: 1.124.8;
more MFREE -> m_free


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.123 23-May-2016 tls

branches: 1.123.2;
Fix a longstanding problem with accept filters noticed by Timo Buhrmester:
sockets sitting in the accept filter can consume the entire listen queue,
such that the application is never able to handle any connections. Handle
this by simply passing through the oldest queued cxn when the queue is full.

This is fair because the longer a cxn lingers in the queue (stays connected
but does not meet the requirements of the filter for passage) the more likely
it is to be passed through, at which point the application can dispose of it.

Works because none of our accept filters actually allocate private state
per-cxn. If they did, we'd have to fix the API bug that there is presently
no way to tell an accf to finish/deallocate for a single cxn (accf_destroy
kills off the entire filter instance for a given listen socket).


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.122 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.121 05-Sep-2014 matt

branches: 1.121.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.120 31-Jul-2014 rtr

split PRU_DISCONNECT, PRU_SHUTDOWN and PRU_ABORT function out of
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


# 1.119 19-May-2014 rmind

- Split off PRU_ATTACH and PRU_DETACH logic into separate functions.
- Replace malloc with kmem and eliminate M_PCB while here.
- Sprinkle more asserts.


Revision tags: rmind-smpnet-nbase rmind-smpnet-base
# 1.118 18-May-2014 rmind

Add struct pr_usrreqs with a pr_generic function and prepare for the
dismantling of pr_usrreq in the protocols; no functional change intended.
PRU_ATTACH/PRU_DETACH changes will follow soon.

Bump for struct protosw. Welcome to 6.99.62!


# 1.117 17-May-2014 rmind

sonewconn: insert the socket into the queue *after* the protocol attach.
This potentially avoids unnecessary race conditions when handling partial
connections.


# 1.116 17-May-2014 rmind

- sonewconn: improve the initialisation order and add some asserts.
- Add various comments describing primitive routines operating on sockets,
clarify connection life-cycle and improve the description of socket queues.
- Sprinkle more asserts.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.115 08-Oct-2013 christos

branches: 1.115.2;
0 -> NULL
MGET -> m_get
No functional change.


# 1.114 15-Sep-2013 martin

Avoid unused variable warnings


# 1.113 29-Aug-2013 rmind

Remove SS_ISCONFIRMING, it is unused and TP4 will not come back.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.112 28-Jun-2013 matt

branches: 1.112.2;
Make sbdrop panic more verbose


# 1.111 27-Jun-2013 christos

Introduce a more general method of sbcreatecontrol, sbcreatecontrol1 that
can take flags (M_WAITOK), and allocate large messages if needed. It also
returns the allocated pointer instead of copying the data to the passed
pointer. Implement sbcreatecontrol() using that.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.110 20-Dec-2011 christos

branches: 1.110.6;
- Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.
- Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis
- Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets.
- Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all
errors?).


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.109 31-Aug-2011 plunky

branches: 1.109.2; 1.109.6;
NULL does not need a cast


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.108 24-Apr-2011 rmind

- Replace few malloc(9) uses with kmem(9).
- Rename buf_malloc() to buf_alloc(), fix comments.
- Remove some unnecessary inclusions.


# 1.107 09-Apr-2011 christos

Preserve SB_ASYNC on the accepted socket. From: Dmitry Matveev
http://mail-index.netbsd.org/tech-net/2011/02/17/msg002457.html


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.106 30-Dec-2009 elad

branches: 1.106.4; 1.106.6;
Don't bother caching egid. It'll be removed soon.


# 1.105 30-Dec-2009 elad

Always use resource limits from the process, as proposed in

http://mail-index.netbsd.org/tech-kern/2009/12/30/msg006756.html

okay christos@.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.104 02-Sep-2009 tls

Add a direction argument to socket upcalls, so they can tell why they've
been called when, for example, they're waiting for space to write. From
Ritesh Agrawal at Coyote Point.


Revision tags: yamt-nfs-mp-base7
# 1.103 24-Jul-2009 christos

check return code from soreserve() (Sean Boudreau)


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 09-Apr-2009 yamt

sonewconn: add an assertion.


Revision tags: nick-hppapmap-base2
# 1.101 21-Jan-2009 yamt

branches: 1.101.2;
restore the pre socket locking patch signal behaviour.
this fixes a busy-loop in nfs_connect.


Revision tags: netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base mjf-devfs2-base
# 1.100 24-Oct-2008 dyoung

branches: 1.100.2; 1.100.4;
Change 'return (expr);' to 'return expr;'. Change (type *)0 to
NULL. No functional change intended.


Revision tags: haad-dm-base1
# 1.99 14-Oct-2008 ad

Accept filters:

- Remove remaining #ifdef INET.
- Avoid holding locks so we don't need to do KM_NOSLEEP allocations.
- Use a rwlock to protect the accept filter list.
- Make it safe to unload accept filter modules.
- Minor KNF.


# 1.98 11-Oct-2008 pooka

Move uidinfo to its own module in kern_uidinfo.c and include in rump.
No functional change to uidinfo.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.97 04-Aug-2008 tls

Add accept filters, ported from FreeBSD by Coyote Point Systems. Add inetd
support for specifying an accept filter for a service (mostly as a usage
example, but it can be handy for other things). Manual pages to follow
in a day or so.

OK core@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 1.96 18-Jun-2008 yamt

branches: 1.96.2;
merge yamt-pf42 branch.
(import newer pf from OpenBSD 4.2)

ok'ed by peter@. requested by core@


Revision tags: yamt-pf42-base4
# 1.95 10-Jun-2008 ad

There can be existing waiters on a socket's condition variables when we
change socket::so_lock, and they rely on the old lock to synchronize.
Wake them up whenever we change so_lock so they can restart their waits.


Revision tags: yamt-pf42-base3
# 1.94 26-May-2008 ad

branches: 1.94.2;
Use pool_cache for sockets.


# 1.93 24-May-2008 christos

Coverity CID 5025: sbreserve is never called with a null socket.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.92 28-Apr-2008 martin

branches: 1.92.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.91 24-Apr-2008 ad

branches: 1.91.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.90 01-Mar-2008 rmind

branches: 1.90.2;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.89 07-Feb-2008 ad

branches: 1.89.2; 1.89.6;
sonewconn: inherit FNONBLOCK from the parent.


# 1.88 29-Jan-2008 yamt

sbreserve: curlwp can't be NULL these days.
XXX these code seems to need an overhaul.


# 1.87 29-Jan-2008 yamt

sbrelease: unwrap a short line.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.86 25-Sep-2007 ad

branches: 1.86.4;
Use selinit() / seldestroy().


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base matt-mips64-base
# 1.85 02-Aug-2007 rmind

branches: 1.85.2; 1.85.4; 1.85.6; 1.85.8;
TCP socket buffers automatic sizing - ported from FreeBSD.
http://mail-index.netbsd.org/tech-net/2007/02/04/0006.html

! Disabled by default, marked as experimental. Testers are very needed.
! Someone should thoroughly test this, and improve if possible.

Discussed on <tech-net>:
http://mail-index.netbsd.org/tech-net/2007/07/12/0002.html
Thanks Greg Troxel for comments.

OK by the long silence on <tech-net>.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.84 04-Jul-2007 tls

branches: 1.84.2;
After looking at FreeBSD 6 again -- we were also failing to copy the
send and receive timeouts. Fix this.


# 1.83 04-Jul-2007 tls

Copy SNDLOWAT and RCVLOWAT socket options to accepted socket, so applications
can rely on all socket options being propagated from the listen socket as
the manual page says (and as everything but Linux has always done). FreeBSD 6
fixes this the same way, but this bug appears elsewhere and is...Old.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.82 04-Mar-2007 christos

branches: 1.82.2; 1.82.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.81 01-Nov-2006 yamt

branches: 1.81.4;
remove some __unused from function parameters.


Revision tags: yamt-splraiseipl-base2
# 1.80 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.79 03-Oct-2006 elad

Back out socket credentials for now, until we figure a better way of
handling the reference counting from interrupt context.


# 1.78 02-Oct-2006 elad

Add credentials to sockets, 'so_cred'.

Brought up on tech-kern@ some ~2 months ago, didn't seem to be an
objection; brought up again recently and no objection either... this is
not too intrusive and I've been running with this for a while.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.77 16-Aug-2006 plunky

branches: 1.77.4;
Fix broken comments - there is no SO_ISCONNECTED or SO_ISCONFIRMING

this fixes kern/32058


# 1.76 16-Aug-2006 plunky

Remove macro call sonewconn() => sonewconn1() as it is no longer necessary.
There are no such calls and the compiler would catch mistakes like this
in any case.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.75 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.74 03-Jul-2006 christos

Make sure we have at least PIPE_BUF bytes available in the socket send buffer.
Review and comment by yamt.


# 1.73 01-Jul-2006 christos

Revert previous change to bump the socket low watermark to sock_loan_thresh.
With sock_loan_thresh=4096, sb_lowat==sb_hiwat, and sowritable will never
be true (even if only a single byte is pending). Some programs (like screen)
expect select() to return that a socket is writable on a socket when there
is space to write to it. XXX: What is the right thing to do here?


Revision tags: yamt-pdpolicy-base6
# 1.72 21-Jun-2006 yamt

bump default so_snd.sb_lowat to increase chance to use loaning.

the idea to tweak the watermark from Jonathan Stone.
reviewed by Bill Studenmund.


Revision tags: chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.71 14-May-2006 elad

branches: 1.71.4;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.70 24-Dec-2005 perry

branches: 1.70.4; 1.70.6; 1.70.8; 1.70.10; 1.70.12;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.69 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.68 29-May-2005 christos

branches: 1.68.2;
- add const.
- remove unnecessary casts.
- add __UNCONST casts and mark them with XXXUNCONST as necessary.


# 1.67 07-May-2005 christos

PR/30154: YAMAMOTO Takashi: tcp_close locking botch
chgsbsize() as mentioned in the PR can be called from an interrupt context
via tcp_close(). Avoid calling uid_find() in chgsbsize().
- Instead of storing so_uid in struct socketvar, store *so_uidinfo
- Add a simple lock to struct uidinfo.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.66 26-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.65 24-Jun-2004 jonathan

branches: 1.65.4; 1.65.6;
Rename MBUFTRACE helper function m_claim() to m_claimm(),
for consistency with M_FREE() and m_freem(). Affected files:

sys/mbuf.h
kern/uipc_socket2.c
kern/uipc_mbuf.c
net/if_ethersubr.c
netatalk/ddp_input.c
nfs/nfs_socket.c


# 1.64 11-Jun-2004 jonathan

Fix potential memory leak in sbappendaddrchain():

We do an MGETHDR)() for each mbuf "packet" of the input chain, to hold
the socket address prepended to that "packet". If those MGETHDR()s
ever failed, we would leak all the successfully-allocated mbuf
headers. Leak noted by Yamamoto-san (yamt@NetBSD.org); thanks for catching it!

Add socketbuf invariant-checking macros to sbappendaddrchain(), and
replace a stray bcopy() with memcpy(), also as suggested by Yamamoto-san.


# 1.63 27-May-2004 jonathan

Rework to make FAST_IPSEC PF_KEY dumps unicast and reliable:

Introduce new socket-layer function sbappendaddrchain() to
sys/kern/uipc_socket2.c: like sbappendaddr(), only takes a chain of
records and appends the entire chain in one pass. sbappendaddrchain()
also takes an `sbprio' argument, which indicates the caller requires
special `reliable' handling of the socket-buffer. `sbprio' is
described in sys/sys/socketvar.h, although (for now) the different
levels are not yet implemented.

Rework sys/netipsec/key.c PF_KEY DUMP responses to build a chain of
mbuf records, one record per dump response. Unicast the entire chain
to the requestor, with all-or-none semantics.

Changed files;
sys/socketvar.h kern/uipc_socket2.c netipsec/key.c
Reviewed by:
Jason Thorpe, Thor Lancelot Simon, post to tech-kern.

Todo: request pullup to 2.0 branch. Post-2.0, rework sysctl() API for
dumps to use new record-chain constructors. Actually implement
the distinct service levels in sbappendaddrchain() so we can use them
to make PF_KEY ACQUIRE messages more reliable.


# 1.62 19-Apr-2004 christos

Charge root for socket buffers without a socket pointer.


# 1.61 18-Apr-2004 matt

Constify the addr parameter to sbappenaddr.


# 1.60 18-Apr-2004 matt

sbreserve can be called with a NULL socket, deal with it.


# 1.59 17-Apr-2004 christos

PR/9347: Eric E. Fair: socket buffer pool exhaustion leads to system deadlock
and unkillable processes.
1. Introduce new SBSIZE resource limit from FreeBSD to limit socket buffer
size resource.
2. make sokvareserve interruptible, so processes ltsleeping on it can be
killed.


Revision tags: netbsd-2-0-base
# 1.58 21-Oct-2003 thorpej

branches: 1.58.2;
Cache the "adjusted" value of sb_max when sb_max is changed, in order
to avoid doing quad math in sbreserve().

Change suggested by Simon Burge, and code inspired by a similar change
in FreeBSD.


# 1.57 22-Sep-2003 christos

- pass signo to fownsignal [ok by jd]
- make urg signal handling use fownsignal
- remove out of band detection in sowakeup


# 1.56 21-Sep-2003 jdolecek

cleanup & uniform descriptor owner handling:
* introduce fsetown(), fgetown(), fownsignal() - this sets/retrieves/signals
the owner of descriptor, according to appropriate sematics
of TIOCSPGRP/FIOSETOWN/SIOCSPGRP/TIOCGPGRP/FIOGETOWN/SIOCGPGRP ioctl; use
these routines instead of custom code where appropriate
* make every place handling TIOCSPGRP/TIOCGPGRP handle also FIOSETOWN/FIOGETOWN
properly, and remove the translation of FIO[SG]OWN to TIOC[SG]PGRP
in sys_ioctl() & sys_fcntl()
* also remove the socket-specific hack in sys_ioctl()/sys_fcntl() and
pass the ioctls down to soo_ioctl() as any other ioctl

change discussed on tech-kern@


# 1.55 06-Sep-2003 christos

SA_SIGINFO changes.


# 1.54 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.53 29-Jun-2003 fvdl

branches: 1.53.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.52 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.51 23-Jun-2003 martin

Make sure to include opt_foo.h if a defflag option FOO is used.


# 1.50 17-Apr-2003 fvdl

A bit of an ugly workaround to avoid a warning for a larger MSIZE.
Shouldn't make a difference in the generated code.


# 1.49 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge
# 1.48 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.47 27-Sep-2002 provos

remove trailing \n in panic(). approved perry.


Revision tags: gehenna-devsw-base
# 1.46 22-Aug-2002 thorpej

In sbcompress(), if we toss an empty mbuf, make sure to update
sb_lastrecord if necessary.

From Daniel Hartmeier <daniel@benzedrine.cx>.


# 1.45 03-Jul-2002 thorpej

Rename SB_UPDATE_TAIL() to SB_EMPTY_FIXUP(), per suggestion from
Jonathan Stone.


# 1.44 03-Jul-2002 thorpej

Rename sbappend_stream() to sbappendstream(), per suggestion from
Jonathan Stone.


# 1.43 03-Jul-2002 thorpej

Make insertion of data into socket buffers O(C):
* Keep pointers to the first and last mbufs of the last record in the
socket buffer.
* Use the sb_lastrecord pointer in the sbappend*() family of functions
to avoid traversing the packet chain to find the last record.
* Add a new sbappend_stream() function for stream protocols which
guarantee that there will never be more than one record in the
socket buffer. This function uses the sb_mbtail pointer to perform
the data insertion. Make TCP use sbappend_stream().

On a profiling run, this makes sbappend of a TCP transmission using
a 1M socket buffer go from 50% of the time to .02% of the time.

Thanks to Bill Sommerfeld and YAMAMOTO Takashi for their debugging
assistance!


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base thorpej-mips-cache-base
# 1.42 12-Nov-2001 lukem

branches: 1.42.8;
add RCSIDs


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 05-Aug-2001 enami

branches: 1.41.4;
Give different names for different wait channels.

# and minor knf fix while I'm here.


# 1.40 27-Jul-2001 thorpej

Now that M_TRAILINGSPACE() checks buffer writeability properly,
we can greatly simplify sbcompress(). Slightly modified from
a similar change in FreeBSD.


# 1.39 16-Jun-2001 manu

branches: 1.39.2;
Use SB_ASYNC in struct sockbuf sb_flags field instead of SS_ASYNC in
struct socket so_state field to decide if we need to send asynchronous
notifications. This makes possible to request notification on write but
not on read, and vice versa.

This is used in Linux emulation code, because when async I/O is requested,
Linux does not send SIGIO to write end of sockets, and it never send any
SIGIO to any end of pipes. Il Linux emulation code, we then set SB_ASYNC
only on the read end of sockets, and on no end for pipes.


# 1.38 30-Apr-2001 kml

Large values of sb_max would cause an overflow in sbreserve(); cast to
u_quad_t to avoid this. (from FreeBSD uipc_socket2.c v1.19)


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.37 27-Feb-2001 lukem

branches: 1.37.2;
convert to ANSI KNF


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 30-Mar-2000 augustss

Get rid of register declarations.


# 1.35 29-Feb-2000 itojun

more fix to ancillary data alignment. we need padding after
last cmsg_data item (see the figure on RFC2292 page 18).


# 1.34 18-Feb-2000 itojun

fix alignment problem in ancillary messages (alpha).

the change constitutes binary compatibility issue hen sizeof(long) !=4.
there's no way to be backward compatible, and only guys affected
are IPv6 userland tools.

From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base
# 1.33 04-Aug-1999 mycroft

branches: 1.33.2;
The old compaction test had an off-by-one error that caused it to not compact
in some cases where it could have. Fix this, and the new version as well.


# 1.32 04-Aug-1999 matt

Don't compress mbuf clusters which are referenced by multiple
mbufs since you might overwriting valuable data. (think of
m_copy'ed data from a TCP re-transmission queue. Since those
might be in clusters and referenced in two sockets).


# 1.31 04-Aug-1999 mycroft

It's now possible for sbcompress() to compact mbuf clusters, so do it.
This helps prevent mbuf cluster exhaustion when receiving lots of small
packets.


Revision tags: chs-ubc2-base
# 1.30 01-Jul-1999 itojun

IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.


# 1.29 22-Apr-1999 simonb

Move inclusion of "opt_sb_max.h" from sys/socketvar.h to
conf/param.c, and move the initialisation of the sb_max
variable from kern/uipc_socket2.c to conf/param.c. Now
everthing that includes sys/socketvar.h doesn't get
recompiled when SB_MAX's value changes.


Revision tags: netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.28 23-Mar-1999 lukem

branches: 1.28.2; 1.28.4; 1.28.6;
Ensure that you can only bind a more specific address when it is done by the
same uid or by root.

This code is from FreeBSD. (Whilst it was originally obtained from OpenBSD,
FreeBSD fixed it to work with multicast. To quote the commit message:
- Don't bother checking for conflicting sockets if we're binding to a
multicast address.
- Don't return an error if we're binding to INADDR_ANY, the conflicting
socket is bound to INADDR_ANY, and the conflicting socket has
SO_REUSEPORT set.
)


# 1.27 20-Jan-1999 mycroft

Do not remove sockets from the accept(2) queue on close.


Revision tags: kenh-if-detach-base chs-ubc-base
# 1.26 04-Aug-1998 perry

Abolition of bcopy, ovbcopy, bcmp, and bzero, phase one.
bcopy(x, y, z) -> memcpy(y, x, z)
ovbcopy(x, y, z) -> memmove(y, x, z)
bcmp(x, y, z) -> memcmp(x, y, z)
bzero(x, y) -> memset(x, 0, y)


# 1.25 02-Aug-1998 thorpej

Use the pool allocator for sockets.


Revision tags: eeh-paddr_t-base
# 1.24 25-Apr-1998 matt

Hook for 0-copy (or other optimized) sends and receives


# 1.23 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.22 07-Jan-1998 thorpej

Make insertion and removal of sockets from the partial and incoming
connections queues O(C) rather than O(N).


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base marc-pcmcia-base
# 1.21 09-Oct-1997 mycroft

branches: 1.21.2;
Make various standard wmesg strings const.


Revision tags: thorpej-signal-base marc-pcmcia-bp SYN_cache_cur_base
# 1.20 26-Jun-1997 thorpej

branches: 1.20.4;
In sbappendaddr(), if the sockaddr length is larger than will fit in
an mbuf, allocate enough external storage to hold the sockaddr. Thanks
to enami tsugutomo <enami@cv.sony.co.jp> for providing sanity-checks.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.19 11-Jan-1997 thorpej

branches: 1.19.8;
Implement sbcreatecontrol(), a generic function to create a "control"
mbuf for presentation on a socket buffer.


# 1.18 09-Dec-1996 thorpej

In sbreserve(), don't allow a count of 0. Fixes PR #2794, from
Erik Berls <cyber@dis.org>.


# 1.17 26-Nov-1996 thorpej

Back out previous soqinsque() and soqremque() changes. This will
stop the panics until the socket queues get converted to <sys/queue.h>.


# 1.16 10-Nov-1996 thorpej

Optimization of soqinsque() and soqremque():

Keep queue of pending sockets in a double linked list. Previously,
a singly linked list was used, giving O(N) insertion/deletion times,
and was a major time consumer for sockets with large pending queues.
The double linked list give O(C) insertion/deletion times with only
a small cost in complexity.

Since a socket can be on, at most, one queue at a time, both so_q and
so_q0 can safely be used as (forward and backward, respectively) queue
pointers.

Submitted my Matt Thomas <matt@3am-software.com>, a long time ago.
(Geez, I've been running with this patch for _months_, and had completely
forgotten about it!)


# 1.15 13-Oct-1996 christos

backout previous kprintf change


# 1.14 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.13 07-Sep-1996 mycroft

Implement poll(2).


# 1.12 22-May-1996 mycroft

Pass a proc pointer down to the usrreq and pcbbind functions for PRU_ATTACH, PRU_BIND and
PRU_CONTROL. The usrreq interface really needs to be split up, but this will have to wait.
Remove SS_PRIV completely.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.11 04-Feb-1996 christos

branches: 1.11.4;
First pass at prototyping


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.10 16-Aug-1995 mycroft

Access rights are now stored in MT_CONTROL mbufs. Document this.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.9 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.8 13-May-1994 mycroft

Update to 4.4-Lite networking code, with a few local changes.


# 1.7 04-May-1994 mycroft

More return types...


# 1.6 25-Apr-1994 mycroft

Remove sbselqueue().


# 1.5 18-Dec-1993 mycroft

Canonicalize all #includes.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 27-Jun-1993 andrew

branches: 1.4.4;
ANSIfications - removed all implicit function return types and argument
definitions. Ensured that all files include "systm.h" to gain access to
general prototypes. Casts where necessary.


# 1.3 18-May-1993 cgd

make kernel select interface be one-stop shopping & clean it all up.


Revision tags: netbsd-0-8 netbsd-alpha-1 patchkit-0-2-2
# 1.2 21-Mar-1993 cgd

after 0.2.2 "stable" patches applied


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.142 26-Oct-2022 riastradh

ddb/db_active.h: New home for extern db_active.

This can be included unconditionally, and db_active can then be
queried unconditionally; if DDB is not in the kernel, then db_active
is a constant zero. Reduces need for #include opt_ddb.h, #ifdef DDB.


Revision tags: bouyer-sunxi-drm-base
# 1.141 09-Apr-2022 riastradh

unix(4): Convert membar_exit to membar_release.

Use atomic_load_consume or atomic_load_relaxed where necessary.

Comment on why unlocked nonatomic access is valid where it is done.


# 1.140 02-Oct-2021 thorpej

- fifo_poll(): If the last writer has disappeared, detect this and return
POLLHUP, per POSIX.
- fifo_close(): Use the new fifo_socantrcvmore(), which is like the
garden-variety socantrcvmore(), except it specifies POLL_HUP rather
than POLL_IN (so the correct code for SIGIO is sent).
- sowakeup(): Allow POLL_HUP as a code (notifies poll'ers with POLLHUP).
- Add test cases for correct POLLHUP behavior with FIFOs.

Fixes PR kern/56429.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.139 04-Mar-2021 msaitoh

Add missing opt_inet.h.


# 1.138 26-Aug-2020 christos

branches: 1.138.2;
add socket info for user and group for unix sockets in fstat.


# 1.137 23-May-2020 ad

Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.136 01-Feb-2020 riastradh

Load struct fdfile::ff_file with atomic_load_consume.

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.)


# 1.135 01-Feb-2020 riastradh

Load struct filedesc::fd_dt with atomic_load_consume.

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.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.134 11-Jul-2019 maxv

branches: 1.134.2; 1.134.4;
Fix info leaks: the alignment of the structures causes uninitialized heap
memory to be copied to userland in sys_recvmsg().


Revision tags: phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.133 04-Nov-2018 christos

- Introduce a new SO_RERROR socket option to explicitly turn on
receive overflow errors re-instating the default behavior to
silently ignore them as before 2018-03-19.
- Introduce a new kern.sooptions sysctl to control the default
behavior of socket options. Setting this to 0x4000 (SO_RERROR),
turns on receive overflow error reporting for all sockets.
- Change dhcpcd to turn on SO_RERROR on all its sockets.

As discussed in tech-net.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.132 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: pgoyette-compat-0728
# 1.131 20-Jul-2018 msaitoh

Add "show socket" command written by Hiroki SUENAGA. It prints usage of
system's socket buffers.


Revision tags: phil-wifi-base pgoyette-compat-0625
# 1.130 06-Jun-2018 roy

branches: 1.130.2;
Separate receive socket errors from general socket errors.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502
# 1.129 29-Apr-2018 maxv

Remove references to m_copy in comments.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.128 19-Mar-2018 roy

socket: report receive buffer overflows

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.


# 1.127 18-Mar-2018 christos

- Convert sb_lowat to unsigned for consistency. There are no negative value
uses
- Check for overflow as mentioned in the comment
- Sprinkle const


Revision tags: pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.126 06-Jul-2017 christos

branches: 1.126.4;
move the timestamp stuff to uipc_socket.c because it already has the compat
includes.


# 1.125 06-Jul-2017 christos

Merge the two copies SO_TIMESTAMP/SO_OTIMESTAMP processing to a single
function, and add a SOOPT_TIMESTAMP define reducing compat pollution from
5 places to 1.


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.124 02-Oct-2016 christos

branches: 1.124.8;
more MFREE -> m_free


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.123 23-May-2016 tls

branches: 1.123.2;
Fix a longstanding problem with accept filters noticed by Timo Buhrmester:
sockets sitting in the accept filter can consume the entire listen queue,
such that the application is never able to handle any connections. Handle
this by simply passing through the oldest queued cxn when the queue is full.

This is fair because the longer a cxn lingers in the queue (stays connected
but does not meet the requirements of the filter for passage) the more likely
it is to be passed through, at which point the application can dispose of it.

Works because none of our accept filters actually allocate private state
per-cxn. If they did, we'd have to fix the API bug that there is presently
no way to tell an accf to finish/deallocate for a single cxn (accf_destroy
kills off the entire filter instance for a given listen socket).


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.122 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.121 05-Sep-2014 matt

branches: 1.121.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.120 31-Jul-2014 rtr

split PRU_DISCONNECT, PRU_SHUTDOWN and PRU_ABORT function out of
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


# 1.119 19-May-2014 rmind

- Split off PRU_ATTACH and PRU_DETACH logic into separate functions.
- Replace malloc with kmem and eliminate M_PCB while here.
- Sprinkle more asserts.


Revision tags: rmind-smpnet-nbase rmind-smpnet-base
# 1.118 18-May-2014 rmind

Add struct pr_usrreqs with a pr_generic function and prepare for the
dismantling of pr_usrreq in the protocols; no functional change intended.
PRU_ATTACH/PRU_DETACH changes will follow soon.

Bump for struct protosw. Welcome to 6.99.62!


# 1.117 17-May-2014 rmind

sonewconn: insert the socket into the queue *after* the protocol attach.
This potentially avoids unnecessary race conditions when handling partial
connections.


# 1.116 17-May-2014 rmind

- sonewconn: improve the initialisation order and add some asserts.
- Add various comments describing primitive routines operating on sockets,
clarify connection life-cycle and improve the description of socket queues.
- Sprinkle more asserts.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.115 08-Oct-2013 christos

branches: 1.115.2;
0 -> NULL
MGET -> m_get
No functional change.


# 1.114 15-Sep-2013 martin

Avoid unused variable warnings


# 1.113 29-Aug-2013 rmind

Remove SS_ISCONFIRMING, it is unused and TP4 will not come back.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.112 28-Jun-2013 matt

branches: 1.112.2;
Make sbdrop panic more verbose


# 1.111 27-Jun-2013 christos

Introduce a more general method of sbcreatecontrol, sbcreatecontrol1 that
can take flags (M_WAITOK), and allocate large messages if needed. It also
returns the allocated pointer instead of copying the data to the passed
pointer. Implement sbcreatecontrol() using that.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.110 20-Dec-2011 christos

branches: 1.110.6;
- Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.
- Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis
- Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets.
- Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all
errors?).


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.109 31-Aug-2011 plunky

branches: 1.109.2; 1.109.6;
NULL does not need a cast


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.108 24-Apr-2011 rmind

- Replace few malloc(9) uses with kmem(9).
- Rename buf_malloc() to buf_alloc(), fix comments.
- Remove some unnecessary inclusions.


# 1.107 09-Apr-2011 christos

Preserve SB_ASYNC on the accepted socket. From: Dmitry Matveev
http://mail-index.netbsd.org/tech-net/2011/02/17/msg002457.html


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.106 30-Dec-2009 elad

branches: 1.106.4; 1.106.6;
Don't bother caching egid. It'll be removed soon.


# 1.105 30-Dec-2009 elad

Always use resource limits from the process, as proposed in

http://mail-index.netbsd.org/tech-kern/2009/12/30/msg006756.html

okay christos@.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.104 02-Sep-2009 tls

Add a direction argument to socket upcalls, so they can tell why they've
been called when, for example, they're waiting for space to write. From
Ritesh Agrawal at Coyote Point.


Revision tags: yamt-nfs-mp-base7
# 1.103 24-Jul-2009 christos

check return code from soreserve() (Sean Boudreau)


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 09-Apr-2009 yamt

sonewconn: add an assertion.


Revision tags: nick-hppapmap-base2
# 1.101 21-Jan-2009 yamt

branches: 1.101.2;
restore the pre socket locking patch signal behaviour.
this fixes a busy-loop in nfs_connect.


Revision tags: netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base mjf-devfs2-base
# 1.100 24-Oct-2008 dyoung

branches: 1.100.2; 1.100.4;
Change 'return (expr);' to 'return expr;'. Change (type *)0 to
NULL. No functional change intended.


Revision tags: haad-dm-base1
# 1.99 14-Oct-2008 ad

Accept filters:

- Remove remaining #ifdef INET.
- Avoid holding locks so we don't need to do KM_NOSLEEP allocations.
- Use a rwlock to protect the accept filter list.
- Make it safe to unload accept filter modules.
- Minor KNF.


# 1.98 11-Oct-2008 pooka

Move uidinfo to its own module in kern_uidinfo.c and include in rump.
No functional change to uidinfo.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.97 04-Aug-2008 tls

Add accept filters, ported from FreeBSD by Coyote Point Systems. Add inetd
support for specifying an accept filter for a service (mostly as a usage
example, but it can be handy for other things). Manual pages to follow
in a day or so.

OK core@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 1.96 18-Jun-2008 yamt

branches: 1.96.2;
merge yamt-pf42 branch.
(import newer pf from OpenBSD 4.2)

ok'ed by peter@. requested by core@


Revision tags: yamt-pf42-base4
# 1.95 10-Jun-2008 ad

There can be existing waiters on a socket's condition variables when we
change socket::so_lock, and they rely on the old lock to synchronize.
Wake them up whenever we change so_lock so they can restart their waits.


Revision tags: yamt-pf42-base3
# 1.94 26-May-2008 ad

branches: 1.94.2;
Use pool_cache for sockets.


# 1.93 24-May-2008 christos

Coverity CID 5025: sbreserve is never called with a null socket.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.92 28-Apr-2008 martin

branches: 1.92.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.91 24-Apr-2008 ad

branches: 1.91.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.90 01-Mar-2008 rmind

branches: 1.90.2;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.89 07-Feb-2008 ad

branches: 1.89.2; 1.89.6;
sonewconn: inherit FNONBLOCK from the parent.


# 1.88 29-Jan-2008 yamt

sbreserve: curlwp can't be NULL these days.
XXX these code seems to need an overhaul.


# 1.87 29-Jan-2008 yamt

sbrelease: unwrap a short line.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.86 25-Sep-2007 ad

branches: 1.86.4;
Use selinit() / seldestroy().


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base matt-mips64-base
# 1.85 02-Aug-2007 rmind

branches: 1.85.2; 1.85.4; 1.85.6; 1.85.8;
TCP socket buffers automatic sizing - ported from FreeBSD.
http://mail-index.netbsd.org/tech-net/2007/02/04/0006.html

! Disabled by default, marked as experimental. Testers are very needed.
! Someone should thoroughly test this, and improve if possible.

Discussed on <tech-net>:
http://mail-index.netbsd.org/tech-net/2007/07/12/0002.html
Thanks Greg Troxel for comments.

OK by the long silence on <tech-net>.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.84 04-Jul-2007 tls

branches: 1.84.2;
After looking at FreeBSD 6 again -- we were also failing to copy the
send and receive timeouts. Fix this.


# 1.83 04-Jul-2007 tls

Copy SNDLOWAT and RCVLOWAT socket options to accepted socket, so applications
can rely on all socket options being propagated from the listen socket as
the manual page says (and as everything but Linux has always done). FreeBSD 6
fixes this the same way, but this bug appears elsewhere and is...Old.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.82 04-Mar-2007 christos

branches: 1.82.2; 1.82.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.81 01-Nov-2006 yamt

branches: 1.81.4;
remove some __unused from function parameters.


Revision tags: yamt-splraiseipl-base2
# 1.80 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.79 03-Oct-2006 elad

Back out socket credentials for now, until we figure a better way of
handling the reference counting from interrupt context.


# 1.78 02-Oct-2006 elad

Add credentials to sockets, 'so_cred'.

Brought up on tech-kern@ some ~2 months ago, didn't seem to be an
objection; brought up again recently and no objection either... this is
not too intrusive and I've been running with this for a while.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.77 16-Aug-2006 plunky

branches: 1.77.4;
Fix broken comments - there is no SO_ISCONNECTED or SO_ISCONFIRMING

this fixes kern/32058


# 1.76 16-Aug-2006 plunky

Remove macro call sonewconn() => sonewconn1() as it is no longer necessary.
There are no such calls and the compiler would catch mistakes like this
in any case.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.75 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.74 03-Jul-2006 christos

Make sure we have at least PIPE_BUF bytes available in the socket send buffer.
Review and comment by yamt.


# 1.73 01-Jul-2006 christos

Revert previous change to bump the socket low watermark to sock_loan_thresh.
With sock_loan_thresh=4096, sb_lowat==sb_hiwat, and sowritable will never
be true (even if only a single byte is pending). Some programs (like screen)
expect select() to return that a socket is writable on a socket when there
is space to write to it. XXX: What is the right thing to do here?


Revision tags: yamt-pdpolicy-base6
# 1.72 21-Jun-2006 yamt

bump default so_snd.sb_lowat to increase chance to use loaning.

the idea to tweak the watermark from Jonathan Stone.
reviewed by Bill Studenmund.


Revision tags: chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.71 14-May-2006 elad

branches: 1.71.4;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.70 24-Dec-2005 perry

branches: 1.70.4; 1.70.6; 1.70.8; 1.70.10; 1.70.12;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.69 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.68 29-May-2005 christos

branches: 1.68.2;
- add const.
- remove unnecessary casts.
- add __UNCONST casts and mark them with XXXUNCONST as necessary.


# 1.67 07-May-2005 christos

PR/30154: YAMAMOTO Takashi: tcp_close locking botch
chgsbsize() as mentioned in the PR can be called from an interrupt context
via tcp_close(). Avoid calling uid_find() in chgsbsize().
- Instead of storing so_uid in struct socketvar, store *so_uidinfo
- Add a simple lock to struct uidinfo.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.66 26-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.65 24-Jun-2004 jonathan

branches: 1.65.4; 1.65.6;
Rename MBUFTRACE helper function m_claim() to m_claimm(),
for consistency with M_FREE() and m_freem(). Affected files:

sys/mbuf.h
kern/uipc_socket2.c
kern/uipc_mbuf.c
net/if_ethersubr.c
netatalk/ddp_input.c
nfs/nfs_socket.c


# 1.64 11-Jun-2004 jonathan

Fix potential memory leak in sbappendaddrchain():

We do an MGETHDR)() for each mbuf "packet" of the input chain, to hold
the socket address prepended to that "packet". If those MGETHDR()s
ever failed, we would leak all the successfully-allocated mbuf
headers. Leak noted by Yamamoto-san (yamt@NetBSD.org); thanks for catching it!

Add socketbuf invariant-checking macros to sbappendaddrchain(), and
replace a stray bcopy() with memcpy(), also as suggested by Yamamoto-san.


# 1.63 27-May-2004 jonathan

Rework to make FAST_IPSEC PF_KEY dumps unicast and reliable:

Introduce new socket-layer function sbappendaddrchain() to
sys/kern/uipc_socket2.c: like sbappendaddr(), only takes a chain of
records and appends the entire chain in one pass. sbappendaddrchain()
also takes an `sbprio' argument, which indicates the caller requires
special `reliable' handling of the socket-buffer. `sbprio' is
described in sys/sys/socketvar.h, although (for now) the different
levels are not yet implemented.

Rework sys/netipsec/key.c PF_KEY DUMP responses to build a chain of
mbuf records, one record per dump response. Unicast the entire chain
to the requestor, with all-or-none semantics.

Changed files;
sys/socketvar.h kern/uipc_socket2.c netipsec/key.c
Reviewed by:
Jason Thorpe, Thor Lancelot Simon, post to tech-kern.

Todo: request pullup to 2.0 branch. Post-2.0, rework sysctl() API for
dumps to use new record-chain constructors. Actually implement
the distinct service levels in sbappendaddrchain() so we can use them
to make PF_KEY ACQUIRE messages more reliable.


# 1.62 19-Apr-2004 christos

Charge root for socket buffers without a socket pointer.


# 1.61 18-Apr-2004 matt

Constify the addr parameter to sbappenaddr.


# 1.60 18-Apr-2004 matt

sbreserve can be called with a NULL socket, deal with it.


# 1.59 17-Apr-2004 christos

PR/9347: Eric E. Fair: socket buffer pool exhaustion leads to system deadlock
and unkillable processes.
1. Introduce new SBSIZE resource limit from FreeBSD to limit socket buffer
size resource.
2. make sokvareserve interruptible, so processes ltsleeping on it can be
killed.


Revision tags: netbsd-2-0-base
# 1.58 21-Oct-2003 thorpej

branches: 1.58.2;
Cache the "adjusted" value of sb_max when sb_max is changed, in order
to avoid doing quad math in sbreserve().

Change suggested by Simon Burge, and code inspired by a similar change
in FreeBSD.


# 1.57 22-Sep-2003 christos

- pass signo to fownsignal [ok by jd]
- make urg signal handling use fownsignal
- remove out of band detection in sowakeup


# 1.56 21-Sep-2003 jdolecek

cleanup & uniform descriptor owner handling:
* introduce fsetown(), fgetown(), fownsignal() - this sets/retrieves/signals
the owner of descriptor, according to appropriate sematics
of TIOCSPGRP/FIOSETOWN/SIOCSPGRP/TIOCGPGRP/FIOGETOWN/SIOCGPGRP ioctl; use
these routines instead of custom code where appropriate
* make every place handling TIOCSPGRP/TIOCGPGRP handle also FIOSETOWN/FIOGETOWN
properly, and remove the translation of FIO[SG]OWN to TIOC[SG]PGRP
in sys_ioctl() & sys_fcntl()
* also remove the socket-specific hack in sys_ioctl()/sys_fcntl() and
pass the ioctls down to soo_ioctl() as any other ioctl

change discussed on tech-kern@


# 1.55 06-Sep-2003 christos

SA_SIGINFO changes.


# 1.54 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.53 29-Jun-2003 fvdl

branches: 1.53.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.52 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.51 23-Jun-2003 martin

Make sure to include opt_foo.h if a defflag option FOO is used.


# 1.50 17-Apr-2003 fvdl

A bit of an ugly workaround to avoid a warning for a larger MSIZE.
Shouldn't make a difference in the generated code.


# 1.49 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge
# 1.48 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.47 27-Sep-2002 provos

remove trailing \n in panic(). approved perry.


Revision tags: gehenna-devsw-base
# 1.46 22-Aug-2002 thorpej

In sbcompress(), if we toss an empty mbuf, make sure to update
sb_lastrecord if necessary.

From Daniel Hartmeier <daniel@benzedrine.cx>.


# 1.45 03-Jul-2002 thorpej

Rename SB_UPDATE_TAIL() to SB_EMPTY_FIXUP(), per suggestion from
Jonathan Stone.


# 1.44 03-Jul-2002 thorpej

Rename sbappend_stream() to sbappendstream(), per suggestion from
Jonathan Stone.


# 1.43 03-Jul-2002 thorpej

Make insertion of data into socket buffers O(C):
* Keep pointers to the first and last mbufs of the last record in the
socket buffer.
* Use the sb_lastrecord pointer in the sbappend*() family of functions
to avoid traversing the packet chain to find the last record.
* Add a new sbappend_stream() function for stream protocols which
guarantee that there will never be more than one record in the
socket buffer. This function uses the sb_mbtail pointer to perform
the data insertion. Make TCP use sbappend_stream().

On a profiling run, this makes sbappend of a TCP transmission using
a 1M socket buffer go from 50% of the time to .02% of the time.

Thanks to Bill Sommerfeld and YAMAMOTO Takashi for their debugging
assistance!


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base thorpej-mips-cache-base
# 1.42 12-Nov-2001 lukem

branches: 1.42.8;
add RCSIDs


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 05-Aug-2001 enami

branches: 1.41.4;
Give different names for different wait channels.

# and minor knf fix while I'm here.


# 1.40 27-Jul-2001 thorpej

Now that M_TRAILINGSPACE() checks buffer writeability properly,
we can greatly simplify sbcompress(). Slightly modified from
a similar change in FreeBSD.


# 1.39 16-Jun-2001 manu

branches: 1.39.2;
Use SB_ASYNC in struct sockbuf sb_flags field instead of SS_ASYNC in
struct socket so_state field to decide if we need to send asynchronous
notifications. This makes possible to request notification on write but
not on read, and vice versa.

This is used in Linux emulation code, because when async I/O is requested,
Linux does not send SIGIO to write end of sockets, and it never send any
SIGIO to any end of pipes. Il Linux emulation code, we then set SB_ASYNC
only on the read end of sockets, and on no end for pipes.


# 1.38 30-Apr-2001 kml

Large values of sb_max would cause an overflow in sbreserve(); cast to
u_quad_t to avoid this. (from FreeBSD uipc_socket2.c v1.19)


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.37 27-Feb-2001 lukem

branches: 1.37.2;
convert to ANSI KNF


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 30-Mar-2000 augustss

Get rid of register declarations.


# 1.35 29-Feb-2000 itojun

more fix to ancillary data alignment. we need padding after
last cmsg_data item (see the figure on RFC2292 page 18).


# 1.34 18-Feb-2000 itojun

fix alignment problem in ancillary messages (alpha).

the change constitutes binary compatibility issue hen sizeof(long) !=4.
there's no way to be backward compatible, and only guys affected
are IPv6 userland tools.

From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base
# 1.33 04-Aug-1999 mycroft

branches: 1.33.2;
The old compaction test had an off-by-one error that caused it to not compact
in some cases where it could have. Fix this, and the new version as well.


# 1.32 04-Aug-1999 matt

Don't compress mbuf clusters which are referenced by multiple
mbufs since you might overwriting valuable data. (think of
m_copy'ed data from a TCP re-transmission queue. Since those
might be in clusters and referenced in two sockets).


# 1.31 04-Aug-1999 mycroft

It's now possible for sbcompress() to compact mbuf clusters, so do it.
This helps prevent mbuf cluster exhaustion when receiving lots of small
packets.


Revision tags: chs-ubc2-base
# 1.30 01-Jul-1999 itojun

IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.


# 1.29 22-Apr-1999 simonb

Move inclusion of "opt_sb_max.h" from sys/socketvar.h to
conf/param.c, and move the initialisation of the sb_max
variable from kern/uipc_socket2.c to conf/param.c. Now
everthing that includes sys/socketvar.h doesn't get
recompiled when SB_MAX's value changes.


Revision tags: netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.28 23-Mar-1999 lukem

branches: 1.28.2; 1.28.4; 1.28.6;
Ensure that you can only bind a more specific address when it is done by the
same uid or by root.

This code is from FreeBSD. (Whilst it was originally obtained from OpenBSD,
FreeBSD fixed it to work with multicast. To quote the commit message:
- Don't bother checking for conflicting sockets if we're binding to a
multicast address.
- Don't return an error if we're binding to INADDR_ANY, the conflicting
socket is bound to INADDR_ANY, and the conflicting socket has
SO_REUSEPORT set.
)


# 1.27 20-Jan-1999 mycroft

Do not remove sockets from the accept(2) queue on close.


Revision tags: kenh-if-detach-base chs-ubc-base
# 1.26 04-Aug-1998 perry

Abolition of bcopy, ovbcopy, bcmp, and bzero, phase one.
bcopy(x, y, z) -> memcpy(y, x, z)
ovbcopy(x, y, z) -> memmove(y, x, z)
bcmp(x, y, z) -> memcmp(x, y, z)
bzero(x, y) -> memset(x, 0, y)


# 1.25 02-Aug-1998 thorpej

Use the pool allocator for sockets.


Revision tags: eeh-paddr_t-base
# 1.24 25-Apr-1998 matt

Hook for 0-copy (or other optimized) sends and receives


# 1.23 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.22 07-Jan-1998 thorpej

Make insertion and removal of sockets from the partial and incoming
connections queues O(C) rather than O(N).


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base marc-pcmcia-base
# 1.21 09-Oct-1997 mycroft

branches: 1.21.2;
Make various standard wmesg strings const.


Revision tags: thorpej-signal-base marc-pcmcia-bp SYN_cache_cur_base
# 1.20 26-Jun-1997 thorpej

branches: 1.20.4;
In sbappendaddr(), if the sockaddr length is larger than will fit in
an mbuf, allocate enough external storage to hold the sockaddr. Thanks
to enami tsugutomo <enami@cv.sony.co.jp> for providing sanity-checks.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.19 11-Jan-1997 thorpej

branches: 1.19.8;
Implement sbcreatecontrol(), a generic function to create a "control"
mbuf for presentation on a socket buffer.


# 1.18 09-Dec-1996 thorpej

In sbreserve(), don't allow a count of 0. Fixes PR #2794, from
Erik Berls <cyber@dis.org>.


# 1.17 26-Nov-1996 thorpej

Back out previous soqinsque() and soqremque() changes. This will
stop the panics until the socket queues get converted to <sys/queue.h>.


# 1.16 10-Nov-1996 thorpej

Optimization of soqinsque() and soqremque():

Keep queue of pending sockets in a double linked list. Previously,
a singly linked list was used, giving O(N) insertion/deletion times,
and was a major time consumer for sockets with large pending queues.
The double linked list give O(C) insertion/deletion times with only
a small cost in complexity.

Since a socket can be on, at most, one queue at a time, both so_q and
so_q0 can safely be used as (forward and backward, respectively) queue
pointers.

Submitted my Matt Thomas <matt@3am-software.com>, a long time ago.
(Geez, I've been running with this patch for _months_, and had completely
forgotten about it!)


# 1.15 13-Oct-1996 christos

backout previous kprintf change


# 1.14 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.13 07-Sep-1996 mycroft

Implement poll(2).


# 1.12 22-May-1996 mycroft

Pass a proc pointer down to the usrreq and pcbbind functions for PRU_ATTACH, PRU_BIND and
PRU_CONTROL. The usrreq interface really needs to be split up, but this will have to wait.
Remove SS_PRIV completely.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.11 04-Feb-1996 christos

branches: 1.11.4;
First pass at prototyping


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.10 16-Aug-1995 mycroft

Access rights are now stored in MT_CONTROL mbufs. Document this.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.9 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.8 13-May-1994 mycroft

Update to 4.4-Lite networking code, with a few local changes.


# 1.7 04-May-1994 mycroft

More return types...


# 1.6 25-Apr-1994 mycroft

Remove sbselqueue().


# 1.5 18-Dec-1993 mycroft

Canonicalize all #includes.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 27-Jun-1993 andrew

branches: 1.4.4;
ANSIfications - removed all implicit function return types and argument
definitions. Ensured that all files include "systm.h" to gain access to
general prototypes. Casts where necessary.


# 1.3 18-May-1993 cgd

make kernel select interface be one-stop shopping & clean it all up.


Revision tags: netbsd-0-8 netbsd-alpha-1 patchkit-0-2-2
# 1.2 21-Mar-1993 cgd

after 0.2.2 "stable" patches applied


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.141 09-Apr-2022 riastradh

unix(4): Convert membar_exit to membar_release.

Use atomic_load_consume or atomic_load_relaxed where necessary.

Comment on why unlocked nonatomic access is valid where it is done.


# 1.140 02-Oct-2021 thorpej

- fifo_poll(): If the last writer has disappeared, detect this and return
POLLHUP, per POSIX.
- fifo_close(): Use the new fifo_socantrcvmore(), which is like the
garden-variety socantrcvmore(), except it specifies POLL_HUP rather
than POLL_IN (so the correct code for SIGIO is sent).
- sowakeup(): Allow POLL_HUP as a code (notifies poll'ers with POLLHUP).
- Add test cases for correct POLLHUP behavior with FIFOs.

Fixes PR kern/56429.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.139 04-Mar-2021 msaitoh

Add missing opt_inet.h.


# 1.138 26-Aug-2020 christos

branches: 1.138.2;
add socket info for user and group for unix sockets in fstat.


# 1.137 23-May-2020 ad

Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.136 01-Feb-2020 riastradh

Load struct fdfile::ff_file with atomic_load_consume.

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.)


# 1.135 01-Feb-2020 riastradh

Load struct filedesc::fd_dt with atomic_load_consume.

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.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.134 11-Jul-2019 maxv

branches: 1.134.2; 1.134.4;
Fix info leaks: the alignment of the structures causes uninitialized heap
memory to be copied to userland in sys_recvmsg().


Revision tags: phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.133 04-Nov-2018 christos

- Introduce a new SO_RERROR socket option to explicitly turn on
receive overflow errors re-instating the default behavior to
silently ignore them as before 2018-03-19.
- Introduce a new kern.sooptions sysctl to control the default
behavior of socket options. Setting this to 0x4000 (SO_RERROR),
turns on receive overflow error reporting for all sockets.
- Change dhcpcd to turn on SO_RERROR on all its sockets.

As discussed in tech-net.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.132 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: pgoyette-compat-0728
# 1.131 20-Jul-2018 msaitoh

Add "show socket" command written by Hiroki SUENAGA. It prints usage of
system's socket buffers.


Revision tags: phil-wifi-base pgoyette-compat-0625
# 1.130 06-Jun-2018 roy

branches: 1.130.2;
Separate receive socket errors from general socket errors.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502
# 1.129 29-Apr-2018 maxv

Remove references to m_copy in comments.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.128 19-Mar-2018 roy

socket: report receive buffer overflows

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.


# 1.127 18-Mar-2018 christos

- Convert sb_lowat to unsigned for consistency. There are no negative value
uses
- Check for overflow as mentioned in the comment
- Sprinkle const


Revision tags: pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.126 06-Jul-2017 christos

branches: 1.126.4;
move the timestamp stuff to uipc_socket.c because it already has the compat
includes.


# 1.125 06-Jul-2017 christos

Merge the two copies SO_TIMESTAMP/SO_OTIMESTAMP processing to a single
function, and add a SOOPT_TIMESTAMP define reducing compat pollution from
5 places to 1.


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.124 02-Oct-2016 christos

branches: 1.124.8;
more MFREE -> m_free


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.123 23-May-2016 tls

branches: 1.123.2;
Fix a longstanding problem with accept filters noticed by Timo Buhrmester:
sockets sitting in the accept filter can consume the entire listen queue,
such that the application is never able to handle any connections. Handle
this by simply passing through the oldest queued cxn when the queue is full.

This is fair because the longer a cxn lingers in the queue (stays connected
but does not meet the requirements of the filter for passage) the more likely
it is to be passed through, at which point the application can dispose of it.

Works because none of our accept filters actually allocate private state
per-cxn. If they did, we'd have to fix the API bug that there is presently
no way to tell an accf to finish/deallocate for a single cxn (accf_destroy
kills off the entire filter instance for a given listen socket).


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.122 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.121 05-Sep-2014 matt

branches: 1.121.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.120 31-Jul-2014 rtr

split PRU_DISCONNECT, PRU_SHUTDOWN and PRU_ABORT function out of
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


# 1.119 19-May-2014 rmind

- Split off PRU_ATTACH and PRU_DETACH logic into separate functions.
- Replace malloc with kmem and eliminate M_PCB while here.
- Sprinkle more asserts.


Revision tags: rmind-smpnet-nbase rmind-smpnet-base
# 1.118 18-May-2014 rmind

Add struct pr_usrreqs with a pr_generic function and prepare for the
dismantling of pr_usrreq in the protocols; no functional change intended.
PRU_ATTACH/PRU_DETACH changes will follow soon.

Bump for struct protosw. Welcome to 6.99.62!


# 1.117 17-May-2014 rmind

sonewconn: insert the socket into the queue *after* the protocol attach.
This potentially avoids unnecessary race conditions when handling partial
connections.


# 1.116 17-May-2014 rmind

- sonewconn: improve the initialisation order and add some asserts.
- Add various comments describing primitive routines operating on sockets,
clarify connection life-cycle and improve the description of socket queues.
- Sprinkle more asserts.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.115 08-Oct-2013 christos

branches: 1.115.2;
0 -> NULL
MGET -> m_get
No functional change.


# 1.114 15-Sep-2013 martin

Avoid unused variable warnings


# 1.113 29-Aug-2013 rmind

Remove SS_ISCONFIRMING, it is unused and TP4 will not come back.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.112 28-Jun-2013 matt

branches: 1.112.2;
Make sbdrop panic more verbose


# 1.111 27-Jun-2013 christos

Introduce a more general method of sbcreatecontrol, sbcreatecontrol1 that
can take flags (M_WAITOK), and allocate large messages if needed. It also
returns the allocated pointer instead of copying the data to the passed
pointer. Implement sbcreatecontrol() using that.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.110 20-Dec-2011 christos

branches: 1.110.6;
- Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.
- Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis
- Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets.
- Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all
errors?).


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.109 31-Aug-2011 plunky

branches: 1.109.2; 1.109.6;
NULL does not need a cast


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.108 24-Apr-2011 rmind

- Replace few malloc(9) uses with kmem(9).
- Rename buf_malloc() to buf_alloc(), fix comments.
- Remove some unnecessary inclusions.


# 1.107 09-Apr-2011 christos

Preserve SB_ASYNC on the accepted socket. From: Dmitry Matveev
http://mail-index.netbsd.org/tech-net/2011/02/17/msg002457.html


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.106 30-Dec-2009 elad

branches: 1.106.4; 1.106.6;
Don't bother caching egid. It'll be removed soon.


# 1.105 30-Dec-2009 elad

Always use resource limits from the process, as proposed in

http://mail-index.netbsd.org/tech-kern/2009/12/30/msg006756.html

okay christos@.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.104 02-Sep-2009 tls

Add a direction argument to socket upcalls, so they can tell why they've
been called when, for example, they're waiting for space to write. From
Ritesh Agrawal at Coyote Point.


Revision tags: yamt-nfs-mp-base7
# 1.103 24-Jul-2009 christos

check return code from soreserve() (Sean Boudreau)


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 09-Apr-2009 yamt

sonewconn: add an assertion.


Revision tags: nick-hppapmap-base2
# 1.101 21-Jan-2009 yamt

branches: 1.101.2;
restore the pre socket locking patch signal behaviour.
this fixes a busy-loop in nfs_connect.


Revision tags: netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base mjf-devfs2-base
# 1.100 24-Oct-2008 dyoung

branches: 1.100.2; 1.100.4;
Change 'return (expr);' to 'return expr;'. Change (type *)0 to
NULL. No functional change intended.


Revision tags: haad-dm-base1
# 1.99 14-Oct-2008 ad

Accept filters:

- Remove remaining #ifdef INET.
- Avoid holding locks so we don't need to do KM_NOSLEEP allocations.
- Use a rwlock to protect the accept filter list.
- Make it safe to unload accept filter modules.
- Minor KNF.


# 1.98 11-Oct-2008 pooka

Move uidinfo to its own module in kern_uidinfo.c and include in rump.
No functional change to uidinfo.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.97 04-Aug-2008 tls

Add accept filters, ported from FreeBSD by Coyote Point Systems. Add inetd
support for specifying an accept filter for a service (mostly as a usage
example, but it can be handy for other things). Manual pages to follow
in a day or so.

OK core@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 1.96 18-Jun-2008 yamt

branches: 1.96.2;
merge yamt-pf42 branch.
(import newer pf from OpenBSD 4.2)

ok'ed by peter@. requested by core@


Revision tags: yamt-pf42-base4
# 1.95 10-Jun-2008 ad

There can be existing waiters on a socket's condition variables when we
change socket::so_lock, and they rely on the old lock to synchronize.
Wake them up whenever we change so_lock so they can restart their waits.


Revision tags: yamt-pf42-base3
# 1.94 26-May-2008 ad

branches: 1.94.2;
Use pool_cache for sockets.


# 1.93 24-May-2008 christos

Coverity CID 5025: sbreserve is never called with a null socket.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.92 28-Apr-2008 martin

branches: 1.92.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.91 24-Apr-2008 ad

branches: 1.91.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.90 01-Mar-2008 rmind

branches: 1.90.2;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.89 07-Feb-2008 ad

branches: 1.89.2; 1.89.6;
sonewconn: inherit FNONBLOCK from the parent.


# 1.88 29-Jan-2008 yamt

sbreserve: curlwp can't be NULL these days.
XXX these code seems to need an overhaul.


# 1.87 29-Jan-2008 yamt

sbrelease: unwrap a short line.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.86 25-Sep-2007 ad

branches: 1.86.4;
Use selinit() / seldestroy().


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base matt-mips64-base
# 1.85 02-Aug-2007 rmind

branches: 1.85.2; 1.85.4; 1.85.6; 1.85.8;
TCP socket buffers automatic sizing - ported from FreeBSD.
http://mail-index.netbsd.org/tech-net/2007/02/04/0006.html

! Disabled by default, marked as experimental. Testers are very needed.
! Someone should thoroughly test this, and improve if possible.

Discussed on <tech-net>:
http://mail-index.netbsd.org/tech-net/2007/07/12/0002.html
Thanks Greg Troxel for comments.

OK by the long silence on <tech-net>.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.84 04-Jul-2007 tls

branches: 1.84.2;
After looking at FreeBSD 6 again -- we were also failing to copy the
send and receive timeouts. Fix this.


# 1.83 04-Jul-2007 tls

Copy SNDLOWAT and RCVLOWAT socket options to accepted socket, so applications
can rely on all socket options being propagated from the listen socket as
the manual page says (and as everything but Linux has always done). FreeBSD 6
fixes this the same way, but this bug appears elsewhere and is...Old.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.82 04-Mar-2007 christos

branches: 1.82.2; 1.82.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.81 01-Nov-2006 yamt

branches: 1.81.4;
remove some __unused from function parameters.


Revision tags: yamt-splraiseipl-base2
# 1.80 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.79 03-Oct-2006 elad

Back out socket credentials for now, until we figure a better way of
handling the reference counting from interrupt context.


# 1.78 02-Oct-2006 elad

Add credentials to sockets, 'so_cred'.

Brought up on tech-kern@ some ~2 months ago, didn't seem to be an
objection; brought up again recently and no objection either... this is
not too intrusive and I've been running with this for a while.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.77 16-Aug-2006 plunky

branches: 1.77.4;
Fix broken comments - there is no SO_ISCONNECTED or SO_ISCONFIRMING

this fixes kern/32058


# 1.76 16-Aug-2006 plunky

Remove macro call sonewconn() => sonewconn1() as it is no longer necessary.
There are no such calls and the compiler would catch mistakes like this
in any case.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.75 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.74 03-Jul-2006 christos

Make sure we have at least PIPE_BUF bytes available in the socket send buffer.
Review and comment by yamt.


# 1.73 01-Jul-2006 christos

Revert previous change to bump the socket low watermark to sock_loan_thresh.
With sock_loan_thresh=4096, sb_lowat==sb_hiwat, and sowritable will never
be true (even if only a single byte is pending). Some programs (like screen)
expect select() to return that a socket is writable on a socket when there
is space to write to it. XXX: What is the right thing to do here?


Revision tags: yamt-pdpolicy-base6
# 1.72 21-Jun-2006 yamt

bump default so_snd.sb_lowat to increase chance to use loaning.

the idea to tweak the watermark from Jonathan Stone.
reviewed by Bill Studenmund.


Revision tags: chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.71 14-May-2006 elad

branches: 1.71.4;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.70 24-Dec-2005 perry

branches: 1.70.4; 1.70.6; 1.70.8; 1.70.10; 1.70.12;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.69 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.68 29-May-2005 christos

branches: 1.68.2;
- add const.
- remove unnecessary casts.
- add __UNCONST casts and mark them with XXXUNCONST as necessary.


# 1.67 07-May-2005 christos

PR/30154: YAMAMOTO Takashi: tcp_close locking botch
chgsbsize() as mentioned in the PR can be called from an interrupt context
via tcp_close(). Avoid calling uid_find() in chgsbsize().
- Instead of storing so_uid in struct socketvar, store *so_uidinfo
- Add a simple lock to struct uidinfo.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.66 26-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.65 24-Jun-2004 jonathan

branches: 1.65.4; 1.65.6;
Rename MBUFTRACE helper function m_claim() to m_claimm(),
for consistency with M_FREE() and m_freem(). Affected files:

sys/mbuf.h
kern/uipc_socket2.c
kern/uipc_mbuf.c
net/if_ethersubr.c
netatalk/ddp_input.c
nfs/nfs_socket.c


# 1.64 11-Jun-2004 jonathan

Fix potential memory leak in sbappendaddrchain():

We do an MGETHDR)() for each mbuf "packet" of the input chain, to hold
the socket address prepended to that "packet". If those MGETHDR()s
ever failed, we would leak all the successfully-allocated mbuf
headers. Leak noted by Yamamoto-san (yamt@NetBSD.org); thanks for catching it!

Add socketbuf invariant-checking macros to sbappendaddrchain(), and
replace a stray bcopy() with memcpy(), also as suggested by Yamamoto-san.


# 1.63 27-May-2004 jonathan

Rework to make FAST_IPSEC PF_KEY dumps unicast and reliable:

Introduce new socket-layer function sbappendaddrchain() to
sys/kern/uipc_socket2.c: like sbappendaddr(), only takes a chain of
records and appends the entire chain in one pass. sbappendaddrchain()
also takes an `sbprio' argument, which indicates the caller requires
special `reliable' handling of the socket-buffer. `sbprio' is
described in sys/sys/socketvar.h, although (for now) the different
levels are not yet implemented.

Rework sys/netipsec/key.c PF_KEY DUMP responses to build a chain of
mbuf records, one record per dump response. Unicast the entire chain
to the requestor, with all-or-none semantics.

Changed files;
sys/socketvar.h kern/uipc_socket2.c netipsec/key.c
Reviewed by:
Jason Thorpe, Thor Lancelot Simon, post to tech-kern.

Todo: request pullup to 2.0 branch. Post-2.0, rework sysctl() API for
dumps to use new record-chain constructors. Actually implement
the distinct service levels in sbappendaddrchain() so we can use them
to make PF_KEY ACQUIRE messages more reliable.


# 1.62 19-Apr-2004 christos

Charge root for socket buffers without a socket pointer.


# 1.61 18-Apr-2004 matt

Constify the addr parameter to sbappenaddr.


# 1.60 18-Apr-2004 matt

sbreserve can be called with a NULL socket, deal with it.


# 1.59 17-Apr-2004 christos

PR/9347: Eric E. Fair: socket buffer pool exhaustion leads to system deadlock
and unkillable processes.
1. Introduce new SBSIZE resource limit from FreeBSD to limit socket buffer
size resource.
2. make sokvareserve interruptible, so processes ltsleeping on it can be
killed.


Revision tags: netbsd-2-0-base
# 1.58 21-Oct-2003 thorpej

branches: 1.58.2;
Cache the "adjusted" value of sb_max when sb_max is changed, in order
to avoid doing quad math in sbreserve().

Change suggested by Simon Burge, and code inspired by a similar change
in FreeBSD.


# 1.57 22-Sep-2003 christos

- pass signo to fownsignal [ok by jd]
- make urg signal handling use fownsignal
- remove out of band detection in sowakeup


# 1.56 21-Sep-2003 jdolecek

cleanup & uniform descriptor owner handling:
* introduce fsetown(), fgetown(), fownsignal() - this sets/retrieves/signals
the owner of descriptor, according to appropriate sematics
of TIOCSPGRP/FIOSETOWN/SIOCSPGRP/TIOCGPGRP/FIOGETOWN/SIOCGPGRP ioctl; use
these routines instead of custom code where appropriate
* make every place handling TIOCSPGRP/TIOCGPGRP handle also FIOSETOWN/FIOGETOWN
properly, and remove the translation of FIO[SG]OWN to TIOC[SG]PGRP
in sys_ioctl() & sys_fcntl()
* also remove the socket-specific hack in sys_ioctl()/sys_fcntl() and
pass the ioctls down to soo_ioctl() as any other ioctl

change discussed on tech-kern@


# 1.55 06-Sep-2003 christos

SA_SIGINFO changes.


# 1.54 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.53 29-Jun-2003 fvdl

branches: 1.53.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.52 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.51 23-Jun-2003 martin

Make sure to include opt_foo.h if a defflag option FOO is used.


# 1.50 17-Apr-2003 fvdl

A bit of an ugly workaround to avoid a warning for a larger MSIZE.
Shouldn't make a difference in the generated code.


# 1.49 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge
# 1.48 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.47 27-Sep-2002 provos

remove trailing \n in panic(). approved perry.


Revision tags: gehenna-devsw-base
# 1.46 22-Aug-2002 thorpej

In sbcompress(), if we toss an empty mbuf, make sure to update
sb_lastrecord if necessary.

From Daniel Hartmeier <daniel@benzedrine.cx>.


# 1.45 03-Jul-2002 thorpej

Rename SB_UPDATE_TAIL() to SB_EMPTY_FIXUP(), per suggestion from
Jonathan Stone.


# 1.44 03-Jul-2002 thorpej

Rename sbappend_stream() to sbappendstream(), per suggestion from
Jonathan Stone.


# 1.43 03-Jul-2002 thorpej

Make insertion of data into socket buffers O(C):
* Keep pointers to the first and last mbufs of the last record in the
socket buffer.
* Use the sb_lastrecord pointer in the sbappend*() family of functions
to avoid traversing the packet chain to find the last record.
* Add a new sbappend_stream() function for stream protocols which
guarantee that there will never be more than one record in the
socket buffer. This function uses the sb_mbtail pointer to perform
the data insertion. Make TCP use sbappend_stream().

On a profiling run, this makes sbappend of a TCP transmission using
a 1M socket buffer go from 50% of the time to .02% of the time.

Thanks to Bill Sommerfeld and YAMAMOTO Takashi for their debugging
assistance!


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base thorpej-mips-cache-base
# 1.42 12-Nov-2001 lukem

branches: 1.42.8;
add RCSIDs


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 05-Aug-2001 enami

branches: 1.41.4;
Give different names for different wait channels.

# and minor knf fix while I'm here.


# 1.40 27-Jul-2001 thorpej

Now that M_TRAILINGSPACE() checks buffer writeability properly,
we can greatly simplify sbcompress(). Slightly modified from
a similar change in FreeBSD.


# 1.39 16-Jun-2001 manu

branches: 1.39.2;
Use SB_ASYNC in struct sockbuf sb_flags field instead of SS_ASYNC in
struct socket so_state field to decide if we need to send asynchronous
notifications. This makes possible to request notification on write but
not on read, and vice versa.

This is used in Linux emulation code, because when async I/O is requested,
Linux does not send SIGIO to write end of sockets, and it never send any
SIGIO to any end of pipes. Il Linux emulation code, we then set SB_ASYNC
only on the read end of sockets, and on no end for pipes.


# 1.38 30-Apr-2001 kml

Large values of sb_max would cause an overflow in sbreserve(); cast to
u_quad_t to avoid this. (from FreeBSD uipc_socket2.c v1.19)


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.37 27-Feb-2001 lukem

branches: 1.37.2;
convert to ANSI KNF


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 30-Mar-2000 augustss

Get rid of register declarations.


# 1.35 29-Feb-2000 itojun

more fix to ancillary data alignment. we need padding after
last cmsg_data item (see the figure on RFC2292 page 18).


# 1.34 18-Feb-2000 itojun

fix alignment problem in ancillary messages (alpha).

the change constitutes binary compatibility issue hen sizeof(long) !=4.
there's no way to be backward compatible, and only guys affected
are IPv6 userland tools.

From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base
# 1.33 04-Aug-1999 mycroft

branches: 1.33.2;
The old compaction test had an off-by-one error that caused it to not compact
in some cases where it could have. Fix this, and the new version as well.


# 1.32 04-Aug-1999 matt

Don't compress mbuf clusters which are referenced by multiple
mbufs since you might overwriting valuable data. (think of
m_copy'ed data from a TCP re-transmission queue. Since those
might be in clusters and referenced in two sockets).


# 1.31 04-Aug-1999 mycroft

It's now possible for sbcompress() to compact mbuf clusters, so do it.
This helps prevent mbuf cluster exhaustion when receiving lots of small
packets.


Revision tags: chs-ubc2-base
# 1.30 01-Jul-1999 itojun

IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.


# 1.29 22-Apr-1999 simonb

Move inclusion of "opt_sb_max.h" from sys/socketvar.h to
conf/param.c, and move the initialisation of the sb_max
variable from kern/uipc_socket2.c to conf/param.c. Now
everthing that includes sys/socketvar.h doesn't get
recompiled when SB_MAX's value changes.


Revision tags: netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.28 23-Mar-1999 lukem

branches: 1.28.2; 1.28.4; 1.28.6;
Ensure that you can only bind a more specific address when it is done by the
same uid or by root.

This code is from FreeBSD. (Whilst it was originally obtained from OpenBSD,
FreeBSD fixed it to work with multicast. To quote the commit message:
- Don't bother checking for conflicting sockets if we're binding to a
multicast address.
- Don't return an error if we're binding to INADDR_ANY, the conflicting
socket is bound to INADDR_ANY, and the conflicting socket has
SO_REUSEPORT set.
)


# 1.27 20-Jan-1999 mycroft

Do not remove sockets from the accept(2) queue on close.


Revision tags: kenh-if-detach-base chs-ubc-base
# 1.26 04-Aug-1998 perry

Abolition of bcopy, ovbcopy, bcmp, and bzero, phase one.
bcopy(x, y, z) -> memcpy(y, x, z)
ovbcopy(x, y, z) -> memmove(y, x, z)
bcmp(x, y, z) -> memcmp(x, y, z)
bzero(x, y) -> memset(x, 0, y)


# 1.25 02-Aug-1998 thorpej

Use the pool allocator for sockets.


Revision tags: eeh-paddr_t-base
# 1.24 25-Apr-1998 matt

Hook for 0-copy (or other optimized) sends and receives


# 1.23 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.22 07-Jan-1998 thorpej

Make insertion and removal of sockets from the partial and incoming
connections queues O(C) rather than O(N).


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base marc-pcmcia-base
# 1.21 09-Oct-1997 mycroft

branches: 1.21.2;
Make various standard wmesg strings const.


Revision tags: thorpej-signal-base marc-pcmcia-bp SYN_cache_cur_base
# 1.20 26-Jun-1997 thorpej

branches: 1.20.4;
In sbappendaddr(), if the sockaddr length is larger than will fit in
an mbuf, allocate enough external storage to hold the sockaddr. Thanks
to enami tsugutomo <enami@cv.sony.co.jp> for providing sanity-checks.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.19 11-Jan-1997 thorpej

branches: 1.19.8;
Implement sbcreatecontrol(), a generic function to create a "control"
mbuf for presentation on a socket buffer.


# 1.18 09-Dec-1996 thorpej

In sbreserve(), don't allow a count of 0. Fixes PR #2794, from
Erik Berls <cyber@dis.org>.


# 1.17 26-Nov-1996 thorpej

Back out previous soqinsque() and soqremque() changes. This will
stop the panics until the socket queues get converted to <sys/queue.h>.


# 1.16 10-Nov-1996 thorpej

Optimization of soqinsque() and soqremque():

Keep queue of pending sockets in a double linked list. Previously,
a singly linked list was used, giving O(N) insertion/deletion times,
and was a major time consumer for sockets with large pending queues.
The double linked list give O(C) insertion/deletion times with only
a small cost in complexity.

Since a socket can be on, at most, one queue at a time, both so_q and
so_q0 can safely be used as (forward and backward, respectively) queue
pointers.

Submitted my Matt Thomas <matt@3am-software.com>, a long time ago.
(Geez, I've been running with this patch for _months_, and had completely
forgotten about it!)


# 1.15 13-Oct-1996 christos

backout previous kprintf change


# 1.14 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.13 07-Sep-1996 mycroft

Implement poll(2).


# 1.12 22-May-1996 mycroft

Pass a proc pointer down to the usrreq and pcbbind functions for PRU_ATTACH, PRU_BIND and
PRU_CONTROL. The usrreq interface really needs to be split up, but this will have to wait.
Remove SS_PRIV completely.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.11 04-Feb-1996 christos

branches: 1.11.4;
First pass at prototyping


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.10 16-Aug-1995 mycroft

Access rights are now stored in MT_CONTROL mbufs. Document this.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.9 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.8 13-May-1994 mycroft

Update to 4.4-Lite networking code, with a few local changes.


# 1.7 04-May-1994 mycroft

More return types...


# 1.6 25-Apr-1994 mycroft

Remove sbselqueue().


# 1.5 18-Dec-1993 mycroft

Canonicalize all #includes.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 27-Jun-1993 andrew

branches: 1.4.4;
ANSIfications - removed all implicit function return types and argument
definitions. Ensured that all files include "systm.h" to gain access to
general prototypes. Casts where necessary.


# 1.3 18-May-1993 cgd

make kernel select interface be one-stop shopping & clean it all up.


Revision tags: netbsd-0-8 netbsd-alpha-1 patchkit-0-2-2
# 1.2 21-Mar-1993 cgd

after 0.2.2 "stable" patches applied


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.140 02-Oct-2021 thorpej

- fifo_poll(): If the last writer has disappeared, detect this and return
POLLHUP, per POSIX.
- fifo_close(): Use the new fifo_socantrcvmore(), which is like the
garden-variety socantrcvmore(), except it specifies POLL_HUP rather
than POLL_IN (so the correct code for SIGIO is sent).
- sowakeup(): Allow POLL_HUP as a code (notifies poll'ers with POLLHUP).
- Add test cases for correct POLLHUP behavior with FIFOs.

Fixes PR kern/56429.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base
# 1.139 04-Mar-2021 msaitoh

Add missing opt_inet.h.


# 1.138 26-Aug-2020 christos

branches: 1.138.2;
add socket info for user and group for unix sockets in fstat.


# 1.137 23-May-2020 ad

Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.136 01-Feb-2020 riastradh

Load struct fdfile::ff_file with atomic_load_consume.

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.)


# 1.135 01-Feb-2020 riastradh

Load struct filedesc::fd_dt with atomic_load_consume.

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.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.134 11-Jul-2019 maxv

branches: 1.134.2; 1.134.4;
Fix info leaks: the alignment of the structures causes uninitialized heap
memory to be copied to userland in sys_recvmsg().


Revision tags: phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.133 04-Nov-2018 christos

- Introduce a new SO_RERROR socket option to explicitly turn on
receive overflow errors re-instating the default behavior to
silently ignore them as before 2018-03-19.
- Introduce a new kern.sooptions sysctl to control the default
behavior of socket options. Setting this to 0x4000 (SO_RERROR),
turns on receive overflow error reporting for all sockets.
- Change dhcpcd to turn on SO_RERROR on all its sockets.

As discussed in tech-net.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.132 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: pgoyette-compat-0728
# 1.131 20-Jul-2018 msaitoh

Add "show socket" command written by Hiroki SUENAGA. It prints usage of
system's socket buffers.


Revision tags: phil-wifi-base pgoyette-compat-0625
# 1.130 06-Jun-2018 roy

branches: 1.130.2;
Separate receive socket errors from general socket errors.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502
# 1.129 29-Apr-2018 maxv

Remove references to m_copy in comments.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.128 19-Mar-2018 roy

socket: report receive buffer overflows

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.


# 1.127 18-Mar-2018 christos

- Convert sb_lowat to unsigned for consistency. There are no negative value
uses
- Check for overflow as mentioned in the comment
- Sprinkle const


Revision tags: pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.126 06-Jul-2017 christos

branches: 1.126.4;
move the timestamp stuff to uipc_socket.c because it already has the compat
includes.


# 1.125 06-Jul-2017 christos

Merge the two copies SO_TIMESTAMP/SO_OTIMESTAMP processing to a single
function, and add a SOOPT_TIMESTAMP define reducing compat pollution from
5 places to 1.


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.124 02-Oct-2016 christos

branches: 1.124.8;
more MFREE -> m_free


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.123 23-May-2016 tls

branches: 1.123.2;
Fix a longstanding problem with accept filters noticed by Timo Buhrmester:
sockets sitting in the accept filter can consume the entire listen queue,
such that the application is never able to handle any connections. Handle
this by simply passing through the oldest queued cxn when the queue is full.

This is fair because the longer a cxn lingers in the queue (stays connected
but does not meet the requirements of the filter for passage) the more likely
it is to be passed through, at which point the application can dispose of it.

Works because none of our accept filters actually allocate private state
per-cxn. If they did, we'd have to fix the API bug that there is presently
no way to tell an accf to finish/deallocate for a single cxn (accf_destroy
kills off the entire filter instance for a given listen socket).


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.122 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.121 05-Sep-2014 matt

branches: 1.121.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.120 31-Jul-2014 rtr

split PRU_DISCONNECT, PRU_SHUTDOWN and PRU_ABORT function out of
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


# 1.119 19-May-2014 rmind

- Split off PRU_ATTACH and PRU_DETACH logic into separate functions.
- Replace malloc with kmem and eliminate M_PCB while here.
- Sprinkle more asserts.


Revision tags: rmind-smpnet-nbase rmind-smpnet-base
# 1.118 18-May-2014 rmind

Add struct pr_usrreqs with a pr_generic function and prepare for the
dismantling of pr_usrreq in the protocols; no functional change intended.
PRU_ATTACH/PRU_DETACH changes will follow soon.

Bump for struct protosw. Welcome to 6.99.62!


# 1.117 17-May-2014 rmind

sonewconn: insert the socket into the queue *after* the protocol attach.
This potentially avoids unnecessary race conditions when handling partial
connections.


# 1.116 17-May-2014 rmind

- sonewconn: improve the initialisation order and add some asserts.
- Add various comments describing primitive routines operating on sockets,
clarify connection life-cycle and improve the description of socket queues.
- Sprinkle more asserts.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.115 08-Oct-2013 christos

branches: 1.115.2;
0 -> NULL
MGET -> m_get
No functional change.


# 1.114 15-Sep-2013 martin

Avoid unused variable warnings


# 1.113 29-Aug-2013 rmind

Remove SS_ISCONFIRMING, it is unused and TP4 will not come back.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.112 28-Jun-2013 matt

branches: 1.112.2;
Make sbdrop panic more verbose


# 1.111 27-Jun-2013 christos

Introduce a more general method of sbcreatecontrol, sbcreatecontrol1 that
can take flags (M_WAITOK), and allocate large messages if needed. It also
returns the allocated pointer instead of copying the data to the passed
pointer. Implement sbcreatecontrol() using that.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.110 20-Dec-2011 christos

branches: 1.110.6;
- Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.
- Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis
- Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets.
- Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all
errors?).


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.109 31-Aug-2011 plunky

branches: 1.109.2; 1.109.6;
NULL does not need a cast


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.108 24-Apr-2011 rmind

- Replace few malloc(9) uses with kmem(9).
- Rename buf_malloc() to buf_alloc(), fix comments.
- Remove some unnecessary inclusions.


# 1.107 09-Apr-2011 christos

Preserve SB_ASYNC on the accepted socket. From: Dmitry Matveev
http://mail-index.netbsd.org/tech-net/2011/02/17/msg002457.html


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.106 30-Dec-2009 elad

branches: 1.106.4; 1.106.6;
Don't bother caching egid. It'll be removed soon.


# 1.105 30-Dec-2009 elad

Always use resource limits from the process, as proposed in

http://mail-index.netbsd.org/tech-kern/2009/12/30/msg006756.html

okay christos@.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.104 02-Sep-2009 tls

Add a direction argument to socket upcalls, so they can tell why they've
been called when, for example, they're waiting for space to write. From
Ritesh Agrawal at Coyote Point.


Revision tags: yamt-nfs-mp-base7
# 1.103 24-Jul-2009 christos

check return code from soreserve() (Sean Boudreau)


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 09-Apr-2009 yamt

sonewconn: add an assertion.


Revision tags: nick-hppapmap-base2
# 1.101 21-Jan-2009 yamt

branches: 1.101.2;
restore the pre socket locking patch signal behaviour.
this fixes a busy-loop in nfs_connect.


Revision tags: netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base mjf-devfs2-base
# 1.100 24-Oct-2008 dyoung

branches: 1.100.2; 1.100.4;
Change 'return (expr);' to 'return expr;'. Change (type *)0 to
NULL. No functional change intended.


Revision tags: haad-dm-base1
# 1.99 14-Oct-2008 ad

Accept filters:

- Remove remaining #ifdef INET.
- Avoid holding locks so we don't need to do KM_NOSLEEP allocations.
- Use a rwlock to protect the accept filter list.
- Make it safe to unload accept filter modules.
- Minor KNF.


# 1.98 11-Oct-2008 pooka

Move uidinfo to its own module in kern_uidinfo.c and include in rump.
No functional change to uidinfo.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.97 04-Aug-2008 tls

Add accept filters, ported from FreeBSD by Coyote Point Systems. Add inetd
support for specifying an accept filter for a service (mostly as a usage
example, but it can be handy for other things). Manual pages to follow
in a day or so.

OK core@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 1.96 18-Jun-2008 yamt

branches: 1.96.2;
merge yamt-pf42 branch.
(import newer pf from OpenBSD 4.2)

ok'ed by peter@. requested by core@


Revision tags: yamt-pf42-base4
# 1.95 10-Jun-2008 ad

There can be existing waiters on a socket's condition variables when we
change socket::so_lock, and they rely on the old lock to synchronize.
Wake them up whenever we change so_lock so they can restart their waits.


Revision tags: yamt-pf42-base3
# 1.94 26-May-2008 ad

branches: 1.94.2;
Use pool_cache for sockets.


# 1.93 24-May-2008 christos

Coverity CID 5025: sbreserve is never called with a null socket.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.92 28-Apr-2008 martin

branches: 1.92.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.91 24-Apr-2008 ad

branches: 1.91.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.90 01-Mar-2008 rmind

branches: 1.90.2;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.89 07-Feb-2008 ad

branches: 1.89.2; 1.89.6;
sonewconn: inherit FNONBLOCK from the parent.


# 1.88 29-Jan-2008 yamt

sbreserve: curlwp can't be NULL these days.
XXX these code seems to need an overhaul.


# 1.87 29-Jan-2008 yamt

sbrelease: unwrap a short line.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.86 25-Sep-2007 ad

branches: 1.86.4;
Use selinit() / seldestroy().


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base matt-mips64-base
# 1.85 02-Aug-2007 rmind

branches: 1.85.2; 1.85.4; 1.85.6; 1.85.8;
TCP socket buffers automatic sizing - ported from FreeBSD.
http://mail-index.netbsd.org/tech-net/2007/02/04/0006.html

! Disabled by default, marked as experimental. Testers are very needed.
! Someone should thoroughly test this, and improve if possible.

Discussed on <tech-net>:
http://mail-index.netbsd.org/tech-net/2007/07/12/0002.html
Thanks Greg Troxel for comments.

OK by the long silence on <tech-net>.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.84 04-Jul-2007 tls

branches: 1.84.2;
After looking at FreeBSD 6 again -- we were also failing to copy the
send and receive timeouts. Fix this.


# 1.83 04-Jul-2007 tls

Copy SNDLOWAT and RCVLOWAT socket options to accepted socket, so applications
can rely on all socket options being propagated from the listen socket as
the manual page says (and as everything but Linux has always done). FreeBSD 6
fixes this the same way, but this bug appears elsewhere and is...Old.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.82 04-Mar-2007 christos

branches: 1.82.2; 1.82.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.81 01-Nov-2006 yamt

branches: 1.81.4;
remove some __unused from function parameters.


Revision tags: yamt-splraiseipl-base2
# 1.80 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.79 03-Oct-2006 elad

Back out socket credentials for now, until we figure a better way of
handling the reference counting from interrupt context.


# 1.78 02-Oct-2006 elad

Add credentials to sockets, 'so_cred'.

Brought up on tech-kern@ some ~2 months ago, didn't seem to be an
objection; brought up again recently and no objection either... this is
not too intrusive and I've been running with this for a while.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.77 16-Aug-2006 plunky

branches: 1.77.4;
Fix broken comments - there is no SO_ISCONNECTED or SO_ISCONFIRMING

this fixes kern/32058


# 1.76 16-Aug-2006 plunky

Remove macro call sonewconn() => sonewconn1() as it is no longer necessary.
There are no such calls and the compiler would catch mistakes like this
in any case.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.75 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.74 03-Jul-2006 christos

Make sure we have at least PIPE_BUF bytes available in the socket send buffer.
Review and comment by yamt.


# 1.73 01-Jul-2006 christos

Revert previous change to bump the socket low watermark to sock_loan_thresh.
With sock_loan_thresh=4096, sb_lowat==sb_hiwat, and sowritable will never
be true (even if only a single byte is pending). Some programs (like screen)
expect select() to return that a socket is writable on a socket when there
is space to write to it. XXX: What is the right thing to do here?


Revision tags: yamt-pdpolicy-base6
# 1.72 21-Jun-2006 yamt

bump default so_snd.sb_lowat to increase chance to use loaning.

the idea to tweak the watermark from Jonathan Stone.
reviewed by Bill Studenmund.


Revision tags: chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.71 14-May-2006 elad

branches: 1.71.4;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.70 24-Dec-2005 perry

branches: 1.70.4; 1.70.6; 1.70.8; 1.70.10; 1.70.12;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.69 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.68 29-May-2005 christos

branches: 1.68.2;
- add const.
- remove unnecessary casts.
- add __UNCONST casts and mark them with XXXUNCONST as necessary.


# 1.67 07-May-2005 christos

PR/30154: YAMAMOTO Takashi: tcp_close locking botch
chgsbsize() as mentioned in the PR can be called from an interrupt context
via tcp_close(). Avoid calling uid_find() in chgsbsize().
- Instead of storing so_uid in struct socketvar, store *so_uidinfo
- Add a simple lock to struct uidinfo.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.66 26-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.65 24-Jun-2004 jonathan

branches: 1.65.4; 1.65.6;
Rename MBUFTRACE helper function m_claim() to m_claimm(),
for consistency with M_FREE() and m_freem(). Affected files:

sys/mbuf.h
kern/uipc_socket2.c
kern/uipc_mbuf.c
net/if_ethersubr.c
netatalk/ddp_input.c
nfs/nfs_socket.c


# 1.64 11-Jun-2004 jonathan

Fix potential memory leak in sbappendaddrchain():

We do an MGETHDR)() for each mbuf "packet" of the input chain, to hold
the socket address prepended to that "packet". If those MGETHDR()s
ever failed, we would leak all the successfully-allocated mbuf
headers. Leak noted by Yamamoto-san (yamt@NetBSD.org); thanks for catching it!

Add socketbuf invariant-checking macros to sbappendaddrchain(), and
replace a stray bcopy() with memcpy(), also as suggested by Yamamoto-san.


# 1.63 27-May-2004 jonathan

Rework to make FAST_IPSEC PF_KEY dumps unicast and reliable:

Introduce new socket-layer function sbappendaddrchain() to
sys/kern/uipc_socket2.c: like sbappendaddr(), only takes a chain of
records and appends the entire chain in one pass. sbappendaddrchain()
also takes an `sbprio' argument, which indicates the caller requires
special `reliable' handling of the socket-buffer. `sbprio' is
described in sys/sys/socketvar.h, although (for now) the different
levels are not yet implemented.

Rework sys/netipsec/key.c PF_KEY DUMP responses to build a chain of
mbuf records, one record per dump response. Unicast the entire chain
to the requestor, with all-or-none semantics.

Changed files;
sys/socketvar.h kern/uipc_socket2.c netipsec/key.c
Reviewed by:
Jason Thorpe, Thor Lancelot Simon, post to tech-kern.

Todo: request pullup to 2.0 branch. Post-2.0, rework sysctl() API for
dumps to use new record-chain constructors. Actually implement
the distinct service levels in sbappendaddrchain() so we can use them
to make PF_KEY ACQUIRE messages more reliable.


# 1.62 19-Apr-2004 christos

Charge root for socket buffers without a socket pointer.


# 1.61 18-Apr-2004 matt

Constify the addr parameter to sbappenaddr.


# 1.60 18-Apr-2004 matt

sbreserve can be called with a NULL socket, deal with it.


# 1.59 17-Apr-2004 christos

PR/9347: Eric E. Fair: socket buffer pool exhaustion leads to system deadlock
and unkillable processes.
1. Introduce new SBSIZE resource limit from FreeBSD to limit socket buffer
size resource.
2. make sokvareserve interruptible, so processes ltsleeping on it can be
killed.


Revision tags: netbsd-2-0-base
# 1.58 21-Oct-2003 thorpej

branches: 1.58.2;
Cache the "adjusted" value of sb_max when sb_max is changed, in order
to avoid doing quad math in sbreserve().

Change suggested by Simon Burge, and code inspired by a similar change
in FreeBSD.


# 1.57 22-Sep-2003 christos

- pass signo to fownsignal [ok by jd]
- make urg signal handling use fownsignal
- remove out of band detection in sowakeup


# 1.56 21-Sep-2003 jdolecek

cleanup & uniform descriptor owner handling:
* introduce fsetown(), fgetown(), fownsignal() - this sets/retrieves/signals
the owner of descriptor, according to appropriate sematics
of TIOCSPGRP/FIOSETOWN/SIOCSPGRP/TIOCGPGRP/FIOGETOWN/SIOCGPGRP ioctl; use
these routines instead of custom code where appropriate
* make every place handling TIOCSPGRP/TIOCGPGRP handle also FIOSETOWN/FIOGETOWN
properly, and remove the translation of FIO[SG]OWN to TIOC[SG]PGRP
in sys_ioctl() & sys_fcntl()
* also remove the socket-specific hack in sys_ioctl()/sys_fcntl() and
pass the ioctls down to soo_ioctl() as any other ioctl

change discussed on tech-kern@


# 1.55 06-Sep-2003 christos

SA_SIGINFO changes.


# 1.54 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.53 29-Jun-2003 fvdl

branches: 1.53.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.52 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.51 23-Jun-2003 martin

Make sure to include opt_foo.h if a defflag option FOO is used.


# 1.50 17-Apr-2003 fvdl

A bit of an ugly workaround to avoid a warning for a larger MSIZE.
Shouldn't make a difference in the generated code.


# 1.49 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge
# 1.48 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.47 27-Sep-2002 provos

remove trailing \n in panic(). approved perry.


Revision tags: gehenna-devsw-base
# 1.46 22-Aug-2002 thorpej

In sbcompress(), if we toss an empty mbuf, make sure to update
sb_lastrecord if necessary.

From Daniel Hartmeier <daniel@benzedrine.cx>.


# 1.45 03-Jul-2002 thorpej

Rename SB_UPDATE_TAIL() to SB_EMPTY_FIXUP(), per suggestion from
Jonathan Stone.


# 1.44 03-Jul-2002 thorpej

Rename sbappend_stream() to sbappendstream(), per suggestion from
Jonathan Stone.


# 1.43 03-Jul-2002 thorpej

Make insertion of data into socket buffers O(C):
* Keep pointers to the first and last mbufs of the last record in the
socket buffer.
* Use the sb_lastrecord pointer in the sbappend*() family of functions
to avoid traversing the packet chain to find the last record.
* Add a new sbappend_stream() function for stream protocols which
guarantee that there will never be more than one record in the
socket buffer. This function uses the sb_mbtail pointer to perform
the data insertion. Make TCP use sbappend_stream().

On a profiling run, this makes sbappend of a TCP transmission using
a 1M socket buffer go from 50% of the time to .02% of the time.

Thanks to Bill Sommerfeld and YAMAMOTO Takashi for their debugging
assistance!


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base thorpej-mips-cache-base
# 1.42 12-Nov-2001 lukem

branches: 1.42.8;
add RCSIDs


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 05-Aug-2001 enami

branches: 1.41.4;
Give different names for different wait channels.

# and minor knf fix while I'm here.


# 1.40 27-Jul-2001 thorpej

Now that M_TRAILINGSPACE() checks buffer writeability properly,
we can greatly simplify sbcompress(). Slightly modified from
a similar change in FreeBSD.


# 1.39 16-Jun-2001 manu

branches: 1.39.2;
Use SB_ASYNC in struct sockbuf sb_flags field instead of SS_ASYNC in
struct socket so_state field to decide if we need to send asynchronous
notifications. This makes possible to request notification on write but
not on read, and vice versa.

This is used in Linux emulation code, because when async I/O is requested,
Linux does not send SIGIO to write end of sockets, and it never send any
SIGIO to any end of pipes. Il Linux emulation code, we then set SB_ASYNC
only on the read end of sockets, and on no end for pipes.


# 1.38 30-Apr-2001 kml

Large values of sb_max would cause an overflow in sbreserve(); cast to
u_quad_t to avoid this. (from FreeBSD uipc_socket2.c v1.19)


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.37 27-Feb-2001 lukem

branches: 1.37.2;
convert to ANSI KNF


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 30-Mar-2000 augustss

Get rid of register declarations.


# 1.35 29-Feb-2000 itojun

more fix to ancillary data alignment. we need padding after
last cmsg_data item (see the figure on RFC2292 page 18).


# 1.34 18-Feb-2000 itojun

fix alignment problem in ancillary messages (alpha).

the change constitutes binary compatibility issue hen sizeof(long) !=4.
there's no way to be backward compatible, and only guys affected
are IPv6 userland tools.

From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base
# 1.33 04-Aug-1999 mycroft

branches: 1.33.2;
The old compaction test had an off-by-one error that caused it to not compact
in some cases where it could have. Fix this, and the new version as well.


# 1.32 04-Aug-1999 matt

Don't compress mbuf clusters which are referenced by multiple
mbufs since you might overwriting valuable data. (think of
m_copy'ed data from a TCP re-transmission queue. Since those
might be in clusters and referenced in two sockets).


# 1.31 04-Aug-1999 mycroft

It's now possible for sbcompress() to compact mbuf clusters, so do it.
This helps prevent mbuf cluster exhaustion when receiving lots of small
packets.


Revision tags: chs-ubc2-base
# 1.30 01-Jul-1999 itojun

IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.


# 1.29 22-Apr-1999 simonb

Move inclusion of "opt_sb_max.h" from sys/socketvar.h to
conf/param.c, and move the initialisation of the sb_max
variable from kern/uipc_socket2.c to conf/param.c. Now
everthing that includes sys/socketvar.h doesn't get
recompiled when SB_MAX's value changes.


Revision tags: netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.28 23-Mar-1999 lukem

branches: 1.28.2; 1.28.4; 1.28.6;
Ensure that you can only bind a more specific address when it is done by the
same uid or by root.

This code is from FreeBSD. (Whilst it was originally obtained from OpenBSD,
FreeBSD fixed it to work with multicast. To quote the commit message:
- Don't bother checking for conflicting sockets if we're binding to a
multicast address.
- Don't return an error if we're binding to INADDR_ANY, the conflicting
socket is bound to INADDR_ANY, and the conflicting socket has
SO_REUSEPORT set.
)


# 1.27 20-Jan-1999 mycroft

Do not remove sockets from the accept(2) queue on close.


Revision tags: kenh-if-detach-base chs-ubc-base
# 1.26 04-Aug-1998 perry

Abolition of bcopy, ovbcopy, bcmp, and bzero, phase one.
bcopy(x, y, z) -> memcpy(y, x, z)
ovbcopy(x, y, z) -> memmove(y, x, z)
bcmp(x, y, z) -> memcmp(x, y, z)
bzero(x, y) -> memset(x, 0, y)


# 1.25 02-Aug-1998 thorpej

Use the pool allocator for sockets.


Revision tags: eeh-paddr_t-base
# 1.24 25-Apr-1998 matt

Hook for 0-copy (or other optimized) sends and receives


# 1.23 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.22 07-Jan-1998 thorpej

Make insertion and removal of sockets from the partial and incoming
connections queues O(C) rather than O(N).


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base marc-pcmcia-base
# 1.21 09-Oct-1997 mycroft

branches: 1.21.2;
Make various standard wmesg strings const.


Revision tags: thorpej-signal-base marc-pcmcia-bp SYN_cache_cur_base
# 1.20 26-Jun-1997 thorpej

branches: 1.20.4;
In sbappendaddr(), if the sockaddr length is larger than will fit in
an mbuf, allocate enough external storage to hold the sockaddr. Thanks
to enami tsugutomo <enami@cv.sony.co.jp> for providing sanity-checks.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.19 11-Jan-1997 thorpej

branches: 1.19.8;
Implement sbcreatecontrol(), a generic function to create a "control"
mbuf for presentation on a socket buffer.


# 1.18 09-Dec-1996 thorpej

In sbreserve(), don't allow a count of 0. Fixes PR #2794, from
Erik Berls <cyber@dis.org>.


# 1.17 26-Nov-1996 thorpej

Back out previous soqinsque() and soqremque() changes. This will
stop the panics until the socket queues get converted to <sys/queue.h>.


# 1.16 10-Nov-1996 thorpej

Optimization of soqinsque() and soqremque():

Keep queue of pending sockets in a double linked list. Previously,
a singly linked list was used, giving O(N) insertion/deletion times,
and was a major time consumer for sockets with large pending queues.
The double linked list give O(C) insertion/deletion times with only
a small cost in complexity.

Since a socket can be on, at most, one queue at a time, both so_q and
so_q0 can safely be used as (forward and backward, respectively) queue
pointers.

Submitted my Matt Thomas <matt@3am-software.com>, a long time ago.
(Geez, I've been running with this patch for _months_, and had completely
forgotten about it!)


# 1.15 13-Oct-1996 christos

backout previous kprintf change


# 1.14 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.13 07-Sep-1996 mycroft

Implement poll(2).


# 1.12 22-May-1996 mycroft

Pass a proc pointer down to the usrreq and pcbbind functions for PRU_ATTACH, PRU_BIND and
PRU_CONTROL. The usrreq interface really needs to be split up, but this will have to wait.
Remove SS_PRIV completely.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.11 04-Feb-1996 christos

branches: 1.11.4;
First pass at prototyping


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.10 16-Aug-1995 mycroft

Access rights are now stored in MT_CONTROL mbufs. Document this.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.9 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.8 13-May-1994 mycroft

Update to 4.4-Lite networking code, with a few local changes.


# 1.7 04-May-1994 mycroft

More return types...


# 1.6 25-Apr-1994 mycroft

Remove sbselqueue().


# 1.5 18-Dec-1993 mycroft

Canonicalize all #includes.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 27-Jun-1993 andrew

branches: 1.4.4;
ANSIfications - removed all implicit function return types and argument
definitions. Ensured that all files include "systm.h" to gain access to
general prototypes. Casts where necessary.


# 1.3 18-May-1993 cgd

make kernel select interface be one-stop shopping & clean it all up.


Revision tags: netbsd-0-8 netbsd-alpha-1 patchkit-0-2-2
# 1.2 21-Mar-1993 cgd

after 0.2.2 "stable" patches applied


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.139 04-Mar-2021 msaitoh

Add missing opt_inet.h.


Revision tags: thorpej-futex-base
# 1.138 26-Aug-2020 christos

add socket info for user and group for unix sockets in fstat.


# 1.137 23-May-2020 ad

Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.136 01-Feb-2020 riastradh

Load struct fdfile::ff_file with atomic_load_consume.

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.)


# 1.135 01-Feb-2020 riastradh

Load struct filedesc::fd_dt with atomic_load_consume.

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.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.134 11-Jul-2019 maxv

branches: 1.134.2; 1.134.4;
Fix info leaks: the alignment of the structures causes uninitialized heap
memory to be copied to userland in sys_recvmsg().


Revision tags: phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.133 04-Nov-2018 christos

- Introduce a new SO_RERROR socket option to explicitly turn on
receive overflow errors re-instating the default behavior to
silently ignore them as before 2018-03-19.
- Introduce a new kern.sooptions sysctl to control the default
behavior of socket options. Setting this to 0x4000 (SO_RERROR),
turns on receive overflow error reporting for all sockets.
- Change dhcpcd to turn on SO_RERROR on all its sockets.

As discussed in tech-net.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.132 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: pgoyette-compat-0728
# 1.131 20-Jul-2018 msaitoh

Add "show socket" command written by Hiroki SUENAGA. It prints usage of
system's socket buffers.


Revision tags: phil-wifi-base pgoyette-compat-0625
# 1.130 06-Jun-2018 roy

branches: 1.130.2;
Separate receive socket errors from general socket errors.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502
# 1.129 29-Apr-2018 maxv

Remove references to m_copy in comments.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.128 19-Mar-2018 roy

socket: report receive buffer overflows

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.


# 1.127 18-Mar-2018 christos

- Convert sb_lowat to unsigned for consistency. There are no negative value
uses
- Check for overflow as mentioned in the comment
- Sprinkle const


Revision tags: pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.126 06-Jul-2017 christos

branches: 1.126.4;
move the timestamp stuff to uipc_socket.c because it already has the compat
includes.


# 1.125 06-Jul-2017 christos

Merge the two copies SO_TIMESTAMP/SO_OTIMESTAMP processing to a single
function, and add a SOOPT_TIMESTAMP define reducing compat pollution from
5 places to 1.


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.124 02-Oct-2016 christos

branches: 1.124.8;
more MFREE -> m_free


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.123 23-May-2016 tls

branches: 1.123.2;
Fix a longstanding problem with accept filters noticed by Timo Buhrmester:
sockets sitting in the accept filter can consume the entire listen queue,
such that the application is never able to handle any connections. Handle
this by simply passing through the oldest queued cxn when the queue is full.

This is fair because the longer a cxn lingers in the queue (stays connected
but does not meet the requirements of the filter for passage) the more likely
it is to be passed through, at which point the application can dispose of it.

Works because none of our accept filters actually allocate private state
per-cxn. If they did, we'd have to fix the API bug that there is presently
no way to tell an accf to finish/deallocate for a single cxn (accf_destroy
kills off the entire filter instance for a given listen socket).


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.122 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.121 05-Sep-2014 matt

branches: 1.121.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.120 31-Jul-2014 rtr

split PRU_DISCONNECT, PRU_SHUTDOWN and PRU_ABORT function out of
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


# 1.119 19-May-2014 rmind

- Split off PRU_ATTACH and PRU_DETACH logic into separate functions.
- Replace malloc with kmem and eliminate M_PCB while here.
- Sprinkle more asserts.


Revision tags: rmind-smpnet-nbase rmind-smpnet-base
# 1.118 18-May-2014 rmind

Add struct pr_usrreqs with a pr_generic function and prepare for the
dismantling of pr_usrreq in the protocols; no functional change intended.
PRU_ATTACH/PRU_DETACH changes will follow soon.

Bump for struct protosw. Welcome to 6.99.62!


# 1.117 17-May-2014 rmind

sonewconn: insert the socket into the queue *after* the protocol attach.
This potentially avoids unnecessary race conditions when handling partial
connections.


# 1.116 17-May-2014 rmind

- sonewconn: improve the initialisation order and add some asserts.
- Add various comments describing primitive routines operating on sockets,
clarify connection life-cycle and improve the description of socket queues.
- Sprinkle more asserts.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.115 08-Oct-2013 christos

branches: 1.115.2;
0 -> NULL
MGET -> m_get
No functional change.


# 1.114 15-Sep-2013 martin

Avoid unused variable warnings


# 1.113 29-Aug-2013 rmind

Remove SS_ISCONFIRMING, it is unused and TP4 will not come back.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.112 28-Jun-2013 matt

branches: 1.112.2;
Make sbdrop panic more verbose


# 1.111 27-Jun-2013 christos

Introduce a more general method of sbcreatecontrol, sbcreatecontrol1 that
can take flags (M_WAITOK), and allocate large messages if needed. It also
returns the allocated pointer instead of copying the data to the passed
pointer. Implement sbcreatecontrol() using that.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.110 20-Dec-2011 christos

branches: 1.110.6;
- Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.
- Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis
- Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets.
- Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all
errors?).


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.109 31-Aug-2011 plunky

branches: 1.109.2; 1.109.6;
NULL does not need a cast


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.108 24-Apr-2011 rmind

- Replace few malloc(9) uses with kmem(9).
- Rename buf_malloc() to buf_alloc(), fix comments.
- Remove some unnecessary inclusions.


# 1.107 09-Apr-2011 christos

Preserve SB_ASYNC on the accepted socket. From: Dmitry Matveev
http://mail-index.netbsd.org/tech-net/2011/02/17/msg002457.html


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.106 30-Dec-2009 elad

branches: 1.106.4; 1.106.6;
Don't bother caching egid. It'll be removed soon.


# 1.105 30-Dec-2009 elad

Always use resource limits from the process, as proposed in

http://mail-index.netbsd.org/tech-kern/2009/12/30/msg006756.html

okay christos@.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.104 02-Sep-2009 tls

Add a direction argument to socket upcalls, so they can tell why they've
been called when, for example, they're waiting for space to write. From
Ritesh Agrawal at Coyote Point.


Revision tags: yamt-nfs-mp-base7
# 1.103 24-Jul-2009 christos

check return code from soreserve() (Sean Boudreau)


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 09-Apr-2009 yamt

sonewconn: add an assertion.


Revision tags: nick-hppapmap-base2
# 1.101 21-Jan-2009 yamt

branches: 1.101.2;
restore the pre socket locking patch signal behaviour.
this fixes a busy-loop in nfs_connect.


Revision tags: netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base mjf-devfs2-base
# 1.100 24-Oct-2008 dyoung

branches: 1.100.2; 1.100.4;
Change 'return (expr);' to 'return expr;'. Change (type *)0 to
NULL. No functional change intended.


Revision tags: haad-dm-base1
# 1.99 14-Oct-2008 ad

Accept filters:

- Remove remaining #ifdef INET.
- Avoid holding locks so we don't need to do KM_NOSLEEP allocations.
- Use a rwlock to protect the accept filter list.
- Make it safe to unload accept filter modules.
- Minor KNF.


# 1.98 11-Oct-2008 pooka

Move uidinfo to its own module in kern_uidinfo.c and include in rump.
No functional change to uidinfo.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.97 04-Aug-2008 tls

Add accept filters, ported from FreeBSD by Coyote Point Systems. Add inetd
support for specifying an accept filter for a service (mostly as a usage
example, but it can be handy for other things). Manual pages to follow
in a day or so.

OK core@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 1.96 18-Jun-2008 yamt

branches: 1.96.2;
merge yamt-pf42 branch.
(import newer pf from OpenBSD 4.2)

ok'ed by peter@. requested by core@


Revision tags: yamt-pf42-base4
# 1.95 10-Jun-2008 ad

There can be existing waiters on a socket's condition variables when we
change socket::so_lock, and they rely on the old lock to synchronize.
Wake them up whenever we change so_lock so they can restart their waits.


Revision tags: yamt-pf42-base3
# 1.94 26-May-2008 ad

branches: 1.94.2;
Use pool_cache for sockets.


# 1.93 24-May-2008 christos

Coverity CID 5025: sbreserve is never called with a null socket.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.92 28-Apr-2008 martin

branches: 1.92.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.91 24-Apr-2008 ad

branches: 1.91.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.90 01-Mar-2008 rmind

branches: 1.90.2;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.89 07-Feb-2008 ad

branches: 1.89.2; 1.89.6;
sonewconn: inherit FNONBLOCK from the parent.


# 1.88 29-Jan-2008 yamt

sbreserve: curlwp can't be NULL these days.
XXX these code seems to need an overhaul.


# 1.87 29-Jan-2008 yamt

sbrelease: unwrap a short line.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.86 25-Sep-2007 ad

branches: 1.86.4;
Use selinit() / seldestroy().


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base matt-mips64-base
# 1.85 02-Aug-2007 rmind

branches: 1.85.2; 1.85.4; 1.85.6; 1.85.8;
TCP socket buffers automatic sizing - ported from FreeBSD.
http://mail-index.netbsd.org/tech-net/2007/02/04/0006.html

! Disabled by default, marked as experimental. Testers are very needed.
! Someone should thoroughly test this, and improve if possible.

Discussed on <tech-net>:
http://mail-index.netbsd.org/tech-net/2007/07/12/0002.html
Thanks Greg Troxel for comments.

OK by the long silence on <tech-net>.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.84 04-Jul-2007 tls

branches: 1.84.2;
After looking at FreeBSD 6 again -- we were also failing to copy the
send and receive timeouts. Fix this.


# 1.83 04-Jul-2007 tls

Copy SNDLOWAT and RCVLOWAT socket options to accepted socket, so applications
can rely on all socket options being propagated from the listen socket as
the manual page says (and as everything but Linux has always done). FreeBSD 6
fixes this the same way, but this bug appears elsewhere and is...Old.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.82 04-Mar-2007 christos

branches: 1.82.2; 1.82.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.81 01-Nov-2006 yamt

branches: 1.81.4;
remove some __unused from function parameters.


Revision tags: yamt-splraiseipl-base2
# 1.80 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.79 03-Oct-2006 elad

Back out socket credentials for now, until we figure a better way of
handling the reference counting from interrupt context.


# 1.78 02-Oct-2006 elad

Add credentials to sockets, 'so_cred'.

Brought up on tech-kern@ some ~2 months ago, didn't seem to be an
objection; brought up again recently and no objection either... this is
not too intrusive and I've been running with this for a while.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.77 16-Aug-2006 plunky

branches: 1.77.4;
Fix broken comments - there is no SO_ISCONNECTED or SO_ISCONFIRMING

this fixes kern/32058


# 1.76 16-Aug-2006 plunky

Remove macro call sonewconn() => sonewconn1() as it is no longer necessary.
There are no such calls and the compiler would catch mistakes like this
in any case.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.75 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.74 03-Jul-2006 christos

Make sure we have at least PIPE_BUF bytes available in the socket send buffer.
Review and comment by yamt.


# 1.73 01-Jul-2006 christos

Revert previous change to bump the socket low watermark to sock_loan_thresh.
With sock_loan_thresh=4096, sb_lowat==sb_hiwat, and sowritable will never
be true (even if only a single byte is pending). Some programs (like screen)
expect select() to return that a socket is writable on a socket when there
is space to write to it. XXX: What is the right thing to do here?


Revision tags: yamt-pdpolicy-base6
# 1.72 21-Jun-2006 yamt

bump default so_snd.sb_lowat to increase chance to use loaning.

the idea to tweak the watermark from Jonathan Stone.
reviewed by Bill Studenmund.


Revision tags: chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.71 14-May-2006 elad

branches: 1.71.4;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.70 24-Dec-2005 perry

branches: 1.70.4; 1.70.6; 1.70.8; 1.70.10; 1.70.12;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.69 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.68 29-May-2005 christos

branches: 1.68.2;
- add const.
- remove unnecessary casts.
- add __UNCONST casts and mark them with XXXUNCONST as necessary.


# 1.67 07-May-2005 christos

PR/30154: YAMAMOTO Takashi: tcp_close locking botch
chgsbsize() as mentioned in the PR can be called from an interrupt context
via tcp_close(). Avoid calling uid_find() in chgsbsize().
- Instead of storing so_uid in struct socketvar, store *so_uidinfo
- Add a simple lock to struct uidinfo.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.66 26-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.65 24-Jun-2004 jonathan

branches: 1.65.4; 1.65.6;
Rename MBUFTRACE helper function m_claim() to m_claimm(),
for consistency with M_FREE() and m_freem(). Affected files:

sys/mbuf.h
kern/uipc_socket2.c
kern/uipc_mbuf.c
net/if_ethersubr.c
netatalk/ddp_input.c
nfs/nfs_socket.c


# 1.64 11-Jun-2004 jonathan

Fix potential memory leak in sbappendaddrchain():

We do an MGETHDR)() for each mbuf "packet" of the input chain, to hold
the socket address prepended to that "packet". If those MGETHDR()s
ever failed, we would leak all the successfully-allocated mbuf
headers. Leak noted by Yamamoto-san (yamt@NetBSD.org); thanks for catching it!

Add socketbuf invariant-checking macros to sbappendaddrchain(), and
replace a stray bcopy() with memcpy(), also as suggested by Yamamoto-san.


# 1.63 27-May-2004 jonathan

Rework to make FAST_IPSEC PF_KEY dumps unicast and reliable:

Introduce new socket-layer function sbappendaddrchain() to
sys/kern/uipc_socket2.c: like sbappendaddr(), only takes a chain of
records and appends the entire chain in one pass. sbappendaddrchain()
also takes an `sbprio' argument, which indicates the caller requires
special `reliable' handling of the socket-buffer. `sbprio' is
described in sys/sys/socketvar.h, although (for now) the different
levels are not yet implemented.

Rework sys/netipsec/key.c PF_KEY DUMP responses to build a chain of
mbuf records, one record per dump response. Unicast the entire chain
to the requestor, with all-or-none semantics.

Changed files;
sys/socketvar.h kern/uipc_socket2.c netipsec/key.c
Reviewed by:
Jason Thorpe, Thor Lancelot Simon, post to tech-kern.

Todo: request pullup to 2.0 branch. Post-2.0, rework sysctl() API for
dumps to use new record-chain constructors. Actually implement
the distinct service levels in sbappendaddrchain() so we can use them
to make PF_KEY ACQUIRE messages more reliable.


# 1.62 19-Apr-2004 christos

Charge root for socket buffers without a socket pointer.


# 1.61 18-Apr-2004 matt

Constify the addr parameter to sbappenaddr.


# 1.60 18-Apr-2004 matt

sbreserve can be called with a NULL socket, deal with it.


# 1.59 17-Apr-2004 christos

PR/9347: Eric E. Fair: socket buffer pool exhaustion leads to system deadlock
and unkillable processes.
1. Introduce new SBSIZE resource limit from FreeBSD to limit socket buffer
size resource.
2. make sokvareserve interruptible, so processes ltsleeping on it can be
killed.


Revision tags: netbsd-2-0-base
# 1.58 21-Oct-2003 thorpej

branches: 1.58.2;
Cache the "adjusted" value of sb_max when sb_max is changed, in order
to avoid doing quad math in sbreserve().

Change suggested by Simon Burge, and code inspired by a similar change
in FreeBSD.


# 1.57 22-Sep-2003 christos

- pass signo to fownsignal [ok by jd]
- make urg signal handling use fownsignal
- remove out of band detection in sowakeup


# 1.56 21-Sep-2003 jdolecek

cleanup & uniform descriptor owner handling:
* introduce fsetown(), fgetown(), fownsignal() - this sets/retrieves/signals
the owner of descriptor, according to appropriate sematics
of TIOCSPGRP/FIOSETOWN/SIOCSPGRP/TIOCGPGRP/FIOGETOWN/SIOCGPGRP ioctl; use
these routines instead of custom code where appropriate
* make every place handling TIOCSPGRP/TIOCGPGRP handle also FIOSETOWN/FIOGETOWN
properly, and remove the translation of FIO[SG]OWN to TIOC[SG]PGRP
in sys_ioctl() & sys_fcntl()
* also remove the socket-specific hack in sys_ioctl()/sys_fcntl() and
pass the ioctls down to soo_ioctl() as any other ioctl

change discussed on tech-kern@


# 1.55 06-Sep-2003 christos

SA_SIGINFO changes.


# 1.54 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.53 29-Jun-2003 fvdl

branches: 1.53.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.52 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.51 23-Jun-2003 martin

Make sure to include opt_foo.h if a defflag option FOO is used.


# 1.50 17-Apr-2003 fvdl

A bit of an ugly workaround to avoid a warning for a larger MSIZE.
Shouldn't make a difference in the generated code.


# 1.49 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge
# 1.48 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.47 27-Sep-2002 provos

remove trailing \n in panic(). approved perry.


Revision tags: gehenna-devsw-base
# 1.46 22-Aug-2002 thorpej

In sbcompress(), if we toss an empty mbuf, make sure to update
sb_lastrecord if necessary.

From Daniel Hartmeier <daniel@benzedrine.cx>.


# 1.45 03-Jul-2002 thorpej

Rename SB_UPDATE_TAIL() to SB_EMPTY_FIXUP(), per suggestion from
Jonathan Stone.


# 1.44 03-Jul-2002 thorpej

Rename sbappend_stream() to sbappendstream(), per suggestion from
Jonathan Stone.


# 1.43 03-Jul-2002 thorpej

Make insertion of data into socket buffers O(C):
* Keep pointers to the first and last mbufs of the last record in the
socket buffer.
* Use the sb_lastrecord pointer in the sbappend*() family of functions
to avoid traversing the packet chain to find the last record.
* Add a new sbappend_stream() function for stream protocols which
guarantee that there will never be more than one record in the
socket buffer. This function uses the sb_mbtail pointer to perform
the data insertion. Make TCP use sbappend_stream().

On a profiling run, this makes sbappend of a TCP transmission using
a 1M socket buffer go from 50% of the time to .02% of the time.

Thanks to Bill Sommerfeld and YAMAMOTO Takashi for their debugging
assistance!


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base thorpej-mips-cache-base
# 1.42 12-Nov-2001 lukem

branches: 1.42.8;
add RCSIDs


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 05-Aug-2001 enami

branches: 1.41.4;
Give different names for different wait channels.

# and minor knf fix while I'm here.


# 1.40 27-Jul-2001 thorpej

Now that M_TRAILINGSPACE() checks buffer writeability properly,
we can greatly simplify sbcompress(). Slightly modified from
a similar change in FreeBSD.


# 1.39 16-Jun-2001 manu

branches: 1.39.2;
Use SB_ASYNC in struct sockbuf sb_flags field instead of SS_ASYNC in
struct socket so_state field to decide if we need to send asynchronous
notifications. This makes possible to request notification on write but
not on read, and vice versa.

This is used in Linux emulation code, because when async I/O is requested,
Linux does not send SIGIO to write end of sockets, and it never send any
SIGIO to any end of pipes. Il Linux emulation code, we then set SB_ASYNC
only on the read end of sockets, and on no end for pipes.


# 1.38 30-Apr-2001 kml

Large values of sb_max would cause an overflow in sbreserve(); cast to
u_quad_t to avoid this. (from FreeBSD uipc_socket2.c v1.19)


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.37 27-Feb-2001 lukem

branches: 1.37.2;
convert to ANSI KNF


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 30-Mar-2000 augustss

Get rid of register declarations.


# 1.35 29-Feb-2000 itojun

more fix to ancillary data alignment. we need padding after
last cmsg_data item (see the figure on RFC2292 page 18).


# 1.34 18-Feb-2000 itojun

fix alignment problem in ancillary messages (alpha).

the change constitutes binary compatibility issue hen sizeof(long) !=4.
there's no way to be backward compatible, and only guys affected
are IPv6 userland tools.

From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base
# 1.33 04-Aug-1999 mycroft

branches: 1.33.2;
The old compaction test had an off-by-one error that caused it to not compact
in some cases where it could have. Fix this, and the new version as well.


# 1.32 04-Aug-1999 matt

Don't compress mbuf clusters which are referenced by multiple
mbufs since you might overwriting valuable data. (think of
m_copy'ed data from a TCP re-transmission queue. Since those
might be in clusters and referenced in two sockets).


# 1.31 04-Aug-1999 mycroft

It's now possible for sbcompress() to compact mbuf clusters, so do it.
This helps prevent mbuf cluster exhaustion when receiving lots of small
packets.


Revision tags: chs-ubc2-base
# 1.30 01-Jul-1999 itojun

IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.


# 1.29 22-Apr-1999 simonb

Move inclusion of "opt_sb_max.h" from sys/socketvar.h to
conf/param.c, and move the initialisation of the sb_max
variable from kern/uipc_socket2.c to conf/param.c. Now
everthing that includes sys/socketvar.h doesn't get
recompiled when SB_MAX's value changes.


Revision tags: netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.28 23-Mar-1999 lukem

branches: 1.28.2; 1.28.4; 1.28.6;
Ensure that you can only bind a more specific address when it is done by the
same uid or by root.

This code is from FreeBSD. (Whilst it was originally obtained from OpenBSD,
FreeBSD fixed it to work with multicast. To quote the commit message:
- Don't bother checking for conflicting sockets if we're binding to a
multicast address.
- Don't return an error if we're binding to INADDR_ANY, the conflicting
socket is bound to INADDR_ANY, and the conflicting socket has
SO_REUSEPORT set.
)


# 1.27 20-Jan-1999 mycroft

Do not remove sockets from the accept(2) queue on close.


Revision tags: kenh-if-detach-base chs-ubc-base
# 1.26 04-Aug-1998 perry

Abolition of bcopy, ovbcopy, bcmp, and bzero, phase one.
bcopy(x, y, z) -> memcpy(y, x, z)
ovbcopy(x, y, z) -> memmove(y, x, z)
bcmp(x, y, z) -> memcmp(x, y, z)
bzero(x, y) -> memset(x, 0, y)


# 1.25 02-Aug-1998 thorpej

Use the pool allocator for sockets.


Revision tags: eeh-paddr_t-base
# 1.24 25-Apr-1998 matt

Hook for 0-copy (or other optimized) sends and receives


# 1.23 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.22 07-Jan-1998 thorpej

Make insertion and removal of sockets from the partial and incoming
connections queues O(C) rather than O(N).


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base marc-pcmcia-base
# 1.21 09-Oct-1997 mycroft

branches: 1.21.2;
Make various standard wmesg strings const.


Revision tags: thorpej-signal-base marc-pcmcia-bp SYN_cache_cur_base
# 1.20 26-Jun-1997 thorpej

branches: 1.20.4;
In sbappendaddr(), if the sockaddr length is larger than will fit in
an mbuf, allocate enough external storage to hold the sockaddr. Thanks
to enami tsugutomo <enami@cv.sony.co.jp> for providing sanity-checks.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.19 11-Jan-1997 thorpej

branches: 1.19.8;
Implement sbcreatecontrol(), a generic function to create a "control"
mbuf for presentation on a socket buffer.


# 1.18 09-Dec-1996 thorpej

In sbreserve(), don't allow a count of 0. Fixes PR #2794, from
Erik Berls <cyber@dis.org>.


# 1.17 26-Nov-1996 thorpej

Back out previous soqinsque() and soqremque() changes. This will
stop the panics until the socket queues get converted to <sys/queue.h>.


# 1.16 10-Nov-1996 thorpej

Optimization of soqinsque() and soqremque():

Keep queue of pending sockets in a double linked list. Previously,
a singly linked list was used, giving O(N) insertion/deletion times,
and was a major time consumer for sockets with large pending queues.
The double linked list give O(C) insertion/deletion times with only
a small cost in complexity.

Since a socket can be on, at most, one queue at a time, both so_q and
so_q0 can safely be used as (forward and backward, respectively) queue
pointers.

Submitted my Matt Thomas <matt@3am-software.com>, a long time ago.
(Geez, I've been running with this patch for _months_, and had completely
forgotten about it!)


# 1.15 13-Oct-1996 christos

backout previous kprintf change


# 1.14 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.13 07-Sep-1996 mycroft

Implement poll(2).


# 1.12 22-May-1996 mycroft

Pass a proc pointer down to the usrreq and pcbbind functions for PRU_ATTACH, PRU_BIND and
PRU_CONTROL. The usrreq interface really needs to be split up, but this will have to wait.
Remove SS_PRIV completely.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.11 04-Feb-1996 christos

branches: 1.11.4;
First pass at prototyping


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.10 16-Aug-1995 mycroft

Access rights are now stored in MT_CONTROL mbufs. Document this.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.9 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.8 13-May-1994 mycroft

Update to 4.4-Lite networking code, with a few local changes.


# 1.7 04-May-1994 mycroft

More return types...


# 1.6 25-Apr-1994 mycroft

Remove sbselqueue().


# 1.5 18-Dec-1993 mycroft

Canonicalize all #includes.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 27-Jun-1993 andrew

branches: 1.4.4;
ANSIfications - removed all implicit function return types and argument
definitions. Ensured that all files include "systm.h" to gain access to
general prototypes. Casts where necessary.


# 1.3 18-May-1993 cgd

make kernel select interface be one-stop shopping & clean it all up.


Revision tags: netbsd-0-8 netbsd-alpha-1 patchkit-0-2-2
# 1.2 21-Mar-1993 cgd

after 0.2.2 "stable" patches applied


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.138 26-Aug-2020 christos

add socket info for user and group for unix sockets in fstat.


# 1.137 23-May-2020 ad

Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.136 01-Feb-2020 riastradh

Load struct fdfile::ff_file with atomic_load_consume.

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.)


# 1.135 01-Feb-2020 riastradh

Load struct filedesc::fd_dt with atomic_load_consume.

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.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.134 11-Jul-2019 maxv

branches: 1.134.4;
Fix info leaks: the alignment of the structures causes uninitialized heap
memory to be copied to userland in sys_recvmsg().


Revision tags: phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.133 04-Nov-2018 christos

- Introduce a new SO_RERROR socket option to explicitly turn on
receive overflow errors re-instating the default behavior to
silently ignore them as before 2018-03-19.
- Introduce a new kern.sooptions sysctl to control the default
behavior of socket options. Setting this to 0x4000 (SO_RERROR),
turns on receive overflow error reporting for all sockets.
- Change dhcpcd to turn on SO_RERROR on all its sockets.

As discussed in tech-net.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.132 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: pgoyette-compat-0728
# 1.131 20-Jul-2018 msaitoh

Add "show socket" command written by Hiroki SUENAGA. It prints usage of
system's socket buffers.


Revision tags: phil-wifi-base pgoyette-compat-0625
# 1.130 06-Jun-2018 roy

branches: 1.130.2;
Separate receive socket errors from general socket errors.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502
# 1.129 29-Apr-2018 maxv

Remove references to m_copy in comments.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.128 19-Mar-2018 roy

socket: report receive buffer overflows

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.


# 1.127 18-Mar-2018 christos

- Convert sb_lowat to unsigned for consistency. There are no negative value
uses
- Check for overflow as mentioned in the comment
- Sprinkle const


Revision tags: pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.126 06-Jul-2017 christos

branches: 1.126.4;
move the timestamp stuff to uipc_socket.c because it already has the compat
includes.


# 1.125 06-Jul-2017 christos

Merge the two copies SO_TIMESTAMP/SO_OTIMESTAMP processing to a single
function, and add a SOOPT_TIMESTAMP define reducing compat pollution from
5 places to 1.


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.124 02-Oct-2016 christos

branches: 1.124.8;
more MFREE -> m_free


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.123 23-May-2016 tls

branches: 1.123.2;
Fix a longstanding problem with accept filters noticed by Timo Buhrmester:
sockets sitting in the accept filter can consume the entire listen queue,
such that the application is never able to handle any connections. Handle
this by simply passing through the oldest queued cxn when the queue is full.

This is fair because the longer a cxn lingers in the queue (stays connected
but does not meet the requirements of the filter for passage) the more likely
it is to be passed through, at which point the application can dispose of it.

Works because none of our accept filters actually allocate private state
per-cxn. If they did, we'd have to fix the API bug that there is presently
no way to tell an accf to finish/deallocate for a single cxn (accf_destroy
kills off the entire filter instance for a given listen socket).


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.122 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.121 05-Sep-2014 matt

branches: 1.121.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.120 31-Jul-2014 rtr

split PRU_DISCONNECT, PRU_SHUTDOWN and PRU_ABORT function out of
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


# 1.119 19-May-2014 rmind

- Split off PRU_ATTACH and PRU_DETACH logic into separate functions.
- Replace malloc with kmem and eliminate M_PCB while here.
- Sprinkle more asserts.


Revision tags: rmind-smpnet-nbase rmind-smpnet-base
# 1.118 18-May-2014 rmind

Add struct pr_usrreqs with a pr_generic function and prepare for the
dismantling of pr_usrreq in the protocols; no functional change intended.
PRU_ATTACH/PRU_DETACH changes will follow soon.

Bump for struct protosw. Welcome to 6.99.62!


# 1.117 17-May-2014 rmind

sonewconn: insert the socket into the queue *after* the protocol attach.
This potentially avoids unnecessary race conditions when handling partial
connections.


# 1.116 17-May-2014 rmind

- sonewconn: improve the initialisation order and add some asserts.
- Add various comments describing primitive routines operating on sockets,
clarify connection life-cycle and improve the description of socket queues.
- Sprinkle more asserts.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.115 08-Oct-2013 christos

branches: 1.115.2;
0 -> NULL
MGET -> m_get
No functional change.


# 1.114 15-Sep-2013 martin

Avoid unused variable warnings


# 1.113 29-Aug-2013 rmind

Remove SS_ISCONFIRMING, it is unused and TP4 will not come back.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.112 28-Jun-2013 matt

branches: 1.112.2;
Make sbdrop panic more verbose


# 1.111 27-Jun-2013 christos

Introduce a more general method of sbcreatecontrol, sbcreatecontrol1 that
can take flags (M_WAITOK), and allocate large messages if needed. It also
returns the allocated pointer instead of copying the data to the passed
pointer. Implement sbcreatecontrol() using that.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.110 20-Dec-2011 christos

branches: 1.110.6;
- Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.
- Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis
- Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets.
- Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all
errors?).


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.109 31-Aug-2011 plunky

branches: 1.109.2; 1.109.6;
NULL does not need a cast


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.108 24-Apr-2011 rmind

- Replace few malloc(9) uses with kmem(9).
- Rename buf_malloc() to buf_alloc(), fix comments.
- Remove some unnecessary inclusions.


# 1.107 09-Apr-2011 christos

Preserve SB_ASYNC on the accepted socket. From: Dmitry Matveev
http://mail-index.netbsd.org/tech-net/2011/02/17/msg002457.html


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.106 30-Dec-2009 elad

branches: 1.106.4; 1.106.6;
Don't bother caching egid. It'll be removed soon.


# 1.105 30-Dec-2009 elad

Always use resource limits from the process, as proposed in

http://mail-index.netbsd.org/tech-kern/2009/12/30/msg006756.html

okay christos@.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.104 02-Sep-2009 tls

Add a direction argument to socket upcalls, so they can tell why they've
been called when, for example, they're waiting for space to write. From
Ritesh Agrawal at Coyote Point.


Revision tags: yamt-nfs-mp-base7
# 1.103 24-Jul-2009 christos

check return code from soreserve() (Sean Boudreau)


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 09-Apr-2009 yamt

sonewconn: add an assertion.


Revision tags: nick-hppapmap-base2
# 1.101 21-Jan-2009 yamt

branches: 1.101.2;
restore the pre socket locking patch signal behaviour.
this fixes a busy-loop in nfs_connect.


Revision tags: netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base mjf-devfs2-base
# 1.100 24-Oct-2008 dyoung

branches: 1.100.2; 1.100.4;
Change 'return (expr);' to 'return expr;'. Change (type *)0 to
NULL. No functional change intended.


Revision tags: haad-dm-base1
# 1.99 14-Oct-2008 ad

Accept filters:

- Remove remaining #ifdef INET.
- Avoid holding locks so we don't need to do KM_NOSLEEP allocations.
- Use a rwlock to protect the accept filter list.
- Make it safe to unload accept filter modules.
- Minor KNF.


# 1.98 11-Oct-2008 pooka

Move uidinfo to its own module in kern_uidinfo.c and include in rump.
No functional change to uidinfo.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.97 04-Aug-2008 tls

Add accept filters, ported from FreeBSD by Coyote Point Systems. Add inetd
support for specifying an accept filter for a service (mostly as a usage
example, but it can be handy for other things). Manual pages to follow
in a day or so.

OK core@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 1.96 18-Jun-2008 yamt

branches: 1.96.2;
merge yamt-pf42 branch.
(import newer pf from OpenBSD 4.2)

ok'ed by peter@. requested by core@


Revision tags: yamt-pf42-base4
# 1.95 10-Jun-2008 ad

There can be existing waiters on a socket's condition variables when we
change socket::so_lock, and they rely on the old lock to synchronize.
Wake them up whenever we change so_lock so they can restart their waits.


Revision tags: yamt-pf42-base3
# 1.94 26-May-2008 ad

branches: 1.94.2;
Use pool_cache for sockets.


# 1.93 24-May-2008 christos

Coverity CID 5025: sbreserve is never called with a null socket.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.92 28-Apr-2008 martin

branches: 1.92.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.91 24-Apr-2008 ad

branches: 1.91.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.90 01-Mar-2008 rmind

branches: 1.90.2;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.89 07-Feb-2008 ad

branches: 1.89.2; 1.89.6;
sonewconn: inherit FNONBLOCK from the parent.


# 1.88 29-Jan-2008 yamt

sbreserve: curlwp can't be NULL these days.
XXX these code seems to need an overhaul.


# 1.87 29-Jan-2008 yamt

sbrelease: unwrap a short line.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.86 25-Sep-2007 ad

branches: 1.86.4;
Use selinit() / seldestroy().


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base matt-mips64-base
# 1.85 02-Aug-2007 rmind

branches: 1.85.2; 1.85.4; 1.85.6; 1.85.8;
TCP socket buffers automatic sizing - ported from FreeBSD.
http://mail-index.netbsd.org/tech-net/2007/02/04/0006.html

! Disabled by default, marked as experimental. Testers are very needed.
! Someone should thoroughly test this, and improve if possible.

Discussed on <tech-net>:
http://mail-index.netbsd.org/tech-net/2007/07/12/0002.html
Thanks Greg Troxel for comments.

OK by the long silence on <tech-net>.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.84 04-Jul-2007 tls

branches: 1.84.2;
After looking at FreeBSD 6 again -- we were also failing to copy the
send and receive timeouts. Fix this.


# 1.83 04-Jul-2007 tls

Copy SNDLOWAT and RCVLOWAT socket options to accepted socket, so applications
can rely on all socket options being propagated from the listen socket as
the manual page says (and as everything but Linux has always done). FreeBSD 6
fixes this the same way, but this bug appears elsewhere and is...Old.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.82 04-Mar-2007 christos

branches: 1.82.2; 1.82.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.81 01-Nov-2006 yamt

branches: 1.81.4;
remove some __unused from function parameters.


Revision tags: yamt-splraiseipl-base2
# 1.80 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.79 03-Oct-2006 elad

Back out socket credentials for now, until we figure a better way of
handling the reference counting from interrupt context.


# 1.78 02-Oct-2006 elad

Add credentials to sockets, 'so_cred'.

Brought up on tech-kern@ some ~2 months ago, didn't seem to be an
objection; brought up again recently and no objection either... this is
not too intrusive and I've been running with this for a while.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.77 16-Aug-2006 plunky

branches: 1.77.4;
Fix broken comments - there is no SO_ISCONNECTED or SO_ISCONFIRMING

this fixes kern/32058


# 1.76 16-Aug-2006 plunky

Remove macro call sonewconn() => sonewconn1() as it is no longer necessary.
There are no such calls and the compiler would catch mistakes like this
in any case.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.75 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.74 03-Jul-2006 christos

Make sure we have at least PIPE_BUF bytes available in the socket send buffer.
Review and comment by yamt.


# 1.73 01-Jul-2006 christos

Revert previous change to bump the socket low watermark to sock_loan_thresh.
With sock_loan_thresh=4096, sb_lowat==sb_hiwat, and sowritable will never
be true (even if only a single byte is pending). Some programs (like screen)
expect select() to return that a socket is writable on a socket when there
is space to write to it. XXX: What is the right thing to do here?


Revision tags: yamt-pdpolicy-base6
# 1.72 21-Jun-2006 yamt

bump default so_snd.sb_lowat to increase chance to use loaning.

the idea to tweak the watermark from Jonathan Stone.
reviewed by Bill Studenmund.


Revision tags: chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.71 14-May-2006 elad

branches: 1.71.4;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.70 24-Dec-2005 perry

branches: 1.70.4; 1.70.6; 1.70.8; 1.70.10; 1.70.12;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.69 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.68 29-May-2005 christos

branches: 1.68.2;
- add const.
- remove unnecessary casts.
- add __UNCONST casts and mark them with XXXUNCONST as necessary.


# 1.67 07-May-2005 christos

PR/30154: YAMAMOTO Takashi: tcp_close locking botch
chgsbsize() as mentioned in the PR can be called from an interrupt context
via tcp_close(). Avoid calling uid_find() in chgsbsize().
- Instead of storing so_uid in struct socketvar, store *so_uidinfo
- Add a simple lock to struct uidinfo.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.66 26-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.65 24-Jun-2004 jonathan

branches: 1.65.4; 1.65.6;
Rename MBUFTRACE helper function m_claim() to m_claimm(),
for consistency with M_FREE() and m_freem(). Affected files:

sys/mbuf.h
kern/uipc_socket2.c
kern/uipc_mbuf.c
net/if_ethersubr.c
netatalk/ddp_input.c
nfs/nfs_socket.c


# 1.64 11-Jun-2004 jonathan

Fix potential memory leak in sbappendaddrchain():

We do an MGETHDR)() for each mbuf "packet" of the input chain, to hold
the socket address prepended to that "packet". If those MGETHDR()s
ever failed, we would leak all the successfully-allocated mbuf
headers. Leak noted by Yamamoto-san (yamt@NetBSD.org); thanks for catching it!

Add socketbuf invariant-checking macros to sbappendaddrchain(), and
replace a stray bcopy() with memcpy(), also as suggested by Yamamoto-san.


# 1.63 27-May-2004 jonathan

Rework to make FAST_IPSEC PF_KEY dumps unicast and reliable:

Introduce new socket-layer function sbappendaddrchain() to
sys/kern/uipc_socket2.c: like sbappendaddr(), only takes a chain of
records and appends the entire chain in one pass. sbappendaddrchain()
also takes an `sbprio' argument, which indicates the caller requires
special `reliable' handling of the socket-buffer. `sbprio' is
described in sys/sys/socketvar.h, although (for now) the different
levels are not yet implemented.

Rework sys/netipsec/key.c PF_KEY DUMP responses to build a chain of
mbuf records, one record per dump response. Unicast the entire chain
to the requestor, with all-or-none semantics.

Changed files;
sys/socketvar.h kern/uipc_socket2.c netipsec/key.c
Reviewed by:
Jason Thorpe, Thor Lancelot Simon, post to tech-kern.

Todo: request pullup to 2.0 branch. Post-2.0, rework sysctl() API for
dumps to use new record-chain constructors. Actually implement
the distinct service levels in sbappendaddrchain() so we can use them
to make PF_KEY ACQUIRE messages more reliable.


# 1.62 19-Apr-2004 christos

Charge root for socket buffers without a socket pointer.


# 1.61 18-Apr-2004 matt

Constify the addr parameter to sbappenaddr.


# 1.60 18-Apr-2004 matt

sbreserve can be called with a NULL socket, deal with it.


# 1.59 17-Apr-2004 christos

PR/9347: Eric E. Fair: socket buffer pool exhaustion leads to system deadlock
and unkillable processes.
1. Introduce new SBSIZE resource limit from FreeBSD to limit socket buffer
size resource.
2. make sokvareserve interruptible, so processes ltsleeping on it can be
killed.


Revision tags: netbsd-2-0-base
# 1.58 21-Oct-2003 thorpej

branches: 1.58.2;
Cache the "adjusted" value of sb_max when sb_max is changed, in order
to avoid doing quad math in sbreserve().

Change suggested by Simon Burge, and code inspired by a similar change
in FreeBSD.


# 1.57 22-Sep-2003 christos

- pass signo to fownsignal [ok by jd]
- make urg signal handling use fownsignal
- remove out of band detection in sowakeup


# 1.56 21-Sep-2003 jdolecek

cleanup & uniform descriptor owner handling:
* introduce fsetown(), fgetown(), fownsignal() - this sets/retrieves/signals
the owner of descriptor, according to appropriate sematics
of TIOCSPGRP/FIOSETOWN/SIOCSPGRP/TIOCGPGRP/FIOGETOWN/SIOCGPGRP ioctl; use
these routines instead of custom code where appropriate
* make every place handling TIOCSPGRP/TIOCGPGRP handle also FIOSETOWN/FIOGETOWN
properly, and remove the translation of FIO[SG]OWN to TIOC[SG]PGRP
in sys_ioctl() & sys_fcntl()
* also remove the socket-specific hack in sys_ioctl()/sys_fcntl() and
pass the ioctls down to soo_ioctl() as any other ioctl

change discussed on tech-kern@


# 1.55 06-Sep-2003 christos

SA_SIGINFO changes.


# 1.54 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.53 29-Jun-2003 fvdl

branches: 1.53.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.52 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.51 23-Jun-2003 martin

Make sure to include opt_foo.h if a defflag option FOO is used.


# 1.50 17-Apr-2003 fvdl

A bit of an ugly workaround to avoid a warning for a larger MSIZE.
Shouldn't make a difference in the generated code.


# 1.49 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge
# 1.48 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.47 27-Sep-2002 provos

remove trailing \n in panic(). approved perry.


Revision tags: gehenna-devsw-base
# 1.46 22-Aug-2002 thorpej

In sbcompress(), if we toss an empty mbuf, make sure to update
sb_lastrecord if necessary.

From Daniel Hartmeier <daniel@benzedrine.cx>.


# 1.45 03-Jul-2002 thorpej

Rename SB_UPDATE_TAIL() to SB_EMPTY_FIXUP(), per suggestion from
Jonathan Stone.


# 1.44 03-Jul-2002 thorpej

Rename sbappend_stream() to sbappendstream(), per suggestion from
Jonathan Stone.


# 1.43 03-Jul-2002 thorpej

Make insertion of data into socket buffers O(C):
* Keep pointers to the first and last mbufs of the last record in the
socket buffer.
* Use the sb_lastrecord pointer in the sbappend*() family of functions
to avoid traversing the packet chain to find the last record.
* Add a new sbappend_stream() function for stream protocols which
guarantee that there will never be more than one record in the
socket buffer. This function uses the sb_mbtail pointer to perform
the data insertion. Make TCP use sbappend_stream().

On a profiling run, this makes sbappend of a TCP transmission using
a 1M socket buffer go from 50% of the time to .02% of the time.

Thanks to Bill Sommerfeld and YAMAMOTO Takashi for their debugging
assistance!


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base thorpej-mips-cache-base
# 1.42 12-Nov-2001 lukem

branches: 1.42.8;
add RCSIDs


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 05-Aug-2001 enami

branches: 1.41.4;
Give different names for different wait channels.

# and minor knf fix while I'm here.


# 1.40 27-Jul-2001 thorpej

Now that M_TRAILINGSPACE() checks buffer writeability properly,
we can greatly simplify sbcompress(). Slightly modified from
a similar change in FreeBSD.


# 1.39 16-Jun-2001 manu

branches: 1.39.2;
Use SB_ASYNC in struct sockbuf sb_flags field instead of SS_ASYNC in
struct socket so_state field to decide if we need to send asynchronous
notifications. This makes possible to request notification on write but
not on read, and vice versa.

This is used in Linux emulation code, because when async I/O is requested,
Linux does not send SIGIO to write end of sockets, and it never send any
SIGIO to any end of pipes. Il Linux emulation code, we then set SB_ASYNC
only on the read end of sockets, and on no end for pipes.


# 1.38 30-Apr-2001 kml

Large values of sb_max would cause an overflow in sbreserve(); cast to
u_quad_t to avoid this. (from FreeBSD uipc_socket2.c v1.19)


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.37 27-Feb-2001 lukem

branches: 1.37.2;
convert to ANSI KNF


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 30-Mar-2000 augustss

Get rid of register declarations.


# 1.35 29-Feb-2000 itojun

more fix to ancillary data alignment. we need padding after
last cmsg_data item (see the figure on RFC2292 page 18).


# 1.34 18-Feb-2000 itojun

fix alignment problem in ancillary messages (alpha).

the change constitutes binary compatibility issue hen sizeof(long) !=4.
there's no way to be backward compatible, and only guys affected
are IPv6 userland tools.

From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base
# 1.33 04-Aug-1999 mycroft

branches: 1.33.2;
The old compaction test had an off-by-one error that caused it to not compact
in some cases where it could have. Fix this, and the new version as well.


# 1.32 04-Aug-1999 matt

Don't compress mbuf clusters which are referenced by multiple
mbufs since you might overwriting valuable data. (think of
m_copy'ed data from a TCP re-transmission queue. Since those
might be in clusters and referenced in two sockets).


# 1.31 04-Aug-1999 mycroft

It's now possible for sbcompress() to compact mbuf clusters, so do it.
This helps prevent mbuf cluster exhaustion when receiving lots of small
packets.


Revision tags: chs-ubc2-base
# 1.30 01-Jul-1999 itojun

IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.


# 1.29 22-Apr-1999 simonb

Move inclusion of "opt_sb_max.h" from sys/socketvar.h to
conf/param.c, and move the initialisation of the sb_max
variable from kern/uipc_socket2.c to conf/param.c. Now
everthing that includes sys/socketvar.h doesn't get
recompiled when SB_MAX's value changes.


Revision tags: netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.28 23-Mar-1999 lukem

branches: 1.28.2; 1.28.4; 1.28.6;
Ensure that you can only bind a more specific address when it is done by the
same uid or by root.

This code is from FreeBSD. (Whilst it was originally obtained from OpenBSD,
FreeBSD fixed it to work with multicast. To quote the commit message:
- Don't bother checking for conflicting sockets if we're binding to a
multicast address.
- Don't return an error if we're binding to INADDR_ANY, the conflicting
socket is bound to INADDR_ANY, and the conflicting socket has
SO_REUSEPORT set.
)


# 1.27 20-Jan-1999 mycroft

Do not remove sockets from the accept(2) queue on close.


Revision tags: kenh-if-detach-base chs-ubc-base
# 1.26 04-Aug-1998 perry

Abolition of bcopy, ovbcopy, bcmp, and bzero, phase one.
bcopy(x, y, z) -> memcpy(y, x, z)
ovbcopy(x, y, z) -> memmove(y, x, z)
bcmp(x, y, z) -> memcmp(x, y, z)
bzero(x, y) -> memset(x, 0, y)


# 1.25 02-Aug-1998 thorpej

Use the pool allocator for sockets.


Revision tags: eeh-paddr_t-base
# 1.24 25-Apr-1998 matt

Hook for 0-copy (or other optimized) sends and receives


# 1.23 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.22 07-Jan-1998 thorpej

Make insertion and removal of sockets from the partial and incoming
connections queues O(C) rather than O(N).


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base marc-pcmcia-base
# 1.21 09-Oct-1997 mycroft

branches: 1.21.2;
Make various standard wmesg strings const.


Revision tags: thorpej-signal-base marc-pcmcia-bp SYN_cache_cur_base
# 1.20 26-Jun-1997 thorpej

branches: 1.20.4;
In sbappendaddr(), if the sockaddr length is larger than will fit in
an mbuf, allocate enough external storage to hold the sockaddr. Thanks
to enami tsugutomo <enami@cv.sony.co.jp> for providing sanity-checks.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.19 11-Jan-1997 thorpej

branches: 1.19.8;
Implement sbcreatecontrol(), a generic function to create a "control"
mbuf for presentation on a socket buffer.


# 1.18 09-Dec-1996 thorpej

In sbreserve(), don't allow a count of 0. Fixes PR #2794, from
Erik Berls <cyber@dis.org>.


# 1.17 26-Nov-1996 thorpej

Back out previous soqinsque() and soqremque() changes. This will
stop the panics until the socket queues get converted to <sys/queue.h>.


# 1.16 10-Nov-1996 thorpej

Optimization of soqinsque() and soqremque():

Keep queue of pending sockets in a double linked list. Previously,
a singly linked list was used, giving O(N) insertion/deletion times,
and was a major time consumer for sockets with large pending queues.
The double linked list give O(C) insertion/deletion times with only
a small cost in complexity.

Since a socket can be on, at most, one queue at a time, both so_q and
so_q0 can safely be used as (forward and backward, respectively) queue
pointers.

Submitted my Matt Thomas <matt@3am-software.com>, a long time ago.
(Geez, I've been running with this patch for _months_, and had completely
forgotten about it!)


# 1.15 13-Oct-1996 christos

backout previous kprintf change


# 1.14 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.13 07-Sep-1996 mycroft

Implement poll(2).


# 1.12 22-May-1996 mycroft

Pass a proc pointer down to the usrreq and pcbbind functions for PRU_ATTACH, PRU_BIND and
PRU_CONTROL. The usrreq interface really needs to be split up, but this will have to wait.
Remove SS_PRIV completely.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.11 04-Feb-1996 christos

branches: 1.11.4;
First pass at prototyping


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.10 16-Aug-1995 mycroft

Access rights are now stored in MT_CONTROL mbufs. Document this.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.9 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.8 13-May-1994 mycroft

Update to 4.4-Lite networking code, with a few local changes.


# 1.7 04-May-1994 mycroft

More return types...


# 1.6 25-Apr-1994 mycroft

Remove sbselqueue().


# 1.5 18-Dec-1993 mycroft

Canonicalize all #includes.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 27-Jun-1993 andrew

branches: 1.4.4;
ANSIfications - removed all implicit function return types and argument
definitions. Ensured that all files include "systm.h" to gain access to
general prototypes. Casts where necessary.


# 1.3 18-May-1993 cgd

make kernel select interface be one-stop shopping & clean it all up.


Revision tags: netbsd-0-8 netbsd-alpha-1 patchkit-0-2-2
# 1.2 21-Mar-1993 cgd

after 0.2.2 "stable" patches applied


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.137 23-May-2020 ad

Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.


Revision tags: bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.136 01-Feb-2020 riastradh

Load struct fdfile::ff_file with atomic_load_consume.

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.)


# 1.135 01-Feb-2020 riastradh

Load struct filedesc::fd_dt with atomic_load_consume.

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.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.134 11-Jul-2019 maxv

branches: 1.134.4;
Fix info leaks: the alignment of the structures causes uninitialized heap
memory to be copied to userland in sys_recvmsg().


Revision tags: phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.133 04-Nov-2018 christos

- Introduce a new SO_RERROR socket option to explicitly turn on
receive overflow errors re-instating the default behavior to
silently ignore them as before 2018-03-19.
- Introduce a new kern.sooptions sysctl to control the default
behavior of socket options. Setting this to 0x4000 (SO_RERROR),
turns on receive overflow error reporting for all sockets.
- Change dhcpcd to turn on SO_RERROR on all its sockets.

As discussed in tech-net.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.132 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: pgoyette-compat-0728
# 1.131 20-Jul-2018 msaitoh

Add "show socket" command written by Hiroki SUENAGA. It prints usage of
system's socket buffers.


Revision tags: phil-wifi-base pgoyette-compat-0625
# 1.130 06-Jun-2018 roy

branches: 1.130.2;
Separate receive socket errors from general socket errors.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502
# 1.129 29-Apr-2018 maxv

Remove references to m_copy in comments.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.128 19-Mar-2018 roy

socket: report receive buffer overflows

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.


# 1.127 18-Mar-2018 christos

- Convert sb_lowat to unsigned for consistency. There are no negative value
uses
- Check for overflow as mentioned in the comment
- Sprinkle const


Revision tags: pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.126 06-Jul-2017 christos

branches: 1.126.4;
move the timestamp stuff to uipc_socket.c because it already has the compat
includes.


# 1.125 06-Jul-2017 christos

Merge the two copies SO_TIMESTAMP/SO_OTIMESTAMP processing to a single
function, and add a SOOPT_TIMESTAMP define reducing compat pollution from
5 places to 1.


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.124 02-Oct-2016 christos

branches: 1.124.8;
more MFREE -> m_free


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.123 23-May-2016 tls

branches: 1.123.2;
Fix a longstanding problem with accept filters noticed by Timo Buhrmester:
sockets sitting in the accept filter can consume the entire listen queue,
such that the application is never able to handle any connections. Handle
this by simply passing through the oldest queued cxn when the queue is full.

This is fair because the longer a cxn lingers in the queue (stays connected
but does not meet the requirements of the filter for passage) the more likely
it is to be passed through, at which point the application can dispose of it.

Works because none of our accept filters actually allocate private state
per-cxn. If they did, we'd have to fix the API bug that there is presently
no way to tell an accf to finish/deallocate for a single cxn (accf_destroy
kills off the entire filter instance for a given listen socket).


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.122 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.121 05-Sep-2014 matt

branches: 1.121.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.120 31-Jul-2014 rtr

split PRU_DISCONNECT, PRU_SHUTDOWN and PRU_ABORT function out of
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


# 1.119 19-May-2014 rmind

- Split off PRU_ATTACH and PRU_DETACH logic into separate functions.
- Replace malloc with kmem and eliminate M_PCB while here.
- Sprinkle more asserts.


Revision tags: rmind-smpnet-nbase rmind-smpnet-base
# 1.118 18-May-2014 rmind

Add struct pr_usrreqs with a pr_generic function and prepare for the
dismantling of pr_usrreq in the protocols; no functional change intended.
PRU_ATTACH/PRU_DETACH changes will follow soon.

Bump for struct protosw. Welcome to 6.99.62!


# 1.117 17-May-2014 rmind

sonewconn: insert the socket into the queue *after* the protocol attach.
This potentially avoids unnecessary race conditions when handling partial
connections.


# 1.116 17-May-2014 rmind

- sonewconn: improve the initialisation order and add some asserts.
- Add various comments describing primitive routines operating on sockets,
clarify connection life-cycle and improve the description of socket queues.
- Sprinkle more asserts.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.115 08-Oct-2013 christos

branches: 1.115.2;
0 -> NULL
MGET -> m_get
No functional change.


# 1.114 15-Sep-2013 martin

Avoid unused variable warnings


# 1.113 29-Aug-2013 rmind

Remove SS_ISCONFIRMING, it is unused and TP4 will not come back.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.112 28-Jun-2013 matt

branches: 1.112.2;
Make sbdrop panic more verbose


# 1.111 27-Jun-2013 christos

Introduce a more general method of sbcreatecontrol, sbcreatecontrol1 that
can take flags (M_WAITOK), and allocate large messages if needed. It also
returns the allocated pointer instead of copying the data to the passed
pointer. Implement sbcreatecontrol() using that.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.110 20-Dec-2011 christos

branches: 1.110.6;
- Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.
- Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis
- Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets.
- Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all
errors?).


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.109 31-Aug-2011 plunky

branches: 1.109.2; 1.109.6;
NULL does not need a cast


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.108 24-Apr-2011 rmind

- Replace few malloc(9) uses with kmem(9).
- Rename buf_malloc() to buf_alloc(), fix comments.
- Remove some unnecessary inclusions.


# 1.107 09-Apr-2011 christos

Preserve SB_ASYNC on the accepted socket. From: Dmitry Matveev
http://mail-index.netbsd.org/tech-net/2011/02/17/msg002457.html


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.106 30-Dec-2009 elad

branches: 1.106.4; 1.106.6;
Don't bother caching egid. It'll be removed soon.


# 1.105 30-Dec-2009 elad

Always use resource limits from the process, as proposed in

http://mail-index.netbsd.org/tech-kern/2009/12/30/msg006756.html

okay christos@.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.104 02-Sep-2009 tls

Add a direction argument to socket upcalls, so they can tell why they've
been called when, for example, they're waiting for space to write. From
Ritesh Agrawal at Coyote Point.


Revision tags: yamt-nfs-mp-base7
# 1.103 24-Jul-2009 christos

check return code from soreserve() (Sean Boudreau)


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 09-Apr-2009 yamt

sonewconn: add an assertion.


Revision tags: nick-hppapmap-base2
# 1.101 21-Jan-2009 yamt

branches: 1.101.2;
restore the pre socket locking patch signal behaviour.
this fixes a busy-loop in nfs_connect.


Revision tags: netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base mjf-devfs2-base
# 1.100 24-Oct-2008 dyoung

branches: 1.100.2; 1.100.4;
Change 'return (expr);' to 'return expr;'. Change (type *)0 to
NULL. No functional change intended.


Revision tags: haad-dm-base1
# 1.99 14-Oct-2008 ad

Accept filters:

- Remove remaining #ifdef INET.
- Avoid holding locks so we don't need to do KM_NOSLEEP allocations.
- Use a rwlock to protect the accept filter list.
- Make it safe to unload accept filter modules.
- Minor KNF.


# 1.98 11-Oct-2008 pooka

Move uidinfo to its own module in kern_uidinfo.c and include in rump.
No functional change to uidinfo.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.97 04-Aug-2008 tls

Add accept filters, ported from FreeBSD by Coyote Point Systems. Add inetd
support for specifying an accept filter for a service (mostly as a usage
example, but it can be handy for other things). Manual pages to follow
in a day or so.

OK core@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 1.96 18-Jun-2008 yamt

branches: 1.96.2;
merge yamt-pf42 branch.
(import newer pf from OpenBSD 4.2)

ok'ed by peter@. requested by core@


Revision tags: yamt-pf42-base4
# 1.95 10-Jun-2008 ad

There can be existing waiters on a socket's condition variables when we
change socket::so_lock, and they rely on the old lock to synchronize.
Wake them up whenever we change so_lock so they can restart their waits.


Revision tags: yamt-pf42-base3
# 1.94 26-May-2008 ad

branches: 1.94.2;
Use pool_cache for sockets.


# 1.93 24-May-2008 christos

Coverity CID 5025: sbreserve is never called with a null socket.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.92 28-Apr-2008 martin

branches: 1.92.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.91 24-Apr-2008 ad

branches: 1.91.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.90 01-Mar-2008 rmind

branches: 1.90.2;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.89 07-Feb-2008 ad

branches: 1.89.2; 1.89.6;
sonewconn: inherit FNONBLOCK from the parent.


# 1.88 29-Jan-2008 yamt

sbreserve: curlwp can't be NULL these days.
XXX these code seems to need an overhaul.


# 1.87 29-Jan-2008 yamt

sbrelease: unwrap a short line.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.86 25-Sep-2007 ad

branches: 1.86.4;
Use selinit() / seldestroy().


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base matt-mips64-base
# 1.85 02-Aug-2007 rmind

branches: 1.85.2; 1.85.4; 1.85.6; 1.85.8;
TCP socket buffers automatic sizing - ported from FreeBSD.
http://mail-index.netbsd.org/tech-net/2007/02/04/0006.html

! Disabled by default, marked as experimental. Testers are very needed.
! Someone should thoroughly test this, and improve if possible.

Discussed on <tech-net>:
http://mail-index.netbsd.org/tech-net/2007/07/12/0002.html
Thanks Greg Troxel for comments.

OK by the long silence on <tech-net>.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.84 04-Jul-2007 tls

branches: 1.84.2;
After looking at FreeBSD 6 again -- we were also failing to copy the
send and receive timeouts. Fix this.


# 1.83 04-Jul-2007 tls

Copy SNDLOWAT and RCVLOWAT socket options to accepted socket, so applications
can rely on all socket options being propagated from the listen socket as
the manual page says (and as everything but Linux has always done). FreeBSD 6
fixes this the same way, but this bug appears elsewhere and is...Old.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.82 04-Mar-2007 christos

branches: 1.82.2; 1.82.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.81 01-Nov-2006 yamt

branches: 1.81.4;
remove some __unused from function parameters.


Revision tags: yamt-splraiseipl-base2
# 1.80 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.79 03-Oct-2006 elad

Back out socket credentials for now, until we figure a better way of
handling the reference counting from interrupt context.


# 1.78 02-Oct-2006 elad

Add credentials to sockets, 'so_cred'.

Brought up on tech-kern@ some ~2 months ago, didn't seem to be an
objection; brought up again recently and no objection either... this is
not too intrusive and I've been running with this for a while.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.77 16-Aug-2006 plunky

branches: 1.77.4;
Fix broken comments - there is no SO_ISCONNECTED or SO_ISCONFIRMING

this fixes kern/32058


# 1.76 16-Aug-2006 plunky

Remove macro call sonewconn() => sonewconn1() as it is no longer necessary.
There are no such calls and the compiler would catch mistakes like this
in any case.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.75 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.74 03-Jul-2006 christos

Make sure we have at least PIPE_BUF bytes available in the socket send buffer.
Review and comment by yamt.


# 1.73 01-Jul-2006 christos

Revert previous change to bump the socket low watermark to sock_loan_thresh.
With sock_loan_thresh=4096, sb_lowat==sb_hiwat, and sowritable will never
be true (even if only a single byte is pending). Some programs (like screen)
expect select() to return that a socket is writable on a socket when there
is space to write to it. XXX: What is the right thing to do here?


Revision tags: yamt-pdpolicy-base6
# 1.72 21-Jun-2006 yamt

bump default so_snd.sb_lowat to increase chance to use loaning.

the idea to tweak the watermark from Jonathan Stone.
reviewed by Bill Studenmund.


Revision tags: chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.71 14-May-2006 elad

branches: 1.71.4;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.70 24-Dec-2005 perry

branches: 1.70.4; 1.70.6; 1.70.8; 1.70.10; 1.70.12;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.69 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.68 29-May-2005 christos

branches: 1.68.2;
- add const.
- remove unnecessary casts.
- add __UNCONST casts and mark them with XXXUNCONST as necessary.


# 1.67 07-May-2005 christos

PR/30154: YAMAMOTO Takashi: tcp_close locking botch
chgsbsize() as mentioned in the PR can be called from an interrupt context
via tcp_close(). Avoid calling uid_find() in chgsbsize().
- Instead of storing so_uid in struct socketvar, store *so_uidinfo
- Add a simple lock to struct uidinfo.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.66 26-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.65 24-Jun-2004 jonathan

branches: 1.65.4; 1.65.6;
Rename MBUFTRACE helper function m_claim() to m_claimm(),
for consistency with M_FREE() and m_freem(). Affected files:

sys/mbuf.h
kern/uipc_socket2.c
kern/uipc_mbuf.c
net/if_ethersubr.c
netatalk/ddp_input.c
nfs/nfs_socket.c


# 1.64 11-Jun-2004 jonathan

Fix potential memory leak in sbappendaddrchain():

We do an MGETHDR)() for each mbuf "packet" of the input chain, to hold
the socket address prepended to that "packet". If those MGETHDR()s
ever failed, we would leak all the successfully-allocated mbuf
headers. Leak noted by Yamamoto-san (yamt@NetBSD.org); thanks for catching it!

Add socketbuf invariant-checking macros to sbappendaddrchain(), and
replace a stray bcopy() with memcpy(), also as suggested by Yamamoto-san.


# 1.63 27-May-2004 jonathan

Rework to make FAST_IPSEC PF_KEY dumps unicast and reliable:

Introduce new socket-layer function sbappendaddrchain() to
sys/kern/uipc_socket2.c: like sbappendaddr(), only takes a chain of
records and appends the entire chain in one pass. sbappendaddrchain()
also takes an `sbprio' argument, which indicates the caller requires
special `reliable' handling of the socket-buffer. `sbprio' is
described in sys/sys/socketvar.h, although (for now) the different
levels are not yet implemented.

Rework sys/netipsec/key.c PF_KEY DUMP responses to build a chain of
mbuf records, one record per dump response. Unicast the entire chain
to the requestor, with all-or-none semantics.

Changed files;
sys/socketvar.h kern/uipc_socket2.c netipsec/key.c
Reviewed by:
Jason Thorpe, Thor Lancelot Simon, post to tech-kern.

Todo: request pullup to 2.0 branch. Post-2.0, rework sysctl() API for
dumps to use new record-chain constructors. Actually implement
the distinct service levels in sbappendaddrchain() so we can use them
to make PF_KEY ACQUIRE messages more reliable.


# 1.62 19-Apr-2004 christos

Charge root for socket buffers without a socket pointer.


# 1.61 18-Apr-2004 matt

Constify the addr parameter to sbappenaddr.


# 1.60 18-Apr-2004 matt

sbreserve can be called with a NULL socket, deal with it.


# 1.59 17-Apr-2004 christos

PR/9347: Eric E. Fair: socket buffer pool exhaustion leads to system deadlock
and unkillable processes.
1. Introduce new SBSIZE resource limit from FreeBSD to limit socket buffer
size resource.
2. make sokvareserve interruptible, so processes ltsleeping on it can be
killed.


Revision tags: netbsd-2-0-base
# 1.58 21-Oct-2003 thorpej

branches: 1.58.2;
Cache the "adjusted" value of sb_max when sb_max is changed, in order
to avoid doing quad math in sbreserve().

Change suggested by Simon Burge, and code inspired by a similar change
in FreeBSD.


# 1.57 22-Sep-2003 christos

- pass signo to fownsignal [ok by jd]
- make urg signal handling use fownsignal
- remove out of band detection in sowakeup


# 1.56 21-Sep-2003 jdolecek

cleanup & uniform descriptor owner handling:
* introduce fsetown(), fgetown(), fownsignal() - this sets/retrieves/signals
the owner of descriptor, according to appropriate sematics
of TIOCSPGRP/FIOSETOWN/SIOCSPGRP/TIOCGPGRP/FIOGETOWN/SIOCGPGRP ioctl; use
these routines instead of custom code where appropriate
* make every place handling TIOCSPGRP/TIOCGPGRP handle also FIOSETOWN/FIOGETOWN
properly, and remove the translation of FIO[SG]OWN to TIOC[SG]PGRP
in sys_ioctl() & sys_fcntl()
* also remove the socket-specific hack in sys_ioctl()/sys_fcntl() and
pass the ioctls down to soo_ioctl() as any other ioctl

change discussed on tech-kern@


# 1.55 06-Sep-2003 christos

SA_SIGINFO changes.


# 1.54 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.53 29-Jun-2003 fvdl

branches: 1.53.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.52 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.51 23-Jun-2003 martin

Make sure to include opt_foo.h if a defflag option FOO is used.


# 1.50 17-Apr-2003 fvdl

A bit of an ugly workaround to avoid a warning for a larger MSIZE.
Shouldn't make a difference in the generated code.


# 1.49 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge
# 1.48 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.47 27-Sep-2002 provos

remove trailing \n in panic(). approved perry.


Revision tags: gehenna-devsw-base
# 1.46 22-Aug-2002 thorpej

In sbcompress(), if we toss an empty mbuf, make sure to update
sb_lastrecord if necessary.

From Daniel Hartmeier <daniel@benzedrine.cx>.


# 1.45 03-Jul-2002 thorpej

Rename SB_UPDATE_TAIL() to SB_EMPTY_FIXUP(), per suggestion from
Jonathan Stone.


# 1.44 03-Jul-2002 thorpej

Rename sbappend_stream() to sbappendstream(), per suggestion from
Jonathan Stone.


# 1.43 03-Jul-2002 thorpej

Make insertion of data into socket buffers O(C):
* Keep pointers to the first and last mbufs of the last record in the
socket buffer.
* Use the sb_lastrecord pointer in the sbappend*() family of functions
to avoid traversing the packet chain to find the last record.
* Add a new sbappend_stream() function for stream protocols which
guarantee that there will never be more than one record in the
socket buffer. This function uses the sb_mbtail pointer to perform
the data insertion. Make TCP use sbappend_stream().

On a profiling run, this makes sbappend of a TCP transmission using
a 1M socket buffer go from 50% of the time to .02% of the time.

Thanks to Bill Sommerfeld and YAMAMOTO Takashi for their debugging
assistance!


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base thorpej-mips-cache-base
# 1.42 12-Nov-2001 lukem

branches: 1.42.8;
add RCSIDs


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 05-Aug-2001 enami

branches: 1.41.4;
Give different names for different wait channels.

# and minor knf fix while I'm here.


# 1.40 27-Jul-2001 thorpej

Now that M_TRAILINGSPACE() checks buffer writeability properly,
we can greatly simplify sbcompress(). Slightly modified from
a similar change in FreeBSD.


# 1.39 16-Jun-2001 manu

branches: 1.39.2;
Use SB_ASYNC in struct sockbuf sb_flags field instead of SS_ASYNC in
struct socket so_state field to decide if we need to send asynchronous
notifications. This makes possible to request notification on write but
not on read, and vice versa.

This is used in Linux emulation code, because when async I/O is requested,
Linux does not send SIGIO to write end of sockets, and it never send any
SIGIO to any end of pipes. Il Linux emulation code, we then set SB_ASYNC
only on the read end of sockets, and on no end for pipes.


# 1.38 30-Apr-2001 kml

Large values of sb_max would cause an overflow in sbreserve(); cast to
u_quad_t to avoid this. (from FreeBSD uipc_socket2.c v1.19)


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.37 27-Feb-2001 lukem

branches: 1.37.2;
convert to ANSI KNF


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 30-Mar-2000 augustss

Get rid of register declarations.


# 1.35 29-Feb-2000 itojun

more fix to ancillary data alignment. we need padding after
last cmsg_data item (see the figure on RFC2292 page 18).


# 1.34 18-Feb-2000 itojun

fix alignment problem in ancillary messages (alpha).

the change constitutes binary compatibility issue hen sizeof(long) !=4.
there's no way to be backward compatible, and only guys affected
are IPv6 userland tools.

From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base
# 1.33 04-Aug-1999 mycroft

branches: 1.33.2;
The old compaction test had an off-by-one error that caused it to not compact
in some cases where it could have. Fix this, and the new version as well.


# 1.32 04-Aug-1999 matt

Don't compress mbuf clusters which are referenced by multiple
mbufs since you might overwriting valuable data. (think of
m_copy'ed data from a TCP re-transmission queue. Since those
might be in clusters and referenced in two sockets).


# 1.31 04-Aug-1999 mycroft

It's now possible for sbcompress() to compact mbuf clusters, so do it.
This helps prevent mbuf cluster exhaustion when receiving lots of small
packets.


Revision tags: chs-ubc2-base
# 1.30 01-Jul-1999 itojun

IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.


# 1.29 22-Apr-1999 simonb

Move inclusion of "opt_sb_max.h" from sys/socketvar.h to
conf/param.c, and move the initialisation of the sb_max
variable from kern/uipc_socket2.c to conf/param.c. Now
everthing that includes sys/socketvar.h doesn't get
recompiled when SB_MAX's value changes.


Revision tags: netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.28 23-Mar-1999 lukem

branches: 1.28.2; 1.28.4; 1.28.6;
Ensure that you can only bind a more specific address when it is done by the
same uid or by root.

This code is from FreeBSD. (Whilst it was originally obtained from OpenBSD,
FreeBSD fixed it to work with multicast. To quote the commit message:
- Don't bother checking for conflicting sockets if we're binding to a
multicast address.
- Don't return an error if we're binding to INADDR_ANY, the conflicting
socket is bound to INADDR_ANY, and the conflicting socket has
SO_REUSEPORT set.
)


# 1.27 20-Jan-1999 mycroft

Do not remove sockets from the accept(2) queue on close.


Revision tags: kenh-if-detach-base chs-ubc-base
# 1.26 04-Aug-1998 perry

Abolition of bcopy, ovbcopy, bcmp, and bzero, phase one.
bcopy(x, y, z) -> memcpy(y, x, z)
ovbcopy(x, y, z) -> memmove(y, x, z)
bcmp(x, y, z) -> memcmp(x, y, z)
bzero(x, y) -> memset(x, 0, y)


# 1.25 02-Aug-1998 thorpej

Use the pool allocator for sockets.


Revision tags: eeh-paddr_t-base
# 1.24 25-Apr-1998 matt

Hook for 0-copy (or other optimized) sends and receives


# 1.23 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.22 07-Jan-1998 thorpej

Make insertion and removal of sockets from the partial and incoming
connections queues O(C) rather than O(N).


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base marc-pcmcia-base
# 1.21 09-Oct-1997 mycroft

branches: 1.21.2;
Make various standard wmesg strings const.


Revision tags: thorpej-signal-base marc-pcmcia-bp SYN_cache_cur_base
# 1.20 26-Jun-1997 thorpej

branches: 1.20.4;
In sbappendaddr(), if the sockaddr length is larger than will fit in
an mbuf, allocate enough external storage to hold the sockaddr. Thanks
to enami tsugutomo <enami@cv.sony.co.jp> for providing sanity-checks.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.19 11-Jan-1997 thorpej

branches: 1.19.8;
Implement sbcreatecontrol(), a generic function to create a "control"
mbuf for presentation on a socket buffer.


# 1.18 09-Dec-1996 thorpej

In sbreserve(), don't allow a count of 0. Fixes PR #2794, from
Erik Berls <cyber@dis.org>.


# 1.17 26-Nov-1996 thorpej

Back out previous soqinsque() and soqremque() changes. This will
stop the panics until the socket queues get converted to <sys/queue.h>.


# 1.16 10-Nov-1996 thorpej

Optimization of soqinsque() and soqremque():

Keep queue of pending sockets in a double linked list. Previously,
a singly linked list was used, giving O(N) insertion/deletion times,
and was a major time consumer for sockets with large pending queues.
The double linked list give O(C) insertion/deletion times with only
a small cost in complexity.

Since a socket can be on, at most, one queue at a time, both so_q and
so_q0 can safely be used as (forward and backward, respectively) queue
pointers.

Submitted my Matt Thomas <matt@3am-software.com>, a long time ago.
(Geez, I've been running with this patch for _months_, and had completely
forgotten about it!)


# 1.15 13-Oct-1996 christos

backout previous kprintf change


# 1.14 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.13 07-Sep-1996 mycroft

Implement poll(2).


# 1.12 22-May-1996 mycroft

Pass a proc pointer down to the usrreq and pcbbind functions for PRU_ATTACH, PRU_BIND and
PRU_CONTROL. The usrreq interface really needs to be split up, but this will have to wait.
Remove SS_PRIV completely.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.11 04-Feb-1996 christos

branches: 1.11.4;
First pass at prototyping


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.10 16-Aug-1995 mycroft

Access rights are now stored in MT_CONTROL mbufs. Document this.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.9 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.8 13-May-1994 mycroft

Update to 4.4-Lite networking code, with a few local changes.


# 1.7 04-May-1994 mycroft

More return types...


# 1.6 25-Apr-1994 mycroft

Remove sbselqueue().


# 1.5 18-Dec-1993 mycroft

Canonicalize all #includes.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 27-Jun-1993 andrew

branches: 1.4.4;
ANSIfications - removed all implicit function return types and argument
definitions. Ensured that all files include "systm.h" to gain access to
general prototypes. Casts where necessary.


# 1.3 18-May-1993 cgd

make kernel select interface be one-stop shopping & clean it all up.


Revision tags: netbsd-0-8 netbsd-alpha-1 patchkit-0-2-2
# 1.2 21-Mar-1993 cgd

after 0.2.2 "stable" patches applied


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.136 01-Feb-2020 riastradh

Load struct fdfile::ff_file with atomic_load_consume.

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.)


# 1.135 01-Feb-2020 riastradh

Load struct filedesc::fd_dt with atomic_load_consume.

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.


Revision tags: netbsd-9-0-RC2 ad-namecache-base2 ad-namecache-base1 ad-namecache-base netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base
# 1.134 11-Jul-2019 maxv

Fix info leaks: the alignment of the structures causes uninitialized heap
memory to be copied to userland in sys_recvmsg().


Revision tags: phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.133 04-Nov-2018 christos

- Introduce a new SO_RERROR socket option to explicitly turn on
receive overflow errors re-instating the default behavior to
silently ignore them as before 2018-03-19.
- Introduce a new kern.sooptions sysctl to control the default
behavior of socket options. Setting this to 0x4000 (SO_RERROR),
turns on receive overflow error reporting for all sockets.
- Change dhcpcd to turn on SO_RERROR on all its sockets.

As discussed in tech-net.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.132 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: pgoyette-compat-0728
# 1.131 20-Jul-2018 msaitoh

Add "show socket" command written by Hiroki SUENAGA. It prints usage of
system's socket buffers.


Revision tags: phil-wifi-base pgoyette-compat-0625
# 1.130 06-Jun-2018 roy

branches: 1.130.2;
Separate receive socket errors from general socket errors.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502
# 1.129 29-Apr-2018 maxv

Remove references to m_copy in comments.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.128 19-Mar-2018 roy

socket: report receive buffer overflows

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.


# 1.127 18-Mar-2018 christos

- Convert sb_lowat to unsigned for consistency. There are no negative value
uses
- Check for overflow as mentioned in the comment
- Sprinkle const


Revision tags: pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.126 06-Jul-2017 christos

branches: 1.126.4;
move the timestamp stuff to uipc_socket.c because it already has the compat
includes.


# 1.125 06-Jul-2017 christos

Merge the two copies SO_TIMESTAMP/SO_OTIMESTAMP processing to a single
function, and add a SOOPT_TIMESTAMP define reducing compat pollution from
5 places to 1.


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.124 02-Oct-2016 christos

branches: 1.124.8;
more MFREE -> m_free


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.123 23-May-2016 tls

branches: 1.123.2;
Fix a longstanding problem with accept filters noticed by Timo Buhrmester:
sockets sitting in the accept filter can consume the entire listen queue,
such that the application is never able to handle any connections. Handle
this by simply passing through the oldest queued cxn when the queue is full.

This is fair because the longer a cxn lingers in the queue (stays connected
but does not meet the requirements of the filter for passage) the more likely
it is to be passed through, at which point the application can dispose of it.

Works because none of our accept filters actually allocate private state
per-cxn. If they did, we'd have to fix the API bug that there is presently
no way to tell an accf to finish/deallocate for a single cxn (accf_destroy
kills off the entire filter instance for a given listen socket).


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.122 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.121 05-Sep-2014 matt

branches: 1.121.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.120 31-Jul-2014 rtr

split PRU_DISCONNECT, PRU_SHUTDOWN and PRU_ABORT function out of
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


# 1.119 19-May-2014 rmind

- Split off PRU_ATTACH and PRU_DETACH logic into separate functions.
- Replace malloc with kmem and eliminate M_PCB while here.
- Sprinkle more asserts.


Revision tags: rmind-smpnet-nbase rmind-smpnet-base
# 1.118 18-May-2014 rmind

Add struct pr_usrreqs with a pr_generic function and prepare for the
dismantling of pr_usrreq in the protocols; no functional change intended.
PRU_ATTACH/PRU_DETACH changes will follow soon.

Bump for struct protosw. Welcome to 6.99.62!


# 1.117 17-May-2014 rmind

sonewconn: insert the socket into the queue *after* the protocol attach.
This potentially avoids unnecessary race conditions when handling partial
connections.


# 1.116 17-May-2014 rmind

- sonewconn: improve the initialisation order and add some asserts.
- Add various comments describing primitive routines operating on sockets,
clarify connection life-cycle and improve the description of socket queues.
- Sprinkle more asserts.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.115 08-Oct-2013 christos

branches: 1.115.2;
0 -> NULL
MGET -> m_get
No functional change.


# 1.114 15-Sep-2013 martin

Avoid unused variable warnings


# 1.113 29-Aug-2013 rmind

Remove SS_ISCONFIRMING, it is unused and TP4 will not come back.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.112 28-Jun-2013 matt

branches: 1.112.2;
Make sbdrop panic more verbose


# 1.111 27-Jun-2013 christos

Introduce a more general method of sbcreatecontrol, sbcreatecontrol1 that
can take flags (M_WAITOK), and allocate large messages if needed. It also
returns the allocated pointer instead of copying the data to the passed
pointer. Implement sbcreatecontrol() using that.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.110 20-Dec-2011 christos

branches: 1.110.6;
- Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.
- Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis
- Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets.
- Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all
errors?).


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.109 31-Aug-2011 plunky

branches: 1.109.2; 1.109.6;
NULL does not need a cast


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.108 24-Apr-2011 rmind

- Replace few malloc(9) uses with kmem(9).
- Rename buf_malloc() to buf_alloc(), fix comments.
- Remove some unnecessary inclusions.


# 1.107 09-Apr-2011 christos

Preserve SB_ASYNC on the accepted socket. From: Dmitry Matveev
http://mail-index.netbsd.org/tech-net/2011/02/17/msg002457.html


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.106 30-Dec-2009 elad

branches: 1.106.4; 1.106.6;
Don't bother caching egid. It'll be removed soon.


# 1.105 30-Dec-2009 elad

Always use resource limits from the process, as proposed in

http://mail-index.netbsd.org/tech-kern/2009/12/30/msg006756.html

okay christos@.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.104 02-Sep-2009 tls

Add a direction argument to socket upcalls, so they can tell why they've
been called when, for example, they're waiting for space to write. From
Ritesh Agrawal at Coyote Point.


Revision tags: yamt-nfs-mp-base7
# 1.103 24-Jul-2009 christos

check return code from soreserve() (Sean Boudreau)


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 09-Apr-2009 yamt

sonewconn: add an assertion.


Revision tags: nick-hppapmap-base2
# 1.101 21-Jan-2009 yamt

branches: 1.101.2;
restore the pre socket locking patch signal behaviour.
this fixes a busy-loop in nfs_connect.


Revision tags: netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base mjf-devfs2-base
# 1.100 24-Oct-2008 dyoung

branches: 1.100.2; 1.100.4;
Change 'return (expr);' to 'return expr;'. Change (type *)0 to
NULL. No functional change intended.


Revision tags: haad-dm-base1
# 1.99 14-Oct-2008 ad

Accept filters:

- Remove remaining #ifdef INET.
- Avoid holding locks so we don't need to do KM_NOSLEEP allocations.
- Use a rwlock to protect the accept filter list.
- Make it safe to unload accept filter modules.
- Minor KNF.


# 1.98 11-Oct-2008 pooka

Move uidinfo to its own module in kern_uidinfo.c and include in rump.
No functional change to uidinfo.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.97 04-Aug-2008 tls

Add accept filters, ported from FreeBSD by Coyote Point Systems. Add inetd
support for specifying an accept filter for a service (mostly as a usage
example, but it can be handy for other things). Manual pages to follow
in a day or so.

OK core@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 1.96 18-Jun-2008 yamt

branches: 1.96.2;
merge yamt-pf42 branch.
(import newer pf from OpenBSD 4.2)

ok'ed by peter@. requested by core@


Revision tags: yamt-pf42-base4
# 1.95 10-Jun-2008 ad

There can be existing waiters on a socket's condition variables when we
change socket::so_lock, and they rely on the old lock to synchronize.
Wake them up whenever we change so_lock so they can restart their waits.


Revision tags: yamt-pf42-base3
# 1.94 26-May-2008 ad

branches: 1.94.2;
Use pool_cache for sockets.


# 1.93 24-May-2008 christos

Coverity CID 5025: sbreserve is never called with a null socket.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.92 28-Apr-2008 martin

branches: 1.92.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.91 24-Apr-2008 ad

branches: 1.91.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.90 01-Mar-2008 rmind

branches: 1.90.2;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.89 07-Feb-2008 ad

branches: 1.89.2; 1.89.6;
sonewconn: inherit FNONBLOCK from the parent.


# 1.88 29-Jan-2008 yamt

sbreserve: curlwp can't be NULL these days.
XXX these code seems to need an overhaul.


# 1.87 29-Jan-2008 yamt

sbrelease: unwrap a short line.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.86 25-Sep-2007 ad

branches: 1.86.4;
Use selinit() / seldestroy().


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base matt-mips64-base
# 1.85 02-Aug-2007 rmind

branches: 1.85.2; 1.85.4; 1.85.6; 1.85.8;
TCP socket buffers automatic sizing - ported from FreeBSD.
http://mail-index.netbsd.org/tech-net/2007/02/04/0006.html

! Disabled by default, marked as experimental. Testers are very needed.
! Someone should thoroughly test this, and improve if possible.

Discussed on <tech-net>:
http://mail-index.netbsd.org/tech-net/2007/07/12/0002.html
Thanks Greg Troxel for comments.

OK by the long silence on <tech-net>.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.84 04-Jul-2007 tls

branches: 1.84.2;
After looking at FreeBSD 6 again -- we were also failing to copy the
send and receive timeouts. Fix this.


# 1.83 04-Jul-2007 tls

Copy SNDLOWAT and RCVLOWAT socket options to accepted socket, so applications
can rely on all socket options being propagated from the listen socket as
the manual page says (and as everything but Linux has always done). FreeBSD 6
fixes this the same way, but this bug appears elsewhere and is...Old.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.82 04-Mar-2007 christos

branches: 1.82.2; 1.82.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.81 01-Nov-2006 yamt

branches: 1.81.4;
remove some __unused from function parameters.


Revision tags: yamt-splraiseipl-base2
# 1.80 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.79 03-Oct-2006 elad

Back out socket credentials for now, until we figure a better way of
handling the reference counting from interrupt context.


# 1.78 02-Oct-2006 elad

Add credentials to sockets, 'so_cred'.

Brought up on tech-kern@ some ~2 months ago, didn't seem to be an
objection; brought up again recently and no objection either... this is
not too intrusive and I've been running with this for a while.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.77 16-Aug-2006 plunky

branches: 1.77.4;
Fix broken comments - there is no SO_ISCONNECTED or SO_ISCONFIRMING

this fixes kern/32058


# 1.76 16-Aug-2006 plunky

Remove macro call sonewconn() => sonewconn1() as it is no longer necessary.
There are no such calls and the compiler would catch mistakes like this
in any case.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.75 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.74 03-Jul-2006 christos

Make sure we have at least PIPE_BUF bytes available in the socket send buffer.
Review and comment by yamt.


# 1.73 01-Jul-2006 christos

Revert previous change to bump the socket low watermark to sock_loan_thresh.
With sock_loan_thresh=4096, sb_lowat==sb_hiwat, and sowritable will never
be true (even if only a single byte is pending). Some programs (like screen)
expect select() to return that a socket is writable on a socket when there
is space to write to it. XXX: What is the right thing to do here?


Revision tags: yamt-pdpolicy-base6
# 1.72 21-Jun-2006 yamt

bump default so_snd.sb_lowat to increase chance to use loaning.

the idea to tweak the watermark from Jonathan Stone.
reviewed by Bill Studenmund.


Revision tags: chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.71 14-May-2006 elad

branches: 1.71.4;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.70 24-Dec-2005 perry

branches: 1.70.4; 1.70.6; 1.70.8; 1.70.10; 1.70.12;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.69 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.68 29-May-2005 christos

branches: 1.68.2;
- add const.
- remove unnecessary casts.
- add __UNCONST casts and mark them with XXXUNCONST as necessary.


# 1.67 07-May-2005 christos

PR/30154: YAMAMOTO Takashi: tcp_close locking botch
chgsbsize() as mentioned in the PR can be called from an interrupt context
via tcp_close(). Avoid calling uid_find() in chgsbsize().
- Instead of storing so_uid in struct socketvar, store *so_uidinfo
- Add a simple lock to struct uidinfo.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.66 26-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.65 24-Jun-2004 jonathan

branches: 1.65.4; 1.65.6;
Rename MBUFTRACE helper function m_claim() to m_claimm(),
for consistency with M_FREE() and m_freem(). Affected files:

sys/mbuf.h
kern/uipc_socket2.c
kern/uipc_mbuf.c
net/if_ethersubr.c
netatalk/ddp_input.c
nfs/nfs_socket.c


# 1.64 11-Jun-2004 jonathan

Fix potential memory leak in sbappendaddrchain():

We do an MGETHDR)() for each mbuf "packet" of the input chain, to hold
the socket address prepended to that "packet". If those MGETHDR()s
ever failed, we would leak all the successfully-allocated mbuf
headers. Leak noted by Yamamoto-san (yamt@NetBSD.org); thanks for catching it!

Add socketbuf invariant-checking macros to sbappendaddrchain(), and
replace a stray bcopy() with memcpy(), also as suggested by Yamamoto-san.


# 1.63 27-May-2004 jonathan

Rework to make FAST_IPSEC PF_KEY dumps unicast and reliable:

Introduce new socket-layer function sbappendaddrchain() to
sys/kern/uipc_socket2.c: like sbappendaddr(), only takes a chain of
records and appends the entire chain in one pass. sbappendaddrchain()
also takes an `sbprio' argument, which indicates the caller requires
special `reliable' handling of the socket-buffer. `sbprio' is
described in sys/sys/socketvar.h, although (for now) the different
levels are not yet implemented.

Rework sys/netipsec/key.c PF_KEY DUMP responses to build a chain of
mbuf records, one record per dump response. Unicast the entire chain
to the requestor, with all-or-none semantics.

Changed files;
sys/socketvar.h kern/uipc_socket2.c netipsec/key.c
Reviewed by:
Jason Thorpe, Thor Lancelot Simon, post to tech-kern.

Todo: request pullup to 2.0 branch. Post-2.0, rework sysctl() API for
dumps to use new record-chain constructors. Actually implement
the distinct service levels in sbappendaddrchain() so we can use them
to make PF_KEY ACQUIRE messages more reliable.


# 1.62 19-Apr-2004 christos

Charge root for socket buffers without a socket pointer.


# 1.61 18-Apr-2004 matt

Constify the addr parameter to sbappenaddr.


# 1.60 18-Apr-2004 matt

sbreserve can be called with a NULL socket, deal with it.


# 1.59 17-Apr-2004 christos

PR/9347: Eric E. Fair: socket buffer pool exhaustion leads to system deadlock
and unkillable processes.
1. Introduce new SBSIZE resource limit from FreeBSD to limit socket buffer
size resource.
2. make sokvareserve interruptible, so processes ltsleeping on it can be
killed.


Revision tags: netbsd-2-0-base
# 1.58 21-Oct-2003 thorpej

branches: 1.58.2;
Cache the "adjusted" value of sb_max when sb_max is changed, in order
to avoid doing quad math in sbreserve().

Change suggested by Simon Burge, and code inspired by a similar change
in FreeBSD.


# 1.57 22-Sep-2003 christos

- pass signo to fownsignal [ok by jd]
- make urg signal handling use fownsignal
- remove out of band detection in sowakeup


# 1.56 21-Sep-2003 jdolecek

cleanup & uniform descriptor owner handling:
* introduce fsetown(), fgetown(), fownsignal() - this sets/retrieves/signals
the owner of descriptor, according to appropriate sematics
of TIOCSPGRP/FIOSETOWN/SIOCSPGRP/TIOCGPGRP/FIOGETOWN/SIOCGPGRP ioctl; use
these routines instead of custom code where appropriate
* make every place handling TIOCSPGRP/TIOCGPGRP handle also FIOSETOWN/FIOGETOWN
properly, and remove the translation of FIO[SG]OWN to TIOC[SG]PGRP
in sys_ioctl() & sys_fcntl()
* also remove the socket-specific hack in sys_ioctl()/sys_fcntl() and
pass the ioctls down to soo_ioctl() as any other ioctl

change discussed on tech-kern@


# 1.55 06-Sep-2003 christos

SA_SIGINFO changes.


# 1.54 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.53 29-Jun-2003 fvdl

branches: 1.53.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.52 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.51 23-Jun-2003 martin

Make sure to include opt_foo.h if a defflag option FOO is used.


# 1.50 17-Apr-2003 fvdl

A bit of an ugly workaround to avoid a warning for a larger MSIZE.
Shouldn't make a difference in the generated code.


# 1.49 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge
# 1.48 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.47 27-Sep-2002 provos

remove trailing \n in panic(). approved perry.


Revision tags: gehenna-devsw-base
# 1.46 22-Aug-2002 thorpej

In sbcompress(), if we toss an empty mbuf, make sure to update
sb_lastrecord if necessary.

From Daniel Hartmeier <daniel@benzedrine.cx>.


# 1.45 03-Jul-2002 thorpej

Rename SB_UPDATE_TAIL() to SB_EMPTY_FIXUP(), per suggestion from
Jonathan Stone.


# 1.44 03-Jul-2002 thorpej

Rename sbappend_stream() to sbappendstream(), per suggestion from
Jonathan Stone.


# 1.43 03-Jul-2002 thorpej

Make insertion of data into socket buffers O(C):
* Keep pointers to the first and last mbufs of the last record in the
socket buffer.
* Use the sb_lastrecord pointer in the sbappend*() family of functions
to avoid traversing the packet chain to find the last record.
* Add a new sbappend_stream() function for stream protocols which
guarantee that there will never be more than one record in the
socket buffer. This function uses the sb_mbtail pointer to perform
the data insertion. Make TCP use sbappend_stream().

On a profiling run, this makes sbappend of a TCP transmission using
a 1M socket buffer go from 50% of the time to .02% of the time.

Thanks to Bill Sommerfeld and YAMAMOTO Takashi for their debugging
assistance!


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base thorpej-mips-cache-base
# 1.42 12-Nov-2001 lukem

branches: 1.42.8;
add RCSIDs


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 05-Aug-2001 enami

branches: 1.41.4;
Give different names for different wait channels.

# and minor knf fix while I'm here.


# 1.40 27-Jul-2001 thorpej

Now that M_TRAILINGSPACE() checks buffer writeability properly,
we can greatly simplify sbcompress(). Slightly modified from
a similar change in FreeBSD.


# 1.39 16-Jun-2001 manu

branches: 1.39.2;
Use SB_ASYNC in struct sockbuf sb_flags field instead of SS_ASYNC in
struct socket so_state field to decide if we need to send asynchronous
notifications. This makes possible to request notification on write but
not on read, and vice versa.

This is used in Linux emulation code, because when async I/O is requested,
Linux does not send SIGIO to write end of sockets, and it never send any
SIGIO to any end of pipes. Il Linux emulation code, we then set SB_ASYNC
only on the read end of sockets, and on no end for pipes.


# 1.38 30-Apr-2001 kml

Large values of sb_max would cause an overflow in sbreserve(); cast to
u_quad_t to avoid this. (from FreeBSD uipc_socket2.c v1.19)


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.37 27-Feb-2001 lukem

branches: 1.37.2;
convert to ANSI KNF


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 30-Mar-2000 augustss

Get rid of register declarations.


# 1.35 29-Feb-2000 itojun

more fix to ancillary data alignment. we need padding after
last cmsg_data item (see the figure on RFC2292 page 18).


# 1.34 18-Feb-2000 itojun

fix alignment problem in ancillary messages (alpha).

the change constitutes binary compatibility issue hen sizeof(long) !=4.
there's no way to be backward compatible, and only guys affected
are IPv6 userland tools.

From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base
# 1.33 04-Aug-1999 mycroft

branches: 1.33.2;
The old compaction test had an off-by-one error that caused it to not compact
in some cases where it could have. Fix this, and the new version as well.


# 1.32 04-Aug-1999 matt

Don't compress mbuf clusters which are referenced by multiple
mbufs since you might overwriting valuable data. (think of
m_copy'ed data from a TCP re-transmission queue. Since those
might be in clusters and referenced in two sockets).


# 1.31 04-Aug-1999 mycroft

It's now possible for sbcompress() to compact mbuf clusters, so do it.
This helps prevent mbuf cluster exhaustion when receiving lots of small
packets.


Revision tags: chs-ubc2-base
# 1.30 01-Jul-1999 itojun

IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.


# 1.29 22-Apr-1999 simonb

Move inclusion of "opt_sb_max.h" from sys/socketvar.h to
conf/param.c, and move the initialisation of the sb_max
variable from kern/uipc_socket2.c to conf/param.c. Now
everthing that includes sys/socketvar.h doesn't get
recompiled when SB_MAX's value changes.


Revision tags: netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.28 23-Mar-1999 lukem

branches: 1.28.2; 1.28.4; 1.28.6;
Ensure that you can only bind a more specific address when it is done by the
same uid or by root.

This code is from FreeBSD. (Whilst it was originally obtained from OpenBSD,
FreeBSD fixed it to work with multicast. To quote the commit message:
- Don't bother checking for conflicting sockets if we're binding to a
multicast address.
- Don't return an error if we're binding to INADDR_ANY, the conflicting
socket is bound to INADDR_ANY, and the conflicting socket has
SO_REUSEPORT set.
)


# 1.27 20-Jan-1999 mycroft

Do not remove sockets from the accept(2) queue on close.


Revision tags: kenh-if-detach-base chs-ubc-base
# 1.26 04-Aug-1998 perry

Abolition of bcopy, ovbcopy, bcmp, and bzero, phase one.
bcopy(x, y, z) -> memcpy(y, x, z)
ovbcopy(x, y, z) -> memmove(y, x, z)
bcmp(x, y, z) -> memcmp(x, y, z)
bzero(x, y) -> memset(x, 0, y)


# 1.25 02-Aug-1998 thorpej

Use the pool allocator for sockets.


Revision tags: eeh-paddr_t-base
# 1.24 25-Apr-1998 matt

Hook for 0-copy (or other optimized) sends and receives


# 1.23 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.22 07-Jan-1998 thorpej

Make insertion and removal of sockets from the partial and incoming
connections queues O(C) rather than O(N).


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base marc-pcmcia-base
# 1.21 09-Oct-1997 mycroft

branches: 1.21.2;
Make various standard wmesg strings const.


Revision tags: thorpej-signal-base marc-pcmcia-bp SYN_cache_cur_base
# 1.20 26-Jun-1997 thorpej

branches: 1.20.4;
In sbappendaddr(), if the sockaddr length is larger than will fit in
an mbuf, allocate enough external storage to hold the sockaddr. Thanks
to enami tsugutomo <enami@cv.sony.co.jp> for providing sanity-checks.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.19 11-Jan-1997 thorpej

branches: 1.19.8;
Implement sbcreatecontrol(), a generic function to create a "control"
mbuf for presentation on a socket buffer.


# 1.18 09-Dec-1996 thorpej

In sbreserve(), don't allow a count of 0. Fixes PR #2794, from
Erik Berls <cyber@dis.org>.


# 1.17 26-Nov-1996 thorpej

Back out previous soqinsque() and soqremque() changes. This will
stop the panics until the socket queues get converted to <sys/queue.h>.


# 1.16 10-Nov-1996 thorpej

Optimization of soqinsque() and soqremque():

Keep queue of pending sockets in a double linked list. Previously,
a singly linked list was used, giving O(N) insertion/deletion times,
and was a major time consumer for sockets with large pending queues.
The double linked list give O(C) insertion/deletion times with only
a small cost in complexity.

Since a socket can be on, at most, one queue at a time, both so_q and
so_q0 can safely be used as (forward and backward, respectively) queue
pointers.

Submitted my Matt Thomas <matt@3am-software.com>, a long time ago.
(Geez, I've been running with this patch for _months_, and had completely
forgotten about it!)


# 1.15 13-Oct-1996 christos

backout previous kprintf change


# 1.14 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.13 07-Sep-1996 mycroft

Implement poll(2).


# 1.12 22-May-1996 mycroft

Pass a proc pointer down to the usrreq and pcbbind functions for PRU_ATTACH, PRU_BIND and
PRU_CONTROL. The usrreq interface really needs to be split up, but this will have to wait.
Remove SS_PRIV completely.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.11 04-Feb-1996 christos

branches: 1.11.4;
First pass at prototyping


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.10 16-Aug-1995 mycroft

Access rights are now stored in MT_CONTROL mbufs. Document this.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.9 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.8 13-May-1994 mycroft

Update to 4.4-Lite networking code, with a few local changes.


# 1.7 04-May-1994 mycroft

More return types...


# 1.6 25-Apr-1994 mycroft

Remove sbselqueue().


# 1.5 18-Dec-1993 mycroft

Canonicalize all #includes.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 27-Jun-1993 andrew

branches: 1.4.4;
ANSIfications - removed all implicit function return types and argument
definitions. Ensured that all files include "systm.h" to gain access to
general prototypes. Casts where necessary.


# 1.3 18-May-1993 cgd

make kernel select interface be one-stop shopping & clean it all up.


Revision tags: netbsd-0-8 netbsd-alpha-1 patchkit-0-2-2
# 1.2 21-Mar-1993 cgd

after 0.2.2 "stable" patches applied


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.134 11-Jul-2019 maxv

Fix info leaks: the alignment of the structures causes uninitialized heap
memory to be copied to userland in sys_recvmsg().


Revision tags: phil-wifi-20190609 isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.133 04-Nov-2018 christos

- Introduce a new SO_RERROR socket option to explicitly turn on
receive overflow errors re-instating the default behavior to
silently ignore them as before 2018-03-19.
- Introduce a new kern.sooptions sysctl to control the default
behavior of socket options. Setting this to 0x4000 (SO_RERROR),
turns on receive overflow error reporting for all sockets.
- Change dhcpcd to turn on SO_RERROR on all its sockets.

As discussed in tech-net.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.132 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: pgoyette-compat-0728
# 1.131 20-Jul-2018 msaitoh

Add "show socket" command written by Hiroki SUENAGA. It prints usage of
system's socket buffers.


Revision tags: phil-wifi-base pgoyette-compat-0625
# 1.130 06-Jun-2018 roy

branches: 1.130.2;
Separate receive socket errors from general socket errors.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502
# 1.129 29-Apr-2018 maxv

Remove references to m_copy in comments.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.128 19-Mar-2018 roy

socket: report receive buffer overflows

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.


# 1.127 18-Mar-2018 christos

- Convert sb_lowat to unsigned for consistency. There are no negative value
uses
- Check for overflow as mentioned in the comment
- Sprinkle const


Revision tags: pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.126 06-Jul-2017 christos

branches: 1.126.4;
move the timestamp stuff to uipc_socket.c because it already has the compat
includes.


# 1.125 06-Jul-2017 christos

Merge the two copies SO_TIMESTAMP/SO_OTIMESTAMP processing to a single
function, and add a SOOPT_TIMESTAMP define reducing compat pollution from
5 places to 1.


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.124 02-Oct-2016 christos

branches: 1.124.8;
more MFREE -> m_free


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.123 23-May-2016 tls

branches: 1.123.2;
Fix a longstanding problem with accept filters noticed by Timo Buhrmester:
sockets sitting in the accept filter can consume the entire listen queue,
such that the application is never able to handle any connections. Handle
this by simply passing through the oldest queued cxn when the queue is full.

This is fair because the longer a cxn lingers in the queue (stays connected
but does not meet the requirements of the filter for passage) the more likely
it is to be passed through, at which point the application can dispose of it.

Works because none of our accept filters actually allocate private state
per-cxn. If they did, we'd have to fix the API bug that there is presently
no way to tell an accf to finish/deallocate for a single cxn (accf_destroy
kills off the entire filter instance for a given listen socket).


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.122 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.121 05-Sep-2014 matt

branches: 1.121.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.120 31-Jul-2014 rtr

split PRU_DISCONNECT, PRU_SHUTDOWN and PRU_ABORT function out of
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


# 1.119 19-May-2014 rmind

- Split off PRU_ATTACH and PRU_DETACH logic into separate functions.
- Replace malloc with kmem and eliminate M_PCB while here.
- Sprinkle more asserts.


Revision tags: rmind-smpnet-nbase rmind-smpnet-base
# 1.118 18-May-2014 rmind

Add struct pr_usrreqs with a pr_generic function and prepare for the
dismantling of pr_usrreq in the protocols; no functional change intended.
PRU_ATTACH/PRU_DETACH changes will follow soon.

Bump for struct protosw. Welcome to 6.99.62!


# 1.117 17-May-2014 rmind

sonewconn: insert the socket into the queue *after* the protocol attach.
This potentially avoids unnecessary race conditions when handling partial
connections.


# 1.116 17-May-2014 rmind

- sonewconn: improve the initialisation order and add some asserts.
- Add various comments describing primitive routines operating on sockets,
clarify connection life-cycle and improve the description of socket queues.
- Sprinkle more asserts.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.115 08-Oct-2013 christos

branches: 1.115.2;
0 -> NULL
MGET -> m_get
No functional change.


# 1.114 15-Sep-2013 martin

Avoid unused variable warnings


# 1.113 29-Aug-2013 rmind

Remove SS_ISCONFIRMING, it is unused and TP4 will not come back.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.112 28-Jun-2013 matt

branches: 1.112.2;
Make sbdrop panic more verbose


# 1.111 27-Jun-2013 christos

Introduce a more general method of sbcreatecontrol, sbcreatecontrol1 that
can take flags (M_WAITOK), and allocate large messages if needed. It also
returns the allocated pointer instead of copying the data to the passed
pointer. Implement sbcreatecontrol() using that.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.110 20-Dec-2011 christos

branches: 1.110.6;
- Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.
- Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis
- Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets.
- Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all
errors?).


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.109 31-Aug-2011 plunky

branches: 1.109.2; 1.109.6;
NULL does not need a cast


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.108 24-Apr-2011 rmind

- Replace few malloc(9) uses with kmem(9).
- Rename buf_malloc() to buf_alloc(), fix comments.
- Remove some unnecessary inclusions.


# 1.107 09-Apr-2011 christos

Preserve SB_ASYNC on the accepted socket. From: Dmitry Matveev
http://mail-index.netbsd.org/tech-net/2011/02/17/msg002457.html


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.106 30-Dec-2009 elad

branches: 1.106.4; 1.106.6;
Don't bother caching egid. It'll be removed soon.


# 1.105 30-Dec-2009 elad

Always use resource limits from the process, as proposed in

http://mail-index.netbsd.org/tech-kern/2009/12/30/msg006756.html

okay christos@.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.104 02-Sep-2009 tls

Add a direction argument to socket upcalls, so they can tell why they've
been called when, for example, they're waiting for space to write. From
Ritesh Agrawal at Coyote Point.


Revision tags: yamt-nfs-mp-base7
# 1.103 24-Jul-2009 christos

check return code from soreserve() (Sean Boudreau)


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 09-Apr-2009 yamt

sonewconn: add an assertion.


Revision tags: nick-hppapmap-base2
# 1.101 21-Jan-2009 yamt

branches: 1.101.2;
restore the pre socket locking patch signal behaviour.
this fixes a busy-loop in nfs_connect.


Revision tags: netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base mjf-devfs2-base
# 1.100 24-Oct-2008 dyoung

branches: 1.100.2; 1.100.4;
Change 'return (expr);' to 'return expr;'. Change (type *)0 to
NULL. No functional change intended.


Revision tags: haad-dm-base1
# 1.99 14-Oct-2008 ad

Accept filters:

- Remove remaining #ifdef INET.
- Avoid holding locks so we don't need to do KM_NOSLEEP allocations.
- Use a rwlock to protect the accept filter list.
- Make it safe to unload accept filter modules.
- Minor KNF.


# 1.98 11-Oct-2008 pooka

Move uidinfo to its own module in kern_uidinfo.c and include in rump.
No functional change to uidinfo.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.97 04-Aug-2008 tls

Add accept filters, ported from FreeBSD by Coyote Point Systems. Add inetd
support for specifying an accept filter for a service (mostly as a usage
example, but it can be handy for other things). Manual pages to follow
in a day or so.

OK core@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 1.96 18-Jun-2008 yamt

branches: 1.96.2;
merge yamt-pf42 branch.
(import newer pf from OpenBSD 4.2)

ok'ed by peter@. requested by core@


Revision tags: yamt-pf42-base4
# 1.95 10-Jun-2008 ad

There can be existing waiters on a socket's condition variables when we
change socket::so_lock, and they rely on the old lock to synchronize.
Wake them up whenever we change so_lock so they can restart their waits.


Revision tags: yamt-pf42-base3
# 1.94 26-May-2008 ad

branches: 1.94.2;
Use pool_cache for sockets.


# 1.93 24-May-2008 christos

Coverity CID 5025: sbreserve is never called with a null socket.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.92 28-Apr-2008 martin

branches: 1.92.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.91 24-Apr-2008 ad

branches: 1.91.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.90 01-Mar-2008 rmind

branches: 1.90.2;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.89 07-Feb-2008 ad

branches: 1.89.2; 1.89.6;
sonewconn: inherit FNONBLOCK from the parent.


# 1.88 29-Jan-2008 yamt

sbreserve: curlwp can't be NULL these days.
XXX these code seems to need an overhaul.


# 1.87 29-Jan-2008 yamt

sbrelease: unwrap a short line.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.86 25-Sep-2007 ad

branches: 1.86.4;
Use selinit() / seldestroy().


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base matt-mips64-base
# 1.85 02-Aug-2007 rmind

branches: 1.85.2; 1.85.4; 1.85.6; 1.85.8;
TCP socket buffers automatic sizing - ported from FreeBSD.
http://mail-index.netbsd.org/tech-net/2007/02/04/0006.html

! Disabled by default, marked as experimental. Testers are very needed.
! Someone should thoroughly test this, and improve if possible.

Discussed on <tech-net>:
http://mail-index.netbsd.org/tech-net/2007/07/12/0002.html
Thanks Greg Troxel for comments.

OK by the long silence on <tech-net>.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.84 04-Jul-2007 tls

branches: 1.84.2;
After looking at FreeBSD 6 again -- we were also failing to copy the
send and receive timeouts. Fix this.


# 1.83 04-Jul-2007 tls

Copy SNDLOWAT and RCVLOWAT socket options to accepted socket, so applications
can rely on all socket options being propagated from the listen socket as
the manual page says (and as everything but Linux has always done). FreeBSD 6
fixes this the same way, but this bug appears elsewhere and is...Old.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.82 04-Mar-2007 christos

branches: 1.82.2; 1.82.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.81 01-Nov-2006 yamt

branches: 1.81.4;
remove some __unused from function parameters.


Revision tags: yamt-splraiseipl-base2
# 1.80 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.79 03-Oct-2006 elad

Back out socket credentials for now, until we figure a better way of
handling the reference counting from interrupt context.


# 1.78 02-Oct-2006 elad

Add credentials to sockets, 'so_cred'.

Brought up on tech-kern@ some ~2 months ago, didn't seem to be an
objection; brought up again recently and no objection either... this is
not too intrusive and I've been running with this for a while.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.77 16-Aug-2006 plunky

branches: 1.77.4;
Fix broken comments - there is no SO_ISCONNECTED or SO_ISCONFIRMING

this fixes kern/32058


# 1.76 16-Aug-2006 plunky

Remove macro call sonewconn() => sonewconn1() as it is no longer necessary.
There are no such calls and the compiler would catch mistakes like this
in any case.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.75 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.74 03-Jul-2006 christos

Make sure we have at least PIPE_BUF bytes available in the socket send buffer.
Review and comment by yamt.


# 1.73 01-Jul-2006 christos

Revert previous change to bump the socket low watermark to sock_loan_thresh.
With sock_loan_thresh=4096, sb_lowat==sb_hiwat, and sowritable will never
be true (even if only a single byte is pending). Some programs (like screen)
expect select() to return that a socket is writable on a socket when there
is space to write to it. XXX: What is the right thing to do here?


Revision tags: yamt-pdpolicy-base6
# 1.72 21-Jun-2006 yamt

bump default so_snd.sb_lowat to increase chance to use loaning.

the idea to tweak the watermark from Jonathan Stone.
reviewed by Bill Studenmund.


Revision tags: chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.71 14-May-2006 elad

branches: 1.71.4;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.70 24-Dec-2005 perry

branches: 1.70.4; 1.70.6; 1.70.8; 1.70.10; 1.70.12;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.69 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.68 29-May-2005 christos

branches: 1.68.2;
- add const.
- remove unnecessary casts.
- add __UNCONST casts and mark them with XXXUNCONST as necessary.


# 1.67 07-May-2005 christos

PR/30154: YAMAMOTO Takashi: tcp_close locking botch
chgsbsize() as mentioned in the PR can be called from an interrupt context
via tcp_close(). Avoid calling uid_find() in chgsbsize().
- Instead of storing so_uid in struct socketvar, store *so_uidinfo
- Add a simple lock to struct uidinfo.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.66 26-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.65 24-Jun-2004 jonathan

branches: 1.65.4; 1.65.6;
Rename MBUFTRACE helper function m_claim() to m_claimm(),
for consistency with M_FREE() and m_freem(). Affected files:

sys/mbuf.h
kern/uipc_socket2.c
kern/uipc_mbuf.c
net/if_ethersubr.c
netatalk/ddp_input.c
nfs/nfs_socket.c


# 1.64 11-Jun-2004 jonathan

Fix potential memory leak in sbappendaddrchain():

We do an MGETHDR)() for each mbuf "packet" of the input chain, to hold
the socket address prepended to that "packet". If those MGETHDR()s
ever failed, we would leak all the successfully-allocated mbuf
headers. Leak noted by Yamamoto-san (yamt@NetBSD.org); thanks for catching it!

Add socketbuf invariant-checking macros to sbappendaddrchain(), and
replace a stray bcopy() with memcpy(), also as suggested by Yamamoto-san.


# 1.63 27-May-2004 jonathan

Rework to make FAST_IPSEC PF_KEY dumps unicast and reliable:

Introduce new socket-layer function sbappendaddrchain() to
sys/kern/uipc_socket2.c: like sbappendaddr(), only takes a chain of
records and appends the entire chain in one pass. sbappendaddrchain()
also takes an `sbprio' argument, which indicates the caller requires
special `reliable' handling of the socket-buffer. `sbprio' is
described in sys/sys/socketvar.h, although (for now) the different
levels are not yet implemented.

Rework sys/netipsec/key.c PF_KEY DUMP responses to build a chain of
mbuf records, one record per dump response. Unicast the entire chain
to the requestor, with all-or-none semantics.

Changed files;
sys/socketvar.h kern/uipc_socket2.c netipsec/key.c
Reviewed by:
Jason Thorpe, Thor Lancelot Simon, post to tech-kern.

Todo: request pullup to 2.0 branch. Post-2.0, rework sysctl() API for
dumps to use new record-chain constructors. Actually implement
the distinct service levels in sbappendaddrchain() so we can use them
to make PF_KEY ACQUIRE messages more reliable.


# 1.62 19-Apr-2004 christos

Charge root for socket buffers without a socket pointer.


# 1.61 18-Apr-2004 matt

Constify the addr parameter to sbappenaddr.


# 1.60 18-Apr-2004 matt

sbreserve can be called with a NULL socket, deal with it.


# 1.59 17-Apr-2004 christos

PR/9347: Eric E. Fair: socket buffer pool exhaustion leads to system deadlock
and unkillable processes.
1. Introduce new SBSIZE resource limit from FreeBSD to limit socket buffer
size resource.
2. make sokvareserve interruptible, so processes ltsleeping on it can be
killed.


Revision tags: netbsd-2-0-base
# 1.58 21-Oct-2003 thorpej

branches: 1.58.2;
Cache the "adjusted" value of sb_max when sb_max is changed, in order
to avoid doing quad math in sbreserve().

Change suggested by Simon Burge, and code inspired by a similar change
in FreeBSD.


# 1.57 22-Sep-2003 christos

- pass signo to fownsignal [ok by jd]
- make urg signal handling use fownsignal
- remove out of band detection in sowakeup


# 1.56 21-Sep-2003 jdolecek

cleanup & uniform descriptor owner handling:
* introduce fsetown(), fgetown(), fownsignal() - this sets/retrieves/signals
the owner of descriptor, according to appropriate sematics
of TIOCSPGRP/FIOSETOWN/SIOCSPGRP/TIOCGPGRP/FIOGETOWN/SIOCGPGRP ioctl; use
these routines instead of custom code where appropriate
* make every place handling TIOCSPGRP/TIOCGPGRP handle also FIOSETOWN/FIOGETOWN
properly, and remove the translation of FIO[SG]OWN to TIOC[SG]PGRP
in sys_ioctl() & sys_fcntl()
* also remove the socket-specific hack in sys_ioctl()/sys_fcntl() and
pass the ioctls down to soo_ioctl() as any other ioctl

change discussed on tech-kern@


# 1.55 06-Sep-2003 christos

SA_SIGINFO changes.


# 1.54 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.53 29-Jun-2003 fvdl

branches: 1.53.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.52 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.51 23-Jun-2003 martin

Make sure to include opt_foo.h if a defflag option FOO is used.


# 1.50 17-Apr-2003 fvdl

A bit of an ugly workaround to avoid a warning for a larger MSIZE.
Shouldn't make a difference in the generated code.


# 1.49 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge
# 1.48 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.47 27-Sep-2002 provos

remove trailing \n in panic(). approved perry.


Revision tags: gehenna-devsw-base
# 1.46 22-Aug-2002 thorpej

In sbcompress(), if we toss an empty mbuf, make sure to update
sb_lastrecord if necessary.

From Daniel Hartmeier <daniel@benzedrine.cx>.


# 1.45 03-Jul-2002 thorpej

Rename SB_UPDATE_TAIL() to SB_EMPTY_FIXUP(), per suggestion from
Jonathan Stone.


# 1.44 03-Jul-2002 thorpej

Rename sbappend_stream() to sbappendstream(), per suggestion from
Jonathan Stone.


# 1.43 03-Jul-2002 thorpej

Make insertion of data into socket buffers O(C):
* Keep pointers to the first and last mbufs of the last record in the
socket buffer.
* Use the sb_lastrecord pointer in the sbappend*() family of functions
to avoid traversing the packet chain to find the last record.
* Add a new sbappend_stream() function for stream protocols which
guarantee that there will never be more than one record in the
socket buffer. This function uses the sb_mbtail pointer to perform
the data insertion. Make TCP use sbappend_stream().

On a profiling run, this makes sbappend of a TCP transmission using
a 1M socket buffer go from 50% of the time to .02% of the time.

Thanks to Bill Sommerfeld and YAMAMOTO Takashi for their debugging
assistance!


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base thorpej-mips-cache-base
# 1.42 12-Nov-2001 lukem

branches: 1.42.8;
add RCSIDs


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 05-Aug-2001 enami

branches: 1.41.4;
Give different names for different wait channels.

# and minor knf fix while I'm here.


# 1.40 27-Jul-2001 thorpej

Now that M_TRAILINGSPACE() checks buffer writeability properly,
we can greatly simplify sbcompress(). Slightly modified from
a similar change in FreeBSD.


# 1.39 16-Jun-2001 manu

branches: 1.39.2;
Use SB_ASYNC in struct sockbuf sb_flags field instead of SS_ASYNC in
struct socket so_state field to decide if we need to send asynchronous
notifications. This makes possible to request notification on write but
not on read, and vice versa.

This is used in Linux emulation code, because when async I/O is requested,
Linux does not send SIGIO to write end of sockets, and it never send any
SIGIO to any end of pipes. Il Linux emulation code, we then set SB_ASYNC
only on the read end of sockets, and on no end for pipes.


# 1.38 30-Apr-2001 kml

Large values of sb_max would cause an overflow in sbreserve(); cast to
u_quad_t to avoid this. (from FreeBSD uipc_socket2.c v1.19)


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.37 27-Feb-2001 lukem

branches: 1.37.2;
convert to ANSI KNF


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 30-Mar-2000 augustss

Get rid of register declarations.


# 1.35 29-Feb-2000 itojun

more fix to ancillary data alignment. we need padding after
last cmsg_data item (see the figure on RFC2292 page 18).


# 1.34 18-Feb-2000 itojun

fix alignment problem in ancillary messages (alpha).

the change constitutes binary compatibility issue hen sizeof(long) !=4.
there's no way to be backward compatible, and only guys affected
are IPv6 userland tools.

From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base
# 1.33 04-Aug-1999 mycroft

branches: 1.33.2;
The old compaction test had an off-by-one error that caused it to not compact
in some cases where it could have. Fix this, and the new version as well.


# 1.32 04-Aug-1999 matt

Don't compress mbuf clusters which are referenced by multiple
mbufs since you might overwriting valuable data. (think of
m_copy'ed data from a TCP re-transmission queue. Since those
might be in clusters and referenced in two sockets).


# 1.31 04-Aug-1999 mycroft

It's now possible for sbcompress() to compact mbuf clusters, so do it.
This helps prevent mbuf cluster exhaustion when receiving lots of small
packets.


Revision tags: chs-ubc2-base
# 1.30 01-Jul-1999 itojun

IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.


# 1.29 22-Apr-1999 simonb

Move inclusion of "opt_sb_max.h" from sys/socketvar.h to
conf/param.c, and move the initialisation of the sb_max
variable from kern/uipc_socket2.c to conf/param.c. Now
everthing that includes sys/socketvar.h doesn't get
recompiled when SB_MAX's value changes.


Revision tags: netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.28 23-Mar-1999 lukem

branches: 1.28.2; 1.28.4; 1.28.6;
Ensure that you can only bind a more specific address when it is done by the
same uid or by root.

This code is from FreeBSD. (Whilst it was originally obtained from OpenBSD,
FreeBSD fixed it to work with multicast. To quote the commit message:
- Don't bother checking for conflicting sockets if we're binding to a
multicast address.
- Don't return an error if we're binding to INADDR_ANY, the conflicting
socket is bound to INADDR_ANY, and the conflicting socket has
SO_REUSEPORT set.
)


# 1.27 20-Jan-1999 mycroft

Do not remove sockets from the accept(2) queue on close.


Revision tags: kenh-if-detach-base chs-ubc-base
# 1.26 04-Aug-1998 perry

Abolition of bcopy, ovbcopy, bcmp, and bzero, phase one.
bcopy(x, y, z) -> memcpy(y, x, z)
ovbcopy(x, y, z) -> memmove(y, x, z)
bcmp(x, y, z) -> memcmp(x, y, z)
bzero(x, y) -> memset(x, 0, y)


# 1.25 02-Aug-1998 thorpej

Use the pool allocator for sockets.


Revision tags: eeh-paddr_t-base
# 1.24 25-Apr-1998 matt

Hook for 0-copy (or other optimized) sends and receives


# 1.23 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.22 07-Jan-1998 thorpej

Make insertion and removal of sockets from the partial and incoming
connections queues O(C) rather than O(N).


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base marc-pcmcia-base
# 1.21 09-Oct-1997 mycroft

branches: 1.21.2;
Make various standard wmesg strings const.


Revision tags: thorpej-signal-base marc-pcmcia-bp SYN_cache_cur_base
# 1.20 26-Jun-1997 thorpej

branches: 1.20.4;
In sbappendaddr(), if the sockaddr length is larger than will fit in
an mbuf, allocate enough external storage to hold the sockaddr. Thanks
to enami tsugutomo <enami@cv.sony.co.jp> for providing sanity-checks.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.19 11-Jan-1997 thorpej

branches: 1.19.8;
Implement sbcreatecontrol(), a generic function to create a "control"
mbuf for presentation on a socket buffer.


# 1.18 09-Dec-1996 thorpej

In sbreserve(), don't allow a count of 0. Fixes PR #2794, from
Erik Berls <cyber@dis.org>.


# 1.17 26-Nov-1996 thorpej

Back out previous soqinsque() and soqremque() changes. This will
stop the panics until the socket queues get converted to <sys/queue.h>.


# 1.16 10-Nov-1996 thorpej

Optimization of soqinsque() and soqremque():

Keep queue of pending sockets in a double linked list. Previously,
a singly linked list was used, giving O(N) insertion/deletion times,
and was a major time consumer for sockets with large pending queues.
The double linked list give O(C) insertion/deletion times with only
a small cost in complexity.

Since a socket can be on, at most, one queue at a time, both so_q and
so_q0 can safely be used as (forward and backward, respectively) queue
pointers.

Submitted my Matt Thomas <matt@3am-software.com>, a long time ago.
(Geez, I've been running with this patch for _months_, and had completely
forgotten about it!)


# 1.15 13-Oct-1996 christos

backout previous kprintf change


# 1.14 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.13 07-Sep-1996 mycroft

Implement poll(2).


# 1.12 22-May-1996 mycroft

Pass a proc pointer down to the usrreq and pcbbind functions for PRU_ATTACH, PRU_BIND and
PRU_CONTROL. The usrreq interface really needs to be split up, but this will have to wait.
Remove SS_PRIV completely.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.11 04-Feb-1996 christos

branches: 1.11.4;
First pass at prototyping


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.10 16-Aug-1995 mycroft

Access rights are now stored in MT_CONTROL mbufs. Document this.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.9 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.8 13-May-1994 mycroft

Update to 4.4-Lite networking code, with a few local changes.


# 1.7 04-May-1994 mycroft

More return types...


# 1.6 25-Apr-1994 mycroft

Remove sbselqueue().


# 1.5 18-Dec-1993 mycroft

Canonicalize all #includes.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 27-Jun-1993 andrew

branches: 1.4.4;
ANSIfications - removed all implicit function return types and argument
definitions. Ensured that all files include "systm.h" to gain access to
general prototypes. Casts where necessary.


# 1.3 18-May-1993 cgd

make kernel select interface be one-stop shopping & clean it all up.


Revision tags: netbsd-0-8 netbsd-alpha-1 patchkit-0-2-2
# 1.2 21-Mar-1993 cgd

after 0.2.2 "stable" patches applied


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


Revision tags: isaki-audio2-base pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.133 04-Nov-2018 christos

- Introduce a new SO_RERROR socket option to explicitly turn on
receive overflow errors re-instating the default behavior to
silently ignore them as before 2018-03-19.
- Introduce a new kern.sooptions sysctl to control the default
behavior of socket options. Setting this to 0x4000 (SO_RERROR),
turns on receive overflow error reporting for all sockets.
- Change dhcpcd to turn on SO_RERROR on all its sockets.

As discussed in tech-net.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.132 03-Sep-2018 riastradh

Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)


Revision tags: pgoyette-compat-0728
# 1.131 20-Jul-2018 msaitoh

Add "show socket" command written by Hiroki SUENAGA. It prints usage of
system's socket buffers.


Revision tags: phil-wifi-base pgoyette-compat-0625
# 1.130 06-Jun-2018 roy

Separate receive socket errors from general socket errors.


Revision tags: pgoyette-compat-0521 pgoyette-compat-0502
# 1.129 29-Apr-2018 maxv

Remove references to m_copy in comments.


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322
# 1.128 19-Mar-2018 roy

socket: report receive buffer overflows

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.


# 1.127 18-Mar-2018 christos

- Convert sb_lowat to unsigned for consistency. There are no negative value
uses
- Check for overflow as mentioned in the comment
- Sprinkle const


Revision tags: pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.126 06-Jul-2017 christos

branches: 1.126.4;
move the timestamp stuff to uipc_socket.c because it already has the compat
includes.


# 1.125 06-Jul-2017 christos

Merge the two copies SO_TIMESTAMP/SO_OTIMESTAMP processing to a single
function, and add a SOOPT_TIMESTAMP define reducing compat pollution from
5 places to 1.


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.124 02-Oct-2016 christos

branches: 1.124.8;
more MFREE -> m_free


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.123 23-May-2016 tls

branches: 1.123.2;
Fix a longstanding problem with accept filters noticed by Timo Buhrmester:
sockets sitting in the accept filter can consume the entire listen queue,
such that the application is never able to handle any connections. Handle
this by simply passing through the oldest queued cxn when the queue is full.

This is fair because the longer a cxn lingers in the queue (stays connected
but does not meet the requirements of the filter for passage) the more likely
it is to be passed through, at which point the application can dispose of it.

Works because none of our accept filters actually allocate private state
per-cxn. If they did, we'd have to fix the API bug that there is presently
no way to tell an accf to finish/deallocate for a single cxn (accf_destroy
kills off the entire filter instance for a given listen socket).


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.122 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.121 05-Sep-2014 matt

branches: 1.121.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.120 31-Jul-2014 rtr

split PRU_DISCONNECT, PRU_SHUTDOWN and PRU_ABORT function out of
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


# 1.119 19-May-2014 rmind

- Split off PRU_ATTACH and PRU_DETACH logic into separate functions.
- Replace malloc with kmem and eliminate M_PCB while here.
- Sprinkle more asserts.


Revision tags: rmind-smpnet-nbase rmind-smpnet-base
# 1.118 18-May-2014 rmind

Add struct pr_usrreqs with a pr_generic function and prepare for the
dismantling of pr_usrreq in the protocols; no functional change intended.
PRU_ATTACH/PRU_DETACH changes will follow soon.

Bump for struct protosw. Welcome to 6.99.62!


# 1.117 17-May-2014 rmind

sonewconn: insert the socket into the queue *after* the protocol attach.
This potentially avoids unnecessary race conditions when handling partial
connections.


# 1.116 17-May-2014 rmind

- sonewconn: improve the initialisation order and add some asserts.
- Add various comments describing primitive routines operating on sockets,
clarify connection life-cycle and improve the description of socket queues.
- Sprinkle more asserts.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.115 08-Oct-2013 christos

branches: 1.115.2;
0 -> NULL
MGET -> m_get
No functional change.


# 1.114 15-Sep-2013 martin

Avoid unused variable warnings


# 1.113 29-Aug-2013 rmind

Remove SS_ISCONFIRMING, it is unused and TP4 will not come back.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.112 28-Jun-2013 matt

branches: 1.112.2;
Make sbdrop panic more verbose


# 1.111 27-Jun-2013 christos

Introduce a more general method of sbcreatecontrol, sbcreatecontrol1 that
can take flags (M_WAITOK), and allocate large messages if needed. It also
returns the allocated pointer instead of copying the data to the passed
pointer. Implement sbcreatecontrol() using that.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.110 20-Dec-2011 christos

branches: 1.110.6;
- Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.
- Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis
- Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets.
- Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all
errors?).


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.109 31-Aug-2011 plunky

branches: 1.109.2; 1.109.6;
NULL does not need a cast


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.108 24-Apr-2011 rmind

- Replace few malloc(9) uses with kmem(9).
- Rename buf_malloc() to buf_alloc(), fix comments.
- Remove some unnecessary inclusions.


# 1.107 09-Apr-2011 christos

Preserve SB_ASYNC on the accepted socket. From: Dmitry Matveev
http://mail-index.netbsd.org/tech-net/2011/02/17/msg002457.html


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.106 30-Dec-2009 elad

branches: 1.106.4; 1.106.6;
Don't bother caching egid. It'll be removed soon.


# 1.105 30-Dec-2009 elad

Always use resource limits from the process, as proposed in

http://mail-index.netbsd.org/tech-kern/2009/12/30/msg006756.html

okay christos@.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.104 02-Sep-2009 tls

Add a direction argument to socket upcalls, so they can tell why they've
been called when, for example, they're waiting for space to write. From
Ritesh Agrawal at Coyote Point.


Revision tags: yamt-nfs-mp-base7
# 1.103 24-Jul-2009 christos

check return code from soreserve() (Sean Boudreau)


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 09-Apr-2009 yamt

sonewconn: add an assertion.


Revision tags: nick-hppapmap-base2
# 1.101 21-Jan-2009 yamt

branches: 1.101.2;
restore the pre socket locking patch signal behaviour.
this fixes a busy-loop in nfs_connect.


Revision tags: netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base mjf-devfs2-base
# 1.100 24-Oct-2008 dyoung

branches: 1.100.2; 1.100.4;
Change 'return (expr);' to 'return expr;'. Change (type *)0 to
NULL. No functional change intended.


Revision tags: haad-dm-base1
# 1.99 14-Oct-2008 ad

Accept filters:

- Remove remaining #ifdef INET.
- Avoid holding locks so we don't need to do KM_NOSLEEP allocations.
- Use a rwlock to protect the accept filter list.
- Make it safe to unload accept filter modules.
- Minor KNF.


# 1.98 11-Oct-2008 pooka

Move uidinfo to its own module in kern_uidinfo.c and include in rump.
No functional change to uidinfo.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.97 04-Aug-2008 tls

Add accept filters, ported from FreeBSD by Coyote Point Systems. Add inetd
support for specifying an accept filter for a service (mostly as a usage
example, but it can be handy for other things). Manual pages to follow
in a day or so.

OK core@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 1.96 18-Jun-2008 yamt

branches: 1.96.2;
merge yamt-pf42 branch.
(import newer pf from OpenBSD 4.2)

ok'ed by peter@. requested by core@


Revision tags: yamt-pf42-base4
# 1.95 10-Jun-2008 ad

There can be existing waiters on a socket's condition variables when we
change socket::so_lock, and they rely on the old lock to synchronize.
Wake them up whenever we change so_lock so they can restart their waits.


Revision tags: yamt-pf42-base3
# 1.94 26-May-2008 ad

branches: 1.94.2;
Use pool_cache for sockets.


# 1.93 24-May-2008 christos

Coverity CID 5025: sbreserve is never called with a null socket.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.92 28-Apr-2008 martin

branches: 1.92.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.91 24-Apr-2008 ad

branches: 1.91.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.90 01-Mar-2008 rmind

branches: 1.90.2;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.89 07-Feb-2008 ad

branches: 1.89.2; 1.89.6;
sonewconn: inherit FNONBLOCK from the parent.


# 1.88 29-Jan-2008 yamt

sbreserve: curlwp can't be NULL these days.
XXX these code seems to need an overhaul.


# 1.87 29-Jan-2008 yamt

sbrelease: unwrap a short line.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.86 25-Sep-2007 ad

branches: 1.86.4;
Use selinit() / seldestroy().


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base matt-mips64-base
# 1.85 02-Aug-2007 rmind

branches: 1.85.2; 1.85.4; 1.85.6; 1.85.8;
TCP socket buffers automatic sizing - ported from FreeBSD.
http://mail-index.netbsd.org/tech-net/2007/02/04/0006.html

! Disabled by default, marked as experimental. Testers are very needed.
! Someone should thoroughly test this, and improve if possible.

Discussed on <tech-net>:
http://mail-index.netbsd.org/tech-net/2007/07/12/0002.html
Thanks Greg Troxel for comments.

OK by the long silence on <tech-net>.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.84 04-Jul-2007 tls

branches: 1.84.2;
After looking at FreeBSD 6 again -- we were also failing to copy the
send and receive timeouts. Fix this.


# 1.83 04-Jul-2007 tls

Copy SNDLOWAT and RCVLOWAT socket options to accepted socket, so applications
can rely on all socket options being propagated from the listen socket as
the manual page says (and as everything but Linux has always done). FreeBSD 6
fixes this the same way, but this bug appears elsewhere and is...Old.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.82 04-Mar-2007 christos

branches: 1.82.2; 1.82.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.81 01-Nov-2006 yamt

branches: 1.81.4;
remove some __unused from function parameters.


Revision tags: yamt-splraiseipl-base2
# 1.80 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.79 03-Oct-2006 elad

Back out socket credentials for now, until we figure a better way of
handling the reference counting from interrupt context.


# 1.78 02-Oct-2006 elad

Add credentials to sockets, 'so_cred'.

Brought up on tech-kern@ some ~2 months ago, didn't seem to be an
objection; brought up again recently and no objection either... this is
not too intrusive and I've been running with this for a while.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.77 16-Aug-2006 plunky

branches: 1.77.4;
Fix broken comments - there is no SO_ISCONNECTED or SO_ISCONFIRMING

this fixes kern/32058


# 1.76 16-Aug-2006 plunky

Remove macro call sonewconn() => sonewconn1() as it is no longer necessary.
There are no such calls and the compiler would catch mistakes like this
in any case.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.75 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.74 03-Jul-2006 christos

Make sure we have at least PIPE_BUF bytes available in the socket send buffer.
Review and comment by yamt.


# 1.73 01-Jul-2006 christos

Revert previous change to bump the socket low watermark to sock_loan_thresh.
With sock_loan_thresh=4096, sb_lowat==sb_hiwat, and sowritable will never
be true (even if only a single byte is pending). Some programs (like screen)
expect select() to return that a socket is writable on a socket when there
is space to write to it. XXX: What is the right thing to do here?


Revision tags: yamt-pdpolicy-base6
# 1.72 21-Jun-2006 yamt

bump default so_snd.sb_lowat to increase chance to use loaning.

the idea to tweak the watermark from Jonathan Stone.
reviewed by Bill Studenmund.


Revision tags: chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.71 14-May-2006 elad

branches: 1.71.4;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.70 24-Dec-2005 perry

branches: 1.70.4; 1.70.6; 1.70.8; 1.70.10; 1.70.12;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.69 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.68 29-May-2005 christos

branches: 1.68.2;
- add const.
- remove unnecessary casts.
- add __UNCONST casts and mark them with XXXUNCONST as necessary.


# 1.67 07-May-2005 christos

PR/30154: YAMAMOTO Takashi: tcp_close locking botch
chgsbsize() as mentioned in the PR can be called from an interrupt context
via tcp_close(). Avoid calling uid_find() in chgsbsize().
- Instead of storing so_uid in struct socketvar, store *so_uidinfo
- Add a simple lock to struct uidinfo.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.66 26-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.65 24-Jun-2004 jonathan

branches: 1.65.4; 1.65.6;
Rename MBUFTRACE helper function m_claim() to m_claimm(),
for consistency with M_FREE() and m_freem(). Affected files:

sys/mbuf.h
kern/uipc_socket2.c
kern/uipc_mbuf.c
net/if_ethersubr.c
netatalk/ddp_input.c
nfs/nfs_socket.c


# 1.64 11-Jun-2004 jonathan

Fix potential memory leak in sbappendaddrchain():

We do an MGETHDR)() for each mbuf "packet" of the input chain, to hold
the socket address prepended to that "packet". If those MGETHDR()s
ever failed, we would leak all the successfully-allocated mbuf
headers. Leak noted by Yamamoto-san (yamt@NetBSD.org); thanks for catching it!

Add socketbuf invariant-checking macros to sbappendaddrchain(), and
replace a stray bcopy() with memcpy(), also as suggested by Yamamoto-san.


# 1.63 27-May-2004 jonathan

Rework to make FAST_IPSEC PF_KEY dumps unicast and reliable:

Introduce new socket-layer function sbappendaddrchain() to
sys/kern/uipc_socket2.c: like sbappendaddr(), only takes a chain of
records and appends the entire chain in one pass. sbappendaddrchain()
also takes an `sbprio' argument, which indicates the caller requires
special `reliable' handling of the socket-buffer. `sbprio' is
described in sys/sys/socketvar.h, although (for now) the different
levels are not yet implemented.

Rework sys/netipsec/key.c PF_KEY DUMP responses to build a chain of
mbuf records, one record per dump response. Unicast the entire chain
to the requestor, with all-or-none semantics.

Changed files;
sys/socketvar.h kern/uipc_socket2.c netipsec/key.c
Reviewed by:
Jason Thorpe, Thor Lancelot Simon, post to tech-kern.

Todo: request pullup to 2.0 branch. Post-2.0, rework sysctl() API for
dumps to use new record-chain constructors. Actually implement
the distinct service levels in sbappendaddrchain() so we can use them
to make PF_KEY ACQUIRE messages more reliable.


# 1.62 19-Apr-2004 christos

Charge root for socket buffers without a socket pointer.


# 1.61 18-Apr-2004 matt

Constify the addr parameter to sbappenaddr.


# 1.60 18-Apr-2004 matt

sbreserve can be called with a NULL socket, deal with it.


# 1.59 17-Apr-2004 christos

PR/9347: Eric E. Fair: socket buffer pool exhaustion leads to system deadlock
and unkillable processes.
1. Introduce new SBSIZE resource limit from FreeBSD to limit socket buffer
size resource.
2. make sokvareserve interruptible, so processes ltsleeping on it can be
killed.


Revision tags: netbsd-2-0-base
# 1.58 21-Oct-2003 thorpej

branches: 1.58.2;
Cache the "adjusted" value of sb_max when sb_max is changed, in order
to avoid doing quad math in sbreserve().

Change suggested by Simon Burge, and code inspired by a similar change
in FreeBSD.


# 1.57 22-Sep-2003 christos

- pass signo to fownsignal [ok by jd]
- make urg signal handling use fownsignal
- remove out of band detection in sowakeup


# 1.56 21-Sep-2003 jdolecek

cleanup & uniform descriptor owner handling:
* introduce fsetown(), fgetown(), fownsignal() - this sets/retrieves/signals
the owner of descriptor, according to appropriate sematics
of TIOCSPGRP/FIOSETOWN/SIOCSPGRP/TIOCGPGRP/FIOGETOWN/SIOCGPGRP ioctl; use
these routines instead of custom code where appropriate
* make every place handling TIOCSPGRP/TIOCGPGRP handle also FIOSETOWN/FIOGETOWN
properly, and remove the translation of FIO[SG]OWN to TIOC[SG]PGRP
in sys_ioctl() & sys_fcntl()
* also remove the socket-specific hack in sys_ioctl()/sys_fcntl() and
pass the ioctls down to soo_ioctl() as any other ioctl

change discussed on tech-kern@


# 1.55 06-Sep-2003 christos

SA_SIGINFO changes.


# 1.54 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.53 29-Jun-2003 fvdl

branches: 1.53.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.52 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.51 23-Jun-2003 martin

Make sure to include opt_foo.h if a defflag option FOO is used.


# 1.50 17-Apr-2003 fvdl

A bit of an ugly workaround to avoid a warning for a larger MSIZE.
Shouldn't make a difference in the generated code.


# 1.49 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge
# 1.48 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.47 27-Sep-2002 provos

remove trailing \n in panic(). approved perry.


Revision tags: gehenna-devsw-base
# 1.46 22-Aug-2002 thorpej

In sbcompress(), if we toss an empty mbuf, make sure to update
sb_lastrecord if necessary.

From Daniel Hartmeier <daniel@benzedrine.cx>.


# 1.45 03-Jul-2002 thorpej

Rename SB_UPDATE_TAIL() to SB_EMPTY_FIXUP(), per suggestion from
Jonathan Stone.


# 1.44 03-Jul-2002 thorpej

Rename sbappend_stream() to sbappendstream(), per suggestion from
Jonathan Stone.


# 1.43 03-Jul-2002 thorpej

Make insertion of data into socket buffers O(C):
* Keep pointers to the first and last mbufs of the last record in the
socket buffer.
* Use the sb_lastrecord pointer in the sbappend*() family of functions
to avoid traversing the packet chain to find the last record.
* Add a new sbappend_stream() function for stream protocols which
guarantee that there will never be more than one record in the
socket buffer. This function uses the sb_mbtail pointer to perform
the data insertion. Make TCP use sbappend_stream().

On a profiling run, this makes sbappend of a TCP transmission using
a 1M socket buffer go from 50% of the time to .02% of the time.

Thanks to Bill Sommerfeld and YAMAMOTO Takashi for their debugging
assistance!


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base thorpej-mips-cache-base
# 1.42 12-Nov-2001 lukem

branches: 1.42.8;
add RCSIDs


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 05-Aug-2001 enami

branches: 1.41.4;
Give different names for different wait channels.

# and minor knf fix while I'm here.


# 1.40 27-Jul-2001 thorpej

Now that M_TRAILINGSPACE() checks buffer writeability properly,
we can greatly simplify sbcompress(). Slightly modified from
a similar change in FreeBSD.


# 1.39 16-Jun-2001 manu

branches: 1.39.2;
Use SB_ASYNC in struct sockbuf sb_flags field instead of SS_ASYNC in
struct socket so_state field to decide if we need to send asynchronous
notifications. This makes possible to request notification on write but
not on read, and vice versa.

This is used in Linux emulation code, because when async I/O is requested,
Linux does not send SIGIO to write end of sockets, and it never send any
SIGIO to any end of pipes. Il Linux emulation code, we then set SB_ASYNC
only on the read end of sockets, and on no end for pipes.


# 1.38 30-Apr-2001 kml

Large values of sb_max would cause an overflow in sbreserve(); cast to
u_quad_t to avoid this. (from FreeBSD uipc_socket2.c v1.19)


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.37 27-Feb-2001 lukem

branches: 1.37.2;
convert to ANSI KNF


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 30-Mar-2000 augustss

Get rid of register declarations.


# 1.35 29-Feb-2000 itojun

more fix to ancillary data alignment. we need padding after
last cmsg_data item (see the figure on RFC2292 page 18).


# 1.34 18-Feb-2000 itojun

fix alignment problem in ancillary messages (alpha).

the change constitutes binary compatibility issue hen sizeof(long) !=4.
there's no way to be backward compatible, and only guys affected
are IPv6 userland tools.

From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base
# 1.33 04-Aug-1999 mycroft

branches: 1.33.2;
The old compaction test had an off-by-one error that caused it to not compact
in some cases where it could have. Fix this, and the new version as well.


# 1.32 04-Aug-1999 matt

Don't compress mbuf clusters which are referenced by multiple
mbufs since you might overwriting valuable data. (think of
m_copy'ed data from a TCP re-transmission queue. Since those
might be in clusters and referenced in two sockets).


# 1.31 04-Aug-1999 mycroft

It's now possible for sbcompress() to compact mbuf clusters, so do it.
This helps prevent mbuf cluster exhaustion when receiving lots of small
packets.


Revision tags: chs-ubc2-base
# 1.30 01-Jul-1999 itojun

IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.


# 1.29 22-Apr-1999 simonb

Move inclusion of "opt_sb_max.h" from sys/socketvar.h to
conf/param.c, and move the initialisation of the sb_max
variable from kern/uipc_socket2.c to conf/param.c. Now
everthing that includes sys/socketvar.h doesn't get
recompiled when SB_MAX's value changes.


Revision tags: netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.28 23-Mar-1999 lukem

branches: 1.28.2; 1.28.4; 1.28.6;
Ensure that you can only bind a more specific address when it is done by the
same uid or by root.

This code is from FreeBSD. (Whilst it was originally obtained from OpenBSD,
FreeBSD fixed it to work with multicast. To quote the commit message:
- Don't bother checking for conflicting sockets if we're binding to a
multicast address.
- Don't return an error if we're binding to INADDR_ANY, the conflicting
socket is bound to INADDR_ANY, and the conflicting socket has
SO_REUSEPORT set.
)


# 1.27 20-Jan-1999 mycroft

Do not remove sockets from the accept(2) queue on close.


Revision tags: kenh-if-detach-base chs-ubc-base
# 1.26 04-Aug-1998 perry

Abolition of bcopy, ovbcopy, bcmp, and bzero, phase one.
bcopy(x, y, z) -> memcpy(y, x, z)
ovbcopy(x, y, z) -> memmove(y, x, z)
bcmp(x, y, z) -> memcmp(x, y, z)
bzero(x, y) -> memset(x, 0, y)


# 1.25 02-Aug-1998 thorpej

Use the pool allocator for sockets.


Revision tags: eeh-paddr_t-base
# 1.24 25-Apr-1998 matt

Hook for 0-copy (or other optimized) sends and receives


# 1.23 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.22 07-Jan-1998 thorpej

Make insertion and removal of sockets from the partial and incoming
connections queues O(C) rather than O(N).


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base marc-pcmcia-base
# 1.21 09-Oct-1997 mycroft

branches: 1.21.2;
Make various standard wmesg strings const.


Revision tags: thorpej-signal-base marc-pcmcia-bp SYN_cache_cur_base
# 1.20 26-Jun-1997 thorpej

branches: 1.20.4;
In sbappendaddr(), if the sockaddr length is larger than will fit in
an mbuf, allocate enough external storage to hold the sockaddr. Thanks
to enami tsugutomo <enami@cv.sony.co.jp> for providing sanity-checks.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.19 11-Jan-1997 thorpej

branches: 1.19.8;
Implement sbcreatecontrol(), a generic function to create a "control"
mbuf for presentation on a socket buffer.


# 1.18 09-Dec-1996 thorpej

In sbreserve(), don't allow a count of 0. Fixes PR #2794, from
Erik Berls <cyber@dis.org>.


# 1.17 26-Nov-1996 thorpej

Back out previous soqinsque() and soqremque() changes. This will
stop the panics until the socket queues get converted to <sys/queue.h>.


# 1.16 10-Nov-1996 thorpej

Optimization of soqinsque() and soqremque():

Keep queue of pending sockets in a double linked list. Previously,
a singly linked list was used, giving O(N) insertion/deletion times,
and was a major time consumer for sockets with large pending queues.
The double linked list give O(C) insertion/deletion times with only
a small cost in complexity.

Since a socket can be on, at most, one queue at a time, both so_q and
so_q0 can safely be used as (forward and backward, respectively) queue
pointers.

Submitted my Matt Thomas <matt@3am-software.com>, a long time ago.
(Geez, I've been running with this patch for _months_, and had completely
forgotten about it!)


# 1.15 13-Oct-1996 christos

backout previous kprintf change


# 1.14 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.13 07-Sep-1996 mycroft

Implement poll(2).


# 1.12 22-May-1996 mycroft

Pass a proc pointer down to the usrreq and pcbbind functions for PRU_ATTACH, PRU_BIND and
PRU_CONTROL. The usrreq interface really needs to be split up, but this will have to wait.
Remove SS_PRIV completely.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.11 04-Feb-1996 christos

branches: 1.11.4;
First pass at prototyping


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.10 16-Aug-1995 mycroft

Access rights are now stored in MT_CONTROL mbufs. Document this.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.9 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.8 13-May-1994 mycroft

Update to 4.4-Lite networking code, with a few local changes.


# 1.7 04-May-1994 mycroft

More return types...


# 1.6 25-Apr-1994 mycroft

Remove sbselqueue().


# 1.5 18-Dec-1993 mycroft

Canonicalize all #includes.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 27-Jun-1993 andrew

branches: 1.4.4;
ANSIfications - removed all implicit function return types and argument
definitions. Ensured that all files include "systm.h" to gain access to
general prototypes. Casts where necessary.


# 1.3 18-May-1993 cgd

make kernel select interface be one-stop shopping & clean it all up.


Revision tags: netbsd-0-8 netbsd-alpha-1 patchkit-0-2-2
# 1.2 21-Mar-1993 cgd

after 0.2.2 "stable" patches applied


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.126 06-Jul-2017 christos

move the timestamp stuff to uipc_socket.c because it already has the compat
includes.


# 1.125 06-Jul-2017 christos

Merge the two copies SO_TIMESTAMP/SO_OTIMESTAMP processing to a single
function, and add a SOOPT_TIMESTAMP define reducing compat pollution from
5 places to 1.


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107 nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.124 02-Oct-2016 christos

more MFREE -> m_free


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.123 23-May-2016 tls

branches: 1.123.2;
Fix a longstanding problem with accept filters noticed by Timo Buhrmester:
sockets sitting in the accept filter can consume the entire listen queue,
such that the application is never able to handle any connections. Handle
this by simply passing through the oldest queued cxn when the queue is full.

This is fair because the longer a cxn lingers in the queue (stays connected
but does not meet the requirements of the filter for passage) the more likely
it is to be passed through, at which point the application can dispose of it.

Works because none of our accept filters actually allocate private state
per-cxn. If they did, we'd have to fix the API bug that there is presently
no way to tell an accf to finish/deallocate for a single cxn (accf_destroy
kills off the entire filter instance for a given listen socket).


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.122 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.121 05-Sep-2014 matt

branches: 1.121.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.120 31-Jul-2014 rtr

split PRU_DISCONNECT, PRU_SHUTDOWN and PRU_ABORT function out of
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


# 1.119 19-May-2014 rmind

- Split off PRU_ATTACH and PRU_DETACH logic into separate functions.
- Replace malloc with kmem and eliminate M_PCB while here.
- Sprinkle more asserts.


Revision tags: rmind-smpnet-nbase rmind-smpnet-base
# 1.118 18-May-2014 rmind

Add struct pr_usrreqs with a pr_generic function and prepare for the
dismantling of pr_usrreq in the protocols; no functional change intended.
PRU_ATTACH/PRU_DETACH changes will follow soon.

Bump for struct protosw. Welcome to 6.99.62!


# 1.117 17-May-2014 rmind

sonewconn: insert the socket into the queue *after* the protocol attach.
This potentially avoids unnecessary race conditions when handling partial
connections.


# 1.116 17-May-2014 rmind

- sonewconn: improve the initialisation order and add some asserts.
- Add various comments describing primitive routines operating on sockets,
clarify connection life-cycle and improve the description of socket queues.
- Sprinkle more asserts.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.115 08-Oct-2013 christos

branches: 1.115.2;
0 -> NULL
MGET -> m_get
No functional change.


# 1.114 15-Sep-2013 martin

Avoid unused variable warnings


# 1.113 29-Aug-2013 rmind

Remove SS_ISCONFIRMING, it is unused and TP4 will not come back.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.112 28-Jun-2013 matt

branches: 1.112.2;
Make sbdrop panic more verbose


# 1.111 27-Jun-2013 christos

Introduce a more general method of sbcreatecontrol, sbcreatecontrol1 that
can take flags (M_WAITOK), and allocate large messages if needed. It also
returns the allocated pointer instead of copying the data to the passed
pointer. Implement sbcreatecontrol() using that.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.110 20-Dec-2011 christos

branches: 1.110.6;
- Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.
- Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis
- Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets.
- Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all
errors?).


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.109 31-Aug-2011 plunky

branches: 1.109.2; 1.109.6;
NULL does not need a cast


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.108 24-Apr-2011 rmind

- Replace few malloc(9) uses with kmem(9).
- Rename buf_malloc() to buf_alloc(), fix comments.
- Remove some unnecessary inclusions.


# 1.107 09-Apr-2011 christos

Preserve SB_ASYNC on the accepted socket. From: Dmitry Matveev
http://mail-index.netbsd.org/tech-net/2011/02/17/msg002457.html


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.106 30-Dec-2009 elad

branches: 1.106.4; 1.106.6;
Don't bother caching egid. It'll be removed soon.


# 1.105 30-Dec-2009 elad

Always use resource limits from the process, as proposed in

http://mail-index.netbsd.org/tech-kern/2009/12/30/msg006756.html

okay christos@.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.104 02-Sep-2009 tls

Add a direction argument to socket upcalls, so they can tell why they've
been called when, for example, they're waiting for space to write. From
Ritesh Agrawal at Coyote Point.


Revision tags: yamt-nfs-mp-base7
# 1.103 24-Jul-2009 christos

check return code from soreserve() (Sean Boudreau)


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 09-Apr-2009 yamt

sonewconn: add an assertion.


Revision tags: nick-hppapmap-base2
# 1.101 21-Jan-2009 yamt

branches: 1.101.2;
restore the pre socket locking patch signal behaviour.
this fixes a busy-loop in nfs_connect.


Revision tags: netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base mjf-devfs2-base
# 1.100 24-Oct-2008 dyoung

branches: 1.100.2; 1.100.4;
Change 'return (expr);' to 'return expr;'. Change (type *)0 to
NULL. No functional change intended.


Revision tags: haad-dm-base1
# 1.99 14-Oct-2008 ad

Accept filters:

- Remove remaining #ifdef INET.
- Avoid holding locks so we don't need to do KM_NOSLEEP allocations.
- Use a rwlock to protect the accept filter list.
- Make it safe to unload accept filter modules.
- Minor KNF.


# 1.98 11-Oct-2008 pooka

Move uidinfo to its own module in kern_uidinfo.c and include in rump.
No functional change to uidinfo.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.97 04-Aug-2008 tls

Add accept filters, ported from FreeBSD by Coyote Point Systems. Add inetd
support for specifying an accept filter for a service (mostly as a usage
example, but it can be handy for other things). Manual pages to follow
in a day or so.

OK core@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 1.96 18-Jun-2008 yamt

branches: 1.96.2;
merge yamt-pf42 branch.
(import newer pf from OpenBSD 4.2)

ok'ed by peter@. requested by core@


Revision tags: yamt-pf42-base4
# 1.95 10-Jun-2008 ad

There can be existing waiters on a socket's condition variables when we
change socket::so_lock, and they rely on the old lock to synchronize.
Wake them up whenever we change so_lock so they can restart their waits.


Revision tags: yamt-pf42-base3
# 1.94 26-May-2008 ad

branches: 1.94.2;
Use pool_cache for sockets.


# 1.93 24-May-2008 christos

Coverity CID 5025: sbreserve is never called with a null socket.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.92 28-Apr-2008 martin

branches: 1.92.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.91 24-Apr-2008 ad

branches: 1.91.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.90 01-Mar-2008 rmind

branches: 1.90.2;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.89 07-Feb-2008 ad

branches: 1.89.2; 1.89.6;
sonewconn: inherit FNONBLOCK from the parent.


# 1.88 29-Jan-2008 yamt

sbreserve: curlwp can't be NULL these days.
XXX these code seems to need an overhaul.


# 1.87 29-Jan-2008 yamt

sbrelease: unwrap a short line.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.86 25-Sep-2007 ad

branches: 1.86.4;
Use selinit() / seldestroy().


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base matt-mips64-base
# 1.85 02-Aug-2007 rmind

branches: 1.85.2; 1.85.4; 1.85.6; 1.85.8;
TCP socket buffers automatic sizing - ported from FreeBSD.
http://mail-index.netbsd.org/tech-net/2007/02/04/0006.html

! Disabled by default, marked as experimental. Testers are very needed.
! Someone should thoroughly test this, and improve if possible.

Discussed on <tech-net>:
http://mail-index.netbsd.org/tech-net/2007/07/12/0002.html
Thanks Greg Troxel for comments.

OK by the long silence on <tech-net>.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.84 04-Jul-2007 tls

branches: 1.84.2;
After looking at FreeBSD 6 again -- we were also failing to copy the
send and receive timeouts. Fix this.


# 1.83 04-Jul-2007 tls

Copy SNDLOWAT and RCVLOWAT socket options to accepted socket, so applications
can rely on all socket options being propagated from the listen socket as
the manual page says (and as everything but Linux has always done). FreeBSD 6
fixes this the same way, but this bug appears elsewhere and is...Old.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.82 04-Mar-2007 christos

branches: 1.82.2; 1.82.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.81 01-Nov-2006 yamt

branches: 1.81.4;
remove some __unused from function parameters.


Revision tags: yamt-splraiseipl-base2
# 1.80 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.79 03-Oct-2006 elad

Back out socket credentials for now, until we figure a better way of
handling the reference counting from interrupt context.


# 1.78 02-Oct-2006 elad

Add credentials to sockets, 'so_cred'.

Brought up on tech-kern@ some ~2 months ago, didn't seem to be an
objection; brought up again recently and no objection either... this is
not too intrusive and I've been running with this for a while.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.77 16-Aug-2006 plunky

branches: 1.77.4;
Fix broken comments - there is no SO_ISCONNECTED or SO_ISCONFIRMING

this fixes kern/32058


# 1.76 16-Aug-2006 plunky

Remove macro call sonewconn() => sonewconn1() as it is no longer necessary.
There are no such calls and the compiler would catch mistakes like this
in any case.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.75 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.74 03-Jul-2006 christos

Make sure we have at least PIPE_BUF bytes available in the socket send buffer.
Review and comment by yamt.


# 1.73 01-Jul-2006 christos

Revert previous change to bump the socket low watermark to sock_loan_thresh.
With sock_loan_thresh=4096, sb_lowat==sb_hiwat, and sowritable will never
be true (even if only a single byte is pending). Some programs (like screen)
expect select() to return that a socket is writable on a socket when there
is space to write to it. XXX: What is the right thing to do here?


Revision tags: yamt-pdpolicy-base6
# 1.72 21-Jun-2006 yamt

bump default so_snd.sb_lowat to increase chance to use loaning.

the idea to tweak the watermark from Jonathan Stone.
reviewed by Bill Studenmund.


Revision tags: chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.71 14-May-2006 elad

branches: 1.71.4;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.70 24-Dec-2005 perry

branches: 1.70.4; 1.70.6; 1.70.8; 1.70.10; 1.70.12;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.69 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.68 29-May-2005 christos

branches: 1.68.2;
- add const.
- remove unnecessary casts.
- add __UNCONST casts and mark them with XXXUNCONST as necessary.


# 1.67 07-May-2005 christos

PR/30154: YAMAMOTO Takashi: tcp_close locking botch
chgsbsize() as mentioned in the PR can be called from an interrupt context
via tcp_close(). Avoid calling uid_find() in chgsbsize().
- Instead of storing so_uid in struct socketvar, store *so_uidinfo
- Add a simple lock to struct uidinfo.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.66 26-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.65 24-Jun-2004 jonathan

branches: 1.65.4; 1.65.6;
Rename MBUFTRACE helper function m_claim() to m_claimm(),
for consistency with M_FREE() and m_freem(). Affected files:

sys/mbuf.h
kern/uipc_socket2.c
kern/uipc_mbuf.c
net/if_ethersubr.c
netatalk/ddp_input.c
nfs/nfs_socket.c


# 1.64 11-Jun-2004 jonathan

Fix potential memory leak in sbappendaddrchain():

We do an MGETHDR)() for each mbuf "packet" of the input chain, to hold
the socket address prepended to that "packet". If those MGETHDR()s
ever failed, we would leak all the successfully-allocated mbuf
headers. Leak noted by Yamamoto-san (yamt@NetBSD.org); thanks for catching it!

Add socketbuf invariant-checking macros to sbappendaddrchain(), and
replace a stray bcopy() with memcpy(), also as suggested by Yamamoto-san.


# 1.63 27-May-2004 jonathan

Rework to make FAST_IPSEC PF_KEY dumps unicast and reliable:

Introduce new socket-layer function sbappendaddrchain() to
sys/kern/uipc_socket2.c: like sbappendaddr(), only takes a chain of
records and appends the entire chain in one pass. sbappendaddrchain()
also takes an `sbprio' argument, which indicates the caller requires
special `reliable' handling of the socket-buffer. `sbprio' is
described in sys/sys/socketvar.h, although (for now) the different
levels are not yet implemented.

Rework sys/netipsec/key.c PF_KEY DUMP responses to build a chain of
mbuf records, one record per dump response. Unicast the entire chain
to the requestor, with all-or-none semantics.

Changed files;
sys/socketvar.h kern/uipc_socket2.c netipsec/key.c
Reviewed by:
Jason Thorpe, Thor Lancelot Simon, post to tech-kern.

Todo: request pullup to 2.0 branch. Post-2.0, rework sysctl() API for
dumps to use new record-chain constructors. Actually implement
the distinct service levels in sbappendaddrchain() so we can use them
to make PF_KEY ACQUIRE messages more reliable.


# 1.62 19-Apr-2004 christos

Charge root for socket buffers without a socket pointer.


# 1.61 18-Apr-2004 matt

Constify the addr parameter to sbappenaddr.


# 1.60 18-Apr-2004 matt

sbreserve can be called with a NULL socket, deal with it.


# 1.59 17-Apr-2004 christos

PR/9347: Eric E. Fair: socket buffer pool exhaustion leads to system deadlock
and unkillable processes.
1. Introduce new SBSIZE resource limit from FreeBSD to limit socket buffer
size resource.
2. make sokvareserve interruptible, so processes ltsleeping on it can be
killed.


Revision tags: netbsd-2-0-base
# 1.58 21-Oct-2003 thorpej

branches: 1.58.2;
Cache the "adjusted" value of sb_max when sb_max is changed, in order
to avoid doing quad math in sbreserve().

Change suggested by Simon Burge, and code inspired by a similar change
in FreeBSD.


# 1.57 22-Sep-2003 christos

- pass signo to fownsignal [ok by jd]
- make urg signal handling use fownsignal
- remove out of band detection in sowakeup


# 1.56 21-Sep-2003 jdolecek

cleanup & uniform descriptor owner handling:
* introduce fsetown(), fgetown(), fownsignal() - this sets/retrieves/signals
the owner of descriptor, according to appropriate sematics
of TIOCSPGRP/FIOSETOWN/SIOCSPGRP/TIOCGPGRP/FIOGETOWN/SIOCGPGRP ioctl; use
these routines instead of custom code where appropriate
* make every place handling TIOCSPGRP/TIOCGPGRP handle also FIOSETOWN/FIOGETOWN
properly, and remove the translation of FIO[SG]OWN to TIOC[SG]PGRP
in sys_ioctl() & sys_fcntl()
* also remove the socket-specific hack in sys_ioctl()/sys_fcntl() and
pass the ioctls down to soo_ioctl() as any other ioctl

change discussed on tech-kern@


# 1.55 06-Sep-2003 christos

SA_SIGINFO changes.


# 1.54 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.53 29-Jun-2003 fvdl

branches: 1.53.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.52 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.51 23-Jun-2003 martin

Make sure to include opt_foo.h if a defflag option FOO is used.


# 1.50 17-Apr-2003 fvdl

A bit of an ugly workaround to avoid a warning for a larger MSIZE.
Shouldn't make a difference in the generated code.


# 1.49 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge
# 1.48 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.47 27-Sep-2002 provos

remove trailing \n in panic(). approved perry.


Revision tags: gehenna-devsw-base
# 1.46 22-Aug-2002 thorpej

In sbcompress(), if we toss an empty mbuf, make sure to update
sb_lastrecord if necessary.

From Daniel Hartmeier <daniel@benzedrine.cx>.


# 1.45 03-Jul-2002 thorpej

Rename SB_UPDATE_TAIL() to SB_EMPTY_FIXUP(), per suggestion from
Jonathan Stone.


# 1.44 03-Jul-2002 thorpej

Rename sbappend_stream() to sbappendstream(), per suggestion from
Jonathan Stone.


# 1.43 03-Jul-2002 thorpej

Make insertion of data into socket buffers O(C):
* Keep pointers to the first and last mbufs of the last record in the
socket buffer.
* Use the sb_lastrecord pointer in the sbappend*() family of functions
to avoid traversing the packet chain to find the last record.
* Add a new sbappend_stream() function for stream protocols which
guarantee that there will never be more than one record in the
socket buffer. This function uses the sb_mbtail pointer to perform
the data insertion. Make TCP use sbappend_stream().

On a profiling run, this makes sbappend of a TCP transmission using
a 1M socket buffer go from 50% of the time to .02% of the time.

Thanks to Bill Sommerfeld and YAMAMOTO Takashi for their debugging
assistance!


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base thorpej-mips-cache-base
# 1.42 12-Nov-2001 lukem

branches: 1.42.8;
add RCSIDs


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 05-Aug-2001 enami

branches: 1.41.4;
Give different names for different wait channels.

# and minor knf fix while I'm here.


# 1.40 27-Jul-2001 thorpej

Now that M_TRAILINGSPACE() checks buffer writeability properly,
we can greatly simplify sbcompress(). Slightly modified from
a similar change in FreeBSD.


# 1.39 16-Jun-2001 manu

branches: 1.39.2;
Use SB_ASYNC in struct sockbuf sb_flags field instead of SS_ASYNC in
struct socket so_state field to decide if we need to send asynchronous
notifications. This makes possible to request notification on write but
not on read, and vice versa.

This is used in Linux emulation code, because when async I/O is requested,
Linux does not send SIGIO to write end of sockets, and it never send any
SIGIO to any end of pipes. Il Linux emulation code, we then set SB_ASYNC
only on the read end of sockets, and on no end for pipes.


# 1.38 30-Apr-2001 kml

Large values of sb_max would cause an overflow in sbreserve(); cast to
u_quad_t to avoid this. (from FreeBSD uipc_socket2.c v1.19)


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.37 27-Feb-2001 lukem

branches: 1.37.2;
convert to ANSI KNF


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 30-Mar-2000 augustss

Get rid of register declarations.


# 1.35 29-Feb-2000 itojun

more fix to ancillary data alignment. we need padding after
last cmsg_data item (see the figure on RFC2292 page 18).


# 1.34 18-Feb-2000 itojun

fix alignment problem in ancillary messages (alpha).

the change constitutes binary compatibility issue hen sizeof(long) !=4.
there's no way to be backward compatible, and only guys affected
are IPv6 userland tools.

From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base
# 1.33 04-Aug-1999 mycroft

branches: 1.33.2;
The old compaction test had an off-by-one error that caused it to not compact
in some cases where it could have. Fix this, and the new version as well.


# 1.32 04-Aug-1999 matt

Don't compress mbuf clusters which are referenced by multiple
mbufs since you might overwriting valuable data. (think of
m_copy'ed data from a TCP re-transmission queue. Since those
might be in clusters and referenced in two sockets).


# 1.31 04-Aug-1999 mycroft

It's now possible for sbcompress() to compact mbuf clusters, so do it.
This helps prevent mbuf cluster exhaustion when receiving lots of small
packets.


Revision tags: chs-ubc2-base
# 1.30 01-Jul-1999 itojun

IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.


# 1.29 22-Apr-1999 simonb

Move inclusion of "opt_sb_max.h" from sys/socketvar.h to
conf/param.c, and move the initialisation of the sb_max
variable from kern/uipc_socket2.c to conf/param.c. Now
everthing that includes sys/socketvar.h doesn't get
recompiled when SB_MAX's value changes.


Revision tags: netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.28 23-Mar-1999 lukem

branches: 1.28.2; 1.28.4; 1.28.6;
Ensure that you can only bind a more specific address when it is done by the
same uid or by root.

This code is from FreeBSD. (Whilst it was originally obtained from OpenBSD,
FreeBSD fixed it to work with multicast. To quote the commit message:
- Don't bother checking for conflicting sockets if we're binding to a
multicast address.
- Don't return an error if we're binding to INADDR_ANY, the conflicting
socket is bound to INADDR_ANY, and the conflicting socket has
SO_REUSEPORT set.
)


# 1.27 20-Jan-1999 mycroft

Do not remove sockets from the accept(2) queue on close.


Revision tags: kenh-if-detach-base chs-ubc-base
# 1.26 04-Aug-1998 perry

Abolition of bcopy, ovbcopy, bcmp, and bzero, phase one.
bcopy(x, y, z) -> memcpy(y, x, z)
ovbcopy(x, y, z) -> memmove(y, x, z)
bcmp(x, y, z) -> memcmp(x, y, z)
bzero(x, y) -> memset(x, 0, y)


# 1.25 02-Aug-1998 thorpej

Use the pool allocator for sockets.


Revision tags: eeh-paddr_t-base
# 1.24 25-Apr-1998 matt

Hook for 0-copy (or other optimized) sends and receives


# 1.23 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.22 07-Jan-1998 thorpej

Make insertion and removal of sockets from the partial and incoming
connections queues O(C) rather than O(N).


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base marc-pcmcia-base
# 1.21 09-Oct-1997 mycroft

branches: 1.21.2;
Make various standard wmesg strings const.


Revision tags: thorpej-signal-base marc-pcmcia-bp SYN_cache_cur_base
# 1.20 26-Jun-1997 thorpej

branches: 1.20.4;
In sbappendaddr(), if the sockaddr length is larger than will fit in
an mbuf, allocate enough external storage to hold the sockaddr. Thanks
to enami tsugutomo <enami@cv.sony.co.jp> for providing sanity-checks.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.19 11-Jan-1997 thorpej

branches: 1.19.8;
Implement sbcreatecontrol(), a generic function to create a "control"
mbuf for presentation on a socket buffer.


# 1.18 09-Dec-1996 thorpej

In sbreserve(), don't allow a count of 0. Fixes PR #2794, from
Erik Berls <cyber@dis.org>.


# 1.17 26-Nov-1996 thorpej

Back out previous soqinsque() and soqremque() changes. This will
stop the panics until the socket queues get converted to <sys/queue.h>.


# 1.16 10-Nov-1996 thorpej

Optimization of soqinsque() and soqremque():

Keep queue of pending sockets in a double linked list. Previously,
a singly linked list was used, giving O(N) insertion/deletion times,
and was a major time consumer for sockets with large pending queues.
The double linked list give O(C) insertion/deletion times with only
a small cost in complexity.

Since a socket can be on, at most, one queue at a time, both so_q and
so_q0 can safely be used as (forward and backward, respectively) queue
pointers.

Submitted my Matt Thomas <matt@3am-software.com>, a long time ago.
(Geez, I've been running with this patch for _months_, and had completely
forgotten about it!)


# 1.15 13-Oct-1996 christos

backout previous kprintf change


# 1.14 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.13 07-Sep-1996 mycroft

Implement poll(2).


# 1.12 22-May-1996 mycroft

Pass a proc pointer down to the usrreq and pcbbind functions for PRU_ATTACH, PRU_BIND and
PRU_CONTROL. The usrreq interface really needs to be split up, but this will have to wait.
Remove SS_PRIV completely.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.11 04-Feb-1996 christos

branches: 1.11.4;
First pass at prototyping


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.10 16-Aug-1995 mycroft

Access rights are now stored in MT_CONTROL mbufs. Document this.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.9 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.8 13-May-1994 mycroft

Update to 4.4-Lite networking code, with a few local changes.


# 1.7 04-May-1994 mycroft

More return types...


# 1.6 25-Apr-1994 mycroft

Remove sbselqueue().


# 1.5 18-Dec-1993 mycroft

Canonicalize all #includes.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 27-Jun-1993 andrew

branches: 1.4.4;
ANSIfications - removed all implicit function return types and argument
definitions. Ensured that all files include "systm.h" to gain access to
general prototypes. Casts where necessary.


# 1.3 18-May-1993 cgd

make kernel select interface be one-stop shopping & clean it all up.


Revision tags: netbsd-0-8 netbsd-alpha-1 patchkit-0-2-2
# 1.2 21-Mar-1993 cgd

after 0.2.2 "stable" patches applied


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004
# 1.124 02-Oct-2016 christos

more MFREE -> m_free


Revision tags: localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529
# 1.123 23-May-2016 tls

branches: 1.123.2;
Fix a longstanding problem with accept filters noticed by Timo Buhrmester:
sockets sitting in the accept filter can consume the entire listen queue,
such that the application is never able to handle any connections. Handle
this by simply passing through the oldest queued cxn when the queue is full.

This is fair because the longer a cxn lingers in the queue (stays connected
but does not meet the requirements of the filter for passage) the more likely
it is to be passed through, at which point the application can dispose of it.

Works because none of our accept filters actually allocate private state
per-cxn. If they did, we'd have to fix the API bug that there is presently
no way to tell an accf to finish/deallocate for a single cxn (accf_destroy
kills off the entire filter instance for a given listen socket).


Revision tags: nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.122 24-Aug-2015 pooka

sprinkle _KERNEL_OPT


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406 nick-nhusb-base
# 1.121 05-Sep-2014 matt

branches: 1.121.2;
Don't next structure and enum definitions.
Don't use C++ keywords new, try, class, private, etc.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.120 31-Jul-2014 rtr

split PRU_DISCONNECT, PRU_SHUTDOWN and PRU_ABORT function out of
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


# 1.119 19-May-2014 rmind

- Split off PRU_ATTACH and PRU_DETACH logic into separate functions.
- Replace malloc with kmem and eliminate M_PCB while here.
- Sprinkle more asserts.


Revision tags: rmind-smpnet-nbase rmind-smpnet-base
# 1.118 18-May-2014 rmind

Add struct pr_usrreqs with a pr_generic function and prepare for the
dismantling of pr_usrreq in the protocols; no functional change intended.
PRU_ATTACH/PRU_DETACH changes will follow soon.

Bump for struct protosw. Welcome to 6.99.62!


# 1.117 17-May-2014 rmind

sonewconn: insert the socket into the queue *after* the protocol attach.
This potentially avoids unnecessary race conditions when handling partial
connections.


# 1.116 17-May-2014 rmind

- sonewconn: improve the initialisation order and add some asserts.
- Add various comments describing primitive routines operating on sockets,
clarify connection life-cycle and improve the description of socket queues.
- Sprinkle more asserts.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.115 08-Oct-2013 christos

branches: 1.115.2;
0 -> NULL
MGET -> m_get
No functional change.


# 1.114 15-Sep-2013 martin

Avoid unused variable warnings


# 1.113 29-Aug-2013 rmind

Remove SS_ISCONFIRMING, it is unused and TP4 will not come back.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.112 28-Jun-2013 matt

branches: 1.112.2;
Make sbdrop panic more verbose


# 1.111 27-Jun-2013 christos

Introduce a more general method of sbcreatecontrol, sbcreatecontrol1 that
can take flags (M_WAITOK), and allocate large messages if needed. It also
returns the allocated pointer instead of copying the data to the passed
pointer. Implement sbcreatecontrol() using that.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.110 20-Dec-2011 christos

branches: 1.110.6;
- Eliminate so_nbio and turn it into a bit SS_NBIO in so_state.
- Introduce MSG_NBIO so that we can turn non blocking i/o on a per call basis
- Use MSG_NBIO to fix the XXX: multi-threaded issues on the fifo sockets.
- Don't set SO_CANTRCVMORE, if we were interrupted (perhaps do it for all
errors?).


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.109 31-Aug-2011 plunky

branches: 1.109.2; 1.109.6;
NULL does not need a cast


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.108 24-Apr-2011 rmind

- Replace few malloc(9) uses with kmem(9).
- Rename buf_malloc() to buf_alloc(), fix comments.
- Remove some unnecessary inclusions.


# 1.107 09-Apr-2011 christos

Preserve SB_ASYNC on the accepted socket. From: Dmitry Matveev
http://mail-index.netbsd.org/tech-net/2011/02/17/msg002457.html


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base
# 1.106 30-Dec-2009 elad

branches: 1.106.4; 1.106.6;
Don't bother caching egid. It'll be removed soon.


# 1.105 30-Dec-2009 elad

Always use resource limits from the process, as proposed in

http://mail-index.netbsd.org/tech-kern/2009/12/30/msg006756.html

okay christos@.


Revision tags: matt-premerge-20091211 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.104 02-Sep-2009 tls

Add a direction argument to socket upcalls, so they can tell why they've
been called when, for example, they're waiting for space to write. From
Ritesh Agrawal at Coyote Point.


Revision tags: yamt-nfs-mp-base7
# 1.103 24-Jul-2009 christos

check return code from soreserve() (Sean Boudreau)


Revision tags: jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.102 09-Apr-2009 yamt

sonewconn: add an assertion.


Revision tags: nick-hppapmap-base2
# 1.101 21-Jan-2009 yamt

branches: 1.101.2;
restore the pre socket locking patch signal behaviour.
this fixes a busy-loop in nfs_connect.


Revision tags: netbsd-5-0-RC1 haad-dm-base2 haad-nbase2 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base mjf-devfs2-base
# 1.100 24-Oct-2008 dyoung

branches: 1.100.2; 1.100.4;
Change 'return (expr);' to 'return expr;'. Change (type *)0 to
NULL. No functional change intended.


Revision tags: haad-dm-base1
# 1.99 14-Oct-2008 ad

Accept filters:

- Remove remaining #ifdef INET.
- Avoid holding locks so we don't need to do KM_NOSLEEP allocations.
- Use a rwlock to protect the accept filter list.
- Make it safe to unload accept filter modules.
- Minor KNF.


# 1.98 11-Oct-2008 pooka

Move uidinfo to its own module in kern_uidinfo.c and include in rump.
No functional change to uidinfo.


Revision tags: wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.97 04-Aug-2008 tls

Add accept filters, ported from FreeBSD by Coyote Point Systems. Add inetd
support for specifying an accept filter for a service (mostly as a usage
example, but it can be handy for other things). Manual pages to follow
in a day or so.

OK core@.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase simonb-wapbl-base wrstuden-revivesa-base
# 1.96 18-Jun-2008 yamt

branches: 1.96.2;
merge yamt-pf42 branch.
(import newer pf from OpenBSD 4.2)

ok'ed by peter@. requested by core@


Revision tags: yamt-pf42-base4
# 1.95 10-Jun-2008 ad

There can be existing waiters on a socket's condition variables when we
change socket::so_lock, and they rely on the old lock to synchronize.
Wake them up whenever we change so_lock so they can restart their waits.


Revision tags: yamt-pf42-base3
# 1.94 26-May-2008 ad

branches: 1.94.2;
Use pool_cache for sockets.


# 1.93 24-May-2008 christos

Coverity CID 5025: sbreserve is never called with a null socket.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.92 28-Apr-2008 martin

branches: 1.92.2;
Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-nfs-mp-base
# 1.91 24-Apr-2008 ad

branches: 1.91.2;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.


Revision tags: yamt-pf42-baseX yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase
# 1.90 01-Mar-2008 rmind

branches: 1.90.2;
Welcome to 4.99.55:

- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call. It will
indicate which event (POLL_IN, POLL_OUT, etc) happen. If unknown,
zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>


Revision tags: nick-net80211-sync-base mjf-devfs-base hpcarm-cleanup-base
# 1.89 07-Feb-2008 ad

branches: 1.89.2; 1.89.6;
sonewconn: inherit FNONBLOCK from the parent.


# 1.88 29-Jan-2008 yamt

sbreserve: curlwp can't be NULL these days.
XXX these code seems to need an overhaul.


# 1.87 29-Jan-2008 yamt

sbrelease: unwrap a short line.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base vmlocking-base
# 1.86 25-Sep-2007 ad

branches: 1.86.4;
Use selinit() / seldestroy().


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base matt-mips64-base
# 1.85 02-Aug-2007 rmind

branches: 1.85.2; 1.85.4; 1.85.6; 1.85.8;
TCP socket buffers automatic sizing - ported from FreeBSD.
http://mail-index.netbsd.org/tech-net/2007/02/04/0006.html

! Disabled by default, marked as experimental. Testers are very needed.
! Someone should thoroughly test this, and improve if possible.

Discussed on <tech-net>:
http://mail-index.netbsd.org/tech-net/2007/07/12/0002.html
Thanks Greg Troxel for comments.

OK by the long silence on <tech-net>.


Revision tags: nick-csl-alignment-base mjf-ufs-trans-base
# 1.84 04-Jul-2007 tls

branches: 1.84.2;
After looking at FreeBSD 6 again -- we were also failing to copy the
send and receive timeouts. Fix this.


# 1.83 04-Jul-2007 tls

Copy SNDLOWAT and RCVLOWAT socket options to accepted socket, so applications
can rely on all socket options being propagated from the listen socket as
the manual page says (and as everything but Linux has always done). FreeBSD 6
fixes this the same way, but this bug appears elsewhere and is...Old.


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.82 04-Mar-2007 christos

branches: 1.82.2; 1.82.4;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.81 01-Nov-2006 yamt

branches: 1.81.4;
remove some __unused from function parameters.


Revision tags: yamt-splraiseipl-base2
# 1.80 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


# 1.79 03-Oct-2006 elad

Back out socket credentials for now, until we figure a better way of
handling the reference counting from interrupt context.


# 1.78 02-Oct-2006 elad

Add credentials to sockets, 'so_cred'.

Brought up on tech-kern@ some ~2 months ago, didn't seem to be an
objection; brought up again recently and no objection either... this is
not too intrusive and I've been running with this for a while.


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.77 16-Aug-2006 plunky

branches: 1.77.4;
Fix broken comments - there is no SO_ISCONNECTED or SO_ISCONFIRMING

this fixes kern/32058


# 1.76 16-Aug-2006 plunky

Remove macro call sonewconn() => sonewconn1() as it is no longer necessary.
There are no such calls and the compiler would catch mistakes like this
in any case.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7
# 1.75 23-Jul-2006 ad

Use the LWP cached credentials where sane.


# 1.74 03-Jul-2006 christos

Make sure we have at least PIPE_BUF bytes available in the socket send buffer.
Review and comment by yamt.


# 1.73 01-Jul-2006 christos

Revert previous change to bump the socket low watermark to sock_loan_thresh.
With sock_loan_thresh=4096, sb_lowat==sb_hiwat, and sowritable will never
be true (even if only a single byte is pending). Some programs (like screen)
expect select() to return that a socket is writable on a socket when there
is space to write to it. XXX: What is the right thing to do here?


Revision tags: yamt-pdpolicy-base6
# 1.72 21-Jun-2006 yamt

bump default so_snd.sb_lowat to increase chance to use loaning.

the idea to tweak the watermark from Jonathan Stone.
reviewed by Bill Studenmund.


Revision tags: chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base simonb-timecounters-base
# 1.71 14-May-2006 elad

branches: 1.71.4;
integrate kauth.


Revision tags: yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5
# 1.70 24-Dec-2005 perry

branches: 1.70.4; 1.70.6; 1.70.8; 1.70.10; 1.70.12;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.69 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.68 29-May-2005 christos

branches: 1.68.2;
- add const.
- remove unnecessary casts.
- add __UNCONST casts and mark them with XXXUNCONST as necessary.


# 1.67 07-May-2005 christos

PR/30154: YAMAMOTO Takashi: tcp_close locking botch
chgsbsize() as mentioned in the PR can be called from an interrupt context
via tcp_close(). Avoid calling uid_find() in chgsbsize().
- Instead of storing so_uid in struct socketvar, store *so_uidinfo
- Add a simple lock to struct uidinfo.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.66 26-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2 yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.65 24-Jun-2004 jonathan

branches: 1.65.4; 1.65.6;
Rename MBUFTRACE helper function m_claim() to m_claimm(),
for consistency with M_FREE() and m_freem(). Affected files:

sys/mbuf.h
kern/uipc_socket2.c
kern/uipc_mbuf.c
net/if_ethersubr.c
netatalk/ddp_input.c
nfs/nfs_socket.c


# 1.64 11-Jun-2004 jonathan

Fix potential memory leak in sbappendaddrchain():

We do an MGETHDR)() for each mbuf "packet" of the input chain, to hold
the socket address prepended to that "packet". If those MGETHDR()s
ever failed, we would leak all the successfully-allocated mbuf
headers. Leak noted by Yamamoto-san (yamt@NetBSD.org); thanks for catching it!

Add socketbuf invariant-checking macros to sbappendaddrchain(), and
replace a stray bcopy() with memcpy(), also as suggested by Yamamoto-san.


# 1.63 27-May-2004 jonathan

Rework to make FAST_IPSEC PF_KEY dumps unicast and reliable:

Introduce new socket-layer function sbappendaddrchain() to
sys/kern/uipc_socket2.c: like sbappendaddr(), only takes a chain of
records and appends the entire chain in one pass. sbappendaddrchain()
also takes an `sbprio' argument, which indicates the caller requires
special `reliable' handling of the socket-buffer. `sbprio' is
described in sys/sys/socketvar.h, although (for now) the different
levels are not yet implemented.

Rework sys/netipsec/key.c PF_KEY DUMP responses to build a chain of
mbuf records, one record per dump response. Unicast the entire chain
to the requestor, with all-or-none semantics.

Changed files;
sys/socketvar.h kern/uipc_socket2.c netipsec/key.c
Reviewed by:
Jason Thorpe, Thor Lancelot Simon, post to tech-kern.

Todo: request pullup to 2.0 branch. Post-2.0, rework sysctl() API for
dumps to use new record-chain constructors. Actually implement
the distinct service levels in sbappendaddrchain() so we can use them
to make PF_KEY ACQUIRE messages more reliable.


# 1.62 19-Apr-2004 christos

Charge root for socket buffers without a socket pointer.


# 1.61 18-Apr-2004 matt

Constify the addr parameter to sbappenaddr.


# 1.60 18-Apr-2004 matt

sbreserve can be called with a NULL socket, deal with it.


# 1.59 17-Apr-2004 christos

PR/9347: Eric E. Fair: socket buffer pool exhaustion leads to system deadlock
and unkillable processes.
1. Introduce new SBSIZE resource limit from FreeBSD to limit socket buffer
size resource.
2. make sokvareserve interruptible, so processes ltsleeping on it can be
killed.


Revision tags: netbsd-2-0-base
# 1.58 21-Oct-2003 thorpej

branches: 1.58.2;
Cache the "adjusted" value of sb_max when sb_max is changed, in order
to avoid doing quad math in sbreserve().

Change suggested by Simon Burge, and code inspired by a similar change
in FreeBSD.


# 1.57 22-Sep-2003 christos

- pass signo to fownsignal [ok by jd]
- make urg signal handling use fownsignal
- remove out of band detection in sowakeup


# 1.56 21-Sep-2003 jdolecek

cleanup & uniform descriptor owner handling:
* introduce fsetown(), fgetown(), fownsignal() - this sets/retrieves/signals
the owner of descriptor, according to appropriate sematics
of TIOCSPGRP/FIOSETOWN/SIOCSPGRP/TIOCGPGRP/FIOGETOWN/SIOCGPGRP ioctl; use
these routines instead of custom code where appropriate
* make every place handling TIOCSPGRP/TIOCGPGRP handle also FIOSETOWN/FIOGETOWN
properly, and remove the translation of FIO[SG]OWN to TIOC[SG]PGRP
in sys_ioctl() & sys_fcntl()
* also remove the socket-specific hack in sys_ioctl()/sys_fcntl() and
pass the ioctls down to soo_ioctl() as any other ioctl

change discussed on tech-kern@


# 1.55 06-Sep-2003 christos

SA_SIGINFO changes.


# 1.54 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.53 29-Jun-2003 fvdl

branches: 1.53.2;
Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.


# 1.52 28-Jun-2003 darrenr

Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records. The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V


# 1.51 23-Jun-2003 martin

Make sure to include opt_foo.h if a defflag option FOO is used.


# 1.50 17-Apr-2003 fvdl

A bit of an ugly workaround to avoid a warning for a larger MSIZE.
Shouldn't make a difference in the generated code.


# 1.49 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge
# 1.48 23-Oct-2002 jdolecek

merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe


Revision tags: kqueue-beforemerge kqueue-base
# 1.47 27-Sep-2002 provos

remove trailing \n in panic(). approved perry.


Revision tags: gehenna-devsw-base
# 1.46 22-Aug-2002 thorpej

In sbcompress(), if we toss an empty mbuf, make sure to update
sb_lastrecord if necessary.

From Daniel Hartmeier <daniel@benzedrine.cx>.


# 1.45 03-Jul-2002 thorpej

Rename SB_UPDATE_TAIL() to SB_EMPTY_FIXUP(), per suggestion from
Jonathan Stone.


# 1.44 03-Jul-2002 thorpej

Rename sbappend_stream() to sbappendstream(), per suggestion from
Jonathan Stone.


# 1.43 03-Jul-2002 thorpej

Make insertion of data into socket buffers O(C):
* Keep pointers to the first and last mbufs of the last record in the
socket buffer.
* Use the sb_lastrecord pointer in the sbappend*() family of functions
to avoid traversing the packet chain to find the last record.
* Add a new sbappend_stream() function for stream protocols which
guarantee that there will never be more than one record in the
socket buffer. This function uses the sb_mbtail pointer to perform
the data insertion. Make TCP use sbappend_stream().

On a profiling run, this makes sbappend of a TCP transmission using
a 1M socket buffer go from 50% of the time to .02% of the time.

Thanks to Bill Sommerfeld and YAMAMOTO Takashi for their debugging
assistance!


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base eeh-devprop-base newlock-base ifpoll-base thorpej-mips-cache-base
# 1.42 12-Nov-2001 lukem

branches: 1.42.8;
add RCSIDs


Revision tags: thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 05-Aug-2001 enami

branches: 1.41.4;
Give different names for different wait channels.

# and minor knf fix while I'm here.


# 1.40 27-Jul-2001 thorpej

Now that M_TRAILINGSPACE() checks buffer writeability properly,
we can greatly simplify sbcompress(). Slightly modified from
a similar change in FreeBSD.


# 1.39 16-Jun-2001 manu

branches: 1.39.2;
Use SB_ASYNC in struct sockbuf sb_flags field instead of SS_ASYNC in
struct socket so_state field to decide if we need to send asynchronous
notifications. This makes possible to request notification on write but
not on read, and vice versa.

This is used in Linux emulation code, because when async I/O is requested,
Linux does not send SIGIO to write end of sockets, and it never send any
SIGIO to any end of pipes. Il Linux emulation code, we then set SB_ASYNC
only on the read end of sockets, and on no end for pipes.


# 1.38 30-Apr-2001 kml

Large values of sb_max would cause an overflow in sbreserve(); cast to
u_quad_t to avoid this. (from FreeBSD uipc_socket2.c v1.19)


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.37 27-Feb-2001 lukem

branches: 1.37.2;
convert to ANSI KNF


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 30-Mar-2000 augustss

Get rid of register declarations.


# 1.35 29-Feb-2000 itojun

more fix to ancillary data alignment. we need padding after
last cmsg_data item (see the figure on RFC2292 page 18).


# 1.34 18-Feb-2000 itojun

fix alignment problem in ancillary messages (alpha).

the change constitutes binary compatibility issue hen sizeof(long) !=4.
there's no way to be backward compatible, and only guys affected
are IPv6 userland tools.

From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


Revision tags: chs-ubc2-newbase wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base
# 1.33 04-Aug-1999 mycroft

branches: 1.33.2;
The old compaction test had an off-by-one error that caused it to not compact
in some cases where it could have. Fix this, and the new version as well.


# 1.32 04-Aug-1999 matt

Don't compress mbuf clusters which are referenced by multiple
mbufs since you might overwriting valuable data. (think of
m_copy'ed data from a TCP re-transmission queue. Since those
might be in clusters and referenced in two sockets).


# 1.31 04-Aug-1999 mycroft

It's now possible for sbcompress() to compact mbuf clusters, so do it.
This helps prevent mbuf cluster exhaustion when receiving lots of small
packets.


Revision tags: chs-ubc2-base
# 1.30 01-Jul-1999 itojun

IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.


# 1.29 22-Apr-1999 simonb

Move inclusion of "opt_sb_max.h" from sys/socketvar.h to
conf/param.c, and move the initialisation of the sb_max
variable from kern/uipc_socket2.c to conf/param.c. Now
everthing that includes sys/socketvar.h doesn't get
recompiled when SB_MAX's value changes.


Revision tags: netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.28 23-Mar-1999 lukem

branches: 1.28.2; 1.28.4; 1.28.6;
Ensure that you can only bind a more specific address when it is done by the
same uid or by root.

This code is from FreeBSD. (Whilst it was originally obtained from OpenBSD,
FreeBSD fixed it to work with multicast. To quote the commit message:
- Don't bother checking for conflicting sockets if we're binding to a
multicast address.
- Don't return an error if we're binding to INADDR_ANY, the conflicting
socket is bound to INADDR_ANY, and the conflicting socket has
SO_REUSEPORT set.
)


# 1.27 20-Jan-1999 mycroft

Do not remove sockets from the accept(2) queue on close.


Revision tags: kenh-if-detach-base chs-ubc-base
# 1.26 04-Aug-1998 perry

Abolition of bcopy, ovbcopy, bcmp, and bzero, phase one.
bcopy(x, y, z) -> memcpy(y, x, z)
ovbcopy(x, y, z) -> memmove(y, x, z)
bcmp(x, y, z) -> memcmp(x, y, z)
bzero(x, y) -> memset(x, 0, y)


# 1.25 02-Aug-1998 thorpej

Use the pool allocator for sockets.


Revision tags: eeh-paddr_t-base
# 1.24 25-Apr-1998 matt

Hook for 0-copy (or other optimized) sends and receives


# 1.23 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.22 07-Jan-1998 thorpej

Make insertion and removal of sockets from the partial and incoming
connections queues O(C) rather than O(N).


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base marc-pcmcia-base
# 1.21 09-Oct-1997 mycroft

branches: 1.21.2;
Make various standard wmesg strings const.


Revision tags: thorpej-signal-base marc-pcmcia-bp SYN_cache_cur_base
# 1.20 26-Jun-1997 thorpej

branches: 1.20.4;
In sbappendaddr(), if the sockaddr length is larger than will fit in
an mbuf, allocate enough external storage to hold the sockaddr. Thanks
to enami tsugutomo <enami@cv.sony.co.jp> for providing sanity-checks.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.19 11-Jan-1997 thorpej

branches: 1.19.8;
Implement sbcreatecontrol(), a generic function to create a "control"
mbuf for presentation on a socket buffer.


# 1.18 09-Dec-1996 thorpej

In sbreserve(), don't allow a count of 0. Fixes PR #2794, from
Erik Berls <cyber@dis.org>.


# 1.17 26-Nov-1996 thorpej

Back out previous soqinsque() and soqremque() changes. This will
stop the panics until the socket queues get converted to <sys/queue.h>.


# 1.16 10-Nov-1996 thorpej

Optimization of soqinsque() and soqremque():

Keep queue of pending sockets in a double linked list. Previously,
a singly linked list was used, giving O(N) insertion/deletion times,
and was a major time consumer for sockets with large pending queues.
The double linked list give O(C) insertion/deletion times with only
a small cost in complexity.

Since a socket can be on, at most, one queue at a time, both so_q and
so_q0 can safely be used as (forward and backward, respectively) queue
pointers.

Submitted my Matt Thomas <matt@3am-software.com>, a long time ago.
(Geez, I've been running with this patch for _months_, and had completely
forgotten about it!)


# 1.15 13-Oct-1996 christos

backout previous kprintf change


# 1.14 10-Oct-1996 christos

printf -> kprintf, sprintf -> ksprintf


# 1.13 07-Sep-1996 mycroft

Implement poll(2).


# 1.12 22-May-1996 mycroft

Pass a proc pointer down to the usrreq and pcbbind functions for PRU_ATTACH, PRU_BIND and
PRU_CONTROL. The usrreq interface really needs to be split up, but this will have to wait.
Remove SS_PRIV completely.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.11 04-Feb-1996 christos

branches: 1.11.4;
First pass at prototyping


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.10 16-Aug-1995 mycroft

Access rights are now stored in MT_CONTROL mbufs. Document this.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.9 29-Jun-1994 cgd

New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.8 13-May-1994 mycroft

Update to 4.4-Lite networking code, with a few local changes.


# 1.7 04-May-1994 mycroft

More return types...


# 1.6 25-Apr-1994 mycroft

Remove sbselqueue().


# 1.5 18-Dec-1993 mycroft

Canonicalize all #includes.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 27-Jun-1993 andrew

branches: 1.4.4;
ANSIfications - removed all implicit function return types and argument
definitions. Ensured that all files include "systm.h" to gain access to
general prototypes. Casts where necessary.


# 1.3 18-May-1993 cgd

make kernel select interface be one-stop shopping & clean it all up.


Revision tags: netbsd-0-8 netbsd-alpha-1 patchkit-0-2-2
# 1.2 21-Mar-1993 cgd

after 0.2.2 "stable" patches applied


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision