mirror of
https://github.com/tailscale/tailscale.git
synced 2026-12-02 06:32:32 -08:00
lanscaping: remove mdlayher/socket dep from dead raw disco code previously removed
-rwxr-xr-x@ 1 bradfitz staff 9870450 Jan 11 15:58 /Users/bradfitz/bin/tailscaled.min -rwxr-xr-x@ 1 bradfitz staff 9765016 Jan 11 15:58 /Users/bradfitz/bin/tailscaled.minlinux Change-Id: Ia7c58661dc27129c2d572cf4ae7d77548a174dda Signed-off-by: Brad Fitzpatrick <[email protected]>
This commit is contained in:
1 parent
9edf7ad1a9
commit
0067f45f67
2 files changed
+2
-98
No files matched your search
@@ -9,7 +9,6 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
|
||||
github.com/klauspost/compress/internal/snapref from github.com/klauspost/compress/zstd
|
||||
github.com/klauspost/compress/zstd from tailscale.com/util/zstdframe
|
||||
github.com/klauspost/compress/zstd/internal/xxhash from github.com/klauspost/compress/zstd
|
||||
L 💣 github.com/mdlayher/socket from tailscale.com/wgengine/magicsock
|
||||
💣 github.com/tailscale/wireguard-go/conn from github.com/tailscale/wireguard-go/device+
|
||||
💣 github.com/tailscale/wireguard-go/device from tailscale.com/net/tstun+
|
||||
💣 github.com/tailscale/wireguard-go/ipc from github.com/tailscale/wireguard-go/device
|
||||
@@ -137,7 +136,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
|
||||
golang.org/x/crypto/poly1305 from github.com/tailscale/wireguard-go/device
|
||||
golang.org/x/crypto/salsa20/salsa from golang.org/x/crypto/nacl/box+
|
||||
golang.org/x/crypto/sha3 from crypto/internal/mlkem768+
|
||||
golang.org/x/net/bpf from github.com/mdlayher/socket+
|
||||
golang.org/x/net/bpf from golang.org/x/net/ipv4+
|
||||
golang.org/x/net/dns/dnsmessage from net
|
||||
golang.org/x/net/http/httpguts from golang.org/x/net/http2+
|
||||
golang.org/x/net/http/httpproxy from net/http
|
||||
@@ -148,9 +147,8 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
|
||||
golang.org/x/net/ipv6 from github.com/tailscale/wireguard-go/conn+
|
||||
golang.org/x/net/proxy from tailscale.com/net/netns
|
||||
D golang.org/x/net/route from net+
|
||||
L golang.org/x/sync/errgroup from github.com/mdlayher/socket
|
||||
golang.org/x/sys/cpu from github.com/tailscale/wireguard-go/tun+
|
||||
golang.org/x/sys/unix from github.com/mdlayher/socket+
|
||||
golang.org/x/sys/unix from github.com/tailscale/wireguard-go/conn+
|
||||
golang.org/x/text/secure/bidirule from golang.org/x/net/idna
|
||||
golang.org/x/text/transform from golang.org/x/text/secure/bidirule+
|
||||
golang.org/x/text/unicode/bidi from golang.org/x/net/idna+
|
||||
|
||||
@@ -4,16 +4,13 @@
|
||||
package magicsock
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/netip"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/mdlayher/socket"
|
||||
"golang.org/x/net/bpf"
|
||||
"golang.org/x/net/ipv4"
|
||||
"golang.org/x/net/ipv6"
|
||||
@@ -22,7 +19,6 @@ import (
|
||||
"tailscale.com/disco"
|
||||
"tailscale.com/envknob"
|
||||
"tailscale.com/types/ipproto"
|
||||
"tailscale.com/types/key"
|
||||
"tailscale.com/types/logger"
|
||||
"tailscale.com/types/nettype"
|
||||
)
|
||||
@@ -252,96 +248,6 @@ func (c *Conn) discoLogf(format string, args ...any) {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Conn) receiveDisco(pc *socket.Conn, isIPV6 bool) {
|
||||
// Given that we're parsing raw packets, be extra careful and recover
|
||||
// from any panics in this function.
|
||||
//
|
||||
// If we didn't have a recover() here and panic'd, we'd take down the
|
||||
// entire process since this function is the top of a goroutine, and Go
|
||||
// will kill the process if a goroutine panics and it unwinds past the
|
||||
// top-level function.
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
c.logf("[unexpected] recovered from panic in receiveDisco(isIPv6=%v): %v", isIPV6, err)
|
||||
}
|
||||
}()
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// Set up our loggers
|
||||
var family string
|
||||
if isIPV6 {
|
||||
family = "ip6"
|
||||
} else {
|
||||
family = "ip4"
|
||||
}
|
||||
var (
|
||||
prefix string = "disco raw " + family + ": "
|
||||
logf logger.Logf = logger.WithPrefix(c.logf, prefix)
|
||||
dlogf logger.Logf = logger.WithPrefix(c.discoLogf, prefix)
|
||||
)
|
||||
|
||||
var buf [1500]byte
|
||||
for {
|
||||
n, src, err := pc.Recvfrom(ctx, buf[:], 0)
|
||||
if debugRawDiscoReads() {
|
||||
logf("read from %s = (%v, %v)", printSockaddr(src), n, err)
|
||||
}
|
||||
if err != nil && (errors.Is(err, net.ErrClosed) || err.Error() == "use of closed file") {
|
||||
// EOF; no need to print an error
|
||||
return
|
||||
} else if err != nil {
|
||||
logf("reader failed: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
srcAddr, dstAddr, payload := parseUDPPacket(buf[:n], family == "ip6")
|
||||
if payload == nil {
|
||||
// callee logged
|
||||
continue
|
||||
}
|
||||
|
||||
dstPort := dstAddr.Port()
|
||||
if dstPort == 0 {
|
||||
logf("[unexpected] received packet for port 0")
|
||||
}
|
||||
|
||||
var acceptPort uint16
|
||||
if isIPV6 {
|
||||
acceptPort = c.pconn6.Port()
|
||||
} else {
|
||||
acceptPort = c.pconn4.Port()
|
||||
}
|
||||
if acceptPort == 0 {
|
||||
// This should only typically happen if the receiving address family
|
||||
// was recently disabled.
|
||||
dlogf("[v1] dropping packet for port %d as acceptPort=0", dstPort)
|
||||
continue
|
||||
}
|
||||
|
||||
// If the packet isn't destined for our local port, then we
|
||||
// should drop it since it might be for another Tailscale
|
||||
// process on the same machine, or NATed to a different machine
|
||||
// if this is a router, etc.
|
||||
//
|
||||
// We get the local port to compare against inside the receive
|
||||
// loop; we can't cache this beforehand because it can change
|
||||
// if/when we rebind.
|
||||
if dstPort != acceptPort {
|
||||
dlogf("[v1] dropping packet for port %d that isn't our local port", dstPort)
|
||||
continue
|
||||
}
|
||||
|
||||
if isIPV6 {
|
||||
metricRecvDiscoPacketIPv6.Add(1)
|
||||
} else {
|
||||
metricRecvDiscoPacketIPv4.Add(1)
|
||||
}
|
||||
|
||||
c.handleDiscoMessage(payload, srcAddr, key.NodePublic{}, discoRXPathRawSocket)
|
||||
}
|
||||
}
|
||||
|
||||
// printSockaddr is a helper function to pretty-print various sockaddr types.
|
||||
func printSockaddr(sa unix.Sockaddr) string {
|
||||
switch sa := sa.(type) {
|
||||
|
||||
Reference in new issue
Block a user