@@ -28,6 +28,7 @@ import (
2828 "github.com/sagernet/gvisor/pkg/tcpip/network/ipv6"
2929 "github.com/sagernet/gvisor/pkg/tcpip/stack"
3030 "github.com/sagernet/gvisor/pkg/tcpip/transport/icmp"
31+ "github.com/sagernet/gvisor/pkg/tcpip/transport/raw"
3132 "github.com/sagernet/gvisor/pkg/tcpip/transport/tcp"
3233 "github.com/sagernet/gvisor/pkg/tcpip/transport/udp"
3334 "github.com/sagernet/gvisor/pkg/waiter"
@@ -310,6 +311,7 @@ func Create(logf logger.Logf, tundev *tstun.Wrapper, e wgengine.Engine, mc *magi
310311 return nil , errors .New ("nil Dialer" )
311312 }
312313 ipstack := stack .New (stack.Options {
314+ RawFactory : new (raw.EndpointFactory ),
313315 NetworkProtocols : []stack.NetworkProtocolFactory {ipv4 .NewProtocol , ipv6 .NewProtocol },
314316 TransportProtocols : []stack.TransportProtocolFactory {tcp .NewProtocol , udp .NewProtocol , icmp .NewProtocol4 , icmp .NewProtocol6 },
315317 })
@@ -798,27 +800,6 @@ func (ns *Impl) handleLocalPackets(p *packet.Parsed, t *tstun.Wrapper, gro *gro.
798800 p .IPVersion , p .IPProto , p .Dst , p .Src )
799801 }
800802
801- // If this is a ping message, handle it and don't pass to
802- // netstack.
803- pingIP , handlePing := ns .shouldHandlePing (p )
804- if handlePing {
805- ns .logf ("netstack: handling local 4via6 ping: dst=%v pingIP=%v" , dst , pingIP )
806-
807- var pong []byte // the reply to the ping, if our relayed ping works
808- if dst .Is4 () {
809- h := p .ICMP4Header ()
810- h .ToResponse ()
811- pong = packet .Generate (& h , p .Payload ())
812- } else if dst .Is6 () {
813- h := p .ICMP6Header ()
814- h .ToResponse ()
815- pong = packet .Generate (& h , p .Payload ())
816- }
817-
818- go ns .userPing (pingIP , pong , userPingDirectionInbound )
819- return filter .DropSilently , gro
820- }
821-
822803 // Fall through to writing inbound so netstack handles the
823804 // 4via6 via connection.
824805
@@ -1182,26 +1163,6 @@ func (ns *Impl) injectInbound(p *packet.Parsed, t *tstun.Wrapper, gro *gro.GRO)
11821163 return filter .Accept , gro
11831164 }
11841165
1185- destIP := p .Dst .Addr ()
1186-
1187- // If this is an echo request and we're a subnet router, handle pings
1188- // ourselves instead of forwarding the packet on.
1189- pingIP , handlePing := ns .shouldHandlePing (p )
1190- if handlePing {
1191- var pong []byte // the reply to the ping, if our relayed ping works
1192- if destIP .Is4 () {
1193- h := p .ICMP4Header ()
1194- h .ToResponse ()
1195- pong = packet .Generate (& h , p .Payload ())
1196- } else if destIP .Is6 () {
1197- h := p .ICMP6Header ()
1198- h .ToResponse ()
1199- pong = packet .Generate (& h , p .Payload ())
1200- }
1201- go ns .userPing (pingIP , pong , userPingDirectionOutbound )
1202- return filter .DropSilently , gro
1203- }
1204-
12051166 if debugPackets {
12061167 ns .logf ("[v2] packet in (from %v): % x" , p .Src , p .Buffer ())
12071168 }
0 commit comments