From a9b5dcd31b12c0e36c58dd9e77fb0c4fd376f5f5 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Thu, 17 Feb 2022 14:52:09 -0800 Subject: [PATCH] Make network test contexts consistent with ipv4 Return by value rather than by pointer. Updates #6910. PiperOrigin-RevId: 429408498 --- pkg/tcpip/network/ip_test.go | 8 ++++---- pkg/tcpip/network/multicast_group_test.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/tcpip/network/ip_test.go b/pkg/tcpip/network/ip_test.go index dcb1a8fdb..85b75401b 100644 --- a/pkg/tcpip/network/ip_test.go +++ b/pkg/tcpip/network/ip_test.go @@ -226,13 +226,13 @@ type testContext struct { s *stack.Stack } -func newTestContext() *testContext { +func newTestContext() testContext { s := stack.New(stack.Options{ NetworkProtocols: []stack.NetworkProtocolFactory{ipv4.NewProtocol, ipv6.NewProtocol}, TransportProtocols: []stack.TransportProtocolFactory{udp.NewProtocol, tcp.NewProtocol}, RawFactory: raw.EndpointFactory{}, }) - return &testContext{s: s} + return testContext{s: s} } func (ctx *testContext) cleanup() { @@ -240,7 +240,7 @@ func (ctx *testContext) cleanup() { ctx.s.Wait() } -func buildIPv4Route(ctx *testContext, local, remote tcpip.Address) (*stack.Route, tcpip.Error) { +func buildIPv4Route(ctx testContext, local, remote tcpip.Address) (*stack.Route, tcpip.Error) { s := ctx.s s.CreateNIC(nicID, loopback.New()) protocolAddr := tcpip.ProtocolAddress{ @@ -259,7 +259,7 @@ func buildIPv4Route(ctx *testContext, local, remote tcpip.Address) (*stack.Route return s.FindRoute(nicID, local, remote, ipv4.ProtocolNumber, false /* multicastLoop */) } -func buildIPv6Route(ctx *testContext, local, remote tcpip.Address) (*stack.Route, tcpip.Error) { +func buildIPv6Route(ctx testContext, local, remote tcpip.Address) (*stack.Route, tcpip.Error) { s := ctx.s s.CreateNIC(nicID, loopback.New()) protocolAddr := tcpip.ProtocolAddress{ diff --git a/pkg/tcpip/network/multicast_group_test.go b/pkg/tcpip/network/multicast_group_test.go index a9e7d8da9..a69a53dec 100644 --- a/pkg/tcpip/network/multicast_group_test.go +++ b/pkg/tcpip/network/multicast_group_test.go @@ -124,12 +124,12 @@ type multicastTestContext struct { clock *faketime.ManualClock } -func newMulticastTestContext(t *testing.T, v4, mgpEnabled bool) *multicastTestContext { +func newMulticastTestContext(t *testing.T, v4, mgpEnabled bool) multicastTestContext { t.Helper() e := channel.New(maxUnsolicitedReports, header.IPv6MinimumMTU, linkAddr) s, clock := createStackWithLinkEndpoint(t, v4, mgpEnabled, e) - return &multicastTestContext{ + return multicastTestContext{ s: s, e: e, clock: clock,