summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/tcpip/link/muxed/BUILD8
-rw-r--r--pkg/tcpip/link/muxed/injectable.go30
-rw-r--r--pkg/tcpip/link/muxed/injectable_test.go14
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
}