From ec0aa657edfd98a1e8dfbbf017ee6cf8c7f1a40e Mon Sep 17 00:00:00 2001 From: Nick Brown Date: Wed, 24 Mar 2021 09:36:50 -0700 Subject: Unexpose immutable fields in stack.Route This change sets the inner `routeInfo` struct to be a named private member and replaces direct access with access through getters. Note that direct access to the fields of `routeInfo` is still possible through the `RouteInfo` struct. Fixes #4902 PiperOrigin-RevId: 364822872 --- pkg/tcpip/transport/tcp/connect.go | 2 +- pkg/tcpip/transport/tcp/endpoint.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'pkg/tcpip/transport/tcp') diff --git a/pkg/tcpip/transport/tcp/connect.go b/pkg/tcpip/transport/tcp/connect.go index 3404af6bb..b32fe2fb1 100644 --- a/pkg/tcpip/transport/tcp/connect.go +++ b/pkg/tcpip/transport/tcp/connect.go @@ -811,7 +811,7 @@ func sendTCP(r *stack.Route, tf tcpFields, data buffer.VectorisedView, gso *stac tf.rcvWnd = math.MaxUint16 } - if r.Loop&stack.PacketLoop == 0 && gso != nil && gso.Type == stack.GSOSW && int(gso.MSS) < data.Size() { + if r.Loop()&stack.PacketLoop == 0 && gso != nil && gso.Type == stack.GSOSW && int(gso.MSS) < data.Size() { return sendTCPBatch(r, tf, data, gso, owner) } diff --git a/pkg/tcpip/transport/tcp/endpoint.go b/pkg/tcpip/transport/tcp/endpoint.go index 43d344350..0a5e9cbb4 100644 --- a/pkg/tcpip/transport/tcp/endpoint.go +++ b/pkg/tcpip/transport/tcp/endpoint.go @@ -2211,8 +2211,8 @@ func (e *endpoint) connect(addr tcpip.FullAddress, handshake bool, run bool) tcp defer r.Release() netProtos := []tcpip.NetworkProtocolNumber{netProto} - e.ID.LocalAddress = r.LocalAddress - e.ID.RemoteAddress = r.RemoteAddress + e.ID.LocalAddress = r.LocalAddress() + e.ID.RemoteAddress = r.RemoteAddress() e.ID.RemotePort = addr.Port if e.ID.LocalPort != 0 { @@ -3102,7 +3102,7 @@ func (e *endpoint) completeState() stack.TCPEndpointState { func (e *endpoint) initHardwareGSO() { gso := &stack.GSO{} - switch e.route.NetProto { + switch e.route.NetProto() { case header.IPv4ProtocolNumber: gso.Type = stack.GSOTCPv4 gso.L3HdrLen = header.IPv4MinimumSize -- cgit v1.2.3