1 diff -r -u -p1 openssh-4.3p1/buffer.c patch/buffer.c
2 --- openssh-4.3p1/buffer.c 2005-03-14 07:22:26.000000000 -0500
3 +++ patch/buffer.c 2006-02-01 10:26:10.000000000 -0500
4 @@ -109,3 +109,3 @@ restart:
5 newlen = buffer->alloc + len + 32768;
6 - if (newlen > BUFFER_MAX_LEN)
7 + if (newlen > BUFFER_MAX_HPN_LEN)
8 fatal("buffer_append_space: alloc %u not supported",
9 diff -r -u -p1 openssh-4.3p1/buffer.h patch/buffer.h
10 --- openssh-4.3p1/buffer.h 2005-03-14 07:22:26.000000000 -0500
11 +++ patch/buffer.h 2006-02-01 10:26:10.000000000 -0500
12 @@ -27,2 +27,3 @@ typedef struct {
13 #define BUFFER_MAX_LEN 0xa00000
14 +#define BUFFER_MAX_HPN_LEN (2<<29)-1
16 diff -r -u -p1 openssh-4.3p1/channels.c patch/channels.c
17 --- openssh-4.3p1/channels.c 2006-01-31 05:47:15.000000000 -0500
18 +++ patch/channels.c 2006-02-01 10:26:10.000000000 -0500
19 @@ -290,2 +290,3 @@ channel_new(char *ctype, int type, int r
20 c->local_maxpacket = maxpack;
21 + c->dynamic_window = 0;
23 @@ -750,5 +751,5 @@ channel_pre_open(Channel *c, fd_set * re
24 u_int limit = compat20 ? c->remote_window : packet_get_maxsize();
27 /* check buffer limits */
28 - limit = MIN(limit, (BUFFER_MAX_LEN - BUFFER_MAX_CHUNK - CHAN_RBUF));
29 + limit = MIN(limit, (BUFFER_MAX_HPN_LEN - BUFFER_MAX_CHUNK - CHAN_RBUF));
31 @@ -1617,5 +1618,20 @@ channel_check_window(Channel *c)
32 c->local_consumed > 0) {
33 + u_int32_t tcpwinsz = 0;
34 + socklen_t optsz = sizeof(tcpwinsz);
36 + u_int32_t addition = 0;
37 + if (c->dynamic_window) {
38 + ret = getsockopt(packet_get_connection_in(),
39 + SOL_SOCKET, SO_RCVBUF, &tcpwinsz, &optsz);
40 + if ((ret == 0) && tcpwinsz > BUFFER_MAX_HPN_LEN)
41 + tcpwinsz = BUFFER_MAX_HPN_LEN;
43 + if (c->dynamic_window && (ret == 0) &&
44 + (tcpwinsz > c->local_window_max)) {
45 + addition = tcpwinsz - c->local_window_max;
46 + c->local_window_max += addition;
48 packet_start(SSH2_MSG_CHANNEL_WINDOW_ADJUST);
49 packet_put_int(c->remote_id);
50 - packet_put_int(c->local_consumed);
51 + packet_put_int(c->local_consumed + addition);
53 @@ -1624,3 +1640,3 @@ channel_check_window(Channel *c)
55 - c->local_window += c->local_consumed;
56 + c->local_window += c->local_consumed + addition;
57 c->local_consumed = 0;
58 diff -r -u -p1 openssh-4.3p1/channels.h patch/channels.h
59 --- openssh-4.3p1/channels.h 2005-12-31 00:22:32.000000000 -0500
60 +++ patch/channels.h 2006-02-01 10:26:10.000000000 -0500
61 @@ -102,2 +102,3 @@ struct Channel {
62 u_int local_maxpacket;
65 @@ -126,7 +127,7 @@ struct Channel {
66 #define CHAN_SES_PACKET_DEFAULT (32*1024)
67 -#define CHAN_SES_WINDOW_DEFAULT (4*CHAN_SES_PACKET_DEFAULT)
68 +#define CHAN_SES_WINDOW_DEFAULT (0xa00000/2)
69 #define CHAN_TCP_PACKET_DEFAULT (32*1024)
70 -#define CHAN_TCP_WINDOW_DEFAULT (4*CHAN_TCP_PACKET_DEFAULT)
71 +#define CHAN_TCP_WINDOW_DEFAULT (0xa00000/2)
72 #define CHAN_X11_PACKET_DEFAULT (16*1024)
73 -#define CHAN_X11_WINDOW_DEFAULT (4*CHAN_X11_PACKET_DEFAULT)
74 +#define CHAN_X11_WINDOW_DEFAULT (0xa00000/2)
76 diff -r -u -p1 openssh-4.3p1/compat.c patch/compat.c
77 --- openssh-4.3p1/compat.c 2005-03-01 05:24:33.000000000 -0500
78 +++ patch/compat.c 2006-02-01 10:26:10.000000000 -0500
79 @@ -164,2 +164,10 @@ compat_datafellows(const char *version)
80 datafellows = check[i].bugs;
81 + /* Check to see if the remote side is OpenSSH and not HPN */
82 + if(strstr(version,"OpenSSH") != NULL)
84 + if (strstr(version,"hpn") == NULL)
86 + datafellows |= SSH_BUG_LARGEWINDOW;
90 diff -r -u -p1 openssh-4.3p1/compat.h patch/compat.h
91 --- openssh-4.3p1/compat.h 2005-03-01 05:24:33.000000000 -0500
92 +++ patch/compat.h 2006-02-01 10:26:10.000000000 -0500
94 #define SSH_OLD_FORWARD_ADDR 0x01000000
95 +#define SSH_BUG_LARGEWINDOW 0x02000000
97 diff -r -u -p1 openssh-4.3p1/readconf.h patch/readconf.h
98 --- openssh-4.3p1/readconf.h 2005-12-13 03:29:02.000000000 -0500
99 +++ patch/readconf.h 2006-02-01 10:26:11.000000000 -0500
100 @@ -59,2 +59,3 @@ typedef struct {
101 int tcp_keep_alive; /* Set SO_KEEPALIVE. */
102 + int tcp_rcv_buf; /* user switch to set tcp recv buffer */
103 LogLevel log_level; /* Level for logging. */
104 diff -r -u -p1 openssh-4.3p1/scp.c patch/scp.c
105 --- openssh-4.3p1/scp.c 2006-01-31 06:11:38.000000000 -0500
106 +++ patch/scp.c 2006-02-01 07:04:50.000000000 -0500
107 @@ -280,3 +280,3 @@ main(int argc, char **argv)
109 - while ((ch = getopt(argc, argv, "dfl:prtvBCc:i:P:q1246S:o:F:")) != -1)
110 + while ((ch = getopt(argc, argv, "dfl:pR:rtvBCc:i:P:q1246S:o:F:w:")) != -1)
112 @@ -341,2 +341,5 @@ main(int argc, char **argv)
115 + addargs(&args, "-r%s", optarg);
118 @@ -555,3 +558,3 @@ source(int argc, char **argv)
119 int fd = -1, haderr, indx;
120 - char *last, *name, buf[2048];
121 + char *last, *name, buf[16384];
123 @@ -782,3 +785,3 @@ sink(int argc, char **argv)
124 int setimes, targisdir, wrerrno = 0;
125 - char ch, *cp, *np, *targ, *why, *vect[1], buf[2048];
126 + char ch, *cp, *np, *targ, *why, *vect[1], buf[16384];
127 struct timeval tv[2];
128 @@ -943,3 +946,3 @@ bad: run_err("%s: %s", np, strerror(er
129 (void) atomicio(vwrite, remout, "", 1);
130 - if ((bp = allocbuf(&buffer, ofd, 4096)) == NULL) {
131 + if ((bp = allocbuf(&buffer, ofd, sizeof(buf))) == NULL) {
133 @@ -953,4 +956,4 @@ bad: run_err("%s: %s", np, strerror(er
134 start_progress_meter(curfile, size, &statbytes);
135 - for (count = i = 0; i < size; i += 4096) {
137 + for (count = i = 0; i < size; i += sizeof(buf)) {
140 @@ -971,3 +974,3 @@ bad: run_err("%s: %s", np, strerror(er
143 + bwlimit(sizeof(buf));
145 @@ -1086,4 +1089,4 @@ usage(void)
146 (void) fprintf(stderr,
147 - "usage: scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]\n"
148 - " [-l limit] [-o ssh_option] [-P port] [-S program]\n"
149 + "usage: scp [-1246BCpqrRv] [-c cipher] [-F ssh_config] [-i identity_file]\n"
150 + " [-l limit] [-o ssh_option] [-P port] [-R buffer size] [-S program]\n"
151 " [[user@]host1:]file1 [...] [[user@]host2:]file2\n");
152 diff -r -u -p1 openssh-4.3p1/serverloop.c patch/serverloop.c
153 --- openssh-4.3p1/serverloop.c 2005-12-31 00:33:37.000000000 -0500
154 +++ patch/serverloop.c 2006-02-01 10:26:11.000000000 -0500
155 @@ -977,2 +977,4 @@ server_request_session(void)
156 0, "server-session", 1);
157 + if (!(datafellows & SSH_BUG_LARGEWINDOW))
158 + c->dynamic_window = 1;
159 if (session_open(the_authctxt, c->self) != 1) {
160 diff -r -u -p1 openssh-4.3p1/ssh.c patch/ssh.c
161 --- openssh-4.3p1/ssh.c 2005-12-31 00:33:37.000000000 -0500
162 +++ patch/ssh.c 2006-02-01 07:02:41.000000000 -0500
167 -"usage: ssh [-1246AaBCfgkMNnqsTtVvXxY] [-b bind_address] [-c cipher_spec]\n"
168 +"usage: ssh [-1246AaBCfgkMNnqRrsTtVvXxY] [-b bind_address] [-c cipher_spec]\n"
169 " [-D [bind_address:]port] [-e escape_char] [-F configfile]\n"
170 " [-i identity_file] [-L [bind_address:]port:host:hostport]\n"
171 " [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]\n"
172 @@ -165,2 +165,3 @@ usage(void)
173 " [-w tunnel:tunnel] [user@]hostname [command]\n"
174 +" [-r receive buffer size]\n"
177 /* Parse command-line arguments. */
180 + /* need to set options.tcp_rcv_buf to 0 */
181 + options.tcp_rcv_buf = 0;
184 while ((opt = getopt(ac, av,
185 - "1246ab:c:e:fgi:kl:m:no:p:qstvxABCD:F:I:L:MNO:PR:S:TVw:XY")) != -1) {
186 + "1246ab:c:e:fgi:kl:m:no:p:qr:stvxABCD:F:I:L:MNO:PR:S:TVw:XY")) != -1) {
189 options.protocol = SSH_PROTO_1;
190 @@ -497,2 +501,5 @@ again:
193 + options.tcp_rcv_buf = atoi(optarg) * 1024;
196 @@ -1132,2 +1139,3 @@ ssh_session2_open(void)
198 + window = 4*CHAN_SES_PACKET_DEFAULT;
200 @@ -1139,3 +1147,5 @@ ssh_session2_open(void)
201 "client-session", /*nonblock*/0);
203 + if (!tty_flag && (!(datafellows & SSH_BUG_LARGEWINDOW))) {
204 + c->dynamic_window = 1;
206 debug3("ssh_session2_open: channel_new: %d", c->self);
207 Only in patch: ssh.c.rej
208 diff -r -u -p1 openssh-4.3p1/sshconnect.c patch/sshconnect.c
209 --- openssh-4.3p1/sshconnect.c 2005-12-13 03:29:03.000000000 -0500
210 +++ patch/sshconnect.c 2006-02-01 10:26:11.000000000 -0500
211 @@ -168,2 +168,25 @@ ssh_create_socket(int privileged, struct
212 debug("Allocated local port %d.", p);
215 + /* tuning needs to happen after the socket is */
216 + /* created but before the connection happens */
217 + /* so winscale is negotiated properly -cjr */
219 + /* Set tcp receive buffer if requested */
220 + if (options.tcp_rcv_buf)
222 + if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
223 + (void *)&options.tcp_rcv_buf,
224 + sizeof(options.tcp_rcv_buf)) >= 0)
226 + debug("setsockopt SO_RCVBUF: %.100s", strerror(errno));
230 + /* coudln't set the socket size to use spec. */
231 + /* should default to system param and continue */
232 + /* warn the user though - cjr */
233 + error("Couldn't set socket receive buffer as requested. Continuing anyway.");
237 @@ -173,4 +196,26 @@ ssh_create_socket(int privileged, struct
238 error("socket: %.100s", strerror(errno));
240 - /* Bind the socket to an alternative local IP address */
242 + /* tuning needs to happen after the socket is */
243 + /* created but before the connection happens */
244 + /* so winscale is negotiated properly -cjr */
246 + /* Set tcp receive buffer if requested */
247 + if (options.tcp_rcv_buf)
249 + if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
250 + (void *)&options.tcp_rcv_buf,
251 + sizeof(options.tcp_rcv_buf)) >= 0)
253 + debug("setsockopt SO_RCVBUF: %.100s", strerror(errno));
257 + /* coudln't set the socket size to use spec. */
258 + /* should default to system param and continue */
259 + /* warn the user though - cjr */
260 + error("Couldn't set socket receive buffer as requested. Continuing anyway.");
264 + /* Bind the socket to an alternative local IP address */
265 if (options.bind_address == NULL)
266 @@ -481,3 +526,3 @@ ssh_exchange_identification(void)
267 compat20 ? PROTOCOL_MINOR_2 : minor1,
270 if (atomicio(vwrite, connection_out, buf, strlen(buf)) != strlen(buf))
271 diff -r -u -p1 openssh-4.3p1/sshd.c patch/sshd.c
272 --- openssh-4.3p1/sshd.c 2005-12-23 22:59:12.000000000 -0500
273 +++ patch/sshd.c 2006-02-01 10:26:11.000000000 -0500
274 @@ -379,3 +379,3 @@ sshd_exchange_identification(int sock_in
276 - snprintf(buf, sizeof buf, "SSH-%d.%d-%.100s\n", major, minor, SSH_VERSION);
277 + snprintf(buf, sizeof buf, "SSH-%d.%d-%.100s\n", major, minor, SSH_RELEASE);
278 server_version_string = xstrdup(buf);
279 diff -r -u -p1 openssh-4.3p1/version.h patch/version.h
280 --- openssh-4.3p1/version.h 2006-02-01 06:27:31.000000000 -0500
281 +++ patch/version.h 2006-02-01 10:26:11.000000000 -0500
283 #define SSH_PORTABLE "p1"
284 -#define SSH_RELEASE SSH_VERSION SSH_PORTABLE
285 +#define SSH_HPN "-hpn"
286 +#define SSH_RELEASE SSH_VERSION SSH_PORTABLE SSH_HPN