Commit aff268a3 authored by Jakob Borg's avatar Jakob Borg

go.crypto/ssh: Increase window size.

Increase window size for channels (session and tcpip) to 64 *
max packet size (32 KB), which is the same value that OpenSSH
uses. Also breaks out the relevant harcoded constants into named
constants in channel.go.

Fixes issue 6675.

R=golang-dev, dave, hanwen, agl
CC=golang-dev
https://codereview.appspot.com/18120043

Committer: Dave Cheney <dave@cheney.net>
parent 9f1a9b73
......@@ -22,6 +22,12 @@ const (
// minPacketLength defines the smallest valid packet
minPacketLength = 9
// channelMaxPacketSize defines the maximum packet size advertised in open messages
channelMaxPacketSize = 1 << 15 // RFC 4253 6.1, minimum 32 KiB
// channelWindowSize defines the window size advertised in open messages
channelWindowSize = 64 * channelMaxPacketSize // Like OpenSSH
)
// A Channel is an ordered, reliable, duplex stream that is multiplexed over an
......
......@@ -356,12 +356,10 @@ func (c *ClientConn) handleChanOpen(msg *channelOpenMsg) {
ch.maxPacket = msg.MaxPacketSize
m := channelOpenConfirmMsg{
PeersId: ch.remoteId,
MyId: ch.localId,
MyWindow: 1 << 14,
// As per RFC 4253 6.1, 32k is also the minimum.
MaxPacketSize: 1 << 15,
PeersId: ch.remoteId,
MyId: ch.localId,
MyWindow: channelWindowSize,
MaxPacketSize: channelMaxPacketSize,
}
c.transport.writePacket(marshal(msgChannelOpenConfirm, m))
......
......@@ -567,8 +567,8 @@ func (c *ClientConn) NewSession() (*Session, error) {
if err := c.transport.writePacket(marshal(msgChannelOpen, channelOpenMsg{
ChanType: "session",
PeersId: ch.localId,
PeersWindow: 1 << 14,
MaxPacketSize: 1 << 15, // RFC 4253 6.1
PeersWindow: channelWindowSize,
MaxPacketSize: channelMaxPacketSize,
})); err != nil {
c.chanList.remove(ch.localId)
return nil, err
......
......@@ -299,8 +299,8 @@ func (c *ClientConn) dial(laddr string, lport int, raddr string, rport int) (*tc
if err := c.transport.writePacket(marshal(msgChannelOpen, channelOpenDirectMsg{
ChanType: "direct-tcpip",
PeersId: ch.localId,
PeersWindow: 1 << 14,
MaxPacketSize: 1 << 15, // RFC 4253 6.1
PeersWindow: channelWindowSize,
MaxPacketSize: channelMaxPacketSize,
raddr: raddr,
rport: uint32(rport),
laddr: laddr,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment