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
b.mu.Unlock()
b.logf("SetPrefs: %v\n", new.Pretty())
if cli != nil && !oldHi.Equal(newHi) {
cli.SetHostinfo(newHi)
}
@ -620,7 +622,6 @@ func (b *LocalBackend) SetPrefs(new *Prefs) {
b.authReconfig()
}
b.logf("SetPrefs: %v\n", new.Pretty())
b.send(Notify{Prefs: new})
}
@ -657,7 +658,6 @@ func (b *LocalBackend) authReconfig() {
b.logf("authReconfig: skipping because !WantRunning.\n")
return
}
b.logf("Configuring wireguard connection.\n")
uflags := controlclient.UDefault
if uc.RouteAll {
@ -674,7 +674,6 @@ func (b *LocalBackend) authReconfig() {
if uc.AllowSingleHosts {
uflags |= controlclient.UAllowSingleHosts
}
b.logf("reconfig: ra=%v dns=%v 0x%02x\n", uc.RouteAll, uc.CorpDNS, uflags)
dns := nm.DNS
dom := nm.DNSDomains
@ -688,9 +687,10 @@ func (b *LocalBackend) authReconfig() {
}
err = b.e.Reconfig(cfg, dom)
if err != nil {
b.logf("reconfig: %v", err)
if err == wgengine.ErrNoChanges {
return
}
b.logf("authReconfig: ra=%v dns=%v 0x%02x: %v\n", uc.RouteAll, uc.CorpDNS, uflags, err)
}
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
// itself doesn't use the traditional 'dns =' setting either.
func (e *userspaceEngine) Reconfig(cfg *wgcfg.Config, dnsDomains []string) error {
e.logf("Reconfig(): configuring userspace wireguard engine.\n")
e.wgLock.Lock()
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")
if rc == e.lastReconfig {
e.logf("...unchanged config, skipping.\n")
return nil
return ErrNoChanges
}
e.logf("wgengine: Reconfig: configuring userspace wireguard engine")
e.lastReconfig = rc
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).
rss := rs.OnlyRelevantParts()
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)
e.lastRoutes = rss
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
}

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

Loading…
Cancel
Save