From 59b7026f487e7e6d642c8e08839c62d653f4a798 Mon Sep 17 00:00:00 2001 From: Markus Friedl Date: Thu, 7 Sep 2000 20:40:31 +0000 Subject: cleanup window and packet sizes for ssh2 flow control; ok niels --- usr.bin/ssh/channels.c | 10 ++-------- usr.bin/ssh/channels.h | 11 ++++++++++- usr.bin/ssh/clientloop.c | 7 +++---- usr.bin/ssh/serverloop.c | 6 ++++-- usr.bin/ssh/ssh.c | 16 +++++++--------- 5 files changed, 26 insertions(+), 24 deletions(-) diff --git a/usr.bin/ssh/channels.c b/usr.bin/ssh/channels.c index c2cb0692a58..e9a64d92f77 100644 --- a/usr.bin/ssh/channels.c +++ b/usr.bin/ssh/channels.c @@ -40,7 +40,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: channels.c,v 1.67 2000/09/07 20:27:50 deraadt Exp $"); +RCSID("$OpenBSD: channels.c,v 1.68 2000/09/07 20:40:29 markus Exp $"); #include "ssh.h" #include "packet.h" @@ -67,12 +67,6 @@ RCSID("$OpenBSD: channels.c,v 1.67 2000/09/07 20:27:50 deraadt Exp $"); /* Max len of agent socket */ #define MAX_SOCKET_NAME 100 -/* default window/packet sizes for tcp/x11-fwd-channel */ -#define CHAN_TCP_WINDOW_DEFAULT (8*1024) -#define CHAN_TCP_PACKET_DEFAULT (CHAN_TCP_WINDOW_DEFAULT/2) -#define CHAN_X11_WINDOW_DEFAULT (4*1024) -#define CHAN_X11_PACKET_DEFAULT (CHAN_X11_WINDOW_DEFAULT/2) - /* * Pointer to an array containing all allocated channels. The array is * dynamically extended as needed. @@ -2305,7 +2299,7 @@ channel_set_fds(int id, int rfd, int wfd, int efd, int extusage) channel_register_fds(c, rfd, wfd, efd, extusage); c->type = SSH_CHANNEL_OPEN; /* XXX window size? */ - c->local_window = c->local_window_max = c->local_maxpacket/2; + c->local_window = c->local_window_max = c->local_maxpacket * 2; packet_start(SSH2_MSG_CHANNEL_WINDOW_ADJUST); packet_put_int(c->remote_id); packet_put_int(c->local_window); diff --git a/usr.bin/ssh/channels.h b/usr.bin/ssh/channels.h index 1cbfb87c24b..f7709c0bdd2 100644 --- a/usr.bin/ssh/channels.h +++ b/usr.bin/ssh/channels.h @@ -21,7 +21,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* RCSID("$OpenBSD: channels.h,v 1.17 2000/09/07 20:27:50 deraadt Exp $"); */ +/* RCSID("$OpenBSD: channels.h,v 1.18 2000/09/07 20:40:29 markus Exp $"); */ #ifndef CHANNELS_H #define CHANNELS_H @@ -97,6 +97,15 @@ struct Channel { #define CHAN_EXTENDED_READ 1 #define CHAN_EXTENDED_WRITE 2 +/* default window/packet sizes for tcp/x11-fwd-channel */ +#define CHAN_SES_WINDOW_DEFAULT (32*1024) +#define CHAN_SES_PACKET_DEFAULT (CHAN_SES_WINDOW_DEFAULT/2) +#define CHAN_TCP_WINDOW_DEFAULT (32*1024) +#define CHAN_TCP_PACKET_DEFAULT (CHAN_TCP_WINDOW_DEFAULT/2) +#define CHAN_X11_WINDOW_DEFAULT (4*1024) +#define CHAN_X11_PACKET_DEFAULT (CHAN_X11_WINDOW_DEFAULT/2) + + void channel_set_fds(int id, int rfd, int wfd, int efd, int extusage); void channel_open(int id); void channel_request(int id, char *service, int wantconfirm); diff --git a/usr.bin/ssh/clientloop.c b/usr.bin/ssh/clientloop.c index 47d351122dd..4f5c39c9273 100644 --- a/usr.bin/ssh/clientloop.c +++ b/usr.bin/ssh/clientloop.c @@ -59,7 +59,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: clientloop.c,v 1.33 2000/09/07 20:27:50 deraadt Exp $"); +RCSID("$OpenBSD: clientloop.c,v 1.34 2000/09/07 20:40:30 markus Exp $"); #include "xmalloc.h" #include "ssh.h" @@ -1053,10 +1053,9 @@ client_input_channel_open(int type, int plen) /* XXX move to channels.c */ sock = x11_connect_display(); if (sock >= 0) { -/*XXX MAXPACK */ id = channel_new("x11", SSH_CHANNEL_X11_OPEN, - sock, sock, -1, 4*1024, 32*1024, 0, - xstrdup("x11")); + sock, sock, -1, CHAN_X11_WINDOW_DEFAULT, + CHAN_X11_PACKET_DEFAULT, 0, xstrdup("x11")); c = channel_lookup(id); } } diff --git a/usr.bin/ssh/serverloop.c b/usr.bin/ssh/serverloop.c index 71f5a4a30bd..ed2886a9783 100644 --- a/usr.bin/ssh/serverloop.c +++ b/usr.bin/ssh/serverloop.c @@ -744,7 +744,8 @@ input_direct_tcpip(void) if (sock < 0) return -1; return channel_new("direct-tcpip", SSH_CHANNEL_OPEN, - sock, sock, -1, 4*1024, 32*1024, 0, xstrdup("direct-tcpip")); + sock, sock, -1, CHAN_TCP_WINDOW_DEFAULT, + CHAN_TCP_PACKET_DEFAULT, 0, xstrdup("direct-tcpip")); } void @@ -777,7 +778,8 @@ server_input_channel_open(int type, int plen) * CHANNEL_REQUEST messages is registered. */ id = channel_new(ctype, SSH_CHANNEL_LARVAL, - -1, -1, -1, 0, 32*1024, 0, xstrdup("server-session")); + -1, -1, -1, 0, CHAN_SES_PACKET_DEFAULT, + 0, xstrdup("server-session")); if (session_open(id) == 1) { channel_register_callback(id, SSH2_MSG_CHANNEL_REQUEST, session_input_channel_req, (void *)0); diff --git a/usr.bin/ssh/ssh.c b/usr.bin/ssh/ssh.c index 07d58330c61..4c4b83632e5 100644 --- a/usr.bin/ssh/ssh.c +++ b/usr.bin/ssh/ssh.c @@ -39,7 +39,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: ssh.c,v 1.64 2000/09/07 20:27:54 deraadt Exp $"); +RCSID("$OpenBSD: ssh.c,v 1.65 2000/09/07 20:40:30 markus Exp $"); #include #include @@ -994,18 +994,16 @@ ssh_session2(void) if (daemon(1, 1) < 0) fatal("daemon() failed: %.200s", strerror(errno)); - window = 32*1024; - if (tty_flag) { - packetmax = window/8; - } else { + window = CHAN_SES_WINDOW_DEFAULT; + packetmax = CHAN_SES_PACKET_DEFAULT; + if (!tty_flag) { window *= 2; - packetmax = window/2; + packetmax *=2; } - -/*XXX MAXPACK */ id = channel_new( "session", SSH_CHANNEL_OPENING, in, out, err, - window, packetmax, CHAN_EXTENDED_WRITE, xstrdup("client-session")); + window, packetmax, CHAN_EXTENDED_WRITE, + xstrdup("client-session")); channel_open(id); channel_register_callback(id, SSH2_MSG_CHANNEL_OPEN_CONFIRMATION, client_init, (void *)0); -- cgit v1.2.3