freebsd-dev/sys
Alan Somers c2090e73d7 Replace 4.4BSD Lite's unix domain socket backpressure hack with a cleaner
mechanism, based on the new SB_STOP sockbuf flag.  The old hack dynamically
changed the sending sockbuf's high water mark whenever adding or removing
data from the receiving sockbuf.  It worked for stream sockets, but it never
worked for SOCK_SEQPACKET sockets because of their atomic nature.  If the
sockbuf was partially full, it might return EMSGSIZE instead of blocking.

The new solution is based on DragonFlyBSD's fix from commit
3a6117bbe0ed6a87605c1e43e12a1438d8844380 on 2008-05-27.  It adds an SB_STOP
flag to sockbufs.  Whenever uipc_send surpasses the socket's size limit, it
sets SB_STOP on the sending sockbuf.  sbspace() will then return 0 for that
sockbuf, causing sosend_generic and friends to block.  uipc_rcvd will
likewise clear SB_STOP.  There are two fringe benefits: uipc_{send,rcvd} no
longer need to call chgsbsize() on every send and receive because they don't
change the sockbuf's high water mark.  Also, uipc_sense no longer needs to
acquire the UIPC linkage lock, because it's simpler to compute the
st_blksizes.

There is one drawback: since sbspace() will only ever return 0 or the
maximum, sosend_generic will allow the sockbuf to exceed its nominal maximum
size by at most one packet of size less than the max.  I don't think that's
a serious problem.  In fact, I'm not even positive that FreeBSD guarantees a
socket will always stay within its nominal size limit.

sys/sys/sockbuf.h
	Add the SB_STOP flag and adjust sbspace()

sys/sys/unpcb.h
	Delete the obsolete unp_cc and unp_mbcnt fields from struct unpcb.

sys/kern/uipc_usrreq.c
	Adjust uipc_rcvd, uipc_send, and uipc_sense to use the SB_STOP
	backpressure mechanism.  Removing obsolete unpcb fields from
	db_show_unpcb.

tests/sys/kern/unix_seqpacket_test.c
	Clear expected failures from ATF.

