summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@tailscale.com>2024-02-24 14:12:03 -0800
committerBrad Fitzpatrick <brad@danga.com>2024-02-24 14:22:56 -0800
commit8b9474b06a240ca7cd56cccdc3e2413fb20d77ca (patch)
tree6fa145ee9e2191566710dd113146b778c1e9d488
parent8d0d46462b44b0779e879a9c8200ad11a8e5d103 (diff)
downloadtailscale-8b9474b06a240ca7cd56cccdc3e2413fb20d77ca.tar.xz
tailscale-8b9474b06a240ca7cd56cccdc3e2413fb20d77ca.zip
wgengine/wgcfg: don't send UAPI to disable keep-alives on new peers
That's already the default. Avoid the overhead of writing it on one side and reading it on the other to do nothing. Updates #cleanup (noticed while researching something else) Change-Id: I449c88a022271afb9be5da876bfaf438fe5d3f58 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
-rw-r--r--wgengine/wgcfg/config.go2
-rw-r--r--wgengine/wgcfg/writer.go2
2 files changed, 2 insertions, 2 deletions
diff --git a/wgengine/wgcfg/config.go b/wgengine/wgcfg/config.go
index a6a130b6f..76583a8e8 100644
--- a/wgengine/wgcfg/config.go
+++ b/wgengine/wgcfg/config.go
@@ -39,7 +39,7 @@ type Peer struct {
AllowedIPs []netip.Prefix
V4MasqAddr *netip.Addr // if non-nil, masquerade IPv4 traffic to this peer using this address
V6MasqAddr *netip.Addr // if non-nil, masquerade IPv6 traffic to this peer using this address
- PersistentKeepalive uint16
+ PersistentKeepalive uint16 // in seconds between keep-alives; 0 to disable
// wireguard-go's endpoint for this peer. It should always equal Peer.PublicKey.
// We represent it explicitly so that we can detect if they diverge and recover.
// There is no need to set WGEndpoint explicitly when constructing a Peer by hand.
diff --git a/wgengine/wgcfg/writer.go b/wgengine/wgcfg/writer.go
index 88864ee0e..9cdd31df2 100644
--- a/wgengine/wgcfg/writer.go
+++ b/wgengine/wgcfg/writer.go
@@ -62,7 +62,7 @@ func (cfg *Config) ToUAPI(logf logger.Logf, w io.Writer, prev *Config) error {
// to ensure that we're writing the full peer configuration.
willSetEndpoint := oldPeer.WGEndpoint != p.PublicKey || !wasPresent
willChangeIPs := !cidrsEqual(oldPeer.AllowedIPs, p.AllowedIPs) || !wasPresent
- willChangeKeepalive := oldPeer.PersistentKeepalive != p.PersistentKeepalive || !wasPresent
+ willChangeKeepalive := oldPeer.PersistentKeepalive != p.PersistentKeepalive // if not wasPresent, no need to redundantly set zero (default)
if !willSetEndpoint && !willChangeIPs && !willChangeKeepalive {
// It's safe to skip doing anything here; wireguard-go