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.
Created attachment 294 [details] Patch to add the TCP_NODELAY flag after the connection acceptance
See patch. Very simple fix
the bug isn't fixed until the patch is accepted and applied in out tree.
This is incorrect. We already set nonblock on the main socket, grep for packet_set_nonblocking a little further down the same function.
I am an idiot - I confused nonblock with nodelay. I'll look at your patch in the morning.
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.
i don't see how your patch affects port forwarding......
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.
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%
Created attachment 1099 [details] Tidy up patch.
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 ***
Change all RESOLVED bug to CLOSED with the exception of the ones fixed post-4.4.