Add -W <windowsize> argument and document it.

--HG--
extra : convert_revision : 98d4c0f15480bf749c451034cbc565d7e9d3b8dc
This commit is contained in:
Matt Johnston 2007-07-25 15:44:25 +00:00
parent 2d4d9627a2
commit e3e4445dc1
8 changed files with 56 additions and 12 deletions

View File

@ -350,7 +350,7 @@ static int cli_initchansess(struct Channel *channel) {
channel->errfd = STDERR_FILENO; channel->errfd = STDERR_FILENO;
setnonblocking(STDERR_FILENO); setnonblocking(STDERR_FILENO);
channel->extrabuf = cbuf_new(RECV_MAX_WINDOW); channel->extrabuf = cbuf_new(opts.recv_window);
if (cli_opts.wantpty) { if (cli_opts.wantpty) {
send_chansess_pty_req(channel); send_chansess_pty_req(channel);

View File

@ -63,10 +63,11 @@ static void printhelp() {
#ifdef ENABLE_CLI_REMOTETCPFWD #ifdef ENABLE_CLI_REMOTETCPFWD
"-R <listenport:remotehost:remoteport> Remote port forwarding\n" "-R <listenport:remotehost:remoteport> Remote port forwarding\n"
#endif #endif
"-W <receive_window_buffer> (default %d, larger may be faster)\n"
#ifdef DEBUG_TRACE #ifdef DEBUG_TRACE
"-v verbose\n" "-v verbose\n"
#endif #endif
,DROPBEAR_VERSION, cli_opts.progname); ,DROPBEAR_VERSION, cli_opts.progname, DEFAULT_RECV_WINDOW);
} }
void cli_getopts(int argc, char ** argv) { void cli_getopts(int argc, char ** argv) {
@ -109,6 +110,8 @@ void cli_getopts(int argc, char ** argv) {
opts.ipv4 = 1; opts.ipv4 = 1;
opts.ipv6 = 1; opts.ipv6 = 1;
*/ */
opts.recv_window = DEFAULT_RECV_WINDOW;
char* recv_window_arg = NULL;
/* Iterate all the arguments */ /* Iterate all the arguments */
for (i = 1; i < (unsigned int)argc; i++) { for (i = 1; i < (unsigned int)argc; i++) {
@ -201,6 +204,9 @@ void cli_getopts(int argc, char ** argv) {
case 'u': case 'u':
/* backwards compatibility with old urandom option */ /* backwards compatibility with old urandom option */
break; break;
case 'W':
next = &recv_window_arg;
break;
#ifdef DEBUG_TRACE #ifdef DEBUG_TRACE
case 'v': case 'v':
debug_trace = 1; debug_trace = 1;
@ -292,6 +298,15 @@ void cli_getopts(int argc, char ** argv) {
&& cli_opts.no_cmd == 0) { && cli_opts.no_cmd == 0) {
dropbear_exit("command required for -f"); dropbear_exit("command required for -f");
} }
if (recv_window_arg)
{
opts.recv_window = atol(recv_window_arg);
if (opts.recv_window == 0)
{
dropbear_exit("Bad recv window '%s'", recv_window_arg);
}
}
} }
#ifdef ENABLE_CLI_PUBKEY_AUTH #ifdef ENABLE_CLI_PUBKEY_AUTH

View File

@ -34,6 +34,7 @@
#include "channel.h" #include "channel.h"
#include "ssh.h" #include "ssh.h"
#include "listener.h" #include "listener.h"
#include "runopts.h"
static void send_msg_channel_open_failure(unsigned int remotechan, int reason, static void send_msg_channel_open_failure(unsigned int remotechan, int reason,
const unsigned char *text, const unsigned char *lang); const unsigned char *text, const unsigned char *lang);
@ -150,9 +151,9 @@ struct Channel* newchannel(unsigned int remotechan,
newchan->await_open = 0; newchan->await_open = 0;
newchan->flushing = 0; newchan->flushing = 0;
newchan->writebuf = cbuf_new(RECV_MAX_WINDOW); newchan->writebuf = cbuf_new(opts.recv_window);
newchan->extrabuf = NULL; /* The user code can set it up */ newchan->extrabuf = NULL; /* The user code can set it up */
newchan->recvwindow = RECV_MAX_WINDOW; newchan->recvwindow = opts.recv_window;
newchan->recvdonelen = 0; newchan->recvdonelen = 0;
newchan->recvmaxpacket = RECV_MAX_PAYLOAD_LEN; newchan->recvmaxpacket = RECV_MAX_PAYLOAD_LEN;
@ -421,7 +422,7 @@ static void writechannel(struct Channel* channel, int fd, circbuffer *cbuf) {
channel->recvdonelen = 0; channel->recvdonelen = 0;
} }
dropbear_assert(channel->recvwindow <= RECV_MAX_WINDOW); dropbear_assert(channel->recvwindow <= opts.recv_window);
dropbear_assert(channel->recvwindow <= cbuf_getavail(channel->writebuf)); dropbear_assert(channel->recvwindow <= cbuf_getavail(channel->writebuf));
dropbear_assert(channel->extrabuf == NULL || dropbear_assert(channel->extrabuf == NULL ||
channel->recvwindow <= cbuf_getavail(channel->extrabuf)); channel->recvwindow <= cbuf_getavail(channel->extrabuf));
@ -710,7 +711,7 @@ void common_recv_msg_channel_data(struct Channel *channel, int fd,
dropbear_assert(channel->recvwindow >= datalen); dropbear_assert(channel->recvwindow >= datalen);
channel->recvwindow -= datalen; channel->recvwindow -= datalen;
dropbear_assert(channel->recvwindow <= RECV_MAX_WINDOW); dropbear_assert(channel->recvwindow <= opts.recv_window);
TRACE(("leave recv_msg_channel_data")) TRACE(("leave recv_msg_channel_data"))
} }
@ -970,7 +971,7 @@ int send_msg_channel_open_init(int fd, const struct ChanType *type) {
buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_OPEN); buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_OPEN);
buf_putstring(ses.writepayload, type->name, strlen(type->name)); buf_putstring(ses.writepayload, type->name, strlen(type->name));
buf_putint(ses.writepayload, chan->index); buf_putint(ses.writepayload, chan->index);
buf_putint(ses.writepayload, RECV_MAX_WINDOW); buf_putint(ses.writepayload, opts.recv_window);
buf_putint(ses.writepayload, RECV_MAX_PAYLOAD_LEN); buf_putint(ses.writepayload, RECV_MAX_PAYLOAD_LEN);
TRACE(("leave send_msg_channel_open_init()")) TRACE(("leave send_msg_channel_open_init()"))

View File

@ -74,6 +74,11 @@ by the ssh server.
.B \-y .B \-y
Always accept hostkeys if they are unknown. If a hostkey mismatch occurs the Always accept hostkeys if they are unknown. If a hostkey mismatch occurs the
connection will abort as normal. connection will abort as normal.
.TP
.B \-W \fIwindowsize
Specify the per-channel receive window buffer size. Increasing this
may improve network performance at the expense of memory use. Use -h to see the
default buffer size.
.SH AUTHOR .SH AUTHOR
Matt Johnston (matt@ucc.asn.au). Matt Johnston (matt@ucc.asn.au).
.br .br

View File

@ -82,6 +82,11 @@ default is /var/run/dropbear.pid
.TP .TP
.B \-a .B \-a
Allow remote hosts to connect to forwarded ports. Allow remote hosts to connect to forwarded ports.
.TP
.B \-W \fIwindowsize
Specify the per-channel receive window buffer size. Increasing this
may improve network performance at the expense of memory use. Use -h to see the
default buffer size.
.SH AUTHOR .SH AUTHOR
Matt Johnston (matt@ucc.asn.au). Matt Johnston (matt@ucc.asn.au).
.br .br

View File

@ -220,8 +220,10 @@ etc) slower (perhaps by 50%). Recommended for most small systems. */
usage and network performance: */ usage and network performance: */
/* Size of the network receive window. This amount of memory is allocated /* Size of the network receive window. This amount of memory is allocated
as a per-channel receive buffer. Increasing this value can make a as a per-channel receive buffer. Increasing this value can make a
significant difference to network performance. */ significant difference to network performance. 24kB was empirically
#define RECV_MAX_WINDOW 8192 chosen for a 100mbit ethernet network. The value can be altered at
runtime with the -W argument. */
#define DEFAULT_RECV_WINDOW 24576
/* Maximum size of a received SSH data packet - this _MUST_ be >= 32768 /* Maximum size of a received SSH data packet - this _MUST_ be >= 32768
in order to interoperate with other implementations */ in order to interoperate with other implementations */
#define RECV_MAX_PAYLOAD_LEN 32768 #define RECV_MAX_PAYLOAD_LEN 32768
@ -339,7 +341,7 @@ etc) slower (perhaps by 50%). Recommended for most small systems. */
#define TRANS_MAX_WINDOW 500000000 /* 500MB is sufficient, stopping overflow */ #define TRANS_MAX_WINDOW 500000000 /* 500MB is sufficient, stopping overflow */
#define TRANS_MAX_WIN_INCR 500000000 /* overflow prevention */ #define TRANS_MAX_WIN_INCR 500000000 /* overflow prevention */
#define RECV_WINDOWEXTEND (RECV_MAX_WINDOW / 3) /* We send a "window extend" every #define RECV_WINDOWEXTEND (opts.recv_window / 3) /* We send a "window extend" every
RECV_WINDOWEXTEND bytes */ RECV_WINDOWEXTEND bytes */
#define MAX_CHANNELS 100 /* simple mem restriction, includes each tcp/x11 #define MAX_CHANNELS 100 /* simple mem restriction, includes each tcp/x11

View File

@ -36,6 +36,7 @@ typedef struct runopts {
#if defined(ENABLE_SVR_REMOTETCPFWD) || defined(ENABLE_CLI_LOCALTCPFWD) #if defined(ENABLE_SVR_REMOTETCPFWD) || defined(ENABLE_CLI_LOCALTCPFWD)
int listen_fwd_all; int listen_fwd_all;
#endif #endif
unsigned int recv_window;
} runopts; } runopts;

View File

@ -80,6 +80,7 @@ static void printhelp(const char * progname) {
#ifdef INETD_MODE #ifdef INETD_MODE
"-i Start for inetd\n" "-i Start for inetd\n"
#endif #endif
"-W <receive_window_buffer> (default %d, larger may be faster)\n"
#ifdef DEBUG_TRACE #ifdef DEBUG_TRACE
"-v verbose\n" "-v verbose\n"
#endif #endif
@ -90,7 +91,7 @@ static void printhelp(const char * progname) {
#ifdef DROPBEAR_RSA #ifdef DROPBEAR_RSA
RSA_PRIV_FILENAME, RSA_PRIV_FILENAME,
#endif #endif
DROPBEAR_MAX_PORTS, DROPBEAR_DEFPORT, DROPBEAR_PIDFILE); DROPBEAR_MAX_PORTS, DROPBEAR_DEFPORT, DROPBEAR_PIDFILE, DEFAULT_RECV_WINDOW);
} }
void svr_getopts(int argc, char ** argv) { void svr_getopts(int argc, char ** argv) {
@ -128,6 +129,8 @@ void svr_getopts(int argc, char ** argv) {
#ifndef DISABLE_SYSLOG #ifndef DISABLE_SYSLOG
svr_opts.usingsyslog = 1; svr_opts.usingsyslog = 1;
#endif #endif
opts.recv_window = DEFAULT_RECV_WINDOW;
char* recv_window_arg = NULL;
#ifdef ENABLE_SVR_REMOTETCPFWD #ifdef ENABLE_SVR_REMOTETCPFWD
opts.listen_fwd_all = 0; opts.listen_fwd_all = 0;
#endif #endif
@ -204,6 +207,9 @@ void svr_getopts(int argc, char ** argv) {
case 'w': case 'w':
svr_opts.norootlogin = 1; svr_opts.norootlogin = 1;
break; break;
case 'W':
next = &recv_window_arg;
break;
#if defined(ENABLE_SVR_PASSWORD_AUTH) || defined(ENABLE_SVR_PAM_AUTH) #if defined(ENABLE_SVR_PASSWORD_AUTH) || defined(ENABLE_SVR_PAM_AUTH)
case 's': case 's':
svr_opts.noauthpass = 1; svr_opts.noauthpass = 1;
@ -265,8 +271,17 @@ void svr_getopts(int argc, char ** argv) {
svr_opts.bannerfile); svr_opts.bannerfile);
} }
buf_setpos(svr_opts.banner, 0); buf_setpos(svr_opts.banner, 0);
}
}
if (recv_window_arg)
{
opts.recv_window = atol(recv_window_arg);
if (opts.recv_window == 0)
{
dropbear_exit("Bad recv window '%s'", recv_window_arg);
}
}
} }
static void addportandaddress(char* spec) { static void addportandaddress(char* spec) {