Obtained from:	DragonFly BSD
PR:		kern/185812
Reviewed by:	silence from freebsd-net@ and rwatson@
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corporation
2014-03-13 18:42:12 +00:00
..
amd64 Delete stray clause 3 (Advertising clause) and renumber while i'm 2014-03-11 23:41:35 +00:00
arm Delete stray clause 3 (Advertising clause) and renumber while i'm 2014-03-11 23:41:35 +00:00
boot Add amd64 EFI headers 2014-03-13 18:17:18 +00:00
bsm Change the cap_rights_t type from uint64_t to a structure that we can extend 2013-09-05 00:09:56 +00:00
cam Fix support for increased logical sector size (4K-native drives). 2014-03-07 09:45:40 +00:00
cddl MFV r262983: 2014-03-11 00:23:50 +00:00
compat Since 32-bit if_baudrate isn't enough to describe a baud rate of a 10 Gbit 2014-03-13 03:42:24 +00:00
conf xen: add an apic_enumerator for PVH 2014-03-11 10:25:08 +00:00
contrib Also tag the current HAL power mode in ar9300_set_power_mode(). 2014-03-10 06:05:26 +00:00
crypto fix broken style(9) in r258399 2013-11-23 00:28:18 +00:00
ddb
dev Fix pointer type in call to malloc 2014-03-13 16:51:40 +00:00
fs ext2fs: Fix a bug when sorting htree entries. 2014-03-06 21:02:16 +00:00
gdb rename scheduler->swapper and SI_SUB_RUN_SCHEDULER->SI_SUB_LAST 2013-07-24 09:45:31 +00:00
geom In g_eli_crypto_hmac_init(), zero out after using the ipad buffer, 2014-02-08 05:17:49 +00:00
gnu Symbolic bindings for the dts files... 2014-02-28 16:51:33 +00:00
i386 Delete stray clause 3 (Advertising clause) and renumber while i'm 2014-03-11 23:41:35 +00:00
ia64 Delete stray clause 3 (Advertising clause) and renumber while i'm 2014-03-11 23:41:35 +00:00
isa
kern Replace 4.4BSD Lite's unix domain socket backpressure hack with a cleaner 2014-03-13 18:42:12 +00:00
kgssapi
libkern Fix typo 2013-11-29 20:14:26 +00:00
mips Since 32-bit if_baudrate isn't enough to describe a baud rate of a 10 Gbit 2014-03-13 03:42:24 +00:00
modules Replace the userspace atpic stub with a more functional vmm.ko model. 2014-03-11 16:56:00 +00:00
net Since 32-bit if_baudrate isn't enough to describe a baud rate of a 10 Gbit 2014-03-13 03:42:24 +00:00
net80211 Another round of removing historical mbuf(9) allocator flags. 2014-01-16 13:44:47 +00:00
netatalk Fix build. 2014-03-05 02:35:41 +00:00
netgraph Be much more specific (and correct) about the device id matching. 2014-01-09 15:31:44 +00:00
netinet Put the offset of the CRC32C in csum_data instead of 0. 2014-03-12 17:18:15 +00:00
netinet6 Since both netinet/ and netinet6/ call into netipsec/ and netpfil/, 2014-03-12 14:29:08 +00:00
netipsec Remove more constants related to static sysctl nodes. The MAXID constants 2014-02-25 18:44:33 +00:00
netipx - Remove rt_metrics_lite and simply put its members into rtentry. 2014-03-05 01:17:47 +00:00
netnatm Provide includes that are needed in these files, and before were read 2013-10-26 18:18:50 +00:00
netpfil - Remove rt_metrics_lite and simply put its members into rtentry. 2014-03-05 01:17:47 +00:00
netsmb Catch up with sb_timeo type change in r255138. This fixes 2013-11-08 08:44:09 +00:00
nfs - Remove rt_metrics_lite and simply put its members into rtentry. 2014-03-05 01:17:47 +00:00
nfsclient For software builds, the NFS client does many small 2013-12-07 23:05:59 +00:00
nfsserver Fix RPC server threads file handle affinity to work better with ZFS. 2013-12-23 08:43:16 +00:00
nlm Correct a typo in nlm_find_host_by_addr(): the intention of the 2014-03-11 00:25:55 +00:00
ofed Since 32-bit if_baudrate isn't enough to describe a baud rate of a 10 Gbit 2014-03-13 03:42:24 +00:00
opencrypto allow the kern.cryptodevallowsoft sysctl to enable symetric/hashes too... 2014-03-11 01:45:46 +00:00
pc98 xen: implement an early timer for Xen PVH 2014-03-11 10:20:42 +00:00
pci - Implement the RX EARLYOFF and RXDV GATED bits as done by RealTek's Linux 2014-02-05 23:13:40 +00:00
powerpc Delete stray clause 3 (Advertising clause) and renumber while i'm 2014-03-11 23:41:35 +00:00
rpc Fix lock acquisition in case no request space available, missed in r260097. 2014-02-04 00:00:01 +00:00
security As constantly reported during kernel compilation, m_buflen is unsigned so 2013-12-25 20:10:17 +00:00
sparc64 Delete stray clause 3 (Advertising clause) and renumber while i'm 2014-03-11 23:41:35 +00:00
sys Replace 4.4BSD Lite's unix domain socket backpressure hack with a cleaner 2014-03-13 18:42:12 +00:00
teken Fix typo. 2014-02-06 13:28:06 +00:00
tools Use proper include path for dtc as well as cpp. 2014-02-28 22:37:35 +00:00
ufs - If we fail to do a non-blocking acquire of a buf lock while doing a 2014-03-06 00:13:21 +00:00
vm Initialize paddr to handle the case of zero size. 2014-03-12 16:38:55 +00:00
x86 Correct type for malloc(). 2014-03-13 18:11:42 +00:00
xdr
xen xen: add and enable Xen console for PVH guests 2014-03-11 10:09:23 +00:00
Makefile Add netpfil to CSCOPEDIRS. 2013-12-30 08:36:17 +00:00