wgengine: quiet some engine reconfig logging, make more consistent

Updates #282

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/277/head
Brad Fitzpatrick 4 years ago committed by Brad Fitzpatrick
parent 806645ea0e
commit 3a3b64301e

@ -610,6 +610,8 @@ func (b *LocalBackend) SetPrefs(new *Prefs) {
cli := b.c cli := b.c
b.mu.Unlock() b.mu.Unlock()
b.logf("SetPrefs: %v\n", new.Pretty())
if cli != nil && !oldHi.Equal(newHi) { if cli != nil && !oldHi.Equal(newHi) {
cli.SetHostinfo(newHi) cli.SetHostinfo(newHi)
} }
@ -620,7 +622,6 @@ func (b *LocalBackend) SetPrefs(new *Prefs) {
b.authReconfig() b.authReconfig()
} }
b.logf("SetPrefs: %v\n", new.Pretty())
b.send(Notify{Prefs: new}) b.send(Notify{Prefs: new})
} }
@ -657,7 +658,6 @@ func (b *LocalBackend) authReconfig() {
b.logf("authReconfig: skipping because !WantRunning.\n") b.logf("authReconfig: skipping because !WantRunning.\n")
return return
} }
b.logf("Configuring wireguard connection.\n")
uflags := controlclient.UDefault uflags := controlclient.UDefault
if uc.RouteAll { if uc.RouteAll {
@ -674,7 +674,6 @@ func (b *LocalBackend) authReconfig() {
if uc.AllowSingleHosts { if uc.AllowSingleHosts {
uflags |= controlclient.UAllowSingleHosts uflags |= controlclient.UAllowSingleHosts
} }
b.logf("reconfig: ra=%v dns=%v 0x%02x\n", uc.RouteAll, uc.CorpDNS, uflags)
dns := nm.DNS dns := nm.DNS
dom := nm.DNSDomains dom := nm.DNSDomains
@ -688,9 +687,10 @@ func (b *LocalBackend) authReconfig() {
} }
err = b.e.Reconfig(cfg, dom) err = b.e.Reconfig(cfg, dom)
if err != nil { if err == wgengine.ErrNoChanges {
b.logf("reconfig: %v", err) return
} }
b.logf("authReconfig: ra=%v dns=%v 0x%02x: %v\n", uc.RouteAll, uc.CorpDNS, uflags, err)
} }
func (b *LocalBackend) enterState(newState State) { func (b *LocalBackend) enterState(newState State) {

@ -311,7 +311,6 @@ func (e *userspaceEngine) pinger(peerKey wgcfg.Key, ips []wgcfg.IP) {
// the traditional wireguard config format. On the other hand, wireguard // the traditional wireguard config format. On the other hand, wireguard
// itself doesn't use the traditional 'dns =' setting either. // itself doesn't use the traditional 'dns =' setting either.
func (e *userspaceEngine) Reconfig(cfg *wgcfg.Config, dnsDomains []string) error { func (e *userspaceEngine) Reconfig(cfg *wgcfg.Config, dnsDomains []string) error {
e.logf("Reconfig(): configuring userspace wireguard engine.\n")
e.wgLock.Lock() e.wgLock.Lock()
defer e.wgLock.Unlock() defer e.wgLock.Unlock()
@ -330,9 +329,10 @@ func (e *userspaceEngine) Reconfig(cfg *wgcfg.Config, dnsDomains []string) error
rc := uapi + "\x00" + strings.Join(dnsDomains, "\x00") rc := uapi + "\x00" + strings.Join(dnsDomains, "\x00")
if rc == e.lastReconfig { if rc == e.lastReconfig {
e.logf("...unchanged config, skipping.\n") return ErrNoChanges
return nil
} }
e.logf("wgengine: Reconfig: configuring userspace wireguard engine")
e.lastReconfig = rc e.lastReconfig = rc
e.lastCfg = cfg.Copy() e.lastCfg = cfg.Copy()
@ -374,7 +374,7 @@ func (e *userspaceEngine) Reconfig(cfg *wgcfg.Config, dnsDomains []string) error
// just what's absolutely needed (the set of actual routes). // just what's absolutely needed (the set of actual routes).
rss := rs.OnlyRelevantParts() rss := rs.OnlyRelevantParts()
if rss != e.lastRoutes { if rss != e.lastRoutes {
e.logf("Reconfiguring router. la=%v dns=%v dom=%v; new routes: %v\n", e.logf("wgengine: Reconfig: reconfiguring router. la=%v dns=%v dom=%v; new routes: %v",
rs.LocalAddr, rs.DNS, rs.DNSDomains, rss) rs.LocalAddr, rs.DNS, rs.DNSDomains, rss)
e.lastRoutes = rss e.lastRoutes = rss
err = e.router.SetRoutes(rs) err = e.router.SetRoutes(rs)
@ -383,7 +383,7 @@ func (e *userspaceEngine) Reconfig(cfg *wgcfg.Config, dnsDomains []string) error
} }
} }
e.logf("Reconfig() done.\n") e.logf("wgengine: Reconfig done")
return nil return nil
} }

@ -5,6 +5,7 @@
package wgengine package wgengine
import ( import (
"errors"
"fmt" "fmt"
"time" "time"
@ -92,6 +93,9 @@ type Router interface {
Close() error Close() error
} }
// ErrNoChanges is returned by Engine.Reconfig if no changes were made.
var ErrNoChanges = errors.New("no changes made to Engine config")
// Engine is the Tailscale WireGuard engine interface. // Engine is the Tailscale WireGuard engine interface.
type Engine interface { type Engine interface {
// Reconfig reconfigures WireGuard and makes sure it's running. // Reconfig reconfigures WireGuard and makes sure it's running.
@ -102,6 +106,8 @@ type Engine interface {
// //
// This is called whenever the tailcontrol (control plane) // This is called whenever the tailcontrol (control plane)
// sends an updated network map. // sends an updated network map.
//
// The returned error is ErrNoChanges if no changes were made.
Reconfig(cfg *wgcfg.Config, dnsDomains []string) error Reconfig(cfg *wgcfg.Config, dnsDomains []string) error
// GetFilter returns the current packet filter, if any. // GetFilter returns the current packet filter, if any.

Loading…
Cancel
Save