www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples

Archive Index This month's Index

Subject: Re: keepalive support

Re: keepalive support

From: Simon Josefsson <simon_at_josefsson.org>
Date: Thu, 28 Jan 2010 15:06:04 +0100

Simon Josefsson <simon_at_josefsson.org> writes:

> There is more to work on though (i.e., GLOBAL_REQUEST), but I'll
> followup on that later.

I've completed this now.

For some wonderful reason, OpenSSH serverloop.c has this logic:

        if ((channel_id = channel_find_open()) == -1) {
                packet_start(SSH2_MSG_GLOBAL_REQUEST);
                packet_put_cstring("keepalive_at_openssh.com");
                packet_put_char(1); /* boolean: want reply */
        } else {
                channel_request_start(channel_id, "keepalive_at_openssh.com", 1);
        }

Which means they use fall back on using a global request if it cannot
find an open channel. Why they don't always send a global request
instead is beyond me, it would appear simpler to do.

However, for completeness libssh2 should support this variant as well.
The main practical reason is that I suspect that other SSH servers out
there just send a GLOBAL_REQUEST instead of CHANNEL_REQUEST. I will
validate this theory with Bitvise/SSHD if I can get hold of them and
configure them properly.

Reproducing the GLOBAL_REQUEST scenario requires modifying the == to !=
in the code above, and re-build your sshd, but if you do, you will see:

debug2: channel 0: rcvd adjust 39321600
debug3: Wrote 52 bytes for a total of 2819
debug3: Wrote 52 bytes for a total of 2871
debug3: Wrote 68 bytes for a total of 2939
debug3: Wrote 68 bytes for a total of 3007
debug3: Wrote 68 bytes for a total of 3075
Timeout, client not responding.

OpenSSH doesn't really say what packets it sends, but I suspect they are
the 68 bytes packets.

Now, pull in the latest libssh2 from git (which now sports
GLOBAL_REQUEST keep-alive support too) and you will see:

debug3: Wrote 52 bytes for a total of 2819
debug3: Wrote 52 bytes for a total of 2871
debug3: Wrote 68 bytes for a total of 2939
debug1: Got 82/13 for keepalive
debug3: Wrote 68 bytes for a total of 3007
debug1: Got 82/14 for keepalive
debug3: Wrote 68 bytes for a total of 3075
debug1: Got 82/15 for keepalive
debug3: Wrote 68 bytes for a total of 3143
debug1: Got 82/16 for keepalive
debug3: Wrote 68 bytes for a total of 3211
debug1: Got 82/17 for keepalive
debug3: Wrote 68 bytes for a total of 3279
debug1: Got 82/18 for keepalive

/Simon
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-01-28

the libssh2 team