bug & patch in ServerAliveInterval (openssh 4.3-p2)

catamus gogu at l.route666.net
Sun Apr 23 03:02:47 EST 2006


Hi openssh-unix-dev subscribers :)

I have found that ServerAliveInterval & ServerAliveCountMax have
some bug. Basically the ssh-alive check function (that verify the
peer is alive) is called only if no data at all gets into ssh (when it 
should work only for server channel).I am pretty sure developers know
about this ..anyway I have tried to fix this issue. Here is the patch:

diff -rNu openssh-4.3p2/clientloop.c openssh-4.3p2-alive-fixed/clientloop.c
--- openssh-4.3p2/clientloop.c  2005-12-31 07:22:32.000000000 +0200
+++ openssh-4.3p2-alive-fixed/clientloop.c      2006-04-22 19:32:17.000000000 +0300
@@ -456,7 +456,7 @@
  client_wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp,
      int *maxfdp, u_int *nallocp, int rekeying)
  {
-       struct timeval tv, *tvp;
+       static struct timeval tv, *tvp;
         int ret;

         /* Add any selections by the channel mechanism. */
@@ -508,12 +508,16 @@

         if (options.server_alive_interval == 0 || !compat20)
                 tvp = NULL;
-       else {
+       else if(tv.tv_sec == 0 && tv.tv_usec == 0) {
                 tv.tv_sec = options.server_alive_interval;
                 tv.tv_usec = 0;
                 tvp = &tv;
         }
         ret = select((*maxfdp)+1, *readsetp, *writesetp, NULL, tvp);
+       if(FD_ISSET(connection_out, *readsetp)) {
+               tv.tv_sec = 0;
+               tv.tv_usec = 0;
+       }
         if (ret < 0) {
                 char buf[100];




More information about the openssh-unix-dev mailing list