From 4ebc0fa70f0994493c3289852701d9b671014d9e Mon Sep 17 00:00:00 2001 From: David Crawshaw Date: Thu, 20 Feb 2020 12:47:33 -0500 Subject: [PATCH] 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 --- wgengine/userspace.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wgengine/userspace.go b/wgengine/userspace.go index 232037abd..0d549691e 100644 --- a/wgengine/userspace.go +++ b/wgengine/userspace.go @@ -231,9 +231,8 @@ func (e *userspaceEngine) Reconfig(cfg *wgcfg.Config, dnsDomains []string) error } e.lastReconfig = rc - r := bufio.NewReader(strings.NewReader(uapi)) - if err = e.wgdev.IpcSetOperation(r); err != nil { - e.logf("IpcSetOperation: %v\n", err) + if err := e.wgdev.Reconfig(cfg); err != nil { + e.logf("wgdev.Reconfig: %v\n", err) return err } @@ -458,7 +457,8 @@ func (e *userspaceEngine) RequestStatus() { } func (e *userspaceEngine) Close() { - e.Reconfig(&wgcfg.Config{}, nil) + r := bufio.NewReader(strings.NewReader("")) + e.wgdev.IpcSetOperation(r) e.linkMon.Close() e.router.Close() e.magicConn.Close()