net/netns: remove spammy logs for interface binding caps

fixes tailscale/tailscale#17990

The logging for the netns caps is spammy.  Log only on changes
to the values and don't log Darwin specific stuff on non Darwin
clients.

Signed-off-by: Jonathan Nobels <jonathan@tailscale.com>
pull/18006/head
Jonathan Nobels 2 weeks ago committed by Brad Fitzpatrick
parent 7d19813618
commit 682172ca2d

@ -17,6 +17,7 @@ import (
"context" "context"
"net" "net"
"net/netip" "net/netip"
"runtime"
"sync/atomic" "sync/atomic"
"tailscale.com/net/netknob" "tailscale.com/net/netknob"
@ -40,8 +41,9 @@ var bindToInterfaceByRoute atomic.Bool
// //
// Currently, this only changes the behaviour on macOS and Windows. // Currently, this only changes the behaviour on macOS and Windows.
func SetBindToInterfaceByRoute(logf logger.Logf, v bool) { func SetBindToInterfaceByRoute(logf logger.Logf, v bool) {
logf("netns: bindToInterfaceByRoute to %v", v) if bindToInterfaceByRoute.Swap(v) != v {
bindToInterfaceByRoute.Store(v) logf("netns: bindToInterfaceByRoute changed to %v", v)
}
} }
var disableBindConnToInterface atomic.Bool var disableBindConnToInterface atomic.Bool
@ -54,8 +56,9 @@ var disableBindConnToInterface atomic.Bool
// SetDisableBindConnToInterfaceAppleExt which will disable explicit interface // SetDisableBindConnToInterfaceAppleExt which will disable explicit interface
// binding only when tailscaled is running inside a network extension process. // binding only when tailscaled is running inside a network extension process.
func SetDisableBindConnToInterface(logf logger.Logf, v bool) { func SetDisableBindConnToInterface(logf logger.Logf, v bool) {
logf("netns: disableBindConnToInterface set to %v", v) if disableBindConnToInterface.Swap(v) != v {
disableBindConnToInterface.Store(v) logf("netns: disableBindConnToInterface changed to %v", v)
}
} }
var disableBindConnToInterfaceAppleExt atomic.Bool var disableBindConnToInterfaceAppleExt atomic.Bool
@ -64,8 +67,9 @@ var disableBindConnToInterfaceAppleExt atomic.Bool
// connections to the default network interface but only on Apple clients where // connections to the default network interface but only on Apple clients where
// tailscaled is running inside a network extension. // tailscaled is running inside a network extension.
func SetDisableBindConnToInterfaceAppleExt(logf logger.Logf, v bool) { func SetDisableBindConnToInterfaceAppleExt(logf logger.Logf, v bool) {
logf("netns: disableBindConnToInterfaceAppleExt set to %v", v) if runtime.GOOS == "darwin" && disableBindConnToInterfaceAppleExt.Swap(v) != v {
disableBindConnToInterfaceAppleExt.Store(v) logf("netns: disableBindConnToInterfaceAppleExt changed to %v", v)
}
} }
// Listener returns a new net.Listener with its Control hook func // Listener returns a new net.Listener with its Control hook func

Loading…
Cancel
Save