diff options
author | Matt Johnston <matt@ucc.asn.au> | 2014-07-09 00:15:20 +0800 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2014-07-09 00:15:20 +0800 |
commit | c884e5000e881f45e5c2328e219eebd07b0560ca (patch) | |
tree | 59c2280892aff108c15690290ad4adbc1f4e2012 /process-packet.c | |
parent | 1ccac01cee0222be332b46d7102336465760aa11 (diff) |
Make -K keepalive behave like OpenSSH's ServerAliveInterval
Diffstat (limited to 'process-packet.c')
-rw-r--r-- | process-packet.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/process-packet.c b/process-packet.c index 6cbcfc7..ddeb9ce 100644 --- a/process-packet.c +++ b/process-packet.c @@ -44,6 +44,7 @@ void process_packet() { unsigned char type; unsigned int i; + time_t now; TRACE2(("enter process_packet")) @@ -52,7 +53,8 @@ void process_packet() { ses.lastpacket = type; - ses.last_packet_time = monotonic_now(); + now = monotonic_now(); + ses.last_packet_time_keepalive_recv = now; /* These packets we can receive at any time */ switch(type) { @@ -65,13 +67,21 @@ void process_packet() { case SSH_MSG_UNIMPLEMENTED: /* debugging XXX */ TRACE(("SSH_MSG_UNIMPLEMENTED")) - dropbear_exit("Received SSH_MSG_UNIMPLEMENTED"); + goto out; case SSH_MSG_DISCONNECT: /* TODO cleanup? */ dropbear_close("Disconnect received"); } + /* Ignore these packet types so that keepalives don't interfere with + idle detection. This is slightly incorrect since a tcp forwarded + global request with failure won't trigger the idle timeout, + but that's probably acceptable */ + if (!(type == SSH_MSG_GLOBAL_REQUEST || type == SSH_MSG_REQUEST_FAILURE)) { + ses.last_packet_time_idle = now; + } + /* This applies for KEX, where the spec says the next packet MUST be * NEWKEYS */ if (ses.requirenext != 0) { |