diff --git a/pkg/tcpip/link/pipe/pipe.go b/pkg/tcpip/link/pipe/pipe.go index c2a888054..0be0a1efd 100644 --- a/pkg/tcpip/link/pipe/pipe.go +++ b/pkg/tcpip/link/pipe/pipe.go @@ -26,12 +26,14 @@ import ( var _ stack.LinkEndpoint = (*Endpoint)(nil) // New returns both ends of a new pipe. -func New(linkAddr1, linkAddr2 tcpip.LinkAddress) (*Endpoint, *Endpoint) { +func New(linkAddr1, linkAddr2 tcpip.LinkAddress, mtu uint32) (*Endpoint, *Endpoint) { ep1 := &Endpoint{ linkAddr: linkAddr1, + mtu: mtu, } ep2 := &Endpoint{ linkAddr: linkAddr2, + mtu: mtu, } ep1.linked = ep2 ep2.linked = ep1 @@ -43,6 +45,7 @@ type Endpoint struct { dispatcher stack.NetworkDispatcher linked *Endpoint linkAddr tcpip.LinkAddress + mtu uint32 } func (e *Endpoint) deliverPackets(r stack.RouteInfo, proto tcpip.NetworkProtocolNumber, pkts stack.PacketBufferList) { @@ -96,8 +99,8 @@ func (e *Endpoint) IsAttached() bool { func (*Endpoint) Wait() {} // MTU implements stack.LinkEndpoint. -func (*Endpoint) MTU() uint32 { - return header.IPv6MinimumMTU +func (e *Endpoint) MTU() uint32 { + return e.mtu } // Capabilities implements stack.LinkEndpoint. diff --git a/pkg/tcpip/tests/integration/istio_test.go b/pkg/tcpip/tests/integration/istio_test.go index 95d994ef8..10166c5ed 100644 --- a/pkg/tcpip/tests/integration/istio_test.go +++ b/pkg/tcpip/tests/integration/istio_test.go @@ -113,7 +113,7 @@ var ( func newTestContext(t *testing.T) *testContext { t.Helper() - localNIC, remoteNIC := pipe.New("" /* linkAddr1 */, "" /* linkAddr2 */) + localNIC, remoteNIC := pipe.New("" /* linkAddr1 */, "" /* linkAddr2 */, header.IPv4MinimumMTU) localStack := stack.New(stack.Options{ NetworkProtocols: []stack.NetworkProtocolFactory{ipv4.NewProtocol}, diff --git a/pkg/tcpip/tests/integration/link_resolution_test.go b/pkg/tcpip/tests/integration/link_resolution_test.go index 8b0968f20..93aa5c87d 100644 --- a/pkg/tcpip/tests/integration/link_resolution_test.go +++ b/pkg/tcpip/tests/integration/link_resolution_test.go @@ -44,10 +44,12 @@ import ( ) func setupStack(t *testing.T, stackOpts stack.Options, host1NICID, host2NICID tcpip.NICID) (*stack.Stack, *stack.Stack) { + const maxFrameSize = header.IPv6MinimumMTU + header.EthernetMinimumSize + host1Stack := stack.New(stackOpts) host2Stack := stack.New(stackOpts) - host1NIC, host2NIC := pipe.New(utils.LinkAddr1, utils.LinkAddr2) + host1NIC, host2NIC := pipe.New(utils.LinkAddr1, utils.LinkAddr2, maxFrameSize) if err := host1Stack.CreateNIC(host1NICID, utils.NewEthernetEndpoint(host1NIC)); err != nil { t.Fatalf("host1Stack.CreateNIC(%d, _): %s", host1NICID, err) diff --git a/pkg/tcpip/tests/utils/utils.go b/pkg/tcpip/tests/utils/utils.go index bf6c69e3b..24afd8794 100644 --- a/pkg/tcpip/tests/utils/utils.go +++ b/pkg/tcpip/tests/utils/utils.go @@ -279,8 +279,9 @@ func SetupRouterStack(t *testing.T, s *stack.Stack, ep1, ep2 stack.LinkEndpoint) // SetupRoutedStacks creates the NICs, sets forwarding, adds addresses and sets // the route tables for the passed stacks. func SetupRoutedStacks(t *testing.T, host1Stack, routerStack, host2Stack *stack.Stack) { - host1NIC, routerNIC1 := pipe.New(LinkAddr1, LinkAddr2) - routerNIC2, host2NIC := pipe.New(LinkAddr3, LinkAddr4) + const maxFrameSize = header.IPv6MinimumMTU + header.EthernetMinimumSize + host1NIC, routerNIC1 := pipe.New(LinkAddr1, LinkAddr2, maxFrameSize) + routerNIC2, host2NIC := pipe.New(LinkAddr3, LinkAddr4, maxFrameSize) SetupRouterStack(t, routerStack, NewEthernetEndpoint(routerNIC1), NewEthernetEndpoint(routerNIC2))