@@ -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 })
@@ -794,27 +796,6 @@ func (ns *Impl) handleLocalPackets(p *packet.Parsed, t *tstun.Wrapper, gro *gro.
794796 p .IPVersion , p .IPProto , p .Dst , p .Src )
795797 }
796798
797- // If this is a ping message, handle it and don't pass to
798- // netstack.
799- pingIP , handlePing := ns .shouldHandlePing (p )
800- if handlePing {
801- ns .logf ("netstack: handling local 4via6 ping: dst=%v pingIP=%v" , dst , pingIP )
802-
803- var pong []byte // the reply to the ping, if our relayed ping works
804- if dst .Is4 () {
805- h := p .ICMP4Header ()
806- h .ToResponse ()
807- pong = packet .Generate (& h , p .Payload ())
808- } else if dst .Is6 () {
809- h := p .ICMP6Header ()
810- h .ToResponse ()
811- pong = packet .Generate (& h , p .Payload ())
812- }
813-
814- go ns .userPing (pingIP , pong , userPingDirectionInbound )
815- return filter .DropSilently , gro
816- }
817-
818799 // Fall through to writing inbound so netstack handles the
819800 // 4via6 via connection.
820801
@@ -1178,26 +1159,6 @@ func (ns *Impl) injectInbound(p *packet.Parsed, t *tstun.Wrapper, gro *gro.GRO)
11781159 return filter .Accept , gro
11791160 }
11801161
1181- destIP := p .Dst .Addr ()
1182-
1183- // If this is an echo request and we're a subnet router, handle pings
1184- // ourselves instead of forwarding the packet on.
1185- pingIP , handlePing := ns .shouldHandlePing (p )
1186- if handlePing {
1187- var pong []byte // the reply to the ping, if our relayed ping works
1188- if destIP .Is4 () {
1189- h := p .ICMP4Header ()
1190- h .ToResponse ()
1191- pong = packet .Generate (& h , p .Payload ())
1192- } else if destIP .Is6 () {
1193- h := p .ICMP6Header ()
1194- h .ToResponse ()
1195- pong = packet .Generate (& h , p .Payload ())
1196- }
1197- go ns .userPing (pingIP , pong , userPingDirectionOutbound )
1198- return filter .DropSilently , gro
1199- }
1200-
12011162 if debugPackets {
12021163 ns .logf ("[v2] packet in (from %v): % x" , p .Src , p .Buffer ())
12031164 }
0 commit comments