summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorIan Gudger <igudger@google.com>2018-12-13 13:01:56 -0800
committerShentubot <shentubot@google.com>2018-12-13 13:02:49 -0800
commit6253d32cc932e76608be5c57a4870b3d61464487 (patch)
tree5d3ad6e99cf83e42f13a19db9ab4e37e32657413 /pkg
parentf484b6d4c2f1dea6169ed50a5d3d1809e8f007be (diff)
transport/tcp: remove unused error return values
PiperOrigin-RevId: 225421480 Change-Id: I1e9259b0b7e8490164e830b73338a615129c7f0e
Diffstat (limited to 'pkg')
-rw-r--r--pkg/tcpip/transport/tcp/accept.go6
-rw-r--r--pkg/tcpip/transport/tcp/connect.go24
2 files changed, 8 insertions, 22 deletions
diff --git a/pkg/tcpip/transport/tcp/accept.go b/pkg/tcpip/transport/tcp/accept.go
index 5a88d25d0..32f65367c 100644
--- a/pkg/tcpip/transport/tcp/accept.go
+++ b/pkg/tcpip/transport/tcp/accept.go
@@ -245,11 +245,7 @@ func (l *listenContext) createEndpointAndPerformHandshake(s *segment, opts *head
}
// Perform the 3-way handshake.
- h, err := newHandshake(ep, l.rcvWnd)
- if err != nil {
- ep.Close()
- return nil, err
- }
+ h := newHandshake(ep, l.rcvWnd)
h.resetToSynRcvd(cookie, irs, opts)
if err := h.execute(); err != nil {
diff --git a/pkg/tcpip/transport/tcp/connect.go b/pkg/tcpip/transport/tcp/connect.go
index 0e6bb6763..cc34e74b2 100644
--- a/pkg/tcpip/transport/tcp/connect.go
+++ b/pkg/tcpip/transport/tcp/connect.go
@@ -86,18 +86,15 @@ type handshake struct {
rcvWndScale int
}
-func newHandshake(ep *endpoint, rcvWnd seqnum.Size) (handshake, *tcpip.Error) {
+func newHandshake(ep *endpoint, rcvWnd seqnum.Size) handshake {
h := handshake{
ep: ep,
active: true,
rcvWnd: rcvWnd,
rcvWndScale: FindWndScale(rcvWnd),
}
- if err := h.resetState(); err != nil {
- return handshake{}, err
- }
-
- return h, nil
+ h.resetState()
+ return h
}
// FindWndScale determines the window scale to use for the given maximum window
@@ -119,7 +116,7 @@ func FindWndScale(wnd seqnum.Size) int {
// resetState resets the state of the handshake object such that it becomes
// ready for a new 3-way handshake.
-func (h *handshake) resetState() *tcpip.Error {
+func (h *handshake) resetState() {
b := make([]byte, 4)
if _, err := rand.Read(b); err != nil {
panic(err)
@@ -130,8 +127,6 @@ func (h *handshake) resetState() *tcpip.Error {
h.ackNum = 0
h.mss = 0
h.iss = seqnum.Value(uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24)
-
- return nil
}
// effectiveRcvWndScale returns the effective receive window scale to be used.
@@ -269,9 +264,7 @@ func (h *handshake) synRcvdState(s *segment) *tcpip.Error {
return tcpip.ErrInvalidEndpointState
}
- if err := h.resetState(); err != nil {
- return err
- }
+ h.resetState()
synOpts := header.TCPSynOptions{
WS: h.rcvWndScale,
TS: h.ep.sendTSOk,
@@ -868,11 +861,8 @@ func (e *endpoint) protocolMainLoop(handshake bool) *tcpip.Error {
// This is an active connection, so we must initiate the 3-way
// handshake, and then inform potential waiters about its
// completion.
- h, err := newHandshake(e, seqnum.Size(e.receiveBufferAvailable()))
- if err == nil {
- err = h.execute()
- }
- if err != nil {
+ h := newHandshake(e, seqnum.Size(e.receiveBufferAvailable()))
+ if err := h.execute(); err != nil {
e.lastErrorMu.Lock()
e.lastError = err
e.lastErrorMu.Unlock()