Honor openssh out max packet size#455
Honor openssh out max packet size#455jquast wants to merge 2 commits intoparamiko:masterfrom jquast:honor-openssh-out_max_packet_size
Conversation
This log message misleads one to believe a maximum packet size, such as 16384 requested by OpenSSH has been honored, when in fact it is "clamped" to 32768.
|
Thanks for the detailed write-up, super appreciated! I wonder if this was worsened by semi-recent work on cleaning up & exposing some of the window/packet size stuff in #372 - though that doesn't really impact how we go ahead with this, is just idle speculation. Looks good to me offhand (& the test suite does pass, the 'fail' is the travis worker for the 3.4 interpreter timing out, which is their end not ours), I'd like to test it out with my real world workflows but otherwise I'm slotting this into a release. |
tests/test_transport.py
Outdated
There was a problem hiding this comment.
val should be 32767, it is purposedly set not to match the correct value, to make sure the clamping works. :)
There was a problem hiding this comment.
Thank you @lndbrg, I'll push such change shortly.
There was a problem hiding this comment.
These were addressed. Travis passed again. Thanks again.
Not fully confident with this change, though I will describe my findings fully in the pull request. The OpenSSH client requests a maximum packet size of 16384, but this MIN_PACKET_SIZE value of 32768 causes its request to be "clamped" up to 32768, later causing an error to stderr on the OpenSSH client. Suggest then, to delineate MIN_WINDOW_SIZE from MIN_PACKET_SIZE, as they are applied. I don't think there is any minimum value of MIN_PACKET_SIZE, however we can suggest a value of 4096 for now.
|
Cool! 👍 |
OpenSSH client requests a value of 16384 for value of
Channel.out_max_packet_size,when opening a session channel, but method
_set_remote_channel“clamps” this value byTransport._sanitize_packet_size, which coerces the value to 32768.Because paramiko server is not honoring the client's requested value, and there is no protocol negotiation to notify the client as such, when a packet larger than 16384 is received by the OpenSSH client, it will write to stderr:
channel 0: rcvd big packet 32704, maxpack 16384.This is especially difficult for interactive programs that use cursor addressing, as the position of the client cursor then becomes indeterminate. A large-windowed terminal (size ~170x100) using a curses application is very likely to receive this message, which will cause corruption in the output display.
This value is specified in common.py:
If you follow rfc4254 for this declaration,
Then, following SSH-TRANS, which is http://www.ietf.org/rfc/rfc4253.txt for section 6.1, it reads:
We read that it is perfectly legal to request a maximum packet size of 16384 as OpenSSH client does (“or less”).
If we modify
demos/demo_server.py,We can see the client emit this message:
channel 0: rcvd big packet 32704, maxpack 16384. Furthermore, the demo_server.log writes a misleading message,[chan 1] Max packet out: 16384 bytes— that was the value received, but not the value set and later honored.This patch suggests separating
MIN_PACKET_SIZEtoMIN_WINDOW_SIZE, and lowering the value ofMIN_PACKET_SIZEto 4096.