From eefa817cfdb04ff07e7069396f21bd6ba2c89957 Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Thu, 18 Jul 2019 15:39:47 -0700 Subject: net/tcp/setockopt: impelment setsockopt(fd, SOL_TCP, TCP_INQ) PiperOrigin-RevId: 258859507 --- pkg/tcpip/transport/tcp/endpoint.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'pkg/tcpip/transport/tcp') diff --git a/pkg/tcpip/transport/tcp/endpoint.go b/pkg/tcpip/transport/tcp/endpoint.go index beb90afb5..89154391b 100644 --- a/pkg/tcpip/transport/tcp/endpoint.go +++ b/pkg/tcpip/transport/tcp/endpoint.go @@ -1100,6 +1100,15 @@ func (e *endpoint) readyReceiveSize() (int, *tcpip.Error) { return e.rcvBufUsed, nil } +// GetSockOptInt implements tcpip.Endpoint.GetSockOptInt. +func (e *endpoint) GetSockOptInt(opt tcpip.SockOpt) (int, *tcpip.Error) { + switch opt { + case tcpip.ReceiveQueueSizeOption: + return e.readyReceiveSize() + } + return -1, tcpip.ErrUnknownProtocolOption +} + // GetSockOpt implements tcpip.Endpoint.GetSockOpt. func (e *endpoint) GetSockOpt(opt interface{}) *tcpip.Error { switch o := opt.(type) { @@ -1130,15 +1139,6 @@ func (e *endpoint) GetSockOpt(opt interface{}) *tcpip.Error { e.rcvListMu.Unlock() return nil - case *tcpip.ReceiveQueueSizeOption: - v, err := e.readyReceiveSize() - if err != nil { - return err - } - - *o = tcpip.ReceiveQueueSizeOption(v) - return nil - case *tcpip.DelayOption: *o = 0 if v := atomic.LoadUint32(&e.delay); v != 0 { -- cgit v1.2.3