wgengine: incremental update of peers on network map change

This is the first, and easier, part of incremental wireguard-go
reconfiguration. It means that a new node appearing on the
network does not cause all existing nodes to re-handshake with
the other nodes they are talking to.

(This code has been running on hello.ipn.dev for a few weeks and
peers have successfully reconnected to it through many network
map updates.)

Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
This commit is contained in:
David Crawshaw 2020-02-20 12:47:33 -05:00
parent 11048b8932
commit 4ebc0fa70f
1 changed files with 4 additions and 4 deletions

View File

@ -231,9 +231,8 @@ func (e *userspaceEngine) Reconfig(cfg *wgcfg.Config, dnsDomains []string) error
} }
e.lastReconfig = rc e.lastReconfig = rc
r := bufio.NewReader(strings.NewReader(uapi)) if err := e.wgdev.Reconfig(cfg); err != nil {
if err = e.wgdev.IpcSetOperation(r); err != nil { e.logf("wgdev.Reconfig: %v\n", err)
e.logf("IpcSetOperation: %v\n", err)
return err return err
} }
@ -458,7 +457,8 @@ func (e *userspaceEngine) RequestStatus() {
} }
func (e *userspaceEngine) Close() { func (e *userspaceEngine) Close() {
e.Reconfig(&wgcfg.Config{}, nil) r := bufio.NewReader(strings.NewReader(""))
e.wgdev.IpcSetOperation(r)
e.linkMon.Close() e.linkMon.Close()
e.router.Close() e.router.Close()
e.magicConn.Close() e.magicConn.Close()