summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/network
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2021-01-14 00:18:26 +0000
committergVisor bot <gvisor-bot@google.com>2021-01-14 00:18:26 +0000
commitfc9aec0925d6ff6bdbc8a0c0866f6199ea054d9f (patch)
tree1b71096a33e99d24f588ac1066797fdc7f0146c4 /pkg/tcpip/network
parentcfa5eea33e3e8a2f8e7cac622ab046df43ccf0a1 (diff)
parent25b5ec7135a6de80674ac1ad4d2289c29e156f42 (diff)
Merge release-20201216.0-105-g25b5ec713 (automated)
Diffstat (limited to 'pkg/tcpip/network')
-rw-r--r--pkg/tcpip/network/ipv4/ipv4.go16
-rw-r--r--pkg/tcpip/network/ipv6/ipv6.go13
2 files changed, 29 insertions, 0 deletions
diff --git a/pkg/tcpip/network/ipv4/ipv4.go b/pkg/tcpip/network/ipv4/ipv4.go
index e9ff70d04..cc045c7a9 100644
--- a/pkg/tcpip/network/ipv4/ipv4.go
+++ b/pkg/tcpip/network/ipv4/ipv4.go
@@ -64,6 +64,7 @@ const (
var ipv4BroadcastAddr = header.IPv4Broadcast.WithPrefix()
+var _ stack.LinkResolvableNetworkEndpoint = (*endpoint)(nil)
var _ stack.GroupAddressableEndpoint = (*endpoint)(nil)
var _ stack.AddressableEndpoint = (*endpoint)(nil)
var _ stack.NetworkEndpoint = (*endpoint)(nil)
@@ -87,6 +88,21 @@ type endpoint struct {
}
}
+// HandleLinkResolutionFailure implements stack.LinkResolvableNetworkEndpoint.
+func (e *endpoint) HandleLinkResolutionFailure(pkt *stack.PacketBuffer) {
+ // handleControl expects the entire offending packet to be in the packet
+ // buffer's data field.
+ pkt = stack.NewPacketBuffer(stack.PacketBufferOptions{
+ Data: buffer.NewVectorisedView(pkt.Size(), pkt.Views()),
+ })
+ pkt.NICID = e.nic.ID()
+ pkt.NetworkProtocolNumber = ProtocolNumber
+ // Use the same control type as an ICMPv4 destination host unreachable error
+ // since the host is considered unreachable if we cannot resolve the link
+ // address to the next hop.
+ e.handleControl(stack.ControlNoRoute, 0, pkt)
+}
+
// NewEndpoint creates a new ipv4 endpoint.
func (p *protocol) NewEndpoint(nic stack.NetworkInterface, _ stack.LinkAddressCache, _ stack.NUDHandler, dispatcher stack.TransportDispatcher) stack.NetworkEndpoint {
e := &endpoint{
diff --git a/pkg/tcpip/network/ipv6/ipv6.go b/pkg/tcpip/network/ipv6/ipv6.go
index f2018d073..2f82c3d5f 100644
--- a/pkg/tcpip/network/ipv6/ipv6.go
+++ b/pkg/tcpip/network/ipv6/ipv6.go
@@ -163,6 +163,7 @@ func getLabel(addr tcpip.Address) uint8 {
panic(fmt.Sprintf("should have a label for address = %s", addr))
}
+var _ stack.LinkResolvableNetworkEndpoint = (*endpoint)(nil)
var _ stack.GroupAddressableEndpoint = (*endpoint)(nil)
var _ stack.AddressableEndpoint = (*endpoint)(nil)
var _ stack.NetworkEndpoint = (*endpoint)(nil)
@@ -224,6 +225,18 @@ type OpaqueInterfaceIdentifierOptions struct {
SecretKey []byte
}
+// HandleLinkResolutionFailure implements stack.LinkResolvableNetworkEndpoint.
+func (e *endpoint) HandleLinkResolutionFailure(pkt *stack.PacketBuffer) {
+ // handleControl expects the entire offending packet to be in the packet
+ // buffer's data field.
+ pkt = stack.NewPacketBuffer(stack.PacketBufferOptions{
+ Data: buffer.NewVectorisedView(pkt.Size(), pkt.Views()),
+ })
+ pkt.NICID = e.nic.ID()
+ pkt.NetworkProtocolNumber = ProtocolNumber
+ e.handleControl(stack.ControlAddressUnreachable, 0, pkt)
+}
+
// onAddressAssignedLocked handles an address being assigned.
//
// Precondition: e.mu must be exclusively locked.