diff options
author | djm@openbsd.org <djm@openbsd.org> | 2016-03-04 04:35:44 +0100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2016-03-04 05:12:21 +0100 |
commit | 988e429d903acfb298bfddfd75e7994327adfed0 (patch) | |
tree | 467226f3c566d260181c2379637b378681d2581c /serverloop.c | |
parent | upstream commit (diff) | |
download | openssh-988e429d903acfb298bfddfd75e7994327adfed0.tar.xz openssh-988e429d903acfb298bfddfd75e7994327adfed0.zip |
upstream commit
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
Diffstat (limited to 'serverloop.c')
-rw-r--r-- | serverloop.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/serverloop.c b/serverloop.c index 80d1db549..e6a92476f 100644 --- a/serverloop.c +++ b/serverloop.c @@ -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; } |