diff options
author | Ian Gudger <igudger@google.com> | 2019-02-08 15:36:22 -0800 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-02-08 15:37:20 -0800 |
commit | 967326131a875047c2b2d51bf4b2984ceefd4730 (patch) | |
tree | 6a56b0ec74f09cee3640ad2a8505dbe61b98cdec /pkg/tcpip | |
parent | b2aa213dd2e19d88b4edf839d20e5bf51534be62 (diff) |
Fix build error.
PiperOrigin-RevId: 233139020
Change-Id: I2e7089fa25d20e5662eb941054a684d41f5d3e12
Diffstat (limited to 'pkg/tcpip')
-rw-r--r-- | pkg/tcpip/link/muxed/BUILD | 8 | ||||
-rw-r--r-- | pkg/tcpip/link/muxed/injectable.go | 30 | ||||
-rw-r--r-- | pkg/tcpip/link/muxed/injectable_test.go | 14 |
3 files changed, 26 insertions, 26 deletions
diff --git a/pkg/tcpip/link/muxed/BUILD b/pkg/tcpip/link/muxed/BUILD index 92d2e3290..f991dca83 100644 --- a/pkg/tcpip/link/muxed/BUILD +++ b/pkg/tcpip/link/muxed/BUILD @@ -3,9 +3,9 @@ load("//tools/go_stateify:defs.bzl", "go_library", "go_test") package(licenses = ["notice"]) # Apache 2.0 go_library( - name = "injectable", + name = "muxed", srcs = ["injectable.go"], - importpath = "gvisor.googlesource.com/gvisor/pkg/tcpip/link/injectable", + importpath = "gvisor.googlesource.com/gvisor/pkg/tcpip/link/muxed", visibility = [ "//visibility:public", ], @@ -17,10 +17,10 @@ go_library( ) go_test( - name = "injectable_test", + name = "muxed_test", size = "small", srcs = ["injectable_test.go"], - embed = [":injectable"], + embed = [":muxed"], deps = [ "//pkg/tcpip", "//pkg/tcpip/buffer", diff --git a/pkg/tcpip/link/muxed/injectable.go b/pkg/tcpip/link/muxed/injectable.go index 1215ba1e7..9d85bda60 100644 --- a/pkg/tcpip/link/muxed/injectable.go +++ b/pkg/tcpip/link/muxed/injectable.go @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Package injectable provides a muxed injectable endpoint. -package injectable +// Package muxed provides a muxed link endpoints. +package muxed import ( "gvisor.googlesource.com/gvisor/pkg/tcpip" @@ -21,17 +21,17 @@ import ( "gvisor.googlesource.com/gvisor/pkg/tcpip/stack" ) -// MuxedInjectableEndpoint is an injectable multi endpoint. The endpoint has +// InjectableEndpoint is an injectable multi endpoint. The endpoint has // trivial routing rules that determine which InjectableEndpoint a given packet // will be written to. Note that HandleLocal works differently for this // endpoint (see WritePacket). -type MuxedInjectableEndpoint struct { +type InjectableEndpoint struct { routes map[tcpip.Address]stack.InjectableLinkEndpoint dispatcher stack.NetworkDispatcher } // MTU implements stack.LinkEndpoint. -func (m *MuxedInjectableEndpoint) MTU() uint32 { +func (m *InjectableEndpoint) MTU() uint32 { minMTU := ^uint32(0) for _, endpoint := range m.routes { if endpointMTU := endpoint.MTU(); endpointMTU < minMTU { @@ -42,7 +42,7 @@ func (m *MuxedInjectableEndpoint) MTU() uint32 { } // Capabilities implements stack.LinkEndpoint. -func (m *MuxedInjectableEndpoint) Capabilities() stack.LinkEndpointCapabilities { +func (m *InjectableEndpoint) Capabilities() stack.LinkEndpointCapabilities { minCapabilities := stack.LinkEndpointCapabilities(^uint(0)) for _, endpoint := range m.routes { minCapabilities &= endpoint.Capabilities() @@ -51,7 +51,7 @@ func (m *MuxedInjectableEndpoint) Capabilities() stack.LinkEndpointCapabilities } // MaxHeaderLength implements stack.LinkEndpoint. -func (m *MuxedInjectableEndpoint) MaxHeaderLength() uint16 { +func (m *InjectableEndpoint) MaxHeaderLength() uint16 { minHeaderLen := ^uint16(0) for _, endpoint := range m.routes { if headerLen := endpoint.MaxHeaderLength(); headerLen < minHeaderLen { @@ -62,12 +62,12 @@ func (m *MuxedInjectableEndpoint) MaxHeaderLength() uint16 { } // LinkAddress implements stack.LinkEndpoint. -func (m *MuxedInjectableEndpoint) LinkAddress() tcpip.LinkAddress { +func (m *InjectableEndpoint) LinkAddress() tcpip.LinkAddress { return "" } // Attach implements stack.LinkEndpoint. -func (m *MuxedInjectableEndpoint) Attach(dispatcher stack.NetworkDispatcher) { +func (m *InjectableEndpoint) Attach(dispatcher stack.NetworkDispatcher) { for _, endpoint := range m.routes { endpoint.Attach(dispatcher) } @@ -75,28 +75,28 @@ func (m *MuxedInjectableEndpoint) Attach(dispatcher stack.NetworkDispatcher) { } // IsAttached implements stack.LinkEndpoint. -func (m *MuxedInjectableEndpoint) IsAttached() bool { +func (m *InjectableEndpoint) IsAttached() bool { return m.dispatcher != nil } // Inject implements stack.InjectableLinkEndpoint. -func (m *MuxedInjectableEndpoint) Inject(protocol tcpip.NetworkProtocolNumber, vv buffer.VectorisedView) { +func (m *InjectableEndpoint) Inject(protocol tcpip.NetworkProtocolNumber, vv buffer.VectorisedView) { m.dispatcher.DeliverNetworkPacket(m, "" /* remote */, "" /* local */, protocol, vv) } // WritePacket writes outbound packets to the appropriate LinkInjectableEndpoint // based on the RemoteAddress. HandleLocal only works if r.RemoteAddress has a // route registered in this endpoint. -func (m *MuxedInjectableEndpoint) WritePacket(r *stack.Route, hdr buffer.Prependable, payload buffer.VectorisedView, protocol tcpip.NetworkProtocolNumber) *tcpip.Error { +func (m *InjectableEndpoint) WritePacket(r *stack.Route, hdr buffer.Prependable, payload buffer.VectorisedView, protocol tcpip.NetworkProtocolNumber) *tcpip.Error { if endpoint, ok := m.routes[r.RemoteAddress]; ok { return endpoint.WritePacket(r, hdr, payload, protocol) } return tcpip.ErrNoRoute } -// NewMuxedInjectableEndpoint creates a new multi-fd-based injectable endpoint. -func NewMuxedInjectableEndpoint(routes map[tcpip.Address]stack.InjectableLinkEndpoint, mtu uint32) (tcpip.LinkEndpointID, *MuxedInjectableEndpoint) { - e := &MuxedInjectableEndpoint{ +// NewInjectableEndpoint creates a new multi-fd-based injectable endpoint. +func NewInjectableEndpoint(routes map[tcpip.Address]stack.InjectableLinkEndpoint, mtu uint32) (tcpip.LinkEndpointID, *InjectableEndpoint) { + e := &InjectableEndpoint{ routes: routes, } return stack.RegisterLinkEndpoint(e), e diff --git a/pkg/tcpip/link/muxed/injectable_test.go b/pkg/tcpip/link/muxed/injectable_test.go index 8a1a863ff..65db14b5d 100644 --- a/pkg/tcpip/link/muxed/injectable_test.go +++ b/pkg/tcpip/link/muxed/injectable_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package injectable +package muxed import ( "bytes" @@ -28,8 +28,8 @@ import ( "gvisor.googlesource.com/gvisor/pkg/tcpip/stack" ) -func TestMuxedEndpointDispatch(t *testing.T) { - endpoint, sock, dstIP := makeMuxedTestEndpoint(t) +func TestInjectableEndpointDispatch(t *testing.T) { + endpoint, sock, dstIP := makeTestInjectableEndpoint(t) hdr := buffer.NewPrependable(1) hdr.Prepend(1)[0] = 0xFA packetRoute := stack.Route{RemoteAddress: dstIP} @@ -47,8 +47,8 @@ func TestMuxedEndpointDispatch(t *testing.T) { } } -func TestMuxedEndpointDispatchHdrOnly(t *testing.T) { - endpoint, sock, dstIP := makeMuxedTestEndpoint(t) +func TestInjectableEndpointDispatchHdrOnly(t *testing.T) { + endpoint, sock, dstIP := makeTestInjectableEndpoint(t) hdr := buffer.NewPrependable(1) hdr.Prepend(1)[0] = 0xFA packetRoute := stack.Route{RemoteAddress: dstIP} @@ -64,7 +64,7 @@ func TestMuxedEndpointDispatchHdrOnly(t *testing.T) { } } -func makeMuxedTestEndpoint(t *testing.T) (*MuxedInjectableEndpoint, *os.File, tcpip.Address) { +func makeTestInjectableEndpoint(t *testing.T) (*InjectableEndpoint, *os.File, tcpip.Address) { dstIP := tcpip.Address(net.ParseIP("1.2.3.4").To4()) pair, err := syscall.Socketpair(syscall.AF_UNIX, syscall.SOCK_SEQPACKET|syscall.SOCK_CLOEXEC|syscall.SOCK_NONBLOCK, 0) @@ -73,6 +73,6 @@ func makeMuxedTestEndpoint(t *testing.T) (*MuxedInjectableEndpoint, *os.File, tc } _, underlyingEndpoint := fdbased.NewInjectable(pair[1], 6500) routes := map[tcpip.Address]stack.InjectableLinkEndpoint{dstIP: underlyingEndpoint} - _, endpoint := NewMuxedInjectableEndpoint(routes, 6500) + _, endpoint := NewInjectableEndpoint(routes, 6500) return endpoint, os.NewFile(uintptr(pair[0]), "test route end"), dstIP } |