wgengine/netstack: simplify netaddrIPFromNetstackIP

Updates #cleanup

Change-Id: I66878b08a75d44170460cbf33c895277c187bd8d
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick 2024-07-25 19:43:12 -07:00 committed by Brad Fitzpatrick
parent 855da47777
commit cf97cff33b

View File

@ -1116,11 +1116,9 @@ func (ns *Impl) shouldHandlePing(p *packet.Parsed) (_ netip.Addr, ok bool) {
func netaddrIPFromNetstackIP(s tcpip.Address) netip.Addr {
switch s.Len() {
case 4:
s := s.As4()
return netaddr.IPv4(s[0], s[1], s[2], s[3])
return netip.AddrFrom4(s.As4())
case 16:
s := s.As16()
return netip.AddrFrom16(s).Unmap()
return netip.AddrFrom16(s.As16()).Unmap()
}
return netip.Addr{}
}