You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Roberto Deandrea (JIRA)" <ji...@apache.org> on 2018/10/08 14:52:00 UTC

[jira] [Commented] (SSHD-848) Possible bug opening local port forwarding channel

    [ https://issues.apache.org/jira/browse/SSHD-848?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16641940#comment-16641940 ] 

Roberto Deandrea commented on SSHD-848:
---------------------------------------

Our proposed solution in StaticIOHandler.sessionCreated() caused a deadlock in SSH client. We found a better solution for the issue changing code in StaticIOHandler.sessionClosed() in defaultForwardingFilter.java.

 

We changed the code as the following:

 

        @Override
        public void sessionClosed(IoSession session) throws Exception {
            TcpipClientChannel channel = (TcpipClientChannel) session.removeAttribute(TcpipClientChannel.class);
                        
            Throwable cause = (Throwable) session.removeAttribute(TcpipForwardingExceptionMarker.class);
            if (channel != null) {
                if (debugEnabled) {
                    log.debug("sessionClosed({}) closing channel={} after {} messages - cause={}",
                            session, channel, messagesCounter, (cause == null) ? null : cause.getClass().getSimpleName());
                }
                
                if (cause != null) {
                  channel.close(true);
                } else {
                  OpenFuture openFuture = channel.getOpenFuture();
                  // channel.getOpenFuture().await();
        
                  if (!openFuture.isDone()) {
                    openFuture.addListener(f -> {
                      // If exception signaled then close channel immediately
                      channel.close(false);        
                    });
                  }
                  else {
                    channel.close(false);                            
                  }                  
                }
            }
        }

 

What do you think about it?

 

> Possible bug opening local port forwarding channel
> --------------------------------------------------
>
>                 Key: SSHD-848
>                 URL: https://issues.apache.org/jira/browse/SSHD-848
>             Project: MINA SSHD
>          Issue Type: Bug
>    Affects Versions: 2.0.1
>            Reporter: Roberto Deandrea
>            Priority: Major
>         Attachments: testlpf.ko, testlpf.ok
>
>
> Hi , We found a possible bug opening a local port forwarding channel.
> Scenario : The SSH client and server are based on Apache SSHD 2.0.1. There is a FTP client sending a file through a local port forwarding channel to a target server.
> The problem manifests when the SSH server is busy and returns the SSH_MSG_CHANNEL_OPEN_CONFIRMATION with a some delay and the client is very fast to send only a few bytes on a local port forwarding channel.
> The outcome is the FTP client is NOT able to send bytes through the channel to the target server.
> Into SSH client traces we see :
> org.apache.sshd.common.channel.WindowClosedException: Already closed: Window[client/remote](TcpipClientChannel[id=4, recipient=4]-ClientSessionImpl[roberto@/192.168.50.61:10022])
>  
> According to us there is a chance that if we don't AWAIT the local port forward channel is TOTALLY opened, when the client is very fast to send bytes... it closes its connection, ao the channel that is already closing prevents bytes to flow through the channel to the target server.
>  
> We guess there is a code bug in *DefaultForwardingFilter.sessionCreated()* method.
> We add the following line at the end of the method and the problem seems definitely fixed.
>             *channel.getOpenFuture().await();*
>  
> Please, can you troubleshoot this issue and comment about our potential code fix ?
> Thanks in advance.
>  
> I attached  the files:
> testslpf.ko SSH client traces with original code and a failed attempt
> testslpf.ok SSH client traces with our code changes and a successful attempt
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)