From bee789b12305f3c5e594fe03c965e0786969eeb7 Mon Sep 17 00:00:00 2001 From: Alexander Bluhm Date: Mon, 12 Aug 2013 21:57:17 +0000 Subject: Add the TCP socket option TCP_NOPUSH to delay sending the stream. This is useful to aggregate data in the kernel from multiple sources like writes and socket splicing. It avoids sending small packets. From FreeBSD via David Hill; OK mikeb@ henning@ --- sys/netinet/tcp_usrreq.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'sys/netinet/tcp_usrreq.c') diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 4e108d144fe..9fd519615ab 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_usrreq.c,v 1.113 2013/08/06 07:31:48 bluhm Exp $ */ +/* $OpenBSD: tcp_usrreq.c,v 1.114 2013/08/12 21:57:16 bluhm Exp $ */ /* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */ /* @@ -532,6 +532,18 @@ tcp_ctloutput(op, so, level, optname, mp) tp->t_flags &= ~TF_NODELAY; break; + case TCP_NOPUSH: + if (m == NULL || m->m_len < sizeof (int)) + error = EINVAL; + else if (*mtod(m, int *)) + tp->t_flags |= TF_NOPUSH; + else if (tp->t_flags & TF_NOPUSH) { + tp->t_flags &= ~TF_NOPUSH; + if (TCPS_HAVEESTABLISHED(tp->t_state)) + error = tcp_output(tp); + } + break; + case TCP_MAXSEG: if (m == NULL || m->m_len < sizeof (int)) { error = EINVAL; @@ -605,6 +617,9 @@ tcp_ctloutput(op, so, level, optname, mp) case TCP_NODELAY: *mtod(m, int *) = tp->t_flags & TF_NODELAY; break; + case TCP_NOPUSH: + *mtod(m, int *) = tp->t_flags & TF_NOPUSH; + break; case TCP_MAXSEG: *mtod(m, int *) = tp->t_maxseg; break; -- cgit v1.2.3