Make network test contexts consistent with ipv4

Return by value rather than by pointer.

Updates #6910.

PiperOrigin-RevId: 429408498
This commit is contained in:
Tamir Duberstein
2022-02-17 14:55:08 -08:00
committed by gVisor bot
parent 8dda736af8
commit a9b5dcd31b
2 changed files with 6 additions and 6 deletions
+4 -4
View File
@@ -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{
+2 -2
View File
@@ -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,