[PATCH] Added Null packet keepalive option
Tom Rudnick
tom at avatar.itc.nrcs.usda.gov
Thu Mar 29 16:47:01 EST 2001
>
> have you tried to send an empty ignore message to the buggy servers?
> sending MSG_NONE relies on another implementation bug, and this should
> be fixed in OpenSSH asap.
>
Markus-
Here is an altered patch which does MSG_IGNORE instead of MSG_NONE.
Is this the more appropriate route?
+ if(compat20)
+ packet_start(SSH2_MSG_IGNORE);
+ else
+ packet_start(SSH_MSG_IGNORE);
+ packet_send();
Another question.
The message posted with the subject: "living with masq" shows
another patch that has similar results, except it sends random
data at random intervals. Is the fixed interval with null
data going to affect the integrity of the connection?
If so, how important is this effect?
I have attached the modified patch using MSG_IGNORE. This patch
is an updated version of the one I posted earlier.
Let me know what you guys think...
-Tom Rudnick
--
----------------/----------------------------------------------
Tom Rudnick | USDA Natural Resources Conservation Service
Fort Collins,CO | tom at avatar.itc.nrcs.usda.gov (970) 295-5427
** The 3rd Millennium started Jan 1, 2001. see: **
** http://aa.usno.navy.mil/AA/faq/docs/millennium.html **
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-------------- next part --------------
--- readconf.h 2001/03/11 01:49:20 1.21
+++ readconf.h 2001/03/23 21:47:36
@@ -61,6 +61,10 @@
int compression_level; /* Compression level 1 (fast) to 9
* (best). */
int keepalives; /* Set SO_KEEPALIVE. */
+ time_t noop_msg_interval; /* Number of seconds between
+ * SSH_MSG_IGNORE packets to keep
+ * firewall connections from
+ * timing out */
LogLevel log_level; /* Level for logging. */
int port; /* Port to connect. */
--- readconf.c 2001/03/22 01:24:05 1.42
+++ readconf.c 2001/03/23 21:47:37
@@ -110,7 +110,7 @@
oUsePrivilegedPort, oLogLevel, oCiphers, oProtocol, oMacs,
oGlobalKnownHostsFile2, oUserKnownHostsFile2, oPubkeyAuthentication,
oKbdInteractiveAuthentication, oKbdInteractiveDevices, oHostKeyAlias,
- oPreferredAuthentications
+ oPreferredAuthentications, oNoopMsgInterval
} OpCodes;
/* Textual representations of the tokens. */
@@ -173,6 +173,7 @@
{ "numberofpasswordprompts", oNumberOfPasswordPrompts },
{ "loglevel", oLogLevel },
{ "preferredauthentications", oPreferredAuthentications },
+ { "noopmsginterval", oNoopMsgInterval },
{ NULL, 0 }
};
@@ -387,6 +388,10 @@
intptr = &options->keepalives;
goto parse_flag;
+ case oNoopMsgInterval:
+ intptr = &options->noop_msg_interval;
+ goto parse_int;
+
case oNumberOfPasswordPrompts:
intptr = &options->number_of_password_prompts;
goto parse_int;
@@ -707,6 +712,7 @@
options->strict_host_key_checking = -1;
options->compression = -1;
options->keepalives = -1;
+ options->noop_msg_interval = -1;
options->compression_level = -1;
options->port = -1;
options->connection_attempts = -1;
@@ -791,6 +797,8 @@
options->compression = 0;
if (options->keepalives == -1)
options->keepalives = 1;
+ if (options->noop_msg_interval == -1)
+ options->noop_msg_interval = 0;
if (options->compression_level == -1)
options->compression_level = 6;
if (options->port == -1)
--- clientloop.c 2001/03/06 03:34:40 1.36
+++ clientloop.c 2001/03/23 21:47:37
@@ -365,6 +365,10 @@
client_wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp,
int *maxfdp)
{
+ struct timeval tv = {0};
+ tv.tv_sec = options.noop_msg_interval;
+ /* Send a noop message at this frequency as a keepalive. */
+
/* Add any selections by the channel mechanism. */
channel_prepare_select(readsetp, writesetp, maxfdp);
@@ -403,7 +407,8 @@
* SSH_MSG_IGNORE packet when the timeout expires.
*/
- if (select((*maxfdp)+1, *readsetp, *writesetp, NULL, NULL) < 0) {
+ switch (select((*maxfdp)+1, *readsetp, *writesetp, NULL, ((tv.tv_sec)?(&tv):NULL))) {
+ case -1: {
char buf[100];
/*
@@ -420,7 +425,24 @@
snprintf(buf, sizeof buf, "select: %s\r\n", strerror(errno));
buffer_append(&stderr_buffer, buf, strlen(buf));
quit_pending = 1;
- }
+
+ }
+ break;
+
+ case 0:
+ /* Send a keepalive packet (SSH_MSG_IGNORE crashes
+ * some servers...).
+ */
+ if(compat20)
+ packet_start(SSH2_MSG_IGNORE);
+ else
+ packet_start(SSH_MSG_IGNORE);
+ packet_send();
+ break;
+
+ default:
+ break;
+ }
}
void
More information about the openssh-unix-dev
mailing list