]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream commit
authordjm@openbsd.org <djm@openbsd.org>
Fri, 4 Mar 2016 03:35:44 +0000 (03:35 +0000)
committerDamien Miller <djm@mindrot.org>
Fri, 4 Mar 2016 04:12:21 +0000 (15:12 +1100)
fix ClientAliveInterval when a time-based RekeyLimit is
 set; previously keepalive packets were not being sent. bz#2252 report and
 analysis by Christian Wittenhorst and Garrett Lee feedback and ok dtucker@

Upstream-ID: d48f9deadd35fdacdd5106b41bb07630ddd4aa81

serverloop.c

index 80d1db5490bcc0b9392824c020291f8ee37cfa8f..e6a92476f7fdad6d391d9745176bbebe89c965e6 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: serverloop.c,v 1.182 2016/02/08 10:57:07 djm Exp $ */
+/* $OpenBSD: serverloop.c,v 1.183 2016/03/04 03:35:44 djm Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -276,7 +276,7 @@ client_alive_check(void)
  */
 static void
 wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, int *maxfdp,
-    u_int *nallocp, u_int64_t max_time_milliseconds)
+    u_int *nallocp, u_int64_t max_time_ms)
 {
        struct timeval tv, *tvp;
        int ret;
@@ -288,9 +288,9 @@ wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, int *maxfdp,
        channel_prepare_select(readsetp, writesetp, maxfdp, nallocp,
            &minwait_secs, 0);
 
+       /* XXX need proper deadline system for rekey/client alive */
        if (minwait_secs != 0)
-               max_time_milliseconds = MIN(max_time_milliseconds,
-                   (u_int)minwait_secs * 1000);
+               max_time_ms = MIN(max_time_ms, (u_int)minwait_secs * 1000);
 
        /*
         * if using client_alive, set the max timeout accordingly,
@@ -300,11 +300,13 @@ wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, int *maxfdp,
         * this could be randomized somewhat to make traffic
         * analysis more difficult, but we're not doing it yet.
         */
-       if (compat20 &&
-           max_time_milliseconds == 0 && options.client_alive_interval) {
+       if (compat20 && options.client_alive_interval) {
+               uint64_t keepalive_ms =
+                   (uint64_t)options.client_alive_interval * 1000;
+
                client_alive_scheduled = 1;
-               max_time_milliseconds =
-                   (u_int64_t)options.client_alive_interval * 1000;
+               if (max_time_ms == 0 || max_time_ms > keepalive_ms)
+                       max_time_ms = keepalive_ms;
        }
 
        if (compat20) {
@@ -353,14 +355,14 @@ wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, int *maxfdp,
         * from it, then read as much as is available and exit.
         */
        if (child_terminated && packet_not_very_much_data_to_write())
-               if (max_time_milliseconds == 0 || client_alive_scheduled)
-                       max_time_milliseconds = 100;
+               if (max_time_ms == 0 || client_alive_scheduled)
+                       max_time_ms = 100;
 
-       if (max_time_milliseconds == 0)
+       if (max_time_ms == 0)
                tvp = NULL;
        else {
-               tv.tv_sec = max_time_milliseconds / 1000;
-               tv.tv_usec = 1000 * (max_time_milliseconds % 1000);
+               tv.tv_sec = max_time_ms / 1000;
+               tv.tv_usec = 1000 * (max_time_ms % 1000);
                tvp = &tv;
        }