Skip to content

Commit 682172c

Browse files
barnstarbradfitz
authored andcommitted
net/netns: remove spammy logs for interface binding caps
fixes 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 <[email protected]>
1 parent 7d19813 commit 682172c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

net/netns/netns.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"context"
1818
"net"
1919
"net/netip"
20+
"runtime"
2021
"sync/atomic"
2122

2223
"tailscale.com/net/netknob"
@@ -40,8 +41,9 @@ var bindToInterfaceByRoute atomic.Bool
4041
//
4142
// Currently, this only changes the behaviour on macOS and Windows.
4243
func SetBindToInterfaceByRoute(logf logger.Logf, v bool) {
43-
logf("netns: bindToInterfaceByRoute to %v", v)
44-
bindToInterfaceByRoute.Store(v)
44+
if bindToInterfaceByRoute.Swap(v) != v {
45+
logf("netns: bindToInterfaceByRoute changed to %v", v)
46+
}
4547
}
4648

4749
var disableBindConnToInterface atomic.Bool
@@ -54,8 +56,9 @@ var disableBindConnToInterface atomic.Bool
5456
// SetDisableBindConnToInterfaceAppleExt which will disable explicit interface
5557
// binding only when tailscaled is running inside a network extension process.
5658
func SetDisableBindConnToInterface(logf logger.Logf, v bool) {
57-
logf("netns: disableBindConnToInterface set to %v", v)
58-
disableBindConnToInterface.Store(v)
59+
if disableBindConnToInterface.Swap(v) != v {
60+
logf("netns: disableBindConnToInterface changed to %v", v)
61+
}
5962
}
6063

6164
var disableBindConnToInterfaceAppleExt atomic.Bool
@@ -64,8 +67,9 @@ var disableBindConnToInterfaceAppleExt atomic.Bool
6467
// connections to the default network interface but only on Apple clients where
6568
// tailscaled is running inside a network extension.
6669
func SetDisableBindConnToInterfaceAppleExt(logf logger.Logf, v bool) {
67-
logf("netns: disableBindConnToInterfaceAppleExt set to %v", v)
68-
disableBindConnToInterfaceAppleExt.Store(v)
70+
if runtime.GOOS == "darwin" && disableBindConnToInterfaceAppleExt.Swap(v) != v {
71+
logf("netns: disableBindConnToInterfaceAppleExt changed to %v", v)
72+
}
6973
}
7074

7175
// Listener returns a new net.Listener with its Control hook func

0 commit comments

Comments
 (0)