From 4524790ff668674149ad6ae6eec805369be0c6e3 Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Thu, 18 Apr 2019 11:40:34 -0700 Subject: netstack: use a proper network protocol to set gso.L3HdrLen It is possible to create a listening socket which will accept IPv4 and IPv6 connections. In this case, we set IPv6ProtocolNumber for all accepted endpoints, even if they handle IPv4 connections. This means that we can't use endpoint.netProto to set gso.L3HdrLen. PiperOrigin-RevId: 244227948 Change-Id: I5e1863596cb9f3d216febacdb7dc75651882eef1 --- pkg/tcpip/transport/tcp/testing/context/context.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'pkg/tcpip/transport/tcp/testing') diff --git a/pkg/tcpip/transport/tcp/testing/context/context.go b/pkg/tcpip/transport/tcp/testing/context/context.go index 8ac411b1d..6e2fed880 100644 --- a/pkg/tcpip/transport/tcp/testing/context/context.go +++ b/pkg/tcpip/transport/tcp/testing/context/context.go @@ -234,6 +234,10 @@ func (c *Context) GetPacket() []byte { copy(b, p.Header) copy(b[len(p.Header):], p.Payload) + if p.GSO != nil && p.GSO.L3HdrLen != header.IPv4MinimumSize { + c.t.Errorf("L3HdrLen %v (expected %v)", p.GSO.L3HdrLen, header.IPv4MinimumSize) + } + checker.IPv4(c.t, b, checker.SrcAddr(StackAddr), checker.DstAddr(TestAddr)) return b @@ -956,3 +960,8 @@ func (c *Context) SACKEnabled() bool { } return bool(v) } + +// SetGSOEnabled enables or disables generic segmentation offload. +func (c *Context) SetGSOEnabled(enable bool) { + c.linkEP.GSO = enable +} -- cgit v1.2.3