all: depend on zstd unconditionally, remove plumbing to make it optional

All platforms use it at this point, including iOS which was the
original hold out for memory reasons. No more reason to make it
optional.

Updates #9332

Change-Id: I743fbc2f370921a852fbcebf4eb9821e2bdd3086
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/9341/head
Brad Fitzpatrick 8 months ago committed by Brad Fitzpatrick
parent f12c71e71c
commit 9a86aa5732

@ -290,7 +290,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
tailscale.com/paths from tailscale.com/ipn/ipnlocal+ tailscale.com/paths from tailscale.com/ipn/ipnlocal+
💣 tailscale.com/portlist from tailscale.com/ipn/ipnlocal 💣 tailscale.com/portlist from tailscale.com/ipn/ipnlocal
tailscale.com/safesocket from tailscale.com/client/tailscale+ tailscale.com/safesocket from tailscale.com/client/tailscale+
tailscale.com/smallzstd from tailscale.com/cmd/tailscaled+ tailscale.com/smallzstd from tailscale.com/control/controlclient+
LD 💣 tailscale.com/ssh/tailssh from tailscale.com/cmd/tailscaled LD 💣 tailscale.com/ssh/tailssh from tailscale.com/cmd/tailscaled
tailscale.com/syncs from tailscale.com/net/netcheck+ tailscale.com/syncs from tailscale.com/net/netcheck+
tailscale.com/tailcfg from tailscale.com/client/tailscale/apitype+ tailscale.com/tailcfg from tailscale.com/client/tailscale/apitype+

@ -48,7 +48,6 @@ import (
"tailscale.com/net/tstun" "tailscale.com/net/tstun"
"tailscale.com/paths" "tailscale.com/paths"
"tailscale.com/safesocket" "tailscale.com/safesocket"
"tailscale.com/smallzstd"
"tailscale.com/syncs" "tailscale.com/syncs"
"tailscale.com/tsd" "tailscale.com/tsd"
"tailscale.com/tsweb/varz" "tailscale.com/tsweb/varz"
@ -551,9 +550,6 @@ func getLocalBackend(ctx context.Context, logf logger.Logf, logID logid.PublicID
if root := lb.TailscaleVarRoot(); root != "" { if root := lb.TailscaleVarRoot(); root != "" {
dnsfallback.SetCachePath(filepath.Join(root, "derpmap.cached.json"), logf) dnsfallback.SetCachePath(filepath.Join(root, "derpmap.cached.json"), logf)
} }
lb.SetDecompressor(func() (controlclient.Decompressor, error) {
return smallzstd.NewDecoder(nil)
})
configureTaildrop(logf, lb) configureTaildrop(logf, lb)
if err := ns.Start(lb); err != nil { if err := ns.Start(lb); err != nil {
log.Fatalf("failed to start netstack: %v", err) log.Fatalf("failed to start netstack: %v", err)

@ -35,7 +35,6 @@ import (
"tailscale.com/net/netns" "tailscale.com/net/netns"
"tailscale.com/net/tsdial" "tailscale.com/net/tsdial"
"tailscale.com/safesocket" "tailscale.com/safesocket"
"tailscale.com/smallzstd"
"tailscale.com/tailcfg" "tailscale.com/tailcfg"
"tailscale.com/tsd" "tailscale.com/tsd"
"tailscale.com/wgengine" "tailscale.com/wgengine"
@ -133,9 +132,6 @@ func newIPN(jsConfig js.Value) map[string]any {
if err := ns.Start(lb); err != nil { if err := ns.Start(lb); err != nil {
log.Fatalf("failed to start netstack: %v", err) log.Fatalf("failed to start netstack: %v", err)
} }
lb.SetDecompressor(func() (controlclient.Decompressor, error) {
return smallzstd.NewDecoder(nil)
})
srv.SetLocalBackend(lb) srv.SetLocalBackend(lb)
jsIPN := &jsIPN{ jsIPN := &jsIPN{

@ -43,6 +43,7 @@ import (
"tailscale.com/net/tlsdial" "tailscale.com/net/tlsdial"
"tailscale.com/net/tsdial" "tailscale.com/net/tsdial"
"tailscale.com/net/tshttpproxy" "tailscale.com/net/tshttpproxy"
"tailscale.com/smallzstd"
"tailscale.com/syncs" "tailscale.com/syncs"
"tailscale.com/tailcfg" "tailscale.com/tailcfg"
"tailscale.com/tka" "tailscale.com/tka"
@ -68,7 +69,6 @@ type Direct struct {
serverURL string // URL of the tailcontrol server serverURL string // URL of the tailcontrol server
clock tstime.Clock clock tstime.Clock
lastPrintMap time.Time lastPrintMap time.Time
newDecompressor func() (Decompressor, error)
logf logger.Logf logf logger.Logf
netMon *netmon.Monitor // or nil netMon *netmon.Monitor // or nil
discoPubKey key.DiscoPublic discoPubKey key.DiscoPublic
@ -119,7 +119,6 @@ type Options struct {
Clock tstime.Clock Clock tstime.Clock
Hostinfo *tailcfg.Hostinfo // non-nil passes ownership, nil means to use default using os.Hostname, etc Hostinfo *tailcfg.Hostinfo // non-nil passes ownership, nil means to use default using os.Hostname, etc
DiscoPublicKey key.DiscoPublic DiscoPublicKey key.DiscoPublic
NewDecompressor func() (Decompressor, error)
Logf logger.Logf Logf logger.Logf
HTTPTestClient *http.Client // optional HTTP client to use (for tests only) HTTPTestClient *http.Client // optional HTTP client to use (for tests only)
NoiseTestClient *http.Client // optional HTTP client to use for noise RPCs (tests only) NoiseTestClient *http.Client // optional HTTP client to use for noise RPCs (tests only)
@ -254,7 +253,6 @@ func NewDirect(opts Options) (*Direct, error) {
serverURL: opts.ServerURL, serverURL: opts.ServerURL,
clock: opts.Clock, clock: opts.Clock,
logf: opts.Logf, logf: opts.Logf,
newDecompressor: opts.NewDecompressor,
persist: opts.Persist.View(), persist: opts.Persist.View(),
authKey: opts.AuthKey, authKey: opts.AuthKey,
discoPubKey: opts.DiscoPublicKey, discoPubKey: opts.DiscoPublicKey,
@ -891,9 +889,7 @@ func (c *Direct) sendMapRequest(ctx context.Context, isStreaming bool, nu Netmap
old := request.DebugFlags old := request.DebugFlags
request.DebugFlags = append(old[:len(old):len(old)], extraDebugFlags...) request.DebugFlags = append(old[:len(old):len(old)], extraDebugFlags...)
} }
if c.newDecompressor != nil { request.Compress = "zstd"
request.Compress = "zstd"
}
bodyData, err := encode(request, serverKey, serverNoiseKey, machinePrivKey) bodyData, err := encode(request, serverKey, serverNoiseKey, machinePrivKey)
if err != nil { if err != nil {
@ -1177,19 +1173,14 @@ func (c *Direct) decodeMsg(msg []byte, v any, mkey key.MachinePrivate) error {
} else { } else {
decrypted = msg decrypted = msg
} }
var b []byte decoder, err := smallzstd.NewDecoder(nil)
if c.newDecompressor == nil { if err != nil {
b = decrypted return err
} else { }
decoder, err := c.newDecompressor() defer decoder.Close()
if err != nil { b, err := decoder.DecodeAll(decrypted, nil)
return err if err != nil {
} return err
defer decoder.Close()
b, err = decoder.DecodeAll(decrypted, nil)
if err != nil {
return err
}
} }
if debugMap() { if debugMap() {
var buf bytes.Buffer var buf bytes.Buffer

@ -153,10 +153,9 @@ type LocalBackend struct {
portpoll *portlist.Poller // may be nil portpoll *portlist.Poller // may be nil
portpollOnce sync.Once // guards starting readPoller portpollOnce sync.Once // guards starting readPoller
gotPortPollRes chan struct{} // closed upon first readPoller result gotPortPollRes chan struct{} // closed upon first readPoller result
newDecompressor func() (controlclient.Decompressor, error) varRoot string // or empty if SetVarRoot never called
varRoot string // or empty if SetVarRoot never called logFlushFunc func() // or nil if SetLogFlusher wasn't called
logFlushFunc func() // or nil if SetLogFlusher wasn't called em *expiryManager // non-nil
em *expiryManager // non-nil
sshAtomicBool atomic.Bool sshAtomicBool atomic.Bool
shutdownCalled bool // if Shutdown has been called shutdownCalled bool // if Shutdown has been called
debugSink *capture.Sink debugSink *capture.Sink
@ -898,16 +897,6 @@ func (b *LocalBackend) peerCapsLocked(src netip.Addr) tailcfg.PeerCapMap {
return nil return nil
} }
// SetDecompressor sets a decompression function, which must be a zstd
// reader.
//
// This exists because the iOS/Mac NetworkExtension is very resource
// constrained, and the zstd package is too heavy to fit in the
// constrained RSS limit.
func (b *LocalBackend) SetDecompressor(fn func() (controlclient.Decompressor, error)) {
b.newDecompressor = fn
}
// SetControlClientStatus is the callback invoked by the control client whenever it posts a new status. // SetControlClientStatus is the callback invoked by the control client whenever it posts a new status.
// Among other things, this is where we update the netmap, packet filters, DNS and DERP maps. // Among other things, this is where we update the netmap, packet filters, DNS and DERP maps.
func (b *LocalBackend) SetControlClientStatus(c controlclient.Client, st controlclient.Status) { func (b *LocalBackend) SetControlClientStatus(c controlclient.Client, st controlclient.Status) {
@ -1460,7 +1449,6 @@ func (b *LocalBackend) Start(opts ipn.Options) error {
ServerURL: serverURL, ServerURL: serverURL,
AuthKey: opts.AuthKey, AuthKey: opts.AuthKey,
Hostinfo: hostinfo, Hostinfo: hostinfo,
NewDecompressor: b.newDecompressor,
HTTPTestClient: httpTestClient, HTTPTestClient: httpTestClient,
DiscoPublicKey: discoPublic, DiscoPublicKey: discoPublic,
DebugFlags: debugFlags, DebugFlags: debugFlags,

@ -550,9 +550,6 @@ func (s *Server) start() (reterr error) {
return fmt.Errorf("failed to start netstack: %w", err) return fmt.Errorf("failed to start netstack: %w", err)
} }
closePool.addFunc(func() { s.lb.Shutdown() }) closePool.addFunc(func() { s.lb.Shutdown() })
lb.SetDecompressor(func() (controlclient.Decompressor, error) {
return smallzstd.NewDecoder(nil)
})
prefs := ipn.NewPrefs() prefs := ipn.NewPrefs()
prefs.Hostname = s.hostname prefs.Hostname = s.hostname
prefs.WantRunning = true prefs.WantRunning = true

@ -33,7 +33,6 @@ import (
_ "tailscale.com/net/tstun" _ "tailscale.com/net/tstun"
_ "tailscale.com/paths" _ "tailscale.com/paths"
_ "tailscale.com/safesocket" _ "tailscale.com/safesocket"
_ "tailscale.com/smallzstd"
_ "tailscale.com/ssh/tailssh" _ "tailscale.com/ssh/tailssh"
_ "tailscale.com/syncs" _ "tailscale.com/syncs"
_ "tailscale.com/tailcfg" _ "tailscale.com/tailcfg"

@ -33,7 +33,6 @@ import (
_ "tailscale.com/net/tstun" _ "tailscale.com/net/tstun"
_ "tailscale.com/paths" _ "tailscale.com/paths"
_ "tailscale.com/safesocket" _ "tailscale.com/safesocket"
_ "tailscale.com/smallzstd"
_ "tailscale.com/ssh/tailssh" _ "tailscale.com/ssh/tailssh"
_ "tailscale.com/syncs" _ "tailscale.com/syncs"
_ "tailscale.com/tailcfg" _ "tailscale.com/tailcfg"

@ -33,7 +33,6 @@ import (
_ "tailscale.com/net/tstun" _ "tailscale.com/net/tstun"
_ "tailscale.com/paths" _ "tailscale.com/paths"
_ "tailscale.com/safesocket" _ "tailscale.com/safesocket"
_ "tailscale.com/smallzstd"
_ "tailscale.com/ssh/tailssh" _ "tailscale.com/ssh/tailssh"
_ "tailscale.com/syncs" _ "tailscale.com/syncs"
_ "tailscale.com/tailcfg" _ "tailscale.com/tailcfg"

@ -33,7 +33,6 @@ import (
_ "tailscale.com/net/tstun" _ "tailscale.com/net/tstun"
_ "tailscale.com/paths" _ "tailscale.com/paths"
_ "tailscale.com/safesocket" _ "tailscale.com/safesocket"
_ "tailscale.com/smallzstd"
_ "tailscale.com/ssh/tailssh" _ "tailscale.com/ssh/tailssh"
_ "tailscale.com/syncs" _ "tailscale.com/syncs"
_ "tailscale.com/tailcfg" _ "tailscale.com/tailcfg"

@ -41,7 +41,6 @@ import (
_ "tailscale.com/net/tstun" _ "tailscale.com/net/tstun"
_ "tailscale.com/paths" _ "tailscale.com/paths"
_ "tailscale.com/safesocket" _ "tailscale.com/safesocket"
_ "tailscale.com/smallzstd"
_ "tailscale.com/syncs" _ "tailscale.com/syncs"
_ "tailscale.com/tailcfg" _ "tailscale.com/tailcfg"
_ "tailscale.com/tsd" _ "tailscale.com/tsd"

Loading…
Cancel
Save