Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

tcp: Ignore TCP_NOPUSH socketopt by default

For ill optimized programs which misuses this sockopt will cause
unpredicted length of network stalling, if the total sending size
is not TCP sending segment size aligned.

sysctl node net.inet.tcp.disable_nopush controls whether TCP_NOPUSH
will take effect or not

I am not going to fight agaist the stupid programs in the wild.

DragonFly-bug: http://bugs.dragonflybsd.org/issues/2368

This is actually _not_ a bug on our side.
  • Loading branch information...
commit 3533a1834a0ba3a7c441ede5120c3720d8a34c4c 1 parent 7a6d805
Sepherosa Ziehau authored
Showing with 13 additions and 1 deletion.
  1. +13 −1 sys/netinet/tcp_usrreq.c
View
14 sys/netinet/tcp_usrreq.c
@@ -159,11 +159,21 @@ static struct tcpcb *
#endif
static int tcp_lport_extension = 1;
-
SYSCTL_INT(_net_inet_tcp, OID_AUTO, lportext, CTLFLAG_RW,
&tcp_lport_extension, 0, "");
/*
+ * For some ill optimized programs, which try to use TCP_NOPUSH
+ * to improve performance, will have small amount of data sits
+ * in the sending buffer. These small amount of data will _not_
+ * be pushed into the network until more data are written into
+ * the socket or the socket write side is shutdown.
+ */
+static int tcp_disable_nopush = 1;
+SYSCTL_INT(_net_inet_tcp, OID_AUTO, disable_nopush, CTLFLAG_RW,
+ &tcp_disable_nopush, 0, "TCP_NOPUSH socket option will have no effect");
+
+/*
* TCP attaches to socket via pru_attach(), reserving space,
* and an internet control block. This is likely occuring on
* cpu0 and may have to move later when we bind/connect.
@@ -1387,6 +1397,8 @@ tcp_ctloutput(netmsg_t msg)
break;
case TCP_NOPUSH:
+ if (tcp_disable_nopush)
+ break;
if (optval)
tp->t_flags |= TF_NOPUSH;
else {
Please sign in to comment.
Something went wrong with that request. Please try again.