Bug 556 - TCP_NODELAY not set for non-interactive sessions
Summary: TCP_NODELAY not set for non-interactive sessions
Status: CLOSED DUPLICATE of bug 981
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sshd (show other bugs)
Version: -current
Hardware: All All
: P2 enhancement
Assignee: OpenSSH Bugzilla mailing list
URL:
Keywords: openbsd, patch
Depends on:
Blocks:
 
Reported: 2003-05-07 23:31 AEST by Brian Genisio
Modified: 2006-10-07 11:35 AEST (History)
0 users

See Also:


Attachments
Patch to add the TCP_NODELAY flag after the connection acceptance (429 bytes, patch)
2003-05-14 22:37 AEST, Brian Genisio
no flags Details | Diff
Tidy up patch. (466 bytes, patch)
2006-03-13 19:25 AEDT, Darren Tucker
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Genisio 2003-05-07 23:31:20 AEST
When port forwarding is set up, TCP_NODELAY is set on the ports, in order to prevent buffering.  This flag is not set in the actual SSH connection.  This causes data that flows from the server to the client to be buffered, causing a bursing effect.  

The solution is to add set_nodelay(newsock) after the accept call in the main function.  This solves the problem, but requires TCP_NODELAY to be set on all connections, regardless of port forwards.
Comment 1 Brian Genisio 2003-05-14 22:37:42 AEST
Created attachment 294 [details]
Patch to add the TCP_NODELAY flag after the connection acceptance
Comment 2 Brian Genisio 2003-05-14 22:38:19 AEST
See patch.  Very simple fix
Comment 3 Damien Miller 2003-05-14 22:49:21 AEST
the bug isn't fixed until the patch is accepted and applied in out tree.
Comment 4 Damien Miller 2003-06-04 19:54:39 AEST
This is incorrect. We already set nonblock on the main socket, grep for
packet_set_nonblocking a little further down the same function.
Comment 5 Damien Miller 2003-06-05 00:28:08 AEST
I am an idiot - I confused nonblock with nodelay. I'll look at your patch in the
morning.
Comment 6 Markus Friedl 2003-08-27 02:56:21 AEST
sshd already sets nodelay for the connection, but conditionally, and
only for interactive sessions, so this is the well known problem:

why does sshd traditionally set no delay only for interactive sessions.
Comment 7 Markus Friedl 2003-08-27 02:57:29 AEST
i don't see how your patch affects port forwarding......
Comment 8 Brian Genisio 2003-08-27 03:12:31 AEST
This patch does not specifically fix port forwarding, as it fixes the problem 
where TCP_NODELAY is not set on all types of connections.  I was using SSH for 
port forwarding, with a non-interactive connection, and was receiving problems 
since TCP_NODELAY was not being set.

By adding this patch, or something similar, the buffering problem I saw with 
small but frequent data packets.
Comment 9 Markus Friedl 2003-08-27 04:02:05 AEST
this would probably be better....

folly% cvs -qd /cvs diff -u packet.c
Index: packet.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/packet.c,v
retrieving revision 1.109
diff -u -r1.109 packet.c
--- packet.c    10 Jul 2003 14:42:28 -0000      1.109
+++ packet.c    26 Aug 2003 18:02:44 -0000
@@ -1429,8 +1429,7 @@
        /* Only set socket options if using a socket.  */
        if (!packet_connection_is_on_socket())
                return;
-       if (interactive)
-               set_nodelay(connection_in);
+       set_nodelay(connection_in);
        packet_set_tos(interactive);
 }
 
[1]
folly% 
Comment 10 Darren Tucker 2006-03-13 19:25:00 AEDT
Created attachment 1099 [details]
Tidy up patch.
Comment 11 Darren Tucker 2006-03-13 19:28:44 AEDT
Oops, the patch suggested by Markus is also in bug #981 (where it's been ok'ed) and covers both this and the client side.

*** This bug has been marked as a duplicate of bug 981 ***
Comment 12 Darren Tucker 2006-10-07 11:35:49 AEST
Change all RESOLVED bug to CLOSED with the exception of the ones fixed post-4.4.