@ -716,22 +716,21 @@ func (ns *Impl) shouldHandlePing(p *packet.Parsed) (_ netip.Addr, ok bool) {
if ! p . IsEchoRequest ( ) {
if ! p . IsEchoRequest ( ) {
return netip . Addr { } , false
return netip . Addr { } , false
}
}
if ! ns . ProcessSubnets {
return netip . Addr { } , false
}
destIP := p . Dst . Addr ( )
destIP := p . Dst . Addr ( )
// For non-4via6 addresses, we don't handle pings if they're destined
// We need to handle pings for all 4via6 addresses, even if this
// for a Tailscale IP.
// netstack instance normally isn't responsible for processing subnets.
if ! viaRange . Contains ( destIP ) {
//
if tsaddr . IsTailscaleIP ( destIP ) {
// For example, on Linux, subnet router traffic could be handled via
return netip . Addr { } , false
// tun+iptables rules for most packets, but we still need to handle
}
// ICMP echo requests over 4via6 since the host networking stack
// doesn't know what to do with a 4via6 address.
return destIP , true
//
}
// shouldProcessInbound returns 'true' to say that we should process
// all IPv6 packets with a destination address in the 'via' range, so
// check before we check the "ProcessSubnets" boolean below.
if viaRange . Contains ( destIP ) {
// The input echo request was to a 4via6 address, which we cannot
// The input echo request was to a 4via6 address, which we cannot
// simply ping as-is from this process. Translate the destination to an
// simply ping as-is from this process. Translate the destination to an
// IPv4 address, so that our relayed ping (in userPing) is pinging the
// IPv4 address, so that our relayed ping (in userPing) is pinging the
@ -743,6 +742,23 @@ func (ns *Impl) shouldHandlePing(p *packet.Parsed) (_ netip.Addr, ok bool) {
// case things are safe because the 'userPing' function doesn't make
// case things are safe because the 'userPing' function doesn't make
// use of the input packet.
// use of the input packet.
return tsaddr . UnmapVia ( destIP ) , true
return tsaddr . UnmapVia ( destIP ) , true
}
// If we get here, we don't do anything unless this netstack instance
// is responsible for processing subnet traffic.
if ! ns . ProcessSubnets {
return netip . Addr { } , false
}
// For non-4via6 addresses, we don't handle pings if they're destined
// for a Tailscale IP.
if tsaddr . IsTailscaleIP ( destIP ) {
return netip . Addr { } , false
}
// This netstack instance is processing subnet traffic, so handle the
// ping ourselves.
return destIP , true
}
}
func netaddrIPFromNetstackIP ( s tcpip . Address ) netip . Addr {
func netaddrIPFromNetstackIP ( s tcpip . Address ) netip . Addr {