1 (edited by Marco Wenzel 2017-05-11 02:13:40)

Topic: [SOLVED] wolfSSH window adjustment

Hi,

I currently implemented a SSH server based on the current wolfSSH v1.0.0 from github, orienting on the example echoserver, that is included.

When I am trying to send a huge amount of data to the client, calling wolfSSH_stream_send, it stops sending data after a specific amount. I found out, that the peer window size (channel->peerWindowSz) gets decreased with every call of wolfSSH_stream_send, but never gets increased anymore. When the value of channel->peerWindowSz reachess zero, the call of wolfSSH_stream_send does not send any data and returns with "0".

So how should the software behave in this case? Is there maybe a possibility to do a window adjustment in order to send all data?

Thanks,
Marco

Share

Re: [SOLVED] wolfSSH window adjustment

Hey Marco,

Thanks for letting us know about your issue.  I'll forward your question to our SSH expert for a response.

Thanks,
Chris

Re: [SOLVED] wolfSSH window adjustment

Marco:

The peerWindowSz value is increased when the peer sends a Channel Window Adjust message. Which client are you using, it sounds to me like it is misbehaving.

--John

Re: [SOLVED] wolfSSH window adjustment

Hey John,

I am using OpenSSH client (1:7.2p2-4ubuntu2.1) on Linux and PuTTY (0.67) on Windows. Both clients show the same behavior.

Best,
Marco

Share

Re: [SOLVED] wolfSSH window adjustment

And you are using commit 87eb3ad from the GitHub repository?

Re: [SOLVED] wolfSSH window adjustment

Right, I am using the latest Github code.

Share

Re: [SOLVED] wolfSSH window adjustment

Could you enable debugging and see if DoChannelWindowAdjust() is called? It should report what the peer wants to add back to the window, the current peerWindowSz and the updated peerWindowSz.

The logging will produce a lot of noisy output. Could you send the log to me directly?

Re: [SOLVED] wolfSSH window adjustment

Hi John,

I have sent you an e-mail.

Best, Marco

Share

Re: [SOLVED] wolfSSH window adjustment

It looks like your server is sending data to the client and never stopping to receive messages from the client. You need to call wolfSSH_stream_read() once in a while as it processes the background bookkeeping messages like Channel Adjust Window.

Re: [SOLVED] wolfSSH window adjustment

That is right. The server calls wolfSSH_stram_send() many times in order to send a huge amount of data, but without calling wolfSSH_stream_read() in between. But the fact is, that when it calls wolfSSH_stream_read() between all these send calls, it expects some data from the client. When the client is not sending any data except the window adjustment message, wolfSSH_stream_read() does not return and any following operation is blocked.

So what do you suggest to do in this case?

Share

11 (edited by Marco Wenzel 2017-05-10 07:04:37)

Re: [SOLVED] wolfSSH window adjustment

Another problem, which I could figure out today:

Putty sends in it's window adjust message a string called "winadj@putty.projects.tartarus.org" (see https://tartarus.org/~simon/putty-snaps … ndixF.html). This string is 34 characters long but the variable, where it is copied (call of GetString() in DoChannelRequest()) has a length of 32 characters. This leads to an invalidation of the next variables on the stack. An increment of the string variable size would solve the problem.

Share

Re: [SOLVED] wolfSSH window adjustment

Marco Wenzel wrote:

That is right. The server calls wolfSSH_stram_send() many times in order to send a huge amount of data, but without calling wolfSSH_stream_read() in between. But the fact is, that when it calls wolfSSH_stream_read() between all these send calls, it expects some data from the client. When the client is not sending any data except the window adjustment message, wolfSSH_stream_read() does not return and any following operation is blocked.

So what do you suggest to do in this case?

Are you using blocking or non-blocking sockets?

The example echoserver is using blocking sockets. The client drives the echoserver's behavior. You should use non-blocking sockets. The call to wolfSSH_stream_read() should return a WS_WANT_READ error if there isn't data available on the socket.


As far as the DoChannelRequest() issue, I agree with you on the solution to the problem. I'm adding this to my list.

Re: [SOLVED] wolfSSH window adjustment

Thank you for the tips. I configured the client socket to non blocking and now I can use wolfSSH_stream_read() in order to trigger the window adjustment processing.

Share