From 515a57a301893e3efca00ff4e793dafb0c27e852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Serv=C3=A9n=20Mar=C3=ADn?= Date: Fri, 28 Feb 2020 15:07:23 +0100 Subject: [PATCH] pkg/mesh: don't synchronize peer endpoints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Kilo had a routine that synchronized the endpoints of peers back into the API to ensure that endpoints updated by WireGuard for a roaming peer would always positively compare with the endpoints in the API. This is no longer needed as Kilo will now simply ignore changes to endpoints for peers with a non-zero persistent keepalive. Signed-off-by: Lucas Servén Marín --- pkg/mesh/mesh.go | 42 ------------------------------------------ 1 file changed, 42 deletions(-) diff --git a/pkg/mesh/mesh.go b/pkg/mesh/mesh.go index b64bcd1..9add840 100644 --- a/pkg/mesh/mesh.go +++ b/pkg/mesh/mesh.go @@ -355,7 +355,6 @@ func (m *Mesh) Run() error { if m.cni { m.updateCNIConfig() } - m.syncEndpoints() m.applyTopology() t.Reset(resyncPeriod) case <-m.stop: @@ -364,47 +363,6 @@ func (m *Mesh) Run() error { } } -// WireGuard updates the endpoints of peers to match the -// last place a valid packet was received from. -// Periodically we need to syncronize the endpoints -// of peers in the backend to match the WireGuard configuration. -func (m *Mesh) syncEndpoints() { - link, err := linkByIndex(m.kiloIface) - if err != nil { - level.Error(m.logger).Log("error", err) - m.errorCounter.WithLabelValues("endpoints").Inc() - return - } - conf, err := wireguard.ShowConf(link.Attrs().Name) - if err != nil { - level.Error(m.logger).Log("error", err) - m.errorCounter.WithLabelValues("endpoints").Inc() - return - } - m.mu.Lock() - defer m.mu.Unlock() - c := wireguard.Parse(conf) - var key string - var tmp *Peer - for i := range c.Peers { - // Peers are indexed by public key. - key = string(c.Peers[i].PublicKey) - if p, ok := m.peers[key]; ok { - tmp = &Peer{ - Name: p.Name, - Peer: *c.Peers[i], - } - if !peersAreEqual(tmp, p) { - p.Endpoint = tmp.Endpoint - if err := m.Peers().Set(p.Name, p); err != nil { - level.Error(m.logger).Log("error", err) - m.errorCounter.WithLabelValues("endpoints").Inc() - } - } - } - } -} - func (m *Mesh) syncNodes(e *NodeEvent) { logger := log.With(m.logger, "event", e.Type) level.Debug(logger).Log("msg", "syncing nodes", "event", e.Type)