Merge release-20190806.1-327-g8f029b3 (automated)
This commit is contained in:
commit
e0b0ba4247
|
@ -281,7 +281,7 @@ type SocketOperations struct {
|
||||||
// New creates a new endpoint socket.
|
// New creates a new endpoint socket.
|
||||||
func New(t *kernel.Task, family int, skType linux.SockType, protocol int, queue *waiter.Queue, endpoint tcpip.Endpoint) (*fs.File, *syserr.Error) {
|
func New(t *kernel.Task, family int, skType linux.SockType, protocol int, queue *waiter.Queue, endpoint tcpip.Endpoint) (*fs.File, *syserr.Error) {
|
||||||
if skType == linux.SOCK_STREAM {
|
if skType == linux.SOCK_STREAM {
|
||||||
if err := endpoint.SetSockOpt(tcpip.DelayOption(1)); err != nil {
|
if err := endpoint.SetSockOptInt(tcpip.DelayOption, 1); err != nil {
|
||||||
return nil, syserr.TranslateNetstackError(err)
|
return nil, syserr.TranslateNetstackError(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1055,8 +1055,8 @@ func getSockOptTCP(t *kernel.Task, ep commonEndpoint, name, outLen int) (interfa
|
||||||
return nil, syserr.ErrInvalidArgument
|
return nil, syserr.ErrInvalidArgument
|
||||||
}
|
}
|
||||||
|
|
||||||
var v tcpip.DelayOption
|
v, err := ep.GetSockOptInt(tcpip.DelayOption)
|
||||||
if err := ep.GetSockOpt(&v); err != nil {
|
if err != nil {
|
||||||
return nil, syserr.TranslateNetstackError(err)
|
return nil, syserr.TranslateNetstackError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1497,11 +1497,11 @@ func setSockOptTCP(t *kernel.Task, ep commonEndpoint, name int, optVal []byte) *
|
||||||
}
|
}
|
||||||
|
|
||||||
v := usermem.ByteOrder.Uint32(optVal)
|
v := usermem.ByteOrder.Uint32(optVal)
|
||||||
var o tcpip.DelayOption
|
var o int
|
||||||
if v == 0 {
|
if v == 0 {
|
||||||
o = 1
|
o = 1
|
||||||
}
|
}
|
||||||
return syserr.TranslateNetstackError(ep.SetSockOpt(o))
|
return syserr.TranslateNetstackError(ep.SetSockOptInt(tcpip.DelayOption, o))
|
||||||
|
|
||||||
case linux.TCP_CORK:
|
case linux.TCP_CORK:
|
||||||
if len(optVal) < sizeOfInt32 {
|
if len(optVal) < sizeOfInt32 {
|
||||||
|
|
|
@ -489,6 +489,11 @@ const (
|
||||||
// number of unread bytes in the output buffer should be returned.
|
// number of unread bytes in the output buffer should be returned.
|
||||||
SendQueueSizeOption
|
SendQueueSizeOption
|
||||||
|
|
||||||
|
// DelayOption is used by SetSockOpt/GetSockOpt to specify if data
|
||||||
|
// should be sent out immediately by the transport protocol. For TCP,
|
||||||
|
// it determines if the Nagle algorithm is on or off.
|
||||||
|
DelayOption
|
||||||
|
|
||||||
// TODO(b/137664753): convert all int socket options to be handled via
|
// TODO(b/137664753): convert all int socket options to be handled via
|
||||||
// GetSockOptInt.
|
// GetSockOptInt.
|
||||||
)
|
)
|
||||||
|
@ -501,11 +506,6 @@ type ErrorOption struct{}
|
||||||
// socket is to be restricted to sending and receiving IPv6 packets only.
|
// socket is to be restricted to sending and receiving IPv6 packets only.
|
||||||
type V6OnlyOption int
|
type V6OnlyOption int
|
||||||
|
|
||||||
// DelayOption is used by SetSockOpt/GetSockOpt to specify if data should be
|
|
||||||
// sent out immediately by the transport protocol. For TCP, it determines if the
|
|
||||||
// Nagle algorithm is on or off.
|
|
||||||
type DelayOption int
|
|
||||||
|
|
||||||
// CorkOption is used by SetSockOpt/GetSockOpt to specify if data should be
|
// CorkOption is used by SetSockOpt/GetSockOpt to specify if data should be
|
||||||
// held until segments are full by the TCP transport protocol.
|
// held until segments are full by the TCP transport protocol.
|
||||||
type CorkOption int
|
type CorkOption int
|
||||||
|
|
|
@ -1133,16 +1133,6 @@ func (e *endpoint) SetSockOptInt(opt tcpip.SockOpt, v int) *tcpip.Error {
|
||||||
e.sndBufMu.Unlock()
|
e.sndBufMu.Unlock()
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetSockOpt sets a socket option.
|
|
||||||
func (e *endpoint) SetSockOpt(opt interface{}) *tcpip.Error {
|
|
||||||
// Lower 2 bits represents ECN bits. RFC 3168, section 23.1
|
|
||||||
const inetECNMask = 3
|
|
||||||
switch v := opt.(type) {
|
|
||||||
case tcpip.DelayOption:
|
case tcpip.DelayOption:
|
||||||
if v == 0 {
|
if v == 0 {
|
||||||
atomic.StoreUint32(&e.delay, 0)
|
atomic.StoreUint32(&e.delay, 0)
|
||||||
|
@ -1154,6 +1144,16 @@ func (e *endpoint) SetSockOpt(opt interface{}) *tcpip.Error {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSockOpt sets a socket option.
|
||||||
|
func (e *endpoint) SetSockOpt(opt interface{}) *tcpip.Error {
|
||||||
|
// Lower 2 bits represents ECN bits. RFC 3168, section 23.1
|
||||||
|
const inetECNMask = 3
|
||||||
|
switch v := opt.(type) {
|
||||||
case tcpip.CorkOption:
|
case tcpip.CorkOption:
|
||||||
if v == 0 {
|
if v == 0 {
|
||||||
atomic.StoreUint32(&e.cork, 0)
|
atomic.StoreUint32(&e.cork, 0)
|
||||||
|
@ -1345,6 +1345,7 @@ func (e *endpoint) GetSockOptInt(opt tcpip.SockOpt) (int, *tcpip.Error) {
|
||||||
switch opt {
|
switch opt {
|
||||||
case tcpip.ReceiveQueueSizeOption:
|
case tcpip.ReceiveQueueSizeOption:
|
||||||
return e.readyReceiveSize()
|
return e.readyReceiveSize()
|
||||||
|
|
||||||
case tcpip.SendBufferSizeOption:
|
case tcpip.SendBufferSizeOption:
|
||||||
e.sndBufMu.Lock()
|
e.sndBufMu.Lock()
|
||||||
v := e.sndBufSize
|
v := e.sndBufSize
|
||||||
|
@ -1357,8 +1358,16 @@ func (e *endpoint) GetSockOptInt(opt tcpip.SockOpt) (int, *tcpip.Error) {
|
||||||
e.rcvListMu.Unlock()
|
e.rcvListMu.Unlock()
|
||||||
return v, nil
|
return v, nil
|
||||||
|
|
||||||
|
case tcpip.DelayOption:
|
||||||
|
var o int
|
||||||
|
if v := atomic.LoadUint32(&e.delay); v != 0 {
|
||||||
|
o = 1
|
||||||
|
}
|
||||||
|
return o, nil
|
||||||
|
|
||||||
|
default:
|
||||||
|
return -1, tcpip.ErrUnknownProtocolOption
|
||||||
}
|
}
|
||||||
return -1, tcpip.ErrUnknownProtocolOption
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSockOpt implements tcpip.Endpoint.GetSockOpt.
|
// GetSockOpt implements tcpip.Endpoint.GetSockOpt.
|
||||||
|
@ -1379,13 +1388,6 @@ func (e *endpoint) GetSockOpt(opt interface{}) *tcpip.Error {
|
||||||
*o = header.TCPDefaultMSS
|
*o = header.TCPDefaultMSS
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
case *tcpip.DelayOption:
|
|
||||||
*o = 0
|
|
||||||
if v := atomic.LoadUint32(&e.delay); v != 0 {
|
|
||||||
*o = 1
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
|
|
||||||
case *tcpip.CorkOption:
|
case *tcpip.CorkOption:
|
||||||
*o = 0
|
*o = 0
|
||||||
if v := atomic.LoadUint32(&e.cork); v != 0 {
|
if v := atomic.LoadUint32(&e.cork); v != 0 {
|
||||||
|
|
Loading…
Reference in New Issue