summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--pkg/tcpip/network/ipv4/icmp.go42
-rw-r--r--pkg/tcpip/network/ipv4/ipv4.go8
-rw-r--r--pkg/tcpip/network/ipv6/icmp.go3
3 files changed, 11 insertions, 42 deletions
diff --git a/pkg/tcpip/network/ipv4/icmp.go b/pkg/tcpip/network/ipv4/icmp.go
index ea8392c98..7fd63c117 100644
--- a/pkg/tcpip/network/ipv4/icmp.go
+++ b/pkg/tcpip/network/ipv4/icmp.go
@@ -17,7 +17,6 @@ package ipv4
import (
"encoding/binary"
- "gvisor.googlesource.com/gvisor/pkg/tcpip"
"gvisor.googlesource.com/gvisor/pkg/tcpip/buffer"
"gvisor.googlesource.com/gvisor/pkg/tcpip/header"
"gvisor.googlesource.com/gvisor/pkg/tcpip/stack"
@@ -67,17 +66,17 @@ func (e *endpoint) handleICMP(r *stack.Route, netHeader buffer.View, vv buffer.V
if len(v) < header.ICMPv4EchoMinimumSize {
return
}
- echoPayload := vv.ToView()
- echoPayload.TrimFront(header.ICMPv4MinimumSize)
- req := echoRequest{r: r.Clone(), v: echoPayload}
- select {
- case e.echoRequests <- req:
- default:
- req.r.Release()
- }
// It's possible that a raw socket expects to receive this.
e.dispatcher.DeliverTransportPacket(r, header.ICMPv4ProtocolNumber, netHeader, vv)
+ vv.TrimFront(header.ICMPv4EchoMinimumSize)
+ hdr := buffer.NewPrependable(int(r.MaxHeaderLength()) + header.ICMPv4EchoMinimumSize)
+ pkt := header.ICMPv4(hdr.Prepend(header.ICMPv4EchoMinimumSize))
+ copy(pkt, h)
+ pkt.SetType(header.ICMPv4EchoReply)
+ pkt.SetChecksum(^header.Checksum(pkt, header.ChecksumVV(vv, 0)))
+ r.WritePacket(hdr, vv, header.ICMPv4ProtocolNumber, r.DefaultTTL())
+
case header.ICMPv4EchoReply:
if len(v) < header.ICMPv4EchoMinimumSize {
return
@@ -100,28 +99,3 @@ func (e *endpoint) handleICMP(r *stack.Route, netHeader buffer.View, vv buffer.V
}
// TODO: Handle other ICMP types.
}
-
-type echoRequest struct {
- r stack.Route
- v buffer.View
-}
-
-func (e *endpoint) echoReplier() {
- for req := range e.echoRequests {
- sendPing4(&req.r, 0, req.v)
- req.r.Release()
- }
-}
-
-func sendPing4(r *stack.Route, code byte, data buffer.View) *tcpip.Error {
- hdr := buffer.NewPrependable(header.ICMPv4EchoMinimumSize + int(r.MaxHeaderLength()))
-
- icmpv4 := header.ICMPv4(hdr.Prepend(header.ICMPv4EchoMinimumSize))
- icmpv4.SetType(header.ICMPv4EchoReply)
- icmpv4.SetCode(code)
- copy(icmpv4[header.ICMPv4MinimumSize:], data)
- data = data[header.ICMPv4EchoMinimumSize-header.ICMPv4MinimumSize:]
- icmpv4.SetChecksum(^header.Checksum(icmpv4, header.Checksum(data, 0)))
-
- return r.WritePacket(hdr, data.ToVectorisedView(), header.ICMPv4ProtocolNumber, r.DefaultTTL())
-}
diff --git a/pkg/tcpip/network/ipv4/ipv4.go b/pkg/tcpip/network/ipv4/ipv4.go
index 545684032..c2f9a1bcf 100644
--- a/pkg/tcpip/network/ipv4/ipv4.go
+++ b/pkg/tcpip/network/ipv4/ipv4.go
@@ -51,7 +51,6 @@ type endpoint struct {
id stack.NetworkEndpointID
linkEP stack.LinkEndpoint
dispatcher stack.TransportDispatcher
- echoRequests chan echoRequest
fragmentation *fragmentation.Fragmentation
}
@@ -62,12 +61,9 @@ func (p *protocol) NewEndpoint(nicid tcpip.NICID, addr tcpip.Address, linkAddrCa
id: stack.NetworkEndpointID{LocalAddress: addr},
linkEP: linkEP,
dispatcher: dispatcher,
- echoRequests: make(chan echoRequest, 10),
fragmentation: fragmentation.NewFragmentation(fragmentation.HighFragThreshold, fragmentation.LowFragThreshold, fragmentation.DefaultReassembleTimeout),
}
- go e.echoReplier()
-
return e, nil
}
@@ -174,9 +170,7 @@ func (e *endpoint) HandlePacket(r *stack.Route, vv buffer.VectorisedView) {
}
// Close cleans up resources associated with the endpoint.
-func (e *endpoint) Close() {
- close(e.echoRequests)
-}
+func (e *endpoint) Close() {}
type protocol struct{}
diff --git a/pkg/tcpip/network/ipv6/icmp.go b/pkg/tcpip/network/ipv6/icmp.go
index e43253d3e..cfc05d9e1 100644
--- a/pkg/tcpip/network/ipv6/icmp.go
+++ b/pkg/tcpip/network/ipv6/icmp.go
@@ -136,8 +136,9 @@ func (e *endpoint) handleICMP(r *stack.Route, netHeader buffer.View, vv buffer.V
if len(v) < header.ICMPv6EchoMinimumSize {
return
}
+
vv.TrimFront(header.ICMPv6EchoMinimumSize)
- hdr := buffer.NewPrependable(int(r.MaxHeaderLength()) + header.IPv6MinimumSize + header.ICMPv6EchoMinimumSize)
+ hdr := buffer.NewPrependable(int(r.MaxHeaderLength()) + header.ICMPv6EchoMinimumSize)
pkt := header.ICMPv6(hdr.Prepend(header.ICMPv6EchoMinimumSize))
copy(pkt, h)
pkt.SetType(header.ICMPv6EchoReply